akhauriyash/Code-Regression huggingface dataset:
// Best practice

#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// #include <functional> // for less

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
// using namespace __gnu_pbds;

// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds;

// #define fbo find_by_order
// #define ook order_of_key

// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

	int a, b, n;
	cin >> a >> b >> n;
	n = min(n, b - 1);
	cout << (a * n) / b - a*(n / b) ;

	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
    int n,k;
    cin >> n >> k;

    int a = 1;
    rep(i,0,n){
        if(a*2 < a+k)a *= 2;
        else a+=k;
    }

    P(a);
	
	return  0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <cstring>
#include <cctype>
#include <functional>
#include <climits>
 
using namespace std;
#define pr(...) do { _ost << #__VA_ARGS__ << " = "; ~(_ost,__VA_ARGS__); } while(0);
ostream & _ost = cout;
template <class T>
ostream &operator,(ostream& ost, const T& value) { return ost << value << ","; }
ostream &operator~(ostream& ost) { return ost << endl; }
template <class T>
string tos(const T& var){ ostringstream ss; ss << var; return ss.str(); }
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
 
typedef vector<int> vi;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;
 
const int mod = 1000000007;
const int INF = 1000000;
const double EPS = 1e-10;

int m,n;
int dp[1][1];

int main(){
    while(cin>>n>>m){
        cout<<abs(m-n)<<endl;
    }
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }

const int inv2 = 500000004;
int N, L;
string S;
int dp[5001][5001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> S;
  L = S.length();
  dp[0][0] = true;
  rep(i, N) {
    rep(j, N) {
      add(dp[i+1][j+1], (2LL*dp[i][j])%MOD);
      add(dp[i+1][max(j-1, 0)], dp[i][j]);
    }
  }
  int m = dp[N][L];
  rep(i, L) m = (1LL*m*inv2) % MOD;
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 97920
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {	
	
	public static void main(String[] args) throws NumberFormatException, IOException 
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class Task {
		
        public void solve(int testNumber, InputReader in, PrintWriter out) {

    		int n = in.nextInt();
    		BigInteger ans = new BigInteger(in.nextToken());
    		for( int i = 1; i < n; i++ ){
    			BigInteger x =  new BigInteger(in.nextToken());
    			BigInteger gcd = x.gcd(ans);
    			ans = ans.multiply(x).divide(gcd);
    		}

    		out.print(ans.toString());

        }
        
	}
	
	static class InputReader {
		
		BufferedReader in;
		StringTokenizer tok;
		
		public InputReader(InputStream stream){
			in = new BufferedReader(new InputStreamReader(stream), 32768);
			tok = null;
		}
		
		String nextToken() 
		{
			String line = "";
			while(tok == null || !tok.hasMoreTokens()) {
				try {
					if((line = in.readLine()) != null)
						tok = new StringTokenizer(line);
					else 
						return null;
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
					return null;
				}
			}
			return tok.nextToken();
		}
		int nextInt(){
			return Integer.parseInt(nextToken());
		}
		long nextLong()	{
			return Long.parseLong(nextToken());
		}
		double nextDouble()	{
			return Double.parseDouble(nextToken());
		}	
		
	}	
	
}








Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		int ans = S.length();
		for(int i = 0; i < ans; i++){
			System.out.print("x");
		}
		stdIn.close();
	}
}

Measured memory_bytes: 35568
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
typedef long long int ll;

#define min(x,y)(x<y?x:y)
 
using namespace std;

#define MAX 1000

int main() {
	//FAST;

	int N;
	
	cin >> N;

	int t=N;
	int dig=0;
	int sum=0;

	while (t) {
		dig = t%10;
		sum = sum+dig;
		t = t/10;
	}

	if ((N % sum) == 0) cout << "Yes";
	else cout << "No";

    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	makei(a);
	makei(b);
	cout << a / b << " " << a % b << " ";
	printf("%f\n", (double)a / b);
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
    
    int a, b;
    int cnt=0;
    
    scanf("%d%d", &a, &b);
    
    for (int i=a; i<=b; i++) {
        if (i/10000==i%10&&(i/1000)%10==(i%100)/10) {
            cnt++;
        }
    }
    
    printf("%d", cnt);
    
    return 0;
}


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

