akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
string S;
signed main(){
    cin>>S;
    while(S!="ABC"){
        int cnt[3]={0};
        rep(i,S.size())cnt[S[i]-'A']++;
        int mi=0;
        rep(i,3)if(cnt[mi]>cnt[i])mi=i;
        rep(i,3)if(cnt[mi]==cnt[i]&&i!=mi){
            cout<<"No"<<endl;
            return 0;
        }
        if(cnt[mi]==0){
            cout<<"No"<<endl;
            return 0;
        }
 
        string SS;
        bool used[5000]={0};
        rep(i,S.size()){
            if(S[i]-'A'!=mi)continue;
            for(int j=i-mi;j<=i+(2-mi);j++){
                if(j<0||j>=S.size()||used[j]||S[j]!=j-i+mi+'A'){
                    cout<<"No"<<endl;
                    return 0;
                }
                used[j]=true;
            }
        }
        rep(i,S.size()){
            if(!used[i])SS+=S[i];
            else if(S[i]=='A')SS+='A'+mi;
        }
        S=SS;
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3260
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	fmt.Print(lucasNumber(N))
}

func lucasNumber(N int) int {
	L0, L1 := 2, 1
	for i := 0; i < N-1; i++ {
		L0, L1 = L1, L1+L0
	}
	return L1
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
	int h,w,i,ii;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0)break;
		for(i=0;i<h;i++){
			for(ii=0;ii<w;ii++){
				if(i==0||i==(h-1)||ii==0||ii==(w-1)){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int  a, b, c, d, X, Y;
//  double  c;
//  long long  a, b, c, d, X, Y;
  int D, G;
  //char s[101][101]={};
  char sv[101]={};
  char ss[101]={};
//  char s_temp[101]={};
  char t[12]={};
//  char s[10000000000000000001]={};
  char s[2][100001]={};
  int len=0;
//  int N, M;
//  int A[1000000001]={};
  long long  A[101]={};
//  long int A[1001]={};
  long long  B[101]={};
  long long  C[101]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=1000;
  int cnt=0;
  double ans=1000;
  int max=0;

  int  Cen_X=0;
  int  Cen_Y=0;
  long long  H=0;
  
  //  int ans=0;
  int str_len=0;
//  char alp[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 ans_o[1001]={};
  double N[1001]={};
  int ans_e[100001]={};
//  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d", &a);
//  cnt = strlen(t);
  //printf("%d\n",cnt);
  tmp=a;
  i=0;
  while(1){
//    printf("test %d\n",tmp);
  b=tmp;
    if(tmp==4||tmp==2||tmp==1) break;
    if(0==(b%2)) tmp=b/2;
    else if(1==(b%2))tmp=(3*b)+1;
    i++; 
  }
//  for(i=0;i<cnt;i++){
//    a=a+(t[cnt-i-1]-'0') * ()(pow(10, i));
//  printf("%d\n",min);
//  }
      
//  if(flag==0)   printf("TLE\n");
  printf("%d\n", i+4);
  
return 0;
}


Measured memory_bytes: 128
from numpy import zeros, maximum

def main():
    N, T, *AB = map(int, open(0).read().split())

    dp = zeros(6010, int)
    for w, v in sorted(zip(*[iter(AB)] * 2)):
        dp[w:T + w] = maximum(dp[w:T + w], dp[:T] + v)

    print(dp.max())

main()


Measured memory_bytes: 12740
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <cassert>

using namespace std;

typedef long long int tint;

#define forsn(i,s,n) for(int i=(s); i<(int)(n); i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for(int i=(n-1); i>=(int)(s); i--)
#define dforn(i,n) dforsn(i,0,n)

typedef long long int tint;

int a[1024];
bool on[1048576];

int main() {
	int n, k; cin >> n >> k;
	forn(i,n) cin >> a[i];
	
	vector<tint> sums;
	forn(i,n) {
		tint cur = 0;
		forsn(j, i, n) {
			cur += a[j];
			on[sums.size()] = true;
			sums.push_back(cur);
		}
	}
	
	tint res = 0;
	dforn(i, 60) {
		int amount = 0;
		forn(j, sums.size()) amount += (on[j] && (((1LL << i) & sums[j]) != 0));
		if (amount >= k) {
			res |= (1LL << i);
			forn(j,sums.size()) if (!((1LL << i) & sums[j])) on[j] = false;
		}
	}
	
	cout << res << endl;
}



Measured memory_bytes: 6512
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int A, B;
    string op;
    cin >> A >> op >> B;

    if(op == "+") cout << A + B << endl;
    else cout << A - B << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
 
  int sum = 0;
  while(n > 0){
    sum += n % 10,n /= 10;
  }
  if(sum == 1){
    cout << 10 << endl;
  }
  else{
  cout << sum << endl;
  }
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<int>V(3);
	rep(i, 3) {
		cin >> V[i];
	}
	sort(V);
	int cnt = 0;
	for (int i = 1; i < 3; i++) {
		if (V[i - 1] == V[i]) {
			cnt++;
		}
	}
	cout << 3 - cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i, s.size()) {
        if (s[i] == 'C') {
            for1(j, i, s.size()) {
                if (s[j] == 'F') {
                    puts("Yes");
                    return 0;
                }
            }
        }
    }
    puts("No");
	return 0;
}

Measured memory_bytes: 256
/*
ID: c4ts0up
LANG: C++
TASK: B - Common Raccoon vs Monster
URL: 
*/
#include <bits/stdc++.h>
using namespace std;

int h, n;
vector <int> att;

int main() {
	cin >> h >> n;
	att.resize(n);
	for (int i=0; i<n; i++) cin >> att[i];
	sort(att.begin(), att.end());
	reverse(att.begin(), att.end());
	
	bool flag = false;
	int res = 0;
	
	for (int x : att) {
		if (res >= h) {
			flag = true;
			break;
		}
		else res+=x;
	}
	
	if (res>=h) flag = true;
	
	if (flag) cout << "Yes";
	else cout << "No";
	cout << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int r;
	cin >> r;
	if (r >= 2800) cout << "AGC" << endl;
	else if (r >= 1200) cout << "ARC" << endl;
	else cout << "ABC" << endl;

}

Measured memory_bytes: 256
queue=[]
N,M=map(int,input().split())
NE=9223372036854775807
mp=[NE]*(N+1)
lst=[[] for _ in range(N+1)]
for _ in range(M):
    L,R,D = map(int, input().split())
    lst[L].append((L,R,D))
    lst[R].append((L,R,D))

def check(L, R, D):
    if mp[L] == NE:
        mp[L] = mp[R]-D
    elif mp[R] == NE:
        mp[R] = mp[L]+D
    else:
        if mp[L]+D != mp[R]:
            print("No")
            exit()

def check_list(ls, checking):
    while len(ls):
        L,R,D = ls.pop()
        check(L,R,D)
        nx = R if L == checking else L
        if len(lst[nx]): queue.append(nx)

for i in range(1, N+1):
    if mp[i] == NE: mp[i] = 0
    check_list(lst[i], i)

    while(len(queue) > 0):
        num = queue.pop()
        check_list(lst[num], num)
print("Yes")


Measured memory_bytes: 62180
import sys
input = sys.stdin.readline
import bisect

def main():
  n = int(input())
  X = list(map(int, input().split()))
  l = int(input())
  U = 17
  dp = [[0]*n for _ in range(U+1)]
  for i, x in enumerate(X):
    t = bisect.bisect_left(X, x+l)
    dp[0][i] = bisect.bisect_right(X, x+l) - 1
  for k in range(U):
    for i in range(n):
      dp[k+1][i] = dp[k][dp[k][i]]
  q = int(input())
  for _ in range(q):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a > b:
      a, b = b, a
    res = 1
    for k in range(U, -1, -1):
      if dp[k][a] < b:
        a = dp[k][a]
        res += (1<<k)
    print(res)
if __name__ == "__main__":
  main()

Measured memory_bytes: 25260
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

int main() {
	int n;
	cin >> n;
	VI a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[n - 1] - a[0] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();

            int max = Integer.MIN_VALUE;
            int min = Integer.MAX_VALUE;

            for (int i = 0; i < n; i++) {
                int cn = in.nextInt();
                if (cn > max)
                    max = cn;
                if (cn < min)
                    min = cn;
            }

            out.println(max - min);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int invmod(int a, int p){ // a^-1 mod p
  int b = p, u = 1, v = 0;
  while(b){
    int t = a / b;
    a -= t*b; swap(a, b);
    u -= t*v; swap(u, v);
  }
  u %= p;
  if(u < 0) u += p;
  return u;
}

int powmod(int a, int p, int m){
  int res = 1, tmp = a;
  while(p != 0){
    if(p % 2)
      res = (res*tmp) % m;
    tmp = (tmp*tmp) % m;
    p /= 2;
  }
  return res;
}

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

  int N, A[10000]; cin >> N;
  REP(i, N) cin >> A[i];
  sort(A, A+N);
  umap<int, int> mp;
  REP(i, N){
    int num = A[i];
    for(int j = 2; j*j <= A[i]; j++){
      int cnt = 0;
      if(num % j == 0){
        while(num % j == 0){
          num /= j; cnt++;
        }
        chmax(mp[j], cnt);
      }
    }
    if(num != 1){
      mp[num] = 1;
    }
  }
  int lcm = 1;
  for(auto itr : mp){
    lcm *= powmod(itr.first, itr.second, MOD);
    lcm %= MOD;
  }
  cerr << lcm << endl;
  int ans = 0;
  REP(i, N){
    ans += invmod(A[i], MOD);
    ans %= MOD;
  }
  cout << (lcm * ans) % MOD << endl;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define N 110
int main()
{
	ios::sync_with_stdio(false);
	int H,W;
	char a[N][N];
	char b[N][N];
	while(cin>>H>>W)
	{
		memset(a,'0',sizeof(a));
		int i,j;
		for(i=1;i<=H;i++)
			for(j=1;j<=W;j++)
				cin>>a[i][j];
		for(i=1;i<=H;i++)
			for(j=1;j<=W;j++)
				if(a[i][j]!='.')
				{
					a[i][0]='1';
					break;
				}
		for(j=1;j<=W;j++)
			for(i=1;i<=H;i++)
				if(a[i][j]!='.')
				{
					a[0][j]='1';
					break;
				}
		for(i=1;i<=H;i++)
		{
			if(a[i][0]=='1')
			{
				for(j=1;j<=W;j++)
				{
					if(a[0][j]=='1')
					{
						cout<<a[i][j];
					}
				}	
				cout<<endl;
			}
		}
	}
	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0);

    int n; cin >> n;

    map<int, int> mp;

    for(int i = 0; i < n; i++)
    {
        int k; cin >> k;

        mp[k]++;
    }

    int ans = 0;

    for(int i = -1; i <= int(1e5); i++)
    {
        ans = max(ans, mp[i] + mp[i - 1] + mp[i + 1]);
    }

    cout << ans << endl;
    return 0;
}

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

int main()
{
  int s;
  cin >> s;
  vector<int> a;
  a.push_back(s);
  
  int cnt = 0;
  while(true)
  {
    if(a.back() % 2 == 0)
    {
      a.push_back(a.back() / 2);          
    }
    else
    {
      a.push_back(a.back() * 3 + 1);  
    }
    
    if(count(a.begin(), a.end(), a.back()) > 1)
    {
      cout << a.size() << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

int N, M;
vvi es;
map<pii, ll> ds;
vb vis;
vl x;
string ans;
void dfs(int i) {
    if (i >= N) return;
    if (vis[i]) return;

    vis[i] = true;

    for(int j : es[i]) {
        ll d = ds[pii(i, j)];
        if (vis[j]) {
            if (x[j] == x[i] + d) continue;
            else {
                ans = "No";
                return;
            }
        }
        x[j] = x[i] + d;
        dfs(j);
    }
}


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

    cin >> N >> M;
    vi L(M), R(M), D(M);
    REP(i, M) {
        cin >> L[i] >> R[i] >> D[i];
        L[i]--; R[i]--;
    }

    es = vvi(N);
    REP(i,M) {
        es[L[i]].push_back(R[i]);
        ds[pii(L[i], R[i])] = D[i];
        es[R[i]].push_back(L[i]);
        ds[pii(R[i], L[i])] = -D[i];
    }

    bool ok = true;
    vis = vb(N, false);
    x = vl(N, 0);
    ans = "Yes";

    REP(i, N) {
        if (vis[i]) continue;
        dfs(i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 41600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m;
    cin >> n >>m;
    float sum=0;
    float a[n];
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];
    	sum+=a[i];
    }
    sort(a, a+n);
    if (a[n-m]>=0.25*sum/float(m))
    {
    	cout << "Yes"<<"\n";
    }
    else
    {
    	cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s):
    if 'LOCAL' in os.environ:
        print(s)

def main():
    global PX, nodes
    if 'BIG' in os.environ:
        N = 2* 10** 5
        Q = 2 * 10 ** 5
        AB = [[i, i + 1] for i in range(1, N)]
        PX = [[i, 10] for i in range(Q)]
    else:
        N, Q = LI()
        #  AB = []
        nodes = [[] for _ in range(N+1)]
        PX = [0] * (N+1)
        for i in range(N-1):
            a, b = LI()
            #  AB += (a, b)
            nodes[a].append(b)
            nodes[b].append(a)

        for i in range(Q):
            p, x = LI()
            PX[p] += x
        dfs(1, -1)
        print(' '.join(map(lambda x: str(x), PX[1:])))
        #  for i in PX[1:]:
        #      print(i, end=' ')
        #  ans = [0 for _ in range(N)]

def dfs(parent, parent_parent):
    for node in nodes[parent]:
        if node != parent_parent:
            PX[node] += PX[parent]
            dfs(node, parent)

if __name__ == '__main__':
    main()


Measured memory_bytes: 235924
import java.util.*;
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();
		if(B-A==C-B){
		    System.out.println("YES");
		}else{
		    System.out.println("NO");
		}
		
		
		
	}
}


Measured memory_bytes: 35748
/*
氏名 : 杉谷　裕貴,学籍番号 : 190441066
概要 : 行列の積を出力するプログラム
*/
#include<stdio.h>

int main(void)
{
	int n, m, l, i, j, k, a[100][100] = { 0 }, b[100][100] = { 0 };
	long long int c[100][100] = { 0 };

	scanf("%d %d %d", &n,&m,&l);

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}

	for (j = 0; j < m; j++)
	{
		for (k = 0; k < l; k++)
		{
			scanf("%d", &b[j][k]);
		}
	}

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			for (k = 0; k < l; k++)
			{
				c[i][k] += a[i][j] * b[j][k];
			}
		}
		
	}

	for (i = 0; i < n; i++)
	{
			for (k = 0; k < l; k++)
			{
				printf("%lld", c[i][k]);
				if (k != l - 1)
				{
					putchar(' ');
				}
			}
			putchar('\n');
	}
	
	return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}

