akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int sum = 0;
        int ans = 0;

        for(int i=0; i<=A; i++){
            for(int j=0; j<=B; j++){
                for(int k=0; k<=C; k++){
                    sum = 500 * i + 100 * j + 50 * k;
                    if(sum==X){
                        ans += 1;
                    }
                    sum = 0;
                }
            }
        }
        System.out.println(ans);
    } 
}

Measured memory_bytes: 21844
def calc_mount_1(height_list):
    for i in range(len(height_list)):
        for i in range(len(height_list)-1):
            if height_list[i+1] < height_list[i]:
                tmp = height_list[i+1]
                height_list[i+1] = height_list[i]
                height_list[i] = tmp
            else:
                continue
    return height_list

N = 10
l = [input() for i in range(N)]
answer_array = calc_mount_1(l)
print "%d" % answer_array[-1]
print "%d" % answer_array[-2]
print "%d" % answer_array[-3]

Measured memory_bytes: 6416
/* Filename: ABC046D.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		while (input.hasNext()) {
			String S = input.next();

			int countP = 0, countG = 0;
			int win = 0, lose = 0;
			for (int i = 0; i < S.length(); ++i) {
				if (countP + 1 <= countG) {
					++countP;

					if (S.charAt(i) == 'g') {
						++win;
					}
					
				} else {
					++countG;
					
					if (S.charAt(i) == 'p') {
						++lose;
					}
				}
			}

			System.out.println(win - lose);
		}
	}

}


Measured memory_bytes: 13008
#include<bits/stdc++.h>
using namespace std;
vector<int>g[2003];
int dfs(int s,int p,int d,int k){
    int ret=0;
    for(int i=0;i<(int)g[s].size();i++){
        if(g[s][i]==p)continue;
        ret+=dfs(g[s][i],s,d+1,k);
    }
    if(d>k)ret++;
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    int a,b;
    for(int i=1;i<n;i++){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int mn=1<<28;
    if(k&1){
        for(int i=1;i<=n;i++){
            for(int j=0;j<(int)g[i].size();j++){
                mn=min(mn,dfs(i,g[i][j],0,k/2)+dfs(g[i][j],i,0,k/2));
            }
        }
    }else{
        for(int i=1;i<=n;i++){
            mn=min(mn,dfs(i,-1,0,k/2));
        }
    }
    cout<<mn<<"\n";
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int A=in(),B=in(),C=in();
  
  cout << min(B/A,C) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  int result = 0;
  if (n >= 10) {
    result += 9;
  } else if (n < 10) {
    result += n;
  }
  if (n >= 1000) {
    result += 900;
  } else if (n < 1000) {
    result += max(n - 99, 0);
  }
  if (n >= 100000) {
    result += 90000;
  } else if (n < 100000) {
    result += max(n - 9999, 0);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  
  int ta, tb, tc;
  int cnt = 0;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
  {
    if (a == b && b == c)
    {
      printf("-1");
      return 0;
    }
    ta = a;
    tb = b;
    tc = c;
    a = tb / 2 + tc / 2;
    b = tc / 2 + ta / 2;
    c = ta / 2 + tb / 2;
    cnt++;
  }
  printf("%d", cnt);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> jengas(n);
    rep(i,n) {cin >> jengas[i];}
    int cur_pos;
    cur_pos = 1;
    rep(i, n) {
        // printf("%d\n", jengas[i]);
        if (jengas[i] == cur_pos) {
            cur_pos++;
        }
    }
    if (cur_pos == 1) {
        cout << -1 << endl;
    } else {
        n = n - cur_pos + 1;
        cout << n << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadLong;
			var D = Divisors(N);
			var D1 = Divisors(N - 1);
			var count = 0;
			foreach(var d in D.Skip(1)) {
				var q = N;
				while(q % d == 0) 
					q /= d;
				if(q % d == 1) count++;
			}
			count += D1.Count() - 1;
			Console.WriteLine(count);
		}
		public List<long> Divisors(long x) {
			var Res = new List<long>();
			for(long i = 1; i * i <= x; i++) {
				if(x % i == 0) {
					Res.Add(i);
					if(i * i != x) Res.Add(x / i);
				}
			}
			return Res;
		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);

	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}

}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    int n; cin >> n;
    int ans = 0;
    REP(i, 0, n){
        int k; cin >> k;
        if((i+1) % 2 == 1 && k % 2 == 1){
            ans++;
        }
    }
    cout << ans<< endl;
}

Measured memory_bytes: 3624
import sys
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
  print(0)
  sys.exit()
  
b = 10 ** 18
ret = 1
for i in a:
  ret = ret * i
  if ret > b:
    print('-1')
    sys.exit()
else:
  print(ret)

Measured memory_bytes: 21732
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> vec(n);
    rep(i, n-1) {
        int tmp; cin >> tmp;
        tmp--;
        vec[tmp]++;
    }
    rep(i, n) cout << vec[i] << endl;
    return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string S; int dp[100009], n;

int main() {
	cin >> n >> S;
	for (int i = 0; i <= 100000; i++) dp[i] = -(1 << 30);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		if (i < n - 1) {
			if (S[i] != S[i + 1]) dp[i + 2] = max(dp[i + 2], dp[i] + 1);
		}
		dp[i + 1] = max(dp[i + 1], dp[i]);
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 3728
#include <iostream>
using namespace std;

long long extgcd(long long a, long long b, long long &x, long long &y) {
    if (b == 0) { x = 1; y = 0; return a; }
    long long d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

int main() {
    long long a, b; cin >> a >> b;
    long long x, y; extgcd(a, b, x, y);
    cout << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define ff(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b) 
string s;
ll dp[N][13];
int n;
ll f(int i, int sum){
    if(i == n)
        return sum % 13 == 5;
    ll &ans = dp[i][sum];
    if(ans != -1)return ans;
    ans = 0;
    ll num;
    if(s[i] == '?'){
        fore(j, 0, 10){
            num = (sum * 10 + j) % 13;
            ans = (ans % mod + f(i + 1, num) % mod ) % mod;
        }
    }else{
        num = ((sum * 10) + (s[i] - '0')) % 13;
        ans = (ans % mod + f(i + 1, num) % mod) % mod;
    }
    return ans;
}
int main(){
    //FL;
    fin;
    cin >> s;
    n = sz(s);
    cls(dp, -1);
    cout << f(0, 0) << '\n';
    time;
    return 0;
}   

Measured memory_bytes: 28624
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Adly
 */
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        int w = in.nextInt();
        int[][] a = new int[t][2];
        for (int i = 0; i < t; i++) {
            a[i][0] = in.nextInt();
            a[i][1] = in.nextInt();
        }
        long[] dp = new long[w + 1];
        for (int i = 0; i < t; i++) {
            for (int cap = w; cap >= a[i][0]; cap--) {
                dp[cap] = Math.max(dp[cap], dp[cap - a[i][0]] + a[i][1]);
            }
        }
        System.out.println(dp[w]);
    }
}