Measured memory_bytes: 2752
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  ll N, M, tmp;
  cin >> N >> M;
  queue<ll> a;
  for( ll i=0; i<M; i++ ){
    cin >> tmp;
    a.push(tmp);
  }
  a.push(-1);
  
  vector<ll> fibo(N+2,1); //フィボナッチ数列をmod(1e9+7)で表現
  for( ll i=3; i<=N+1; i++ ) fibo[i] = (fibo[i-2]+fibo[i-1])%(ll)(1e9+7);
  
  ll ans = 1;
  ll rep = 1;
  for( ll i=1; i<=N; i++ ){
    if( rep>0 && i==a.front() ){ //ox
      ans = ( ans * fibo[rep] )%(ll)(1e9+7);
      rep = 0;
      a.pop();
    }else if( rep>0 && i!=a.front() ){ //oo
      rep++;
      if( i==N ) ans = ( ans * fibo[rep] )%(ll)(1e9+7); 
    }else if( rep==0 && i==a.front() ){ //xx
      ans = 0;
      cout << 0;
      return 0;
    }else if( rep==0 && i!=a.front() ){ //xo
      rep = 1;
    }
  }
  cout << ans;
  return 0;
}



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

int main() {
  int k, x;
  cin >> k >> x;
  for(int i = x-k+1; i < x+k; i++) {
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program{
  static void Main(){
    string[] input = Console.ReadLine().Split(' ');
    long A = long.Parse(input[0]);
    long B = long.Parse(input[1]);
    long G = Gcd(A, B);
    Console.WriteLine(HowManyFactors(G) + 1);
  }
  
  // 最大公約数
  static long Gcd(long a, long b){
    if (a < b)
      return Gcd(b, a);
    while (b != 0) {
      long tmp = a % b;
      a = b;
      b = tmp;
    }
    return a;
  }
  
  // 与えられた整数の素因数の個数を返す
  static int HowManyFactors(long N){
    // 素因数を格納しておくもの
    var flist = new List<long>();
    flist.Add(1);
    int i = 0;  // flist.Length - 1 と同じ
    
    long factor = 2;
    long tmp = N;
    
    while (factor * factor <= N){
      if (tmp % factor == 0){ //factorで割り切れるなら
        if (flist[i] != factor){// そのfactorが新出なら
          flist.Add(factor); // listに追加
          i++;
        }
        tmp = tmp / factor;
      }
      else
        factor++;
    }
    
    // 最大の素因数
    if (tmp != 1){
      flist.Add(factor);
      i++;
    }
    
    return i;
  }
}

Measured memory_bytes: 13140
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void coVec(const Vec1<T> &v){for(T i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll h;
	cin >> h;

	ll t = 1;
	while(t <= h){
		t <<= 1;
	}
	co(t-1);

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool yes = true;
    for(int i = 0; i < s.size(); i++){
        if(i%2 == 0 && s[i] != 'h') yes = false;
        if(i%2 == 1 && s[i] != 'i') yes = false; 
    }
    if(s.size()%2 == 1) yes = false;
    if(yes) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define fi first
#define se second


int main(void){
	while(1){
		int m; scanf("%d", &m);
		if(m == 0) break;
		vector<pair<int, int> > seiza(m);
		rep(i, m) scanf("%d %d", &seiza[i].fi, &seiza[i].se);

		//?????§??????????????????????????????????¨????
		vector<pair<int, int> > v(m);//fi x se y;
		v[0].fi = 0, v[0].se = 0;//????????????????????????????????????
		reps(i, 1, m){
			v[i].fi = seiza[i].fi - seiza[0].fi;
			v[i].se = seiza[i].se - seiza[0].se;
		}

		int n; scanf("%d", &n);
		vector<pair<int, int> > hosizora(n);
		rep(i, n) scanf("%d %d", &hosizora[i].fi, &hosizora[i].se);
	
		int nowx, nowy;
		int cnt = 0;
		rep(i, n){
			nowx = hosizora[i].fi;
			nowy = hosizora[i].se;
			rep(j, n){
				int vx = hosizora[j].fi - nowx;
				int vy = hosizora[j].se - nowy;
				rep(k, m){
					if(vx == v[k].fi && vy == v[k].se){
						cnt++;
						break;
					}
				}
			}
			if(cnt == m) break;
			cnt = 0;
		}
		//printf("%d %d\n", nowx, nowy);
		printf("%d %d\n", nowx - seiza[0].fi, nowy - seiza[0].se);
	}
	return 0;
}

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

struct UnionFind {
	const int V;
	// par[x] := xのroot
	vector<int> par;
	// sz[x] := xを含む集合のサイズ
	vector<int> sz;
	UnionFind(const int V) :
		V(V),
		par(vector<int>(V)),
		sz(vector<int>(V, 1))
		{
			for(int i = 0; i < V; ++i) par[i] = i;
		}
	bool unite(int x, int y) {
		x = root(x), y = root(y);
		if(same(x, y)) return false;
		if(y < x) swap(x, y);
		par[y] = x;
		sz[x] += sz[y];
		return true;
	}
	int root(int x) {
		if(par[x] == x) return x;
		return (par[x] = root(par[x]));
	}
	bool same(int x, int y) {
		return (root(x) == root(y));
	}
	int size(int x) {
		return sz[root(x)];
	}
};

int main() {
	int n, m; cin >> n >> m;
	int64_t a[n]; for(int i = 0; i < n; ++i) cin >> a[i];
	UnionFind uf(n);
	while(m--) {
		int x, y; cin >> x >> y;
		uf.unite(x, y);
	}
	priority_queue<int64_t, vector<int64_t>, greater<int64_t>> pq[n];
	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		if(uf.root(i) == i) ++cnt;
		pq[uf.root(i)].push(a[i]);
	}
	if(cnt == 1) {
		cout << 0 << '\n';
		return 0;
	}
	priority_queue<int64_t, vector<int64_t>, greater<int64_t>> pqr;
	int64_t ans = 0;
	for(int i = 0; i < n; ++i) {
		if(pq[i].size()) {
			int64_t x = pq[i].top();
			pq[i].pop();
			ans += x;
			while(pq[i].size()) {
				pqr.push(pq[i].top());
				pq[i].pop();
			}
		}
	}
	cnt = cnt - 2;
	while(cnt--) {
		if(pqr.empty()) {
			cout << "Impossible" << '\n';
			return 0;
		}
		ans += pqr.top();
		pqr.pop();
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e10;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	ll a[n];
	REP(i,n) cin >> a[i];
	ll sum = 0;
	REP(i,n) sum += a[i];
	ll ans = INF,x = 0;
	REP(i,n - 1){
		x += a[i];
		ans = min(ans, abs(sum - 2 * x));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
int x[100010];
signed main(){
	int n,z=0;
	cin>>n;
	f(i,n){
		cin>>x[i];
		z=x[i]*2-z;
	}
	z/=2;
	f(i,n){
		if(i)cout<<" ";
		cout<<z;
		z=x[i]*2-z;
	}
}


Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main(){
    int D;
    cin >> D;

    if(D == 25){
        cout << "Christmas" << endl;
    }else if(D == 24){
        cout <<  "Christmas Eve" << endl;
    }else if(D == 23){
        cout << "Christmas Eve Eve" << endl;
    }else if(D == 22){
        cout << "Christmas Eve Eve Eve" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int32_t main()
{

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS
    int n,d,x,y,count=0;
    cin>>n>>d;
    while(n--)
    {
        cin>>x>>y;
        if( (d*d) - (x*x) - (y*y) >=0)
            count++;
    }
    cout<<count<<endl;
    
    return 0;
}

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

using namespace std;

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

int main(void)
{
  int n;
  while(cin >> n)
    {
      if(n ==0 ) break;
      int counter = 0;
      for(int i = 1; i <= n/2; i++){
	int sum = 0;
	int j = i;
	
	while(1){
	  sum += j;
	  if(sum == n){
	    counter++;
	    break;
	  }
	  if(sum > n){
	    break;
	  }
	  j++;
	}

      }

      cout << counter << endl;

    }

  return 0;
}

Measured memory_bytes: 2952
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        
        if(n==1){
            System.out.println("Hello World");
        }
        if(n==2){
            int a=sc.nextInt();
            int b=sc.nextInt();
            System.out.println(a+b);
        }
        sc.close();
    }
}

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

int main() {
  int N, M, a[55], b[55];
  cin >> N >> M;
  
  int count[N];
  for(int i=1; i<=N; i++) count[i]=0;
  
  for(int i=0; i<M; i++){
    cin >> a[i] >> b[i];
    for(int j=1; j<=N; j++){
      if(a[i]==j) count[j]++;
      else if(b[i]==j) count[j]++;
    }
    
  }
  
  for(int i=1; i<=N; i++){
    cout << count[i] << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int c[5][5];
int a[3],b[3];

int main(void){
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			scanf("%d",&c[i][j]);
		}
	}
	bool flag=false;
	for(int i=-100;i<=100;i++){
		for(int j=-100;j<=100;j++){
			for(int k=-100;k<=100;k++){
				a[0]=i;
				a[1]=j;
				a[2]=k;
				b[0]=c[0][0]-a[0];
				b[1]=c[1][1]-a[1];
				b[2]=c[2][2]-a[2];
				bool ok=true;
				for(int l=0;l<3;l++){
					for(int m=0;m<3;m++){
						if(a[l]+b[m]!=c[l][m]){
							ok=false;
						}
					}
				}
				if(ok)flag=true;
			}
		}
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class Main{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) throws IOException {
        FastReader in = new FastReader();
        Scanner sc = new Scanner(System.in);
        BigInteger a = sc.nextBigInteger() , b = sc.nextBigInteger();
        if(a.equals(b)){
            System.out.println("EQUAL");
        } else {
            if(a.compareTo(b) == -1){
                System.out.println("LESS");
            } else {
                System.out.println("GREATER");
            }
        }
    }
}



Measured memory_bytes: 21972
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = l[0], a = l[1], b = l[2];
            var min = a+b <= n ? 0 : (a+b)-n;
            var max = Math.Min(a,b);
            Console.WriteLine($"{max} {min}");
        }
    }
}


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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int ans;
	for(int i = 1; i <= 5; ++i) {
		int x;
		cin >> x;
		if(!x) ans = i;
	}
	cout << ans;

	return 0;
}

/*
A - Five Variables / 
Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 
100
 points

Problem Statement
We have five variables 
x
1
,
x
2
,
x
3
,
x
4
,
 and 
x
5
.

The variable 
x
i
 was initially assigned a value of 
i
.

Snuke chose one of these variables and assigned it 
0
.

You are given the values of the five variables after this assignment.

Find out which variable Snuke assigned 
0
.

Constraints
The values of 
x
1
,
x
2
,
x
3
,
x
4
,
 and 
x
5
 given as input are a possible outcome of the assignment by Snuke.
Input
Input is given from Standard Input in the following format:

x
1
 
x
2
 
x
3
 
x
4
 
x
5

Output
If the variable Snuke assigned 
0
 was 
x
i
, print the integer 
i
.

Sample Input 1 
Copy
0 2 3 4 5
Sample Output 1 
Copy
1
In this case, Snuke assigned 
0
 to 
x
1
, so we should print 
1
.

Sample Input 2 
Copy
1 2 0 4 5
Sample Output 2 
Copy
3
*/


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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


void solve() {
	int n, m; cin >> n >> m;
	vector<int> a(n);
	int sum = 0;
	rep(i, n) {
		cin >> a[i]; sum += a[i];
	}
	int cnt = 0;
	rep(i, n) {
		if (a[i] * 4 * m < sum)continue;
		cnt++;
	}
	if (cnt >= m) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var n = int.Parse(str);

            str = Console.ReadLine();
            var strs = str.Split(' ');

            var ls = new int[n];
            for (int i = 0; i < ls.Length; i++)
            {
                ls[i] = int.Parse(strs[i]);
            }

            var max = ls.Max();

            if (max < ls.Sum() - max)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
import java.util.*

data class Process(val name: String, var time: Int)

fun run(queue: Queue<Process>, q: Int) {
    var time = 0
    while (queue.size > 0) {
        val process = queue.poll()
        if (process.time > q) {
            process.time -= q
            time += q
            queue.add(process)
        } else {
            time += process.time
            println("${process.name} ${time}")
        }
    }
}

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val q = scanner.nextInt()
    val queue = LinkedList<Process>()
    (1..n).forEach {
        queue.add(Process(scanner.next(), scanner.nextInt()))
    }
    run(queue, q)

}


Measured memory_bytes: 75060
import sys
import math

'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
n, d = map(int, input().split())
if n%(d*2+1)==0:
  print(int(n/(d*2+1)))
else:
  print(int(n//(d*2+1)+1))

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

int main() {
  std::string s;
  std::cin >> s;

  int64_t a1 = 0, a2 = 0;

  for (int64_t i = 0; i < s.size(); i++) {
    if (i % 2 == 0) {
      if (s[i] == '0') {
        a1++;
      } else {
        a2++;
      }
    } else {
      if (s[i] == '1') {
        a1++;
      } else {
        a2++;
      }
    }
  }

  std::cout << std::min(a1, a2) << std::endl;
  return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, M, a, b;
bool able[8][8];
int main() {
	cin >> N >> M;
	REP(i, 8) REP(j, 8) able[i][j] = false;
	REP(i, M) {
		cin >> a >> b; a--; b--;
		able[a][b] = true;
		able[b][a] = true;
	}
	vector<lint> vec;
	REP(i, N - 1) {
		vec.push_back(i + 1);
	}
	lint cnt = 0;
	do {
		bool flag = false;
		if (!able[0][vec[0]]) flag = true;
		REP(i, N - 2) {
			flag |= (!able[vec[i]][vec[i + 1]]);
		}
		if (flag) continue;
		cnt++;
	} while (next_permutation(ALL(vec)));
	cout << cnt << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll h, w, d; cin >> h >> w >> d;
  vector<pair<ll, ll>> v(h*w);
  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      ll a; cin >> a;
      v[a-1] = make_pair(i, j);
    }
  }
  
  vll dis(h*w, 0);
  for (ll i = 0; i < h*w; i++) {
    if (i+d >= h*w) break;
    dis[i] = abs(v[i+d].first-v[i].first)+abs(v[i+d].second-v[i].second);
  }
  
  vll sum(h*w+d, 0);
  for (ll i = d; i < h*w; i++) {
    if (i < 2*d) sum[i] = dis[i-d];
    else sum[i] = sum[i-d] + dis[i-d];
  }
  
  ll q; cin >> q;
  for (ll i = 0; i < q; i++) {
    ll l, r; cin >> l >> r;
    l--, r--;
    cout << sum[r] - sum[l] << endl;
  }
}

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

using namespace std;
const int N = 2505, M = 5005;
int head[N], nxt[M], to[M], cost[M], ne = 0;
vector<int> adj[N];

void addedge(int a, int b, int c) {
    nxt[ne] = head[a];
    to[ne] = b;
    cost[ne] = c;
    head[a] = ne++;
}

long long dist[N];

void init() {
    memset(head, -1, sizeof head);
}

int n, m, p;
bool inq[N];
bool inc[N];

bool bellman() {
    for (int i = 2; i <= n; ++i) dist[i] = 1e18;
    dist[1] = 0;
    queue<int> q;
    q.push(1);
    inq[1] = 1;
    for (int z = 0; z <= n * 3; ++z) {
        if (q.empty()) break;
        int sz = q.size();
        while (sz--) {
            int u = q.front();
            q.pop();
            inq[u] = 0;
            for (int i = head[u]; ~i; i = nxt[i]) {
                int v = to[i];
                long long ds = cost[i] + dist[u];
                if (dist[v] > ds) {
                    dist[v] = ds;
                    if (!inq[v]) {
                        inq[v] = 1;
                        q.push(v);
                    }
                    if (z >= n * 2) {
                        inc[v] = 1;
                    }
                }
            }
        }
    }
    return true;
}

int vis[N];

bool bfs() {
    queue<int> q;
    q.push(n);
    vis[n] = 1;
    while (q.size()) {
        int u = q.front();
        q.pop();
        if (inc[u]) return 0;
        for (auto v:adj[u]) {
            if (vis[v]) continue;
            q.push(v);
            vis[v] = 1;
        }
    }
    return 1;
}


int main() {
 //   freopen("in.txt", "rt", stdin);
    scanf("%d %d %d", &n, &m, &p);
    int a, b, c;
    init();
    while (m--) {
        scanf("%d %d %d", &a, &b, &c);
        addedge(a, b, -c + p);
        adj[b].push_back(a);
    }
    bellman();
    if (bfs()) printf("%lld\n", max(-dist[n], 0ll));
    else puts("-1");
}

Measured memory_bytes: 512
S=input()
T=input()
flg=False
ans='UNRESTORABLE'
for i in reversed(range(len(S)-len(T)+1)):
    if flg:
        break

    for j in range(len(T)):
        if S[i+j]==T[j] or S[i+j]=='?':
            pass
        else:
            break
        
        if j==len(T)-1:
            S=S.replace('?','a')
            ans=S[:i]+T+S[i+len(T):]
            flg=True
            break
print(ans)

Measured memory_bytes: 3064
while True:
    a, op, b = map(str, input().split())
    
    if op=='?' :
        break
    
    a = int(a)
    b = int(b)
    
    if op=='+':
        print(a+b)
    
    if op=='-':
        print(a-b)
    
    if op=='*':
        print(a*b)
    
    if op=='/':
        print(a//b)


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

int main() {
  int N, i;
  int cnt = 1;
  cin >> N;
  vector<int> mochi(N);
  for (i = 0; i < N; i++) {
    cin >> mochi.at(i);
  }
  sort(mochi.begin(), mochi.end());
  
  for (i = 1; i < N; i++) {
    if (mochi.at(i) > mochi.at(i-1)) {
      cnt++;
    }
  }
  
  cout << cnt << endl;
   
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean hasNext(){return sc.hasNext();}
        static char[] mySplit(String str){return str.toCharArray();}
        public static void main(String[] args){
          long N = getLong();
          long A = getLong();
          long B = getLong();
          long mod = 1000000007;
          long aRes = originComb(N,A,mod);
          long bRes = originComb(N,B,mod);
          long output = (originPow(2,N,mod) - 1) - aRes - bRes;
          myout((output + (3 * mod)) % mod);
        }
        //Method addition frame start
public static long originComb(long n, long k, long m){
  long ret = 1;
  for(int i = 0; i < k; i++){
    ret = (ret * (n - i)) % m;
    ret = (ret * originPow(i + 1, m - 2, m)) % m;
  }
  return ret;
}
static long originPow(long x, long n,long m) {
        long ans = 1;
        while (n > 0) {
                if ((n & 1) == 1){
                  ans = ans * x;
                  if(m != -1){ans %= m;}
                }
                x = x * x;
                if(m != -1){x %= m;}
                n >>= 1;
        }
        return ans;
}
        //Method addition frame end
}


Measured memory_bytes: 23892
#include<stdio.h>
#define MAX 10001
#define NIL -1
void Preorder(int);
void Inorder(int);
void Postorder(int);
typedef struct Node{int p,l,r;}Node;
Node T[MAX];
int n;

int main(){
  int i,u,l,r,id;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id].l = l;
    T[id].r = r;
    if(l != NIL) T[l].p = id;
    if(r != NIL) T[r].p = id;
  }
  for(i = 0; i < n; i++) if(T[i].p == NIL) u = i;
  printf("Preorder\n");
  Preorder(u);
  printf("\nInorder\n");
  Inorder(u);
  printf("\nPostorder\n");
  Postorder(u);
  printf("\n");
  return 0;
}//main


void Preorder(int u){
  if(u == NIL) return;
  printf(" %d",u);
  Preorder(T[u].l);
  Preorder(T[u].r);
}//preorder

void Inorder(int u){
  if(u == NIL) return;
  Inorder(T[u].l);
  printf(" %d",u);
  Inorder(T[u].r);
}//Inorder

void Postorder(int u){
  if(u == NIL) return;
  Postorder(T[u].l);
  Postorder(T[u].r);
  printf(" %d",u);
}//Postorder

Measured memory_bytes: 620
N,A,B,C,D=map(int,input().split())
mod=10**9+7

F=[1]*(N+1)
for i in range(1,N+1):
  F[i]=F[i-1]*(i)%mod
def power(x,y):
  if y==0:
    return 1
  elif y==1:
    return x%mod
  elif y%2==0:
    return power(x,y//2)**2%mod
  else:
    return (power(x,y//2)**2)*x%mod

invF=[1]*(N+1)
invF[N]=power(F[N],mod-2)
for i in range(0,N)[::-1]:
  invF[i]=(invF[i+1]*(i+1))%mod
invp=[[0]*(N+1) for i in range(N+1)]
for i in range(N+1):  
  for k in range(N+1):
    if k==0:
      invp[i][k]=1
    else:
      invp[i][k]=(invp[i][k-1]*invF[i])%mod
dp=[[0]*(N+1) for i in range(B-A+2)]
dp[0][0]=1
for i in range(A,B+1):
  for j in range(N+1):
    dp[i-A+1][j]=dp[i-A][j]
    for k in range(C,min(D,j//i)+1):
      dp[i-A+1][j]+=(dp[i-A][j-k*i]*F[N-j+k*i]*invF[N-j]*invp[i][k]*invF[k])%mod
      dp[i-A+1][j]%=mod
    
print((dp[B-A+1][N])%mod)


        
  


    
                                      

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

int main() {
  int k;
  cin >> k;
  
  int ans = 0;
  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        ans += gcd(gcd(a, b), c);
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <set>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
	int n,x;
	set<int>s,t,r;
	for(scanf("%d",&n);n--;s.insert(x))scanf("%d",&x);
	for(scanf("%d",&n);n--;t.insert(x))scanf("%d",&x);
	set_intersection(s.begin(),s.end(),t.begin(),t.end(),inserter(r,r.end()));
	printf("%d\n",r.size());
}

Measured memory_bytes: 1100
#include <iostream>
#include <set>
#include <array>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    vector<ll> vs(n);
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
         cin >> vs[i];
         sum += vs[i];
    }

    const ll num_stone_per_once = n * (n + 1) / 2;
    if (sum % num_stone_per_once != 0)
    {
        cout << "NO" << endl;
    } 
    else
    {
        const ll num_op = sum / num_stone_per_once;

        vector<ll> diffs(n);
        for (int i = 0; i < n - 1; i++) diffs[i] = vs[i + 1] - vs[i];
        diffs[n - 1] = vs[0] - vs[n - 1];

        for (int i = 0; i < n; i++) {
            diffs[i] -= num_op;
        }

        if (all_of(diffs.begin(), diffs.end(), [&](ll val){ return (val == 0 || (val < 0 && val % n == 0) ); })) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll power(ll x, ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2,m)%m; 
    p = (p * p)%m; 
  
    return (y%2 == 0)? p : (x * p)%m ; 
} 

ll modInverse(ll a, ll m) 
{ 
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
    return power(a, m-2,m); 
} 
  
// To compute x^y under modulo m 


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    double p[n+1];
    double dp[n+1][n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    mset(dp,0.0);
    dp[1][0] = 1.0-p[1];
    dp[1][1] = p[1];
    for(int i=2;i<=n;i++)
    {
        dp[i][0] = dp[i-1][0]*(1-p[i]);
        for(int j=1;j<=n;j++)
        {
            dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
        }
    }
    double ans=0.0;
    for(int i=n/2+1;i<=n;i++)
    {
        ans+=dp[n][i];
    }
    cout<<setprecision(12)<<fixed;
    cout<<ans;
   
    
    return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

int n;
int x[25],y[25],r[25],c[25];
int cover[25];
double d[25][25];
bool check[1<<25];
int cnt,comb,a,b;
int m,ans;
int u;

double dis(int i,int j){
  return sqrt( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j]) * (y[i]-y[j]) );
}

void cov(int a){
  cover[a] = -1;
  for(int j=a-1;j>=0;j--){
    if(d[j][a]<r[a]+r[j] && u>>j & 1){
      cover[a] = j;
      break;
    }
  }
} 

  
void rec(void){
  int cnt;
  for(int i=1;i<=4;i++){
    cnt = 0;
    for(int j=0;j<n;j++){
      if( (u>>j & 1) && cover[j]<0 && c[j] == i)cnt++;
    }
    if(cnt==6){
      for(int j=0;j<n;j++){
	if(c[j] == i)u -= 1<<j;
      }
      for(int j=0;j<n;j++)cov(j);

      ans += 6;
      m = max(m,ans);
      if(!check[u]){
	rec();
	check[u] = true;
      }
      ans -= 6;

      for(int j=0;j<n;j++){
	if(c[j] == i)u += 1<<j;
      }
      for(int j=0;j<n;j++)cov(j);
    }else{
      for(int j=0;j<n;j++){
	if( (u>>j & 1) && cover[j]<0 && c[j] == i){
	  for(int k=j+1;k<n;k++){
	    if( (u>>k & 1) && cover[k]<0 && c[k] == i){
	      u -= 1<<j;
	      u -= 1<<k;
	      for(int l=0;l<n;l++)cov(l);

	      ans += 2;
	      m = max(m,ans);
	      if(!check[u]){
		rec();
		check[u] = true;
	      }
	      ans -= 2;

	      u += 1<<j;
	      u += 1<<k;
	      for(int l=0;l<n;l++)cov(l);
	    }
	  }
	}
      }
    }
  }
}



int main(){
  while(1){
    cin >> n;
    if(!n)break;

    for(int i=0;i<n;i++)cin >> x[i] >> y[i] >> r[i] >> c[i];

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)d[i][j] = dis(i,j);
    }

    u = (1<<n) - 1;
    for(int i=0;i<(1<<n);i++)check[i] = false;
    for(int i=0;i<n;i++)cov(i);

    
    m = 0;
    ans = 0;
    rec();

    cout << m << endl;
  }
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define Mx 1000000000005 
#define ll long long  
#define pi 3.141592653
#define vi vector<ll>
#define Mo 1000000007
#define mp make_pair
#define M map<ll,ll>
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define vii vector<pair<ll,ll> > 
#define fi first
#define se second
#define pb push_back
#define ld long double
#define fill(a,x) memset(a,x,sizeof(a))
using namespace std;
bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
  return a.second<b.second;
}
/*vi b=v;
   sort(b.begin(), b.end());
  b.resize(unique(b.begin(), b.end()) - b.begin());
  ll t; cin>>t; fr(f,0,t){ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 */

int main()
{
  ll n,W; cin>>n>>W;
  ll wt[n],v[n],ans;
  fr(i,0,n)
    cin>>wt[i]>>v[i];

  vector<vector<ll>> dp(n+1, vector<ll>(1e5 + 1, 0));

  fr(i,1,n+1)
    dp[i][0]=0;
  fr(j,1,1e5 + 1)
    dp[0][j]=Mx;

  dp[0][0]=0;

  fr(i,1,n+1)
  {
    fr(j,1,1e5+1)
    {
      dp[i][j]=dp[i-1][j];
      if(j>=v[i-1])
        dp[i][j]=min(dp[i][j], wt[i-1]+dp[i-1][j-v[i-1]]);
    }
  }

  for(ll i=1e5;i>=0;i--)
    if(dp[n][i]<=W)
    {
      ans=i;
      break;
    }

  cout<<ans;

}

Measured memory_bytes: 83148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int a, b, c;

int main()
{
    cin >> a >> b >> c;
    if (b + c < a)
        cout << 0 << "\n";
    else
        cout << c - a + b << "\n";
}

Measured memory_bytes: 256