template <class E>
using Graph = vector<vector<E>>;

template<class D, D INF>
struct Dijkstra {
    vector<D> res; //res[i] = sからiまでの最短距離
    
    template<class E>
    Dijkstra(const Graph<E> &g, int s) {
        int V = (int)g.size();
        res = vector<D>(V, INF);
        
        using P = pair<D, int>;
        priority_queue<P, vector<P>, greater<P>> q;
        q.push(P(0, s));
        res[s] = 0;
        while (!q.empty()) {
            P p = q.top(); q.pop();
            if (res[p.second] < p.first) continue;
            for (E e: g[p.second]) {
                if (p.first+e.dist < res[e.to]) {
                    res[e.to] = p.first+e.dist;
                    q.push(P(res[e.to], e.to));
                }
            }
        }
    }
};

const int MN = 100100;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    using P = pair<int, int>;
    set<int> gc[MN];
    vector<P> g[MN];
    for (int i = 0; i < m; i++) {
        int p, q, c;
        scanf("%d %d %d", &p, &q, &c); p--; q--;
        gc[p].insert(c);
        gc[q].insert(c);
        g[p].push_back(P(q, c));
        g[q].push_back(P(p, c));
    }

    int co = 0;
    map<P, int> p2id;
    for (int i = 0; i < n; i++) {
        gc[i].insert(0);
        for (int c: gc[i]) {
            p2id[P(i, c)] = co;
            co++;
        }
    }

    struct Edge {
        int to, dist;
    };
    Graph<Edge> gdist(co);
    for (int i = 0; i < n; i++) {
        for (P p: g[i]) {
            int j = p.first;
            int c = p.second;
            int mid = p2id[P(i, c)];
            int yid = p2id[P(j, c)];
            gdist[mid].push_back(Edge{yid, 0});
        }
        for (int c: gc[i]) {
            if (c == 0) continue;
            int mid = p2id[P(i, c)];
            int yid = p2id[P(i, 0)];
            gdist[mid].push_back(Edge{yid, 0});
            gdist[yid].push_back(Edge{mid, 1});
        }
    }
    Dijkstra<int, TEN(9)> djk(gdist, p2id[P(0, 0)]);
    int sid = p2id[P(0, 0)];
    int tid = p2id[P(n-1, 0)];
    int ans = Dijkstra<int, TEN(9)>(gdist, sid).res[tid];
    if (ans == TEN(9)) ans = -1;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 103484