Measured memory_bytes: 23892
a = int(input())
b = []
c = []
for i in range(a):
    b.append(list(map(int,input().split())))
    for j in range(i):
        c.append(((b[i][0]-b[j][0])**2+(b[i][1]-b[j][1])**2)**0.5)
print(sum(c)*(a-1)/len(c))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
int n,p[1005];
int a,b;
int main()
{
	SPEED;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
		cin>>p[i];
	sort(p+1,p+n+1);
	int cn=0,cn1=0,cn2=0;
	for(int i=1;i<=n;i++)
		if(p[i]<=a)
			cn++;
		else if(p[i]<=b)
			cn1++;
		else
			cn2++;
	cout<<min({cn,cn1,cn2})<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;

#define pll pair<ll,ll>

vector<pll> edges[1000001];
int ans[1000001];
bool visit[1000001];

int main(){
    int N; cin>>N;
    REP(count,N-1){
        ll u,v,w; cin>>u>>v>>w;
        edges[u].push_back( make_pair(v,w) );
        edges[v].push_back( make_pair(u,w) );
    }
    
    queue<ll> que;
    FILL(visit,N+1,false);
    ans[1] = 0;
    visit[1] = true;
    que.push(1);
    while(!que.empty()){
        ll cur = que.front(); que.pop();
        for(pll x:edges[cur]){
            ll next = x.first;
            if(visit[next]){ continue;}
            if(x.second%2==0){ ans[next] = ans[cur]; }
            else{ ans[next] = (ans[cur]+1)%2; }
            visit[next] = true;
            que.push(next);
        }
        
    }
    
    for(int i=1;i<=N;++i){
        cout << ans[i] << "\n";
    }

    
}


Measured memory_bytes: 30336
#include <bits/stdc++.h>
using namespace std;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int x, y;
    cin >> x >> y;
    for (Int i = 0; i <= (Int)x; i++) {
        if (i * 2 + (x - i) * 4 == y) {
            print("Yes");
            return 0;
        }
    }
    print("No");
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ull;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    // string sa,b;
    // cin >> sa >> b;
    // ll a = stoll(sa);
    // int l = b.length();
    // double sum = 0;
    // vector<ll> cn;
    // REP(i,l){
    //     if(i==2){
    //         continue;
    //     }
    //     cn.pb(a * (b[l - i - 1] - '0'));
    // }
    // REP(i,cn.size()){
    //     sum += cn[i]*(int)pow(10,i);
    // }
    // cout << (ll)(sum/100) << endl;

    ll a;
    double b;
    cin >> a >> b;
    ll b2 = b*100+EPS;
    cout << a*b2/100 << endl;
}

