akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {
    
    int cnt=0,en=0;
    vi A(3),B(3);
    cin >>A[0]>>A[1]>>A[2];
    rSORT(A);
    B=A;
    A[1]=B[0];
    A[2]=B[2]+(B[0]-B[1]);
    cnt+=(B[0]-B[1]);
    if((A[0]-A[2])%2==0) cout <<(cnt+((A[0]-A[2])/2))<<endl;
    if((A[0]-A[2])%2==1) cout <<(cnt+((A[0]-A[2])/2)+2)<<endl;

    return 0;
}








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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

using ll = long long;

int main() {
    IN(int, n);
    IN(int, m);
    cout << n*(n-1)/2+m*(m-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = true;

int main(){

    const ll mod = 1000000007;
    ll p = 1;
    ll n;
    cin >> n;
    for(ll i = 1; i <= n; i++) p = (p * i) % mod;
    cout << p << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	int p[n];
	for(int i=0; i<n; i++)
		cin>>p[i];
	sort(p, p+n);
	int k=p[n/2]-p[n/2-1];
	cout<<k;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int x1, x2, x3, x4, y1, y2, y3, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    int a = x2-x1;
    int b = y2-y1;
    x3 = x2-b;;
    y3 = y2+a;
    x4 = x1-b;
    y4 = y1+a;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << 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> 
using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int> , null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update> 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fi first
#define se second
// #define endl '\n'
#define int int64_t
#define double long double
#define fdt fuck donald trump
mt19937 rnd(time(0));
const int MAXN = 100001;

signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
	// freopen("FDT.txt","r",stdin);
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

vector<int> to[200005];
int buka[200005];

void dfs(int x, int p) {
    vector<int> b;
    for (int e: to[x]) {
        if (e==p) continue;
        dfs(e, x);
        b.push_back(e);
    }
    for (int e: b) {
        buka[x] += (buka[e]+1);
    }

}

int main(){
    int n;
    cin >> n;
    
    rep(i, n) {
        if (i==0) continue;
        int x;
        cin >> x;
        x--;
        to[x].push_back(i);
        to[i].push_back(x);
    }
    //dfs(0, -1);
    rep(i, n) {
        int ans = to[i].size();
        if (i!=0) ans--;
        cout << ans << endl;
    }
   
    return 0;
}


Measured memory_bytes: 15288
import bisect
N = int(input())
l = [int(i) for i in input().split()]
count = 0
l_new = sorted(l)
for i,a in enumerate(l_new):
    for j,b in enumerate(l_new[i+1:],start = i+1):
        left = bisect.bisect_right(l_new,abs(a-b))
        right = bisect.bisect_left(l_new,a + b)
        count += right - left
        
        if left <= i < right:
            count -= 1
        if left <= j < right:
            count -= 1
        
print(count//3)

Measured memory_bytes: 53468
a, b, x = map(int,input().split())



## ことごとくTLEする件
# forを回すからだめなのかも→回さないですませるには？
# bまでに約数いくつあるか出す → a-1 までに約数いくつあるか出す→引き算



## まず、aが割り切れるかどうか判定
## aが割り切れるなら、最小値はa
## 割り切れないなら、a+（除数 - あまり ) が最小値

#### divmodを使ってみよう！！


result = 0

a_x = divmod(a,x)  ## a/x の商と余り
## a = x * a_x[0] + a_x[1]
if a_x[1]==0:  ## 割り切れるとき
    first = a
else:  ## 割り切れないとき
    first = x * (a_x[0]+1)
    first2 = a + (x - a_x[1])  ## 検算用


b_x = divmod(b-first, x)

result = b_x[0]+1

print(result)






"""
名答だと思ったがだめだった

count = 0
first = 0
for i in range(a, b+1):
#    print(i)
    if i%x == 0:
        first = i
        count = 1
        break
    
if count != 0:
    result  = (b-first) // x +1

else :
    result = 0


print(result)



"""



Measured memory_bytes: 38256
import sys
sys.setrecursionlimit(2 * 10 ** 5)


class StronglyConnectedComponets:
    def __init__(self, n: int) -> None:
        self.n = n
        self.edges = [[] for _ in range(n)]
        self.rev_edeges = [[] for _ in range(n)]
        self.vs = []
        self.order = [0] * n
        self.used = [False] * n

    def add_edge(self, from_v: int, to_v: int) -> None:
        self.edges[from_v].append(to_v)
        self.rev_edeges[to_v].append(from_v)

    def dfs(self, v) -> None:
        self.used[v] = True
        for child in self.edges[v]:
            if not self.used[child]:
                self.dfs(child)
        self.vs.append(v)

    def rdfs(self, v, k) -> None:
        self.used[v] = True
        self.order[v] = k
        for child in self.rev_edeges[v]:
            if not self.used[child]:
                self.rdfs(child, k)

    def run(self) -> int:
        self.used = [False] * self.n
        self.vs.clear()
        for v in range(self.n):
            if not self.used[v]:
                self.dfs(v)
        self.used = [False] * self.n
        k = 0
        for v in reversed(self.vs):
            if not self.used[v]:
                self.rdfs(v, k)
                k += 1
        return k


def aoj():
    # https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/3/GRL_3_C
    V, E = map(int, input().split())
    scc = StronglyConnectedComponets(V)
    for _ in range(E):
        u, v = map(int, input().split())
        scc.add_edge(u, v)
    scc.run()
    for _ in range(int(input())):
        u, v = map(int, input().split())
        print(int(scc.order[u] == scc.order[v]))


if __name__ == "__main__":
    aoj()



Measured memory_bytes: 19512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		
		long[] valArr = new long[n];
		for(int i = 0; i < n; i++) {
			valArr[i] = fs.nextLong();
		}
		
		long ans = 0;
		
		int l = 0;
		int r = 0;
		
		long cumSum = 0;
		long cumXor = 0;
		while(l < n && r < n) {
			
			long nextCumSum = cumSum + valArr[r];
			long nextCumXor = cumXor ^ valArr[r];
			
			if(nextCumSum == nextCumXor) {
				cumSum = nextCumSum;
				cumXor = nextCumXor;
				r++;
			}else {
				
				int diff = r - l;
				ans += diff;
				
				cumSum = cumSum - valArr[l];
				cumXor = cumXor ^ valArr[l];
				l++;
			}
		}
		
		
		for(int i = l; i < n; i++) {
			ans += n - i;
		}
		
		System.out.println(ans);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 55108
#include "bits/stdc++.h"
using namespace std;

int main() {
	int H, W, K;
	static long long DP[101][8] = {}, X[8][8] = {}, MOD = 1000000007;
	DP[0][0] = 1;
	cin >> H >> W >> K;
	for (int i = 0; i < pow(2, W - 1); i++) {
		int A[7] = {}, I = i;
		for (int j = 0; j < W - 1; j++) {
			if (I % 2 == 1) A[j] = 1;
			I /= 2;
		}
		for (int j = 0; j < W - 2; j++) {
			if (A[j] == 1 && A[j + 1] == 1) goto END;
		}
		for (int j = 0; j < W - 1; j++) {
			if (A[j] == 1) X[j][j + 1]++, X[j + 1][j]++;
		}
		if (A[0] == 0) X[0][0]++;
		for (int j = 1; j < W - 1; j++) {
			if (A[j - 1] == 0 && A[j] == 0) X[j][j]++;
		}
		if (A[W - 2] == 0) X[W - 1][W - 1]++;
	END:;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = -1; k <= 1; k++) {
				if (0 <= j + k && j + k < W) {
					DP[i + 1][j + k] += X[j][j + k] * DP[i][j];
					DP[i + 1][j + k] = DP[i + 1][j + k] % MOD;
				}
			}
		}
	}
	cout << DP[H][K - 1];
}

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

int main() {
	ll i, j, k, l, test, n;
	string a;
	cin >> a;
	if(a[2] == a[3] && a[4] == a[5]) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const long double EPS = 1e-14;
const long double INF = 1e+20;
const long double PI = acos(-1);
int x[110000];
int y[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",x+i);
	}
	for(int i=0;i<b;i++)scanf("%d",y+i);
	long long X=0;
	long long Y=0;
	for(int i=0;i<a;i++){
		X=(X+(long long)x[i]*i)%mod;
		X=(X+mod-(long long)x[i]*(a-1-i)%mod);
	}
	for(int i=0;i<b;i++){
		Y=(Y+(long long)y[i]*i)%mod;
		Y=(Y+mod-(long long)y[i]*(b-1-i)%mod);
	}
	
	printf("%lld\n",X*Y%mod);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

template <class T>
struct SegmentTree{
	std::vector<T> v;
	T def;
	int n;
	template<class I>
	SegmentTree(I first, I last, T default_value){
		n = 1;
		def = default_value;
		while(n < last-first) n <<= 1;
		v.assign(2*n-1, default_value);
		copy(first, last, v.begin()+n-1);
		for(int i=n-2; i>=0; i--)
			v[i] = merge(v[2*i+1], v[2*i+2]);
	}
	SegmentTree(std::vector<T> initial_data, T default_value):
	SegmentTree(initial_data.begin(), initial_data.end(), default_value){}
	void update(int idx, T val){
		idx += n-1;
		v[idx] = val;
		while(idx > 0){
			idx = (idx-1)/2;
			v[idx] = merge(v[2*idx+1], v[2*idx+2]);
		}
	}
	T q(int a, int b, int k, int l, int r){
		if(a<=l&&r<=b) return v[k];
		if(b<=l||r<=a) return def;
		return merge(q(a, b, 2*k+1, l, (l+r)/2), q(a, b, 2*k+2, (l+r)/2, r));
	}
	T query(int a, int b){
		return q(a, b, 0, 0, n);
	}
	T merge(T left, T right);
};

// Example

template <>
pair<int, int> SegmentTree<pair<int, int>>::merge(pair<int, int> a, pair<int, int> b){
	return std::max(a, b);
}

int main(){
	int N;
	cin >> N;
	vector<pair<int, int>> AB(N);
	for(int i=0; i<N; i++) cin >> AB[i].first;
	for(int i=0; i<N; i++) cin >> AB[i].second;
	sort(AB.begin(), AB.end());

	vector<pair<int, int>> bs(N);
	for(int i=0; i<N; i++) bs[i]={AB[i].second, -i};
	SegmentTree<pair<int, int>> st(bs, {0, 0});

	int cnt = 0;
	for(int i=N-1; i>0; i--){
		int a = AB[i].first;
		int b = AB[i].second;
		if(a<=b) continue;
		debug(a, b);
		cnt++;
		auto p = st.query(0, i);
		int x = p.first;
		int n = -p.second;
		if(x<a) {
			cout << "No" << endl;
			return 0;
		}
		p = st.query(0, 1);
		x = p.first;
		n = -p.second;
		if(x>=a){
			st.update(0, {b, 0});
			AB[n].second = b;
			continue;
		}
		int lb = 1, ub = i;
		while(ub-lb>1){
			int m = (lb+ub)/2;
			p = st.query(0, m);
			x = p.first;
			if(x>=a){
				ub = m;
			} else {
				lb = m;
			}
		}
		p = st.query(0, ub);
		n = -p.second;
		st.update(n, {b, -n});
		AB[n].second = b;
	}


	if(AB[0].first <= AB[0].second && cnt <= N-2){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 4608
#pragma GCC optimize("O2")
#pragma G++ optimize("O2")
#include<cstdio>
#include<algorithm>
#define ll long long
#define For(i,x,y)  for(ll i=x;i<=y;++i)
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
#define lf else if
using namespace std;
inline ll read(){   ll x=0,f=1;char ch=getchar();   while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}  while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}  return x*f; } 
inline void write(ll x){    if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10);   putchar(x%10+'0');  } 
inline void writeln(ll x){ write(x);   puts("");   }
ll n;
ll gcd(ll a,ll b){	return b?gcd(b,a%b):a;	}
int main(){
	n=read();	ll ans=1;
	For(i,1,n){
		ll x=read();
		ans=ans/gcd(ans,x)*x;
	}writeln(ans);
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;

public class Main
{

public static void main( String[] args ) throws Exception
{
	final Scanner sc = new Scanner( System.in );
	final int N = sc.nextInt();
	long score1 = 0;
	long score2 = 0;
	
	int firstH = sc.nextInt();
	int pos1 = firstH;
	int pos2 = firstH;
	
	while( sc.hasNext() )
	{
		int h = sc.nextInt();
		long score = 0;
		int diff1 = Math.abs( pos1 - h );
		int diff2 = Math.abs( pos2 - h );
		long scoreIf1 = score1 + diff1;
		long scoreIf2 = score2 + diff2;
		if( scoreIf1 < scoreIf2 )
		{
			score = scoreIf1;
		}
		else
		{
			score = scoreIf2;
		}
		pos1 = pos2;
		pos2 = h;
		
		score1 = score2;
		score2 = score;
	}
	p( score2 );
}

public static void p( Object o )
{
	System.out.println( o );
}

}

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

using namespace std;

typedef long long ll;
#define INF (1<<29)
#define INFF 0x7fffffff
#define LINF (1ll<<60)
#define LINFF 0x7fffffffffffffff
#define PI 3.14159265359
#define _fi(n) for(int i = 0;i < n;i++)
#define _fj(n) for(int j = 0;j < n;j++)
#define _fk(n) for(int k = 0;k < n;k++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define YESNO(ans) cout << (ans?"YES":"NO") << endl;
#define pqueue priority_queue
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'


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

    string s, t;cin>>s>>t;
    cout << t+s << endl;

    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;

int main() {
    int n; cin >> n;
    V<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(ALL(a));

    ll ans = a[n - 1];
    ll ite = 0;
    for(int i = 0; i < n - 1; i++){
        if(a[i] < ans / 2) ite = i;
        else break;
    }

    if(abs(ans - a[ite] * 2) <= abs(ans - a[ite + 1] * 2)){
        cout << ans << " " << a[ite] << endl;
    }else{
        cout << ans << " " << a[ite + 1] << endl;
    }

}


Measured memory_bytes: 640
#include <stdio.h>

#define N 100000
#define Q 50000

main(){
  int n,q;
  int i,l,r,m;
  int S[N],T[Q];
  int count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    l=0;
    r=n; //両端に初期化?
    while(l<r){
      m=(l+r)/2;

      if(S[m]==T[i]){
	count++;
	break;
      }
      else if(S[m]<T[i]){
	l=m+1;
      }
      else{
	r=m;
      }
    }
  }

    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include <string>
#include<vector>

using namespace std;

int main(){

	int a, b, c;
	cin >> a >> b >> c;
	if( b-a == c-b){
		cout << "YES" << endl;
	}
	else{
		cout <<"NO" << endl;
	}

	return 0;

}

Measured memory_bytes: 504
n = int(raw_input())
a = map(int,raw_input().split())
m = [-1]*n

m2 = a[0]
for i in xrange(1,n):
	m2 += (-1)**(i+1)*a[i]
m[1] = m2
m[0] = 2*a[0]-m2
for i in xrange(2,n):
	m[i] = 2*a[i-1]-m[i-1]
print " ".join(str(x) for x in m)

Measured memory_bytes: 15588
//Name : Rupa Dey
  //Date : 27 august 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
//#define n cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gap " ";
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cout<<"1"<<endl;
    int k,n,i,total=0;
    cin>>n>>k;
    vi vec(n);
    for(i,0,n)
        cin>>vec[i];
    sort(vec.begin(),vec.end());
    //for(i,0,n)
       // cout<<vec[i]<<" ";

    for(i,0,k)
    {
        total+=vec[i];
    }
    cout<<total;
}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>

int main()
{
  int N, D;
  int X[10][10];
  int dist_pow, dist_sqrt, num;
  int i, j, k, ret;

  ret = scanf("%d %d", &N, &D);
  for ( i=0; i<N; i++ ) {
    for ( j=0; j<D; j++ ) {
      ret = scanf("%d", &(X[i][j]));
    }
  }
  num = 0;
  for ( i=0; i<N-1; i++ ) {
    for ( j=i+1; j<N; j++ ) {
      dist_pow = 0;
      for ( k=0; k<D; k++ ) {
        dist_pow += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      dist_sqrt = (int)sqrt((double)dist_pow);
      if ( dist_pow == dist_sqrt * dist_sqrt )
        num++;
    }
  }
  printf("%d\n", num);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline ll lowbit(ll x){
	return x&-x;
}
inline ll query(ll x){
	ll ans=0;
	for(;x;x-=lowbit(x)){
		ans++;
	}
	return ans;
}
ll t,n[16],cnt,peo[16][16],w[16][16];
int main(){
	cin>>t;
	for(ll i=1;i<=t;i++){
		scanf("%lld",&n[i]);
		for(ll j=1;j<=n[i];j++)
		scanf("%lld%lld",&peo[i][j],&w[i][j]);
	}
	for(ll i=0;i<(1<<t);i++){
		bool flag=false;
		ll pan=0;
		for(ll j=1;j<=t;j++){
			pan=0;
			for(ll k=1;k<=n[j];k++){
				if(w[j][k]^((i&(1<<(peo[j][k]-1)))>>(peo[j][k]-1))){
					pan=1;
				}
			}
			if(i&(1<<(j-1))){
				if(pan){
					flag=true;
					break;
				}
			}
			else{
				if(!pan){
					flag=true;
					break;
				}
			}
		}
		if(!flag){
			cnt=max(cnt,query(i));
		}
	}
	cout<<cnt;
	return 0;
} 

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

bool is_used[26];
int main()
{
  std::string s,t;
  std::cin >> s;
  t = s;

  std::sort(t.begin(), t.end());
  t.erase(std::unique(t.begin(), t.end()), t.end());

  if (s.size() == t.size()) {
    std::cout << "yes" << std::endl;
  } else {
    std::cout << "no"  << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,m,i,j,k;
    scanf("%d",&n);
    long a[n],ki[n],gu[n];
    for(i=1;i<n+1;i++)
    {
        scanf("%ld",&a[i]);
    }
    for(m=1;m<n+1;m++)
    {
       if(m%2 == 0)
       {
           gu[m/2]=a[m];
       }
       else if(m%2 ==1)
       {
           ki[(m+1)/2]=a[m];
       }
    }
    if(n%2==0)
    {
        for(j=n/2;j>0;j--)
        {
            printf("%ld ",gu[j]);
        }
        for(j=1;j<n/2+1;j++)
        {
            printf("%ld ",ki[j]);
        }
    }
    else if(n%2==1)
    {
        for(k=(n-1)/2+1;k>0;k--)
        {
            printf("%ld ",ki[k]);
        }
        for(k=1;k<(n-1)/2+1;k++)
        {
            printf("%ld ",gu[k]);
        }
    }
}


Measured memory_bytes: 6784
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		boolean[] town = new boolean[N];
		long counter = 1;
		int[] A = new int[N];
		for(int i = 0;i < N;i++){
			A[i] = sc.nextInt() - 1;
		}
		int pointer = A[0];
		town[0] = true;
		while(town[pointer] == false){
			town[pointer] = true;
			pointer = A[pointer];
			counter++;
		}
		int ans = pointer;
		int pointer2 = 0;
		long counter2 = 0;
		while(pointer2 != pointer){
			pointer2 = A[pointer2];
			counter2++;
		}
		if(K < counter){
			ans = 0;
			for(long i = 0;i < K;i++){
				ans = A[ans];
			}
		}else if(K > counter2 && counter > counter2){
			long buf = (K - counter2) % (counter - counter2);
			ans = pointer;
			for(long i = 0;i < buf;i++){
				ans = A[ans];
			}
		}
		System.out.println((ans + 1));
	}
}

Measured memory_bytes: 60368
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
ll p=1000000007;
vector<ll> q(30);
vector<int> e(30);
ll f(int k){
  q[0]=k;
  for(int i=1;i<=30;i++){
    q[i]=(q[i-1]*q[i-1])%p;}
  e[0]=e[2]=e[9]=e[11]=e[14]=e[15]=e[17]=e[19]=e[20]=e[23]=
    e[24]=e[25]=e[27]=e[28]=e[29]=1;
  ll t=1;
  rep(i,30){if(e[i]==1){t=(t*q[i])%p;}}
  return t;}
int main(){
  int x,y;
  cin>>x>>y;
  if(-x+2*y>=0&&(-x+2*y)%3==0&&2*x-y>=0&&(2*x-y)%3==0){
    int a=(-x+2*y)/3,b=(2*x-y)/3;
    ll v=1,w=1,z=1;
    for(int i=1;i<=a+b;i++){v=v*i%p;}
    for(int i=1;i<=a;i++){w=w*i%p;}
    for(int i=1;i<=b;i++){z=z*i%p;}
    ll s=(v*f(w)%p)*f(z)%p;
    cout<<s<<endl;}
  else cout<<0<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=6005;
int ne[N],tot,fi[N],zz[N],n,a[N],f[N],x,y,Ans[N];
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
int cmp(int x,int y){
	return a[x]<a[y];
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	for (int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		jb(x,y);jb(y,x);
	}
	for (int i=1;i<=n;i++)f[i]=i;
	sort(f+1,f+n+1,cmp);
	for (int i=1;i<=n;i++){
		Ans[f[i]]=0;
		for (int j=fi[f[i]];j;j=ne[j])
			if (a[f[i]]>a[zz[j]])Ans[f[i]]|=!Ans[zz[j]];
	}
	for (int i=1;i<=n;i++)
		if (Ans[i])printf("%d ",i);
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


long double ternary_search(
    const std::function<long double(long double)> &fn,
    long double lo = 0., long double hi = 1e9) {
    for (int iter = 0; iter < 1000; iter++) {
        long double midl = lo + (hi - lo) / 3;
        long double midr = lo + (hi - lo) / 3 * 2;
        if (fn(midl) < fn(midr)) hi = midr;
        else lo = midl;
    }
    return lo;
}

constexpr long double EPS = 1e-18;

long double binary_search_left(
    const std::function<long double(long double)> &fn,
    long double t, long double lo = 0., long double hi = 1e9) {
    hi = t;
    long double targ = fn(t);
    for (int iter = 0; iter < 100; iter++) {
        long double mid = lo + (hi - lo) / 2;
        if (std::abs(fn(mid) - targ) < EPS) hi = mid;
        else lo = mid;
    }
    return lo;
}

long double binary_search_right(
    const std::function<long double(long double)> &fn,
    long double t, long double lo = 0., long double hi = 1e9) {
    lo = t;
    long double targ = fn(t);
    for (int iter = 0; iter < 100; iter++) {
        long double mid = lo + (hi - lo) / 2;
        if (std::abs(fn(mid) - targ) < EPS) lo = mid;
        else hi = mid;
    }
    return lo;
}

int main() {
    int n; std::cin >> n;
    std::vector<long double> x(n), y(n);
    std::vector<long double> dx(n), dy(n);
    for (int i = 0; i < n; i++) {
        std::cin >> x[i] >> y[i];
        char c; std::cin >> c;
        if (c == 'R') dx[i] = 1;
        if (c == 'L') dx[i] = -1;
        if (c == 'U') dy[i] = 1;
        if (c == 'D') dy[i] = -1;
    }
    auto fxmax = [&](long double t) {
        long double ret = -1e18;
        for (int i = 0; i < n; i++) {
            ret = std::max(ret, x[i] + t*dx[i]);
        }
        return ret;
    };
    auto fxmin = [&](long double t) {
        long double ret = 1e18;
        for (int i = 0; i < n; i++) {
            ret = std::min(ret, x[i] + t*dx[i]);
        }
        return -ret;
    };
    auto fymax = [&](long double t) {
        long double ret = -1e18;
        for (int i = 0; i < n; i++) {
            ret = std::max(ret, y[i] + t*dy[i]);
        }
        return ret;
    };
    auto fymin = [&](long double t) {
        long double ret = 1e18;
        for (int i = 0; i < n; i++) {
            ret = std::min(ret, y[i] + t*dy[i]);
        }
        return -ret;
    };

    std::vector<long double> cand = { 0. };
    auto push = [&](const auto& fn) {
        long double t = ternary_search(fn);
        cand.push_back(binary_search_left(fn, t));
        cand.push_back(binary_search_right(fn, t));
    };
    push(fxmax);
    push(fxmin);
    push(fymax);
    push(fymin);

    long double ans = 2e18;
    for (long double t : cand) {
        ans = std::min(ans, (fxmax(t) + fxmin(t))*(fymax(t) + fymin(t)));
    }
    printf("%.14Lf\n", ans);
    return 0;
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;

vector<vector<pair<int, int> > > edge(10);//edge[i][j] firstがiからj番目のノード、secondがその重み
vector<int> d(15,INF);

void dijkstra(int start){
    priority_queue<int, vector<int>, greater<int> > q;

    d[start] = 0;
    q.push(start);

    while(!q.empty()){
        int now = q.top();
        q.pop();
        for(int j = 0; j < edge[now].size(); j++){
            int next = edge[now][j].first;
            int nextd = d[now] + edge[now][j].second;
            if(nextd < d[next]){
                d[next] = nextd;
				q.push(next);
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int h,w;
	cin >> h >> w;
	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			int c;
			cin >> c;
			edge[j].push_back(make_pair(i, c));
		}
	}
	dijkstra(1);
	ll ans = 0;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			int a;
			cin >> a;
			if(a != -1){
				ans += d[a];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def gen_prime():
	yield 2
	yield 3
	n=0
	while 1:
		yield n+5
		yield n+7
		n+=6


def resolve():
	l=list(range(55556))
	l[1]=0
	p=gen_prime()
	for i in p:
		if i**2>55556:
			break
		if i in l:
			t=i+i
			while t<55556:
				l[t]=0
				t+=i
	prime=[i for i in l if i%5==1]
	n=int(input())
	ans=prime[:n]
	x=''
	for i in ans:
		x+=str(i)+' '
	print(x[:-1])

resolve()

Measured memory_bytes: 39408
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		char[] c = in.nextToken().toCharArray();
		int n = c.length;
		for (int i = 0; i < c.length; i++) {
			c[i] = (char) (c[i] - 'a');
		}
		
		int[] dp = new int[n + 1];
		Arrays.fill(dp, Integer.MAX_VALUE / 2);
		Map<Integer, Integer> best = new HashMap<>();
		best.put(0, 0);
		int mask = 0;
		for (int i = 0; i < c.length; i++) {
			mask ^= 1 << c[i];
			int ans = best.containsKey(mask) ? best.get(mask) : Integer.MAX_VALUE / 2;
			for (int j = 0; j < 26; j++) {
				if (best.containsKey(mask ^ (1 << j))) {
					ans = Math.min(ans, best.get(mask ^ (1 << j)) + 1);
				}
			}
			best.put(mask, ans);
		}
		out.println(mask == 0 ? 1 : best.get(mask));
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 96356
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
div = 1000000007

a.sort()
A = [0]*(N+1)
A[0] = 1

flag = True
if M==0: flag = False

for i in range(1, N+1):
  if flag and i == a[0]:
    A[i] = 0
    a.remove(i)
    if len(a)==0: flag = False
  else:
    if i==1: A[i] = 1
    else:
      A[i] = (A[i-1] + A[i-2])%div

print(A[N])

Measured memory_bytes: 7824
from collections import Counter
N = int(input())
listBlue = [input() for i in range(N)]
M = int(input())
listRed = [input() for i in range(M)]

counterBlue = Counter(listBlue)
counterRed = Counter(listRed)
counterSum = counterBlue - counterRed
if len(counterSum) == 0:
    print(0)
else:
    ans = max(counterSum.values())
    print(ans)

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

#define LOCAL 0

#define lli long long int
#define llu unsigned long long int
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define slli(n) scanf("%lld",&n);
#define ss(n) scanf("%s",n);

const long double EPS = 1e-10;
const int MOD = 1000000007ll;
const int mod1 = 1000000009ll;
const int mod2 = 1100000009ll;
int INF = (int)1e9;
lli INFINF = (lli)1e18;
int debug = 0;
long double PI = acos(-1.0);

using namespace std;

int bit_count(lli _x){lli _ret=0;while(_x){if(_x%2==1)_ret++;_x/=2;}return _ret;}
int bit(lli _mask,int _i){return (_mask&(1ll<<_i))==0?0:1;}
int add(int a,int b,int m=MOD){int x=a+b;while(x>=m)x-=m;while(x<0)x+=m;return x;}
int sub(int a,int b,int m=MOD){int x=a-b;while(x<0)x+=m;while(x>=m)x-=m;return x;}
int mul(int a,int b,int m=MOD){lli x=a*1ll*b;x%=m;while(x<0)x+=m;return (int)x;}
int ldtoint(ld x){return (int)(x+0.5);}lli ldtolli(ld x){return (lli)(x+0.5);}
int powermod(lli _a,lli _b,int _m=MOD){lli _r=1;while(_b){if(_b%2==1)_r=mul(_r,_a,_m);_b>>=1;_a=mul(_a,_a,_m);}return _r;}

template<class T1,class T2>ostream&operator<<(ostream& os,const pair<T1,T2>&p){os<<"["<<p.first<<","<<p.second<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,const vector<T>&v){os << "[";bool first=true;for (T it:v){if (!first)os<<", ";first = false;os<<it;}os<<"]";return os;}
template<class T>ostream&operator<<(ostream& os,set<T>&v){os<<"[";bool first=true;for (T it:v){if(!first)os<<", ";first=false;os<<it;}os<<"]";return os;}
template<class T1,class T2>ostream&operator<<(ostream& os,map<T1,T2>&v){os<<"[";bool first=true;for(pair<T1,T2> it:v){if(!first)os<<", ";first=false;os<<"("<<it.F<<","<<it.S<<")";}os<<"]";return os;}
template<class T>void parr(T a[],int s,int e){cout<<"[";for(int i=s;i<e;i++)cout<<a[i]<<", ";cout<<a[e]<<"]\n";}

lli N;
lli A[100010];
lli B[100010];

int main()
{
if(LOCAL){
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    debug = 1;
}
    srand (time(NULL));

    slli(N);

    if(N == 1){
        cout<<"YES\n";
        return 0;
    }

    for(int i=1;i<=N;i++)
        slli(A[i]);

    lli sum = 0;
    lli sign = (N*(N+1))/2;

    for(int i=1;i<=N;i++)
        sum += A[i];

    if(sum%sign != 0){
        cout<<"NO\n";
        return 0;
    }

    lli x = 0;
    for(int i=2;i<=N;i++){
        x += A[i] - A[i-1];
    }
    x += A[1] - A[N];

    if(x != 0){
        cout<<"NO\n";
        return 0;
    }

    lli turns = sum/sign;
    lli t = 0;
    for(int i=2;i<=N;i++){
        lli diff = A[i] - A[i-1];
        t += (turns - diff)/N;
        if((turns-diff)%N != 0 || turns<diff){
            cout<<"NO\n";
            return 0;
        }
    }
    lli diff = A[1] - A[N];
    t += (turns - diff)/N;

    if((turns-diff)%N != 0 || turns<diff){
        cout<<"NO\n";
        return 0;
    }

    if(t != turns){
        cout<<"NO\n";
        return 0;
    }
    cout<<"YES\n";

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

typedef long long int lli;

int main()
{
	lli m, n, p, q, s, t, u, v;
	
	while(cin >> n && n){
		cin >> s >> t >> u >> v;
		
		while(v > 0){
			if((s-t*v) >= 0 && (s-t*v)/u+v >= n){
				break;
			}
			v--;
		}
		
		if(v == 0){
			cout << "NA" << endl;
		} else {
			cout << v << " " << ((s-t*v)/u) << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define Fst first
#define Snd second
#define RG register
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned int UI;
typedef unsigned long long ULL;
template<typename T> inline void read(T& x) {
	char c = getchar();
	bool f = false;
	for (x = 0; !isdigit(c); c = getchar()) {
		if (c == '-') {
			f = true;
		}
	}
	for (; isdigit(c); c = getchar()) {
		x = x * 10 + c - '0';
	}
	if (f) {
		x = -x;
	}
}
template<typename T, typename... U> inline void read(T& x, U& ... y) {
	read(x), read(y...);
}
const int N=2e5+10,P=1e9+7;
int n;
int ST[N],F[N][2];
struct Data {
  int x,v;
  Data () {}
  Data (int x,int v) :x(x),v(v) {}
}A[N];
bool cmp(Data A,Data B) {
  return A.v<B.v;
}
struct Sec {
  int l,r;
  Sec () {}
  Sec (int l,int r) :l(l),r(r) {}
}G[N];
bool cmp1(Sec A,Sec B) {
  //return A.r<B.r;
  return A.r==B.r?A.l<B.l:A.r<B.r;
}
//#define rua
int main() {
//	ios::sync_with_stdio(false);
#ifdef rua
	freopen("GG.in","r",stdin);
#endif
  read(n);
  for(int i=1;i<=n;++i) read(A[i].x,A[i].v);
  sort(A+1,A+n+1,cmp);
  int top=0;
  for(int i=1;i<=n;++i) {
    if(!top||A[i].x>A[ST[top]].x) ST[++top]=i;
    int l=1,r=top;
    while(l!=r) {
      int mid=l+r>>1;
      if(A[ST[mid]].x>=A[i].x) r=mid;
      else l=mid+1;
    }
    G[i].l=ST[l];
  }
  top=0;
  for(int i=n;i;--i) {
    if(!top||A[i].x<A[ST[top]].x) ST[++top]=i;
    int l=1,r=top;
    while(l!=r) {
      int mid=l+r>>1;
      if(A[ST[mid]].x<=A[i].x) r=mid;
      else l=mid+1;
    }
    G[i].r=ST[l];
  }
  sort(G+1,G+n+1,cmp1);
  int res=0;
  for(int i=1;i<=n;++i) {
    if(G[i].l==1) F[i][1]=(F[i-1][0]+F[i-1][1]+1)%P;
    else {
      int l=0,r=i-1;
      while(l!=r) {
        int mid=l+r>>1; ++mid;
        if(G[mid].r<G[i].l-1) l=mid;
        else r=mid-1;
      }
      F[i][1]=(F[i-1][1]-F[l][1]+P)%P;
      F[i][0]=(F[i-1][0]-F[l][0]+P+1)%P;
    }
    if(G[i].r==n) res=(res+F[i][1])%P;
    F[i][1]=(F[i-1][1]+F[i][1])%P;
    F[i][0]=(F[i-1][0]+F[i][0])%P;
  }
  printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 5760
using System;
using System.Linq;

namespace _0160
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                int output = 0;
                for (int i = 0; i < n; i++)
                {
                    int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    int nagasa = x[0] + x[1] + x[2];
                    if (nagasa <= 60 && x[3] <= 2)
                    {
                        output += 600;
                    }
                    else if (nagasa <= 80 && x[3] <= 5)
                    {
                        output += 800;
                    }
                    else if (nagasa <= 100 && x[3] <= 10)
                    {
                        output += 1000;
                    }
                    else if (nagasa <= 120 && x[3] <= 15)
                    {
                        output += 1200;
                    }
                    else if (nagasa <= 140 && x[3] <= 20)
                    {
                        output += 1400;
                    }
                    else if (nagasa <= 160 && x[3] <= 25)
                    {
                        output += 1600;
                    }
                }
                Console.WriteLine(output);
            }
        }
    }
}

Measured memory_bytes: 9624
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n,m;
    cin >> n >> m;
    if(abs(n- m ) > 1){
        cout << 0 << endl;
    }else{
        ll ans = 1;
        repi(i,n + 1,1){
            ans *= i;
            ans %= MOD;
        }
        repi(i,m + 1,1){
            ans *= i;
            ans %= MOD;
        }
        if(n == m)ans *= 2;
        cout << ans % MOD << endl;
    }
    return 0;
}

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

int n, m;
vector<vector<int>> graph;
bool truth = false;
vector<bool> visited;

void dfs(int index, int cnt) {
    if(index == n-1) {
        truth = true;
        return ;
    }
    visited.at(index) = true;

    if(cnt < 2) {
        int len = graph.at(index).size();
        for(int i = 0; i < len; ++i) {
            int next = graph.at(index).at(i);
            if(!visited.at(next)) dfs(next, cnt+1);
        }
    }
}

int main() {
    cin >> n >> m;
    graph = vector<vector<int>>(n);
    visited = vector<bool>(n, false);
    for(int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph.at(a).push_back(b);
        graph.at(b).push_back(a);
    }

    dfs(0, 0);

    if(truth) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 12016
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

l=int(input())
r=l/3
print(r*r*r)

Measured memory_bytes: 66028
import java.util.Scanner;
import java.io.IOException;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String[] strAry = scan.nextLine().split(" ");
			int h = Integer.parseInt(strAry[0]);
			int w = Integer.parseInt(strAry[1]);
			
			if (h == 0 && w == 0) break;
			
			for (int i = 0; i < h; i++) {
				if (i == 0 || i == h - 1) {
					for (int j = 0; j < w; j++) {
						System.out.print("#");
					}
				}
				else {
					for (int j = 0; j < w; j++) {
						if (j == 0 || j == w - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int n, k, a[100001];

int main(){
	cin >> n >> k;
	int m;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] == 1) m = i;
	}
	
	int cnt = 0;
	cnt = ((n-1) / (k-1)) + !!((n-k) % (k-1));
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 640
ls = list(map(str,input().split()))
data = []
for cur in ls:
    if cur in ['+','-','*']:
        b = int(data.pop())
        a = int(data.pop())
        if cur == '+':
            data.append(a+b)
        elif cur == '-':
            data.append(a-b)
        else:
            data.append(a*b)
    else:
        data.append(cur)

print(data[0])


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll 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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};



int main()
{
  int n; cin >> n;
  map<ll, ll> mp;
  rep(i, n) {
    ll a; cin >> a;
    ++mp[a];
  }
  int q; cin >> q;
  ll ans = 0;
  for(auto x : mp) ans += x.first*x.second;
  rep(i, q) {
    ll b, c; cin >> b >> c;
    ans += (c-b)*mp[b];
    mp[c] += mp[b];
    mp[b] = 0;
    cout << ans << endl;
  }
}


Measured memory_bytes: 9328
import sys
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
#dp[v]: start from v maxpath
dp = [-1 for _ in range(N)]

gragh = [[] for _ in range(N)]
for _ in range(M):
    x,y = map(int, input().split())
    gragh[x-1].append(y-1)

#solve DAG and topological sort by memo recursive funciton
def f(v,G=gragh):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for u in G[v]:
        ret = max(ret, f(u) + 1)
    dp[v] = ret
    return ret
for v in range(N):
    dp[v] = f(v)
print(max(dp))

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  long N, M;
  const long MOD = 1000000007;
  cin >> N >> M;
  long ans = 1;
  if (abs(N - M) > 1) {
    ans = 0;
  } else {
    for (long i = 2; i <= N; i++) {
      ans = (ans * i) % MOD;
    }
    for (long i = 2; i <= M; i++) {
      ans = (ans * i) % MOD;
    }

    if (N == M)
      ans = (ans * 2) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
pair<string, int>A[101];
signed main() {
  int N; cin>>N;
  vector<int>V(N);
  vector<int>C(N);
  int count=0;
  rep(i,N)cin>>V[i];
  rep(i,N){
    cin>>C[i];
    if(V[i]>C[i])count+=V[i]-C[i];
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#define For(i,A,B) for(i=(A);i<=(B);++i)
char s[200050];
int main(){
	int n,i;
	scanf("%s",s);n=strlen(s);
	For(i,0,n-1)if(s[i]=='?')s[i]='D';
	puts(s);
	return 0;
}

Measured memory_bytes: 1836
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a==b&&b==c)cout << "Yes"<<endl;
  else cout << "No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int n, a, sum = 0, x;
	cin >> n;
	a = n;
	while (a != 0) {
		x = a % 10;
		sum += x;
		a /= 10;
	}
	cout << (n % sum == 0 ? "Yes" : "No") << endl;
}

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

int main() {
    int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int A=(a-1)/10*10+10;
  int B=(b-1)/10*10+10;
  int C=(c-1)/10*10+10;
  int D=(d-1)/10*10+10;
  int E=(e-1)/10*10+10;
  int f=A-a;
  int g=B-b;
  int h=C-c;
  int i=D-d;
  int j=E-e;
  int n=9;
  
    
   while(n>f&&n>g&&n>h&&n>i&&n>j)
     n--;
  

    cout <<A+B+C+D+E-n<< endl;
}


Measured memory_bytes: 256