#include<iostream>
using namespace std;
#include<string>
#define REP(i,a,b) \
for(int i=a; i<b; i++)
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define tr(c,i) for(typeof(c.begin()) i = (c).begin(); i != (c).end();i++)

int main()
{
	int n;
	cin >> n;
	if(n < 1200)cout << "ABC";
	else if(n < 2800)cout << "ARC";
	else cout << "AGC";
}


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

int main() {
	int n, a = 1, b = -1, c = 0;
	cin >> n;
	vector<int> vec(n);
	for(int i = 0; i < n; i++) {
		cin >> vec.at(i);
	}
	while(c < n) {
        c++;
		a = vec.at(a - 1);
		if(a == 2) {
			b = c;
			break;
		}
	}
	cout << b << endl;
}

Measured memory_bytes: 640
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define debug(args...){ string _s = #args;replace(_s.begin(),_s.end(),',', ' ');stringstream _ss(_s);istream_iterator<string>_it(_ss);err(_it, args);}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << "=" << a << ", "; err(++it, args...);}

#define ll              long long int
#define MAX             2134567891
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define rev(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define TC(t)           printf("Case %lld: ",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb              push_back
#define eb              emplace_back
#define ff              first
#define ss              second
#define NL              printf("\n");
#define bug(a)          cout<<#a<<" "<<a<<" ";
#define hlw             printf("hlw\n");
#define NN              111
#define MOD             1000000007///10^9
#define N               1000007 ///10^6->6 zero after 1 **



ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
bitset<N>B;
//map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc=1,in,loc,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
//cin>>tc;
rep(t,tc)
{
    cin>>n;
    rep(i,n)
    {
        cin>>x[i]>>y[i];
    }
    ll last=0;
    for(i=n;i>=1;i--)
    {
        a=x[i]+ans;
        b=a%y[i];
        if(b!=0)
        b=y[i]-b;
        ans+=b;
    }
    cout<<ans<<endl;
}
}
    return 0;
}

/*


*/
/// Check for constraint 0 or 1?
/// Division MOD needs BigMod(a,n-2)
/// long long or double? sqrt or division will work fine??
/// sort(begin(v), end(v), [] (int a, int b) { return a > b; });    /// Lambda Function for manual Sort


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    string s[n];
    vector<pair<ll, ll>> vp;
    ll l = 0, r = 0,lastr=0;
    for(i = 0; i < n; i++) {
        cin >> s[i];
        ll cntl = 0, cntr = 0;
        for(j = 0; j < s[i].size(); j++) {
            if(s[i][j] == '(') {
                cntl++;
            } else {
                if(cntl > 0)
                    cntl--;
                else
                    cntr++;
            }
        }
        if(cntr==0)l+=cntl;
        else if(cntl==0)lastr+=cntr;
        else vp.push_back({cntr, cntl});
    }
    sort(vp.begin(), vp.end(), [](const pair<ll, ll> a, const pair<ll, ll> b) {
        if(a.second - a.first != b.second - b.first) {
            return a.second - a.first > b.second - b.first;
        } else {
            return a.first < b.first;
        }
    });
    for(i = 0; i < vp.size(); i++) {
        r += vp[i].first;
        if(r - l > 0) {
            cout << "No" << endl;
            return 0;
        }
        l -= r;
        r = 0;
        l += vp[i].second;
    }

    if(l - lastr == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 34880
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int N, i;
  string s, t;
  cin >> N >> s >> t;
  for (i = N; i; --i)
    if (equal(begin(s) + N - i, end(s), begin(t))) break;
  cout << 2 * N - i << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
    ll n, m;
    rep(i, 7) {
        cin >> n >> m;
        cout << n-m << endl;
    }
}


Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main(){
    char name[4];
    cin >> name;
    int count1 = 0;
    int count2 = 0;

    if (name[0] == name[1]){
        count1 = 2;
        if (name[2] == name[3]){
            count2 = 2;
            if (name[0] == name[2]){
                count2 = 0;
            }
        }
    }
    else{
        if (name[0] == name[2]){
            count1 = 2;
            if (name[1] == name[3]){
                count2 = 2;
            }
            if (name[0] == name[1]){
                count2 = 0;
            }
        }
        else{
            if (name[0] == name[3]){
                count1 = 2;
                if (name[1] == name[2]){
                    count2 = 2;
                }
                if (name[0] == name[1]){
                    count2 = 0;
                }
            }
        }
    }

    if ((count1 == 2) && (count2 == 2)){
        cout << "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)
#define CC(x) cout<<x<<endl


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
} 

int main(){
   //Fast_IO();
      ll n;
      cin>>n;
      vector<string>v;
      f(i,0,n){
         string s;
         cin>>s;
         v.pb(s);
      }
      ll a=0,b=0,c=0,d=0;
      f(i,0,n){
         if(v[i]=="AC"){
            a++;
         }
         if(v[i]=="WA"){
            b++;
         }
         if(v[i]=="TLE"){
            c++;
         }
         if(v[i]=="RE"){
            d++;
         }
      }
      cout<<"AC"<<spc<<"x"<<spc<<a<<endl;
      cout<<"WA"<<spc<<"x"<<spc<<b<<endl;
      cout<<"TLE"<<spc<<"x"<<spc<<c<<endl;
      cout<<"RE"<<spc<<"x"<<spc<<d<<endl;
}



Measured memory_bytes: 7464
import java.util.Scanner;
public class Main {

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

		int  N=  sc.nextInt();
		int  K=  sc.nextInt();
		
		int ans = K * (K -1);
		int anw = K * (K -1);
		if(N == 1)
		{
			System.out.println(K);
		}else if(N == 2)
		{
			System.out.println(ans);
		}else
		{
			for(int i = 2; i < N; i++)
			{
				anw =  anw * (K - 1);
			}
			System.out.println(anw);
		}
		
	}

}


Measured memory_bytes: 22996
/*
    Created by Rahul Goel.
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/*******************************************************************************/
using namespace std;
using namespace __gnu_pbds;
template < typename T >
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*******************************************************************************/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
ll mod_sum() { return 0LL; }
template < typename T, typename... Args >
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%MOD + MOD)%MOD; }
/*******************************************************************************/
ll mod_prod() { return 1LL; }
template< typename T, typename... Args >
T mod_prod(T a, Args... args) { return (a * mod_prod(args...))%MOD; }
/*******************************************************************************/
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
/*******************************************************************************/
//.-.. . -. -.- .- .. ... .-.. --- ...- .
/*
    Code begins after this.
*/