Measured memory_bytes: 3724
import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 100000;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static int [] Ft = new int  [max+1];
    public static void main(String args[]) throws IOException {
        int N  = in.nextInt();
        int [] A = new int[N];
        int [] placement = new int [N+1];
        for(int i=1;i<=N;i++)
            {
                int Ai = in.nextInt();
                placement[Ai] = i;
            }
            for(int i=1;i<=N;i++){
                out.print(i!=N?placement[i]+" ":placement[i]);
            }
       

        out.flush();
        }
        static int lsb(int i){return i&-i;};
        static int prefix(int idx){
            int sum=0;
            while(idx>0){
                sum+=Ft[idx];
                idx-=lsb(idx);
            }
            return sum; 
        }
        static void update(int idx){
            while(idx<=max){
                Ft[idx]+=1;
                idx+=lsb(idx);
            }
        }
       static boolean isEven(long a){
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
        static boolean same(int [] arr,int [] temp){
            Arrays.sort(arr);
           Arrays.sort(temp);
            for(int i=0;i<arr.length;i++){
                if(temp[i]!=arr[i])
                return false;
            }
            return true;
        }

 
  


    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

Measured memory_bytes: 45280
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//摂動と言えばいいのか？


int main(void){
	int N,A,p;
	pair<int,ll>q;
	map<int,ll> M;
	queue<pair<int,ll> > Q;
	cin>>N>>A;
	rep(i,N){
		cin>>p;
		p = p-A;//合計が０になれば良い
		// マップ全てをqueueに入れる
		for (map<int,ll>::iterator p=M.begin(); p!=M.end();++p) {
			Q.push(make_pair(p->first, p->second));
		}
	    while(!Q.empty()){
	    	q = Q.front();//合計値，場合の数
	    	M[q.first + p] += q.second;//上から順番にとれば，場合の数を記録する必要はない。
	    	Q.pop();
	    }
	    M[p]+=1;
	}
	cout<<M[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	double r; cin >> r;
	printf("%lf %lf \n",M_PI*r*r,2*M_PI*r);
}


Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

int main()
{
    int N, K;
    std::cin >> N >> K;
    std::vector<std::pair<long long, long long> > p(N);
    for(int i=0; i<N; i++) scanf(" %lld %lld", &(p[i].first), &(p[i].second));

    std::sort(p.begin(), p.end());
    long long min = LLONG_MAX;
    // choose x
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            long long dx = p[j].first - p[i].first;
            // printf("i, j = %d, %d, dx = %lld\n", i, j, dx);
            if(dx > min) continue;

            // choose y
            for(int k=i; k<j; k++){
                for(int l=k+1; l<=j; l++){
                    long long y1 = std::min(p[k].second, p[l].second);
                    long long y2 = std::max(p[k].second, p[l].second);
                    long long dy = y2 - y1;
                    // printf("k, l = %d, %d, dy = %lld\n", k, l, dy);
                    if(dx*dy > min) continue;

                    //count number of point in the domain
                    int count = 0;
                    for(int m=i; m<=j; m++){
                        if(y1 <= p[m].second && p[m].second <= y2) count++;
                    }
                    if(K <= count && dx*dy < min) min = dx*dy;
                }
            }
        }
    }

    std::cout << min << std::endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.abs
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val sPair = Array(n) {
        val (a, b) = readIntegerList()
        a to b
    }

    for (i in 0 until n - 2) {
        if (sPair[i].first == sPair[i].second && sPair[i + 1].first == sPair[i + 1].second && sPair[i + 2].first == sPair[i + 2].second) {
            out.println("Yes")
            return
        }
    }
    out.println("No")
}



fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 36520
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

n, m = map(int,input().split())
a = [list(map(int, input().split())) for i in range(m)]
uf = UnionFind(n)
for i in range(m):
    uf.union(a[i][0]-1, a[i][1]-1)
print(uf.group_count()-1)

Measured memory_bytes: 29324
#include<bits/stdc++.h>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define pb(i) push_back(i)
#define mk(x,y) make_pair(x,y)
#define F first
#define S second
#define accu(i) fixed<<setprecision(i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
using namespace std;


int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    ll n = __gcd(a, b);
    ll m=n;
    ll cnt = 0;
    for(ll i=2;i<=sqrt(m);i++){
    	if(n%i==0){
    		while(n%i==0){
    			n=n/i;
			}
			cnt++;
		}
	}
	if(n!=1) cnt++;
    cout << cnt + 1 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)

int32_t main(){
  
  fast;
  int r; cin >> r;
  cout << 3*r*r;

 
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int X, N; cin >> X >> N;
    vector<bool> p(101, false);
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        p[a] = true;
    }
    for (int i = 0; i < 101; i++) {
        if (X-i < 0 || !p[X-i]) {
            cout << X-i << endl;
            return 0;
        }
        if (X+i > 100 || !p[X+i]) {
            cout << X+i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

using Graph=vector<vector<int>>;
int main(){
  int n,m;
  cin>>n>>m;

  Graph G(n);

  rep(i,m){
     int a,b;
     cin>>a>>b;
     G[a-1].push_back(b-1);
     G[b-1].push_back(a-1);
  }
  vector<int> dist(n,-1);
  vector<int> ans(n,-1);
  queue<int> que;
  ans[0]=0;
  dist[0]=0;
  que.push(0);

  while(!que.empty()){
     int v=que.front();
     que.pop();

     for(int nv:G[v]){
        if(dist[nv]!=-1) continue;

        dist[nv]=dist[v]+1;
        ans[nv]=v;
        que.push(nv);
     }
  }

  bool f=true;
  rep(i,n){
     if(dist[i]==-1) {
        cout<<"No"<<endl;
        f=false;
        return 0;
     }
  }
  if(f==true) cout<<"Yes"<<endl;

  for(int i=1;i<n;i++){
     cout<<ans[i]+1<<endl;
  }

  





return 0;
}


Measured memory_bytes: 10632
#include <stdio.h>

int main() {
    int n, tmp, mi = 1000000,ma = -mi;
    signed long long sum = 0;
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        scanf("%d", &tmp);
        sum += tmp;
        if(mi>tmp) mi = tmp;
        if(ma<tmp) ma = tmp;
    }
    printf("%d %d %lld\n", mi, ma, sum);
}


Measured memory_bytes: 2744
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long M){
    rrep(i, 1, M/N + 1) {
        if (M%i != 0 || M/i<N) continue;
        cout << i << endl;
        return;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 3760
#define INF 999

int main( void ) {
	int i, j, n, m, num[ 2 ][ 100 ], sum[ 2 ], min[ 2 ], diff;

	for ( ; scanf( "%d %d", &n, &m ), n; printf( min[ 0 ] == INF ? "-1\n" : "%d %d\n", min[ 0 ], min[ 1 ] ) ) {
		sum[ 0 ] = sum[ 1 ] = 0;
		for ( i = n; i--; sum[ 0 ] += num[ 0 ][ i ] )
			scanf( "%d", num[ 0 ] + i );
		for ( i = m; i--; sum[ 1 ] += num[ 1 ][ i ] )
			scanf( "%d", num[ 1 ] + i );

		diff = sum[ 0 ] - sum[ 1 ];
		min[ 0 ] = INF;
		for ( i = n; i--;  )
			for ( j = m; j--;  )
				if ( ( num[ 0 ][ i ] - num[ 1 ][ j ] ) * 2 == diff )
					if ( num[ 0 ][ i ] + num[ 1 ][ j ] < min[ 0 ] + min[ 1 ] ) {
						min[ 0 ] = num[ 0 ][ i ];
						min[ 1 ] = num[ 1 ][ j ];
					}
	}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N, W;
	cin >> N >> W;
	vll w(N + 1), v(N + 1);
	repn(i, N) cin >> w[i] >> v[i];

	ll c = w[1];

	vvll val(4);
	repn(i, N) {
		val[w[i] - c].push_back(v[i]);
	}
	rep(i, 4)sort(val[i].begin(), val[i].end(), greater<ll>());

	vll sz(4);
	vvll rval(4);
	rep(i, 4) {
		sz[i] = val[i].size();
		rval[i].assign(sz[i] + 1, 0);
		repn(j, sz[i])rval[i][j] = rval[i][j - 1] + val[i][j-1];
	}

	ll ans = 0;

	rep(x, sz[0] + 1)rep(y, sz[1] + 1)rep(z, sz[2] + 1)rep(w, sz[3] + 1) {
		ll wei = x * c + y * (c + 1) + z * (c + 2) + w * (c + 3);
		if (wei <= W) {
			ll now = rval[0][x] + rval[1][y] + rval[2][z] + rval[3][w];
			ans = max(now, ans);
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    int r = x%y;
    if (r == 0) {
        return y;
    }
    return gcd(y, r);
}

ll mypow(ll x, ll n) {
    if (n == 0) return 1;
    if (n%2 == 0) return mypow(((x%mod)*(x%mod))%mod, n/2);
    else return ((x%mod) * mypow(((x%mod)*(x%mod))%mod, (n-1)/2))%mod;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i=0; i<M; i++) cin >> A.at(i);
    ll sum = 0;
    for (int i=0; i<M; i++) sum += A.at(i);
    if (N - sum < 0) cout << -1 << endl;
    else cout << N - sum << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;
ll com(string a,string b,ll k){
	bool f = true ;
	rep(i,k)
		if(a[i]==b[i])
			f = false ;
	return 	f ;
}


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
	// int t ;
	// cin>>t;
	// whln(t){
	 ll k,x ;

	 cin>>k>>x;
	 if(k*500>=x)
	 	cout<<"Yes\n";
	 else
	 	cout<<"No\n";




		
	return 0 ;
	 // }
		
}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

Measured memory_bytes: 3632
#include<bits/stdc++.h>

using namespace std;

int main(void) {
    int n, m;
    cin >> n >> m;

    vector<vector<int>> G(3*n);
    for(int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[3*a+0].push_back(3*b+1);
        G[3*a+1].push_back(3*b+2);
        G[3*a+2].push_back(3*b+0);
    }

    int s, t;
    cin >> s >> t;
    s--, t--;

    priority_queue<pair<int,int>> q;
    q.push(pair<int,int>(-0, 3*s));

    vector<int> dis(3*n, 1e9);
    dis[3*s] = 0;

    while(!q.empty()) {
        auto p = q.top(); q.pop();
        int d = -p.first;
        int v = p.second;

        if(dis[v] < d) continue;

        for(auto w: G[v]) {
            if(dis[w] > d+1) {
                dis[w] = d+1;
                q.push(pair<int,int>(-(d+1),w));
            }
        }
    }

    cout << (dis[3*t] == 1e9 ? -1 : dis[3*t]/3) << endl;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  if(N%2==0)
  {
    cout << N/2 - 1 << endl;
  }
  else
  {
    cout << N / 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

ll n;
ll f(vector<ll> sum, bool flag)
{
	ll cnt, tmp;

	if (flag)
		sum[0] = -1;
	else
		sum[0] = 1;
	cnt = tmp = 0;
	for (int i = 1; i <= n; i++)
	{
		sum[i] += tmp;
		if (sum[i] * sum[i - 1] >= 0)
		{
			if (sum[i] == 0)
			{
				if (sum[i - 1] < 0)
				{
					sum[i] = 1;
					tmp += 1;
				}
				else
				{
					sum[i] = -1;
					tmp += -1;
				}
				cnt++;
			}
			else if (sum[i] < 0)
			{
				tmp += 1 - sum[i];
				cnt += abs(1 - sum[i]);
				sum[i] = 1;
			}
			else if (sum[i] > 0)
			{
				tmp += -1 * (1 + sum[i]);
				cnt += abs(-1 * (1 + sum[i]));
				sum[i] = -1;
			}
		}
	}
	return cnt;
}

signed main(void)
{
	cin >> n;
	vector<ll> s(n + 1, 0);
	ll ans;

	for (int i = 1; i <= n; i++)
		cin >> s[i];
	rep(i, n) s[i + 1] += s[i];
	ans = f(s, true);
	ans = min(ans, f(s, false));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;

    int h[N];
    REP(i, N){
        cin >> h[i];
    }

    int ans = 0;
    REP(i, N){
        if (h[i] >= K) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3924
#include <iostream>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n); ++i)

using namespace std;

int main(){
    
    int H(0), W(0), K(0);
    cin >> H >> W >> K;
    vector<string> c(H);
    int answer(0);

    rep(i, H) cin >> c[i];

    rep(i, 1 << H) rep(j, 1 << W){
        int count(0);
        rep(m, H) rep(n, W){
            if(i >> m & 1) continue;
            if(j >> n & 1) continue;
            if(c[m][n] == '#') ++count;
        }
        if(count == K)
            ++answer;
    }
    cout << answer << endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=2e5+10;
ll pre[maxn],a[maxn];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        pre[i]=(pre[i-1]+a[i])%mod;
    }
    ll ans=0;
    for(int i=1; i<=n; i++){
        ll tmp=(a[i]%mod)*( (pre[n]+mod-pre[i])%mod )%mod;
        ans=(ans+tmp)%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6292
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}
//struct compare
//{
//  bool operator()(const int& l, const int& r)
//  {
//      return l>r;
//  }
//};

bool cmp(int a, int b)
{
    return a<b;
}
int on(int mask,int st)
{
    return mask|(1<<st);
}
int off(int mask,int st)
{
    return mask&(~(1<<st));
}
bool check(int mask,int st)
{
    return mask&(1<<st);
}
ll inf=1e18;
ll mod=1e9+7;
//ll mod=993344777;
const int sz=300005;
vector<int>G[10];
int countt=0;
int main(void)
{
//    READ;
    int n,k,x,y;
    for(int i=0;i<3;i++)
    {
        sf2(x,y);
        G[x].pb(y);
        G[y].pb(x);
    }
    for(int i=1;i<=4;i++)
    {
        if(G[i].size()>2){
            cout<<"NO"<<endl;return 0;}
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

#define End exit(0)
#define LL long long
#define mp make_pair
#define SZ(x) ((int) x.size())
#define GO cerr << "GO" << endl
#define DE(x) cout << #x << " = " << x << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

void proc_status()
{
	freopen("/proc/self/status","r",stdin);
	string s; while(getline(cin, s)) if (s[2] == 'P') { cerr << s << endl; return; }
}

template<typename T> inline T read() 
{
	register T x = 0;
	register char c; register int f(1);
	while (!isdigit(c = getchar())) if (c == '-') f = -1;
	while (x = (x << 1) + (x << 3) + (c ^ 48), isdigit(c = getchar()));
	return x * f;
}

template<typename T> inline bool chkmin(T &a,T b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a,T b) { return a < b ? a = b, 1 : 0; }

const int maxN = 5000 + 2;
const int mod = 1e9 + 7;

int n;
int ver[maxN << 1], nxt[maxN << 1], head[maxN + 2];
int dp[maxN + 2][maxN + 2], tmp[maxN + 2], size[maxN + 2], g[maxN + 2];

inline void Inc(int &x) { x < 0 ? x += mod : 0; }
inline void Dec(int &x) { x >= mod ? x -= mod : 0; }

void link(int u, int v)
{
    static int ecnt = 0;
    ver[++ecnt] = v, nxt[ecnt] = head[u], head[u] = ecnt;
}

void dfs(int u, int fa)
{
    dp[u][1] = 1;
    size[u] = 1;
    for (int i = head[u]; i; i = nxt[i])
    {
        int v = ver[i];
        if (v == fa) continue;
        dfs(v, u);
        for (int i = 0; i <= size[u]; ++i)
            for (int j = 0; j <= size[v]; ++j)
                Dec(tmp[i + j] += 1ll * dp[u][i] * dp[v][j] % mod);
        size[u] += size[v];
        for (int i = 0; i <= size[u]; ++i) dp[u][i] = tmp[i], tmp[i] = 0;
    }
    for (int i = 1; i <= size[u]; ++i) Inc(dp[u][0] -= 1ll * dp[u][i] * g[i] % mod);
}

int main() 
{    
    n = read<int>();
    for (int i = 1; i < n; ++i) 
    {
        int u = read<int>(), v = read<int>();
        link(u, v), link(v, u);
    }
    g[0] = 1;
    for (int i = 2; i <= n; ++i) g[i] = 1ll * g[i - 2] * (i - 1) % mod;
    dfs(1, 0);
    printf("%d\n", (mod - dp[1][0]) % mod);
	return 0;
}


Measured memory_bytes: 97152
#include <iostream>
using namespace std;
long long a[52],p[52];

long long f(int n,long long x){
  if(n==0)return p[0];
  if(x==1)return 0;
  if(x<1+a[n-1])return f(n-1,x-1);
  if(x==1+a[n-1])return p[n-1];
  if(x==1+a[n-1]+1)return p[n-1]+1;
  if(x<1+a[n-1]+1+a[n-1])return p[n-1]+1+f(n-1,x-2-a[n-1]);
  if(x>=1+a[n-1]+1+a[n-1])return 2*p[n-1]+1;
}
int main(){
  int n,i,j;
  long long x;
  cin >> n >> x;
  a[0]=p[0]=1;
  for(i=1;i<=n;i++){
    a[i]=3+2*a[i-1];
    p[i]=1+2*p[i-1];
  }
  cout << f(n,x) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
// vector<int> fac; //precompute fac array
// fac.resize(n+1);
// fac[0] = 1; 
// for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i));
// int modInverse(int n){ 
// return p(n, MOD-2); 
// }  
// int nCrModPFermat(int n, int r){   
//     if(r == 0)  return 1; 
//     return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
// } 
signed main(){
    fast();
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> ma;
    for(int i=0; i<n; i++){
        cin >> a[i];
        ma[a[i]]++;
    }
    sort(a.begin(), a.end());
    set<int> st;
    int ans = 0;
    for(int i=0; i<n; i++){
        if(ma[a[i]] > 1){
            
        }
        else{
            bool f = false;
            for(int j=1; j*j<=a[i]; j++){
                if(a[i]%j == 0){
                    if(st.count(a[i]/j) || st.count(j)){
                        f = true;
                        break;
                    }
                }
            }
            if(!f)   ans++;
        }
        st.ins(a[i]);
    }
    cout << ans << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 26696
#include <iostream>
using namespace std;

int main(){
    int n;
    cin>>n;
    string a,b;
    int A=0,B=0;
    for(int i=0;i<n ;i++){
    cin>>a;
        cin>>b;
        if(a>b){
            A+=3;
        }else if(a<b){
            B+=3;
        }else{
            A++;
            B++;
        }
    }
        cout<<A<<" "<<B<<endl;
    return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m,w,v;
long long f[100005];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%d%d",&w,&v);
		for(int j=m;j>=w;--j)
			f[j]=max(f[j],f[j-w]+v);
	}
	printf("%lld\n",f[m]);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define elif else if
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

const int N = 3e5, M = N;
//=======================
void solve() {
 int n,i;
 cin >> n;
 vl d(n+1,0);
 Fo(i,1,n+1){
   for(int j=i; j<n+1; j+=i){
     d[j]++;
   }
 }
 ll sum = 0;
 fo(i,n+1){
   sum+=(i*d[i]);
 }
 cout << sum;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 81384