ll power(ll x, ll y) {
    ll ret = 1;
    while (y) {
        if (y & 1) {
            ret = (ret * x) % MOD;
        }
        y >>= 1;
        x = (x * x) % MOD;
    }
    return ret;
}

ll inv(ll x) {
    return power(x, MOD - 2);
}

ll fac[2005];

ll choose(ll x, ll y) {
    if (x < y) {
        return 0;
    } else if (x == y) {
        return 1;
    }
    ll ret = fac[x];
    ret = (ret * inv(fac[y])) % MOD;
    ret = (ret * inv(fac[x - y])) % MOD;
    return ret;
}

ll solve() {
    fac[0] = 1;
    for (ll i = 1; i < 2005; i++) {
        fac[i] = (fac[i - 1] * i) % MOD;
    }

    ll s;
    cin >> s;

    if (s < 3) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    for (ll i = 1; s - i * 3 >= 0; i++) {
        ans = (ans + choose(s - i * 3 + (i - 1), i - 1)) % MOD;
    }

    cout << ans << endl;

    return 0;
}

signed main() {
    fastio;

    ll t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int A[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {A[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;A[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {A[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;A[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",A[i][j]);
                else printf("%d\n",A[i][j]);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 384
# ABC138D - Ki (entirely global namespace)
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def dfs(v: int, p: int) -> None:
    for u in T[v]:
        if u != p:  # p: parent -> skip
            cnt[u] += cnt[v]  # cumulative sum
            dfs(u, v)


# Ai (A[i][0]) may be not a parent of Bi (A[i][1])
N, Q = tuple(map(int, input().split()))  # vertices and queues
E = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
P = tuple(tuple(map(int, input().split())) for _ in range(Q))
T = [[] for _ in range(N + 1)]  # tree, (N+1: 1-idx -> 0-idx)
for a, b in E:
    T[a] += [b]
    T[b] += [a]
cnt = [0] * (N + 1)
for p, x in P:
    cnt[p] += x  # increase vertex p by x
dfs(1, -1)
print(*cnt[1:])


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

int main() {
    const int MOD = 1e9 + 7;

    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;

    ll ans = 3;
    for (int i = 0; i < n; i++) {
        bool a = s1[i - 1] == s2[i - 1];
        if (s1[i] == s2[i]) {
            if (i > 0 && a) ans = ans * 2 % MOD;
        } else {
            ans = ans * (a ? 2 : 3) % MOD;
            i++;
        }
    }

    cout << ans << endl;
    return 0;
}


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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1e9
using namespace std;
typedef long long ll;

string s;

int main(){
  std::cin >> s;
  ll one = 0;
  ll zero = 0;
  rep(i,0,s.size()){
    if(s[i]=='0')zero++;
    else one++;
  }
  std::cout << 2*min(zero,one) << '\n';
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    int A, B, C;
    scanf("%d%d%d", &A, &B, &C);
    if (A == 7) {
        if (B == 5 && C == 5) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    } else if (B == 7) {
        if (C == 5 && A == 5) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    } else if (C == 7) {
        if (A == 5 && B == 5) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    } else {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
//#include<math.h>
using namespace std;

//int i=1;
int n;
int i=1;
int temp=0;
int ans=0;

int pow(int a,int b){
  int ans=1;
  if(b==0){
    return 1;
  }
  else{
    for(int i=0;i<b;i++){
      ans = a*ans;
    }
    return ans;
  }
}

int solve(int a){
  temp=0;
  i=1;
  while(1){
    if(a%pow(10,i)==a)break;
    else{
      temp=max(temp,(a%pow(10,i))*((a-a%pow(10,i))/pow(10,i)));
      i++;
    }
  }
  return temp;
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> temp;
    while(1){
      if(temp%10==temp)break;
      else{
        solve(temp);
        ans++;
      }
    }
    cout << ans << endl;
    ans=0;
  }
}



Measured memory_bytes: 3068
from collections import defaultdict
def gcd(a, b) : 
    while a :
        a, b = b%a, a 
    return b 

def c(K) :
    dp = defaultdict(int)
    ans = 0
    for i in range(1, K+1) :
        for j in range(1, K+1) :
            if i > j and (j,i) not in dp :
                temp = dp[(j,i)]
            else : 
                dp[(i,j)] = gcd(i,j)
                temp = dp[(i,j)]  
            for k in range(1, K+1) : 
                if k > temp :
                    q = (temp, k)
                else :
                    q = (k, temp)
                if q not in dp :
                    dp[q] = gcd(temp,k )
                ans += dp[q]
    return ans 

if __name__ == "__main__" :
    k = int(input())
    print(c(k))


Measured memory_bytes: 13064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                decimal[] input = Array.ConvertAll(Console.ReadLine().Split(' '), decimal.Parse);

                decimal ax = input[0], ay = input[1];
                decimal bx = input[2], by = input[3];
                decimal cx = input[4], cy = input[5];
                decimal dx = input[6], dy = input[7];

                decimal p = (bx - ax) * (dy - cy);
                decimal q = (dx - cx) * (by - ay);

                sb.AppendLine(p == q ? "YES" : "NO");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9272
import java.util.Scanner;

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

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int cnt1 = 0;
		int cnt2 = 0;
		int cnt3 = 0;

		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();
			if (p <= a)
				cnt1++;
			if (a + 1 <= p && p <= b)
				cnt2++;
			if (b + 1 <= p)
				cnt3++;
		}

		int ans = Math.min(cnt1, Math.min(cnt2, cnt3));

		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 22100
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int, stdin.readline().rstrip().split()))

lf = 0
lb = 0
front = 0
back = n-1
for i in range(n):
    if lf <= lb:
        lf += a[front]
        front += 1
    else:
        lb += a[back]
        back += -1
if lf <= lb:
    h = lb-lf
else:
    h = lf-lb
print(h)


Measured memory_bytes: 26224
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <limits>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <iterator>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef unsigned                    ui;
typedef int                         si;
typedef long                        sl;
typedef long long                   ll;
typedef unsigned long long          ull;

#ifdef LOCALHOST
std::ifstream in("input.txt", std::ifstream::in);
#endif // LOCALHOST

#ifdef LOCALHOST
#define is in
#else
#define is cin
#endif // LOCALHOST

int main(int argc, char *argv[])
{
    std::ios_base::sync_with_stdio(false);

    ll n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;

    string T;
    cin >> T;

    vector<char> hands = { 'r', 's', 'p' };
    auto points = [&](const char a, const char b) {
        if (a == 'r' && b == 's') {
            return r;
        } else if (a == 's' && b == 'p') {
            return s;
        } else if (a == 'p' && b == 'r') {
            return p;
        }
        return 0ll;
    };

    ll answer = 0;
    string moves(n, 0);
    // cout << "moves = " << moves.size() << endl;
    for (int i = 0; i < n; ++i) {
        ll current = 0;
        char move = 0;
        for (int j = 0; j < 3; ++j) {
            // cout << "i = " << i << ", k = " << k << endl;
            if (i >= k && hands[j] == moves[i - k]) {
                continue;
            }

            ll p = points(hands[j], T[i]);
            if (p > current) {
                current = p;
                move = hands[j];
            }
        }

        // cout << "current = " << current << ", move = " << move << endl;
        answer += current;
        moves[i] = move;
    }

    /*
    vector<vector<ll>> dp(n + 1, vector<ll>(3, 0));
    for (int i = 1; i <= n; ++i) {
        for (int h = 0; h < 3; ++h) {
            dp[i][h] = 0;
            for (int ph = 0; ph < 3; ++ph) {
                const ll p = points(hands[h], T[i - 1]);
                if (i <= k) {
                    dp[i][h] = max(p, dp[i][h]);
                } else {
                    if (hands[ph] != T[i - k - 1]) {
                        dp[i][h] = max(p, dp[i][h]);
                    }
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    c=c-a+b;
    if(c>=0){
		printf("%d",c);
	}
    else{
		printf("0");
	}
    return 0;
}

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

int main() {
  double n, m, d; cin >> n >> m >> d;
  cout << fixed << setprecision(10);
  if (d == 0) cout << (m - 1) / n << endl;
  else cout << 2 * (n - d) * (m - 1) / (n * n) << endl;
}

Measured memory_bytes: 256
I=lambda:list(map(int,input().split()))
n,m,q=I()
l=[[0]*-~n for _ in range(n+1)]
for _ in range(m):
  s,g=I()
  l[s][g]+=1
for i in range(1,n+1):
  for j in range(1,n+1):
    l[i][j]+=l[i][j-1]
for i in range(1,n+1):
  for j in range(1,n+1):
    l[i][j]+=l[i-1][j]
for _ in range(q):
  s,g=I()
  print(l[g][g]-l[s-1][g]-l[g][s-1]+l[s-1][s-1])

Measured memory_bytes: 61220
gets
vals = gets.split.map(&:to_i)

cnts = []
64.times do |k|
  c = 0
  vals.each do |v|
    c += 1 if v[k] == 1
  end
  cnts << c
end

#p cnts

sum = 0
64.times do |k|
  c = cnts[k]
  n = vals.size

  sum += 2**k * (n-c)*c

  # vals.size.times do |i|
  #   vals.size.times do |j|
  #     next if i < j
  #     if i < c && j < c
  #     elsif i < c || j < c
  #       sum += 2 ** k
  #     end
  #   end
  # end
end

p sum % (10 ** 9 + 7)


Measured memory_bytes: 34820