akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    ll s = S.size();
    if(s != 26){
        map<char,ll> ma;
        rep(i,s){
            ma[S[i]]++;
        }
        for(char c = 'a';c <= 'z';c++){
            if(!ma[c]){
                S += c;
                break;
            }
        }
        cout << S << endl;
    }
    else{
        if(S == "zyxwvutsrqponmlkjihgfedcba"){
            cout << "-1\n";
            return 0;
        }
        string T = S;
        next_permutation(all(S));
        rep(i,s){
            if(T[i] == S[i])cout << S[i];
            else{
                cout << S[i] << "\n";
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3668
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    K = I()

    ans = (K // 2) * (K - K // 2)
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9928
#include<stdio.h>
#include<stdlib.h>
#include <string.h>

int main(){
  char s[11];
  int A, B, len, i, flag;
  scanf("%d%d", &A, &B);
  scanf(" %s", s);
  len = strlen(s);
  
  flag=1;

  if(len!=A+B+1)flag=0;

  for(i=0; i<len; i++){
    if(i==A){
      if(s[i]!='-')flag=0;
    }else{
      if(s[i]>'9' || s[i]<'0')flag=0;
    }
  }

  if(flag)
    printf("Yes\n");
  else
    printf("No\n");

}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
inline void shoki()
{
	srand((unsigned int)time(NULL));
}

/*Library End!*/

signed main() {
	int n;
	cin >> n;
	if (n/100 * 111 < n) {
		cout << (n/100+1) * 111 << endl;
	}
	else if (n/100 * 111 >= n) {
		cout << (n / 100) * 111 << endl;
	}
	
end:;
	system("PAUSE");
	return 0;
}



Measured memory_bytes: 504
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char S[210000];
char T[210000];

int main(){
	scanf("%s%s",S,T);
	int ret=0;
	for(int i=0;S[i];i++){
		if(S[i]!=T[i])ret++;
	}	printf("%d\n",ret);
}

Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define INF 10e10
#define LL long long int
LL dp[100001];
int main() {
    ios_base::sync_with_stdio(false);
    int n,w,valSum=0;
    cin >> n >> w;
    int wgt[n+1],val[n+1];
    for(int i=1; i<100001; i++) dp[i] = INF;
    for(int i=1; i<=n; i++) {
        cin >> wgt[i] >> val[i];
        valSum += val[i];
    }
    for(int i=1; i<=n; i++) {
        for(int j=valSum; j>=val[i]; j--) {
            dp[j] = min(dp[j],dp[j-val[i]]+wgt[i]);
        }
    }
    for(int i=valSum; i>=0; i--) {
        if(dp[i]<=w) {
            cout << i << "\n";
            break;
        }
    }
}


Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
const int MAX=1e6+7;
const int mod=1e9+7;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
  	string s;cin>>s;
  	ll ans=0,t=0;
  	for(int i=0;i<3;i++){
  		if(s[i]=='R')t++;
  		else {
  			ans=max(ans,t);
			  t=0;	
		}
	}
	ans=max(ans,t);
  cout<<ans;
   return 0;
} 

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

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, Z, W; cin >> N >> Z >> W;
  int a[N];
  for(int i=0;i<N;i++) cin >> a[i];
  if(N != 1) cout << max(abs(a[N-1] - W), abs(a[N-1] - a[N-2])) << endl;
  else cout << abs(a[0] - W) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main()
{
	int i,j;
	double n;
	
	for(;;)
	{
		cin >> n;
		if(n<0.0)
			break;
		
		if(n>=256.0)
			cout << "NA" << endl;
		
		string str1,str2;
		int a=(int)n;
		n-=(double)a;
		
		for(i=128;i>0;i/=2)
		{
			if(i<=a)
			{
				str1+="1";
				a-=i;
			}
			else
				str1+="0";
		}
		for(double a=2.0,j=0;j<4;a*=2,j++)
		{
			if(1.0/a<=n)
			{
				str2+="1";
				n-=1/a;
			}
			else
				str2+="0";
		}
		if(n==0.0)
		{
				cout << str1 << "." << str2 << endl;
		}
		else
			cout << "NA" << endl;
	}
}

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define int ll
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

void solve() {
	int n,m;
	cin >> n >> m;
	if(m <= 4*n && m >= 2*n && m%2==0) cout << "Yes\n";
	else cout << "No\n";
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}



Measured memory_bytes: 3800
from itertools import product
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
ans = min(
    sum(
        abs(sum(x for k, x in zip(p, l) if k == r) - y) + 10 * (p.count(r) - 1)
        for r, y in enumerate((A, B, C), 1)
    )
    for p in product(range(4), repeat=N)
    if {1, 2, 3} <= set(p)
)
print(ans)


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;


	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			int n = sc.nextInt();
			long X = sc.nextLong();
			long[] x = new long[n];
			long[] y = new long[n-1];
			
			
			
			for(int i=0;i<n;i++) {
				x[i] = sc.nextLong();
			}
			
			if(n==1) {
				System.out.println(Math.abs(x[0]-X));
				return;
			}
			
			Arrays.sort(x);
			
			long ini = Math.abs(X-x[0]);
			
			for(int i=0;i<n-1;i++) {
				y[i]=x[i+1]-x[i];
				ini = Math.min(ini, Math.abs(X-x[i]));
			}
			
			ini = Math.min(ini, Math.abs(X-x[n-1]));
			long ret = gcd(ini,y[0]);
			
			
			for(int i=0;i<n-2;i++) {
				ret = gcd(ret,y[i+1]);
			}
			
			System.out.println(ret);
			
		}
		
		static long gcd (long a, long b) {
			long temp;
			while((temp = a%b)!=0) {
				a = b;
				b = temp;
			}
			return b;
		}
		
	}


Measured memory_bytes: 52608
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	string s;
	cin >> s;
	if(s[2]==s[3] and s[4] == s[5]) cout << "Yes";
	else cout << "No";	
}

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

int main(int argc, const char * argv[])
{
    int a, n, debt = 100000;
    double rate = 0.05;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        debt *= (1.00 + rate);
        a = debt % 1000;
        if (a != 0){
            debt = debt / 1000 * 1000 + 1000;
        }
    }
    cout << debt << endl;
    
    return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

    public int countValidSquare(int[] arr) {
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if ((i + 1) % 2 != 0 && arr[i] % 2 != 0) {
                count++;
            }
        }
        return count;
    }

    public static void main(String args[]) {
        Main aop = new Main();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }
        System.out.println(aop.countValidSquare(arr));
    }
}


Measured memory_bytes: 35680
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,M;
    cin>>N;
    string s[N];
    map<string, int> S,T;
    rep(i,0,N){
        string u;
        cin>>u;
        s[i]=u;
        S[u]++;
    }
    cin>>M;
    rep(i,0,M){
        string t;
        cin>>t;
        T[t]++;
    }
    int  ans=0;
    rep(i,0,N){
        ans=max(ans,S[s[i]]-T[s[i]]);
    }
    cout <<ans <<"\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	vector<long long int> v;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		v.push_back(a);
	}
	int max = 0;
	long long int ans = 0;
	for (int i = 0; i < v.size(); i++) {
		if (v[i] < max) {
			ans = ans + max - v[i];
		}
		else if (v[i] > max) {
			max = v[i];
		}
	}
	cout << ans;
}

Measured memory_bytes: 5272
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  double m[2][2],ans[2],inv[2][2],x,y,det;
  while(cin >>m[0][0]>>m[0][1]>>ans[0]>>m[1][0]>>m[1][1]>>ans[1]){
    det = m[0][0]*m[1][1]-m[0][1]*m[1][0];
    inv[0][0] = m[1][1]/det;
    inv[0][1] = -m[0][1]/det;
    inv[1][0] = -m[1][0]/det;
    inv[1][1] = m[0][0]/det;
    x = ans[0]*inv[0][0]+ans[1]*inv[0][1];
    y = ans[0]*inv[1][0]+ans[1]*inv[1][1];
    printf("%.3lf %.3lf\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 1236
import heapq as hq

N, D, A = map(int,input().split())
m = []
for i in range(N):
    hq.heappush(m, tuple(map(int,input().split())))
ans = 0
dmg = 0; d = []
while m:
    X, H = m[0]
    if not d or (X <= d[0][0]):
        if dmg < H:
            k = (H - dmg + A - 1) // A
            ans += k
            dmg += k * A
            hq.heappush(d, (X + 2 * D, - k * A))
        hq.heappop(m)
    else:
        dmg += d[0][1]
        hq.heappop(d)
    # print(dmg, m, d) #DB

print(ans)

Measured memory_bytes: 34692
#include<bits/stdc++.h>
using namespace std;
long long fact[2000015], invfact[2000015];
long long mod = 1e9 + 7;
long long bigmod(long long a, long long p){
    if(p == 0){
        return 1;
    }
    long long ans = bigmod(a, p/2);
    ans = (ans * ans) % mod;
    if(p % 2 == 1){
        ans = (ans * a) % mod;
    }
    return ans;
}
long long inverse(long long a){
    return bigmod(a, mod - 2);
}
void precalc(){
    fact[0] = 1;
    invfact[0] = inverse(fact[0]);
    for(long long i = 1; i <= 2000005; i++){
        fact[i] = (fact[i - 1] * i) % mod;
        invfact[i] = inverse(fact[i]);
    }
}
long long nCr(long long n, long long m){
    long long ans = (fact[n] * invfact[m]) % mod;
    return (ans * invfact[n - m]) % mod;
}
long long solve(long long r1, long long r2, long long c1, long long c2){
    long long ans = 0;
    for(long long i = r1; i <= r2; i++){
        ans = (ans + nCr(i + c2 + 1, c2) - nCr(i + c1, c1 - 1) + 4 * mod) % mod;
    }
    return ans;
}
int main(){
    precalc();
    long long r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    cout << solve(r1, r2, c1, c2);
    return 0;
}

Measured memory_bytes: 34812
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans;cin >> n;ans = n;  
  for(int i=0;i<10;i++){
    int tmp=n-i*10,res=i;   
    if(tmp<0) continue;
    res+=tmp/25;tmp%=25;res+=tmp/5;tmp%=5;res+=tmp/1;tmp%=1;
    ans = min(ans,res);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
int gcf(int a, int b) {return (b == 0) ?  a : gcf(b, a%b);}
ll gcf(ll a, ll b) {return (b == 0) ? a : gcf(b, a%b);} 
int lcm(int a, int b) {return (a*b)/gcf(a, b);}
ll lcm(ll a, ll b) {return (a*b)/gcf(a, b);}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}

ll sumTo(int x) {
    return ((ll)x*(ll)(x+1))/2;
}

void solve() {
    int n; cin >> n;
    int m3 = n/3;
    int m5 = n/5;
    int m15 = n/15;
    cout << sumTo(n) - 3 * sumTo(m3) - 5*sumTo(m5) +15 * sumTo(m15);
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    int n;
    cin >> n;
    vec fml(n);
    rep(i, n){
        cin >> fml[i];
    }
    long long int dp[101][21];
    memset( dp, 0, sizeof(dp) );
    dp[1][fml[0]] = 1;
    rep(i, n-1){
        rep(j, 21){
            if( dp[i][j] > 0 ){
                int plus = j + fml[i];
                int minus = j - fml[i];
                if( plus <= 20 ) dp[i+1][plus] += dp[i][j];
                if( minus >= 0 ) dp[i+1][minus] += dp[i][j];
            }
        }
    }
    cout << dp[n-1][fml[n-1]] << endl;
}

Measured memory_bytes: 1216
#include <stdio.h>

int main() {
    long long n, x, tmp, ans=0, last=0;
    scanf("%lld %lld", &n, &x);
    for (long i=1; i<=n; i++) {
        scanf(" %lld", &tmp);
        if (last + tmp > x) {
            ans += last + tmp - x;
            tmp = x - last;
        }
        last = tmp;
    }
    printf("%lld\n", ans);
}

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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    int a;
    cin >> a;
    cout << a * a * a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n;
    cin >> n;

    ll a[n][n];
    rep(i, n)rep(j, n)cin >> a[i][j];

    //存在するかしないか
    rep(k, n)rep(i, n)rep(j, n){
        if(a[i][k] + a[k][j] < a[i][j]){
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans = 0;
    
    rep(i, n){
        for(int j = i+1; j < n; ++j){
            bool isUse = true;
            rep(k, n){
                if(k == i || k == j)continue;
                //他を経由して最短ならこの経路はいらない
                if(a[i][k] + a[k][j] == a[i][j]){
                    isUse = false;
                    break;
                }
            }
            
            if(isUse)ans += a[i][j];
        }
    }

    cout << ans << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for (int i = 0; i < n; i+=2)
    {
        if(a[i]%2==1) 
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

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

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

            var dict = new Dictionary<string,int>() {
                {"AC",0},
                {"WA",0},
                {"TLE",0},
                {"RE",0},
            };
            
            for (var i = 0; i < n; ++i) {
                dict[Console.ReadLine()]++;
            }

            Console.WriteLine("AC x " + dict["AC"]);
            Console.WriteLine("WA x " + dict["WA"]);
            Console.WriteLine("TLE x " + dict["TLE"]);
            Console.WriteLine("RE x " + dict["RE"]);
        }
    }
}


Measured memory_bytes: 30928
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h=scan.nextInt();
		int a=scan.nextInt();
		scan.close();
		System.out.println((h%a==0)? h/a:h/a+1);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
const int N=1e6+7;
int n,dep[N],ds[N];
std::vector<int>e[N];
void f1(int w){
	int sz=e[w].size();
	for(int i=0;i<sz;++i)f1(e[w][i]);
	for(int i=0;i<sz;++i)ds[i]=dep[e[w][i]];
	std::sort(ds,ds+sz);
	for(int i=0;i<sz;++i)dep[w]=std::max(dep[w],ds[i])+1;
}
int main(){
	scanf("%d",&n);
	for(int i=2,f;i<=n;++i){
		scanf("%d",&f);
		e[f].push_back(i);
	}
	f1(1);
	printf("%d\n",dep[1]);
	return 0;
}

Measured memory_bytes: 37760
#include<bits/stdc++.h>
using namespace std;
#define fr(dt,i,a,b) for(dt i=a;i<b;i++)
#define f0(a,b) for(int i=a;i<b;i++)
#define fn(b,a) for(int i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define UL9 1000000007
#define UL5 100007
#define INF 1e9+7
#define PI 3.1415926
#define sq(a) (a)*(a)
#define fs first
#define sd second
typedef vector<long long int> vlli;
typedef vector<int> vi;
typedef map<char,int> mci;
typedef map<int,int> mii;
typedef long long int lli;  //  e-18 to e18
int main(){
    fastIO();
    int n,k,d,x;
    cin>>n>>k;
    mii a;
    f0(0,k){
       cin>>d;
       f0(0,d){
           cin>>x;
           a[x]++;
       } 
    }
    x=0;
    f0(1,n+1){
        if(a[i]==0) x++; 
    }
    cout<<x<<"\n";
    ret 0; 
}                                                             

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

class Main {
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.nextLine());
        int[] xs = new int[n];
        int[] ys = new int[n];
        int[] hs = new int[n];

        for (int i = 0; i < n; i++) {
            int[] xyh = Arrays.stream(sc.nextLine().split(" +")).mapToInt(Integer::parseInt).toArray();
            xs[i] = xyh[0];
            ys[i] = xyh[1];
            hs[i] = xyh[2];
        }


        for (int cx = 0; cx <= 100; cx++) {
            for (int cy = 0; cy <= 100; cy++) {
                int h = -1;
                int maxH = Integer.MAX_VALUE;
                boolean ok = true;
                for (int k = 0; k < n; k++) {
                    if (hs[k] == 0) {
                        maxH = Math.min(maxH, Math.abs(xs[k] - cx) + Math.abs(ys[k] - cy));
                    }
                    else {
                        int l = height(hs[k], cx, cy, xs[k], ys[k]);
                        if (h == -1) h = l;
                        else if (h != l) {
                            ok = false;
                            break;
                        }
                    }
                }
                if (ok && 1 <= h && h <= maxH) {
                    System.out.printf("%d %d %d\n", cx, cy, h);
                    return;
                }
            }
        }

        sc.close();
    }

    private static int height(int v, int cx, int cy, int x, int y) {
        return v + Math.abs(x - cx) + Math.abs(y - cy);
    }
}


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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

// 超難しい、浮動小数点の精度
// 小数点2桁までとの制約があるのでまずBをstringで受けるのがポイント
ll A;
string B;

int main(){
    cin >> A >> B;
    rep(i, B.size()){
        if(B[i]=='.'){
            B.erase(B.begin() + i);
            break;
        }
    }


    int b = atoi(B.c_str());

    cout << A*b/100 <<endl;

}

Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int A[N],B[N];
  REP(i,N)cin>>A[i];
  int temp=0;
  REP(i,N-1){
    temp+=(i%2==0?1:-1)*A[i];
  }
  B[0]=temp+A[N-1];
  FOR(i,1,N){
    B[i]=2*A[i-1]-B[i-1];
  }
  REP(i,N)cout<<B[i]<<" ";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
using namespace std;
using ll = long long;

ll table[] = {0, 6000, 4000, 3000, 2000};

int main()
{
    ll t, n;

    for (int i = 0; i < 4; i++) {
        cin >> t >> n;
        cout << table[t] * n << endl;
    }

    return 0;
}



Measured memory_bytes: 3096
import Control.Monad

main = do
    [n, m] <- fmap read <$> words <$> getLine
    ka <- forM [1..n] $ \i -> do
        (k : a) <- fmap read <$> words <$> getLine
        return (k, a)
    putStrLn $ show $ solve n m ka

solve :: Int -> Int -> [(Int, [Int])] -> Int
solve n m ka = length $ filter (== n) $ map count [1 .. m]
  where
    count f = length $ filter (any (== f)) $ map snd ka

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

class Program{
    class Area{
        public int area;
        public int height;
    }

    public static void Main(){
        var s=Console.ReadLine();

        var stack=new Stack();
        var areas=new Area[s.Length];
        var height=0;
        for(var i=0; i<s.Length; i++){
            var c=s[i];
            var area=0;
            switch(c){
                case '\\':{
                    stack.Push(i);
                    height--;
                    break;
                }
                case '/':{
                    if(stack.Count!=0){
                        var j=(int)stack.Pop();
                        var u=i-j+1;
                        var d=u-2;
                        area=(u+d)*1/2;
                    }
                    height++;
                    break;
                }
                default:{ // '_'
                    break;
                }
            }
            var a=new Area();
            a.area=area;
            a.height=height;
            areas[i]=a;
        }
        
        stack.Clear();
        var tmp=new Area();
        tmp.area=0;
        tmp.height=0;
        stack.Push(tmp);
        foreach(var area in areas){
            if(area.area==0){
                stack.Push(area);
            } else{
                var top=(Area)stack.Pop();
                while(top.height+1==area.height){
                    area.area+=top.area;
                    top=(Area)stack.Pop();
                }
                stack.Push(top);
                stack.Push(area);
            }
        }
        var result=new Stack();
        var sumArea=0;
        while(stack.Count!=0){
            var area=((Area)stack.Pop()).area;
            if(area!=0){
                result.Push(area);
                sumArea+=area;
            }
        }

        Console.WriteLine(sumArea);
        Console.Write(result.Count);
        while(result.Count!=0){
            var area=(int)result.Pop();
            Console.Write(" "+area);
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 10840
#include <stdio.h>
int main(void){
    int A[4][3][10]={},N,i,j,k,t;
    for(scanf("%d",&N);N--;){
        scanf("%d%d%d%d",&i,&j,&k,&t);
        A[i-1][j-1][k-1]+=t;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d%s",A[i][j][k],k==9?"\n":"");
            }
        }
        if(i!=3)
        puts("####################");
    }
}

Measured memory_bytes: 1800
#include<stdio.h>
#include<stdlib.h>
#define MAX 100000
long long baggage[MAX];
int n, k;

bool vertification(long long P){
	int j = 0;
	long long track=0;
	for (int i = 0; i < n; i++){
		if (track + baggage[i] <= P){
			track += baggage[i];
			if (i == n - 1){
				return true;
			}
		}else{
			if (j < k-1){
				j++;
				track = 0;
                                i--;
			}
			else{
				return false;
			}
		}
	}
}

long long check(){
	long long left = 0;
	long long right = MAX*10000;
	long long mid;
	while (right-left>1){
		mid = (left + right) / 2;
		if (vertification(mid)){
			right = mid;
		}
		else{
			left = mid;
		}
	}
	return right;
}

int main(){
	long long result;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++){
		scanf("%d", &baggage[i]);
	}
	result = check();
	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum=0;
	cin>>n;
	string s;
	cin>>s;
	int l=0,r=n-1;
	while(l<r){
//		cout<<l<<" "<<r<<endl;
		while(s[r]!='R'&&r>l)
		r--;
		while(s[l]!='W'&&l<r)
		l++;
		if(l==r)
		break;
		swap(s[l],s[r]);
		sum++;
	}
	if(l==r&&s[l]=='W'&&l<n-1&&s[l+1]=='R')
	sum++;
	cout<<sum<<endl;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k;
    cin >> k;
    ll ans = 0;
    for(int i = 1; i <= k; ++i)
        for(int j = 1; j <= k; ++j)
            for(int x = 1; x <= k; ++x)
                ans += __gcd(__gcd(i, j), x);
    cout << ans;
    return 0;
}


Measured memory_bytes: 3652
import heapq

class UnionFind():
  def __init__(self,n):
    self.n=n
    self.root=[-1]*(n+1)
    self.rank=[0]*(n+1)
  def FindRoot(self,x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.FindRoot(self.root[x])
      return self.root[x]
  def Unite(self,x,y):
    x=self.FindRoot(x)
    y=self.FindRoot(y)
    if x==y:
      return
    else:
      if self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      elif self.rank[x]<=self.rank[y]:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
  def isSameGroup(self,x,y):
    return self.FindRoot(x)==self.FindRoot(y)
  def Count(self,x):
    return -self.root[self.FindRoot(x)]

n,m=map(int,input().split())
cost=list(map(int,input().split()))
if n==1:
  print(0)
  exit()
if n==2:
  if m==0:
    print(cost[0]+cost[1])
    exit()
  if m==1:
    print(0)
    exit()
edges=[list(map(int,input().split())) for _ in range(m)]
uf=UnionFind(n)
for a,b in edges:
  uf.Unite(a,b)
isolates=set()
isolates_cnt=0
groups=set()
groups_cnt=2
roots=[]
qs=[[] for _ in range(n)]
for i in range(n):
  root=uf.FindRoot(i)
  cnt=uf.Count(i)
  if cnt==1:
    isolates_cnt+=1
    isolates.add(root)
    heapq.heappush(qs[root],(cost[i],i))
  else:
    if root not in groups:
      groups_cnt+=cnt-2
      roots.append((root,cnt))
    groups.add(root)
    heapq.heappush(qs[root],(cost[i],i))
if groups_cnt<isolates_cnt:
  print('Impossible')
else:
  ans=0
  roots=sorted(roots,reverse=True,key=lambda x:x[1])
  root=roots[0][0]
  for tmp_root,_ in roots[1:]:
    cv,v=heapq.heappop(qs[root])
    cu,u=heapq.heappop(qs[tmp_root])
    ans+=(cv+cu)
    while len(qs[tmp_root])!=0:
      tc,tv=heapq.heappop(qs[tmp_root])
      heapq.heappush(qs[root],(tc,tv))
  for tmp_root in isolates:
    cv,v=heapq.heappop(qs[root])
    cu,u=heapq.heappop(qs[tmp_root])
    ans+=(cv+cu)
  print(ans)

Measured memory_bytes: 50484
#include <bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long n,m,k;
long long ans;
long long f[200005],r[200005];
inline long long Pow(long long a,long long b){
	long long res=1;
	while(b){
		if(b&1){
			res*=a;
			res%=mod;
		}
		a*=a;
		a%=mod;
		b>>=1;
	}
	return res;
}
inline long long C(int n,int k){
	return f[n]*r[k]%mod*r[n-k]%mod;
}
int main(){
	cin>>n>>m>>k;
	f[0]=1;
	for(int i=1;i<=n;++i){
		f[i]=f[i-1]*i%mod;
	}
	r[n]=Pow(f[n],mod-2);
	for(int i=n;i>0;--i){
		r[i-1]=r[i]*i%mod;
	}
	for(long long i=0;i<=k;++i){
		long long res=1;
		res*=m;
		res*=C(n-1,i);
		res%=mod;
		res*=Pow(m-1,n-1-i);
		res%=mod;
		ans+=res;
		if(ans>=mod){
			ans-=mod;
		}
	}
	cout<<ans<<'\n';
	return 0;
} 

Measured memory_bytes: 6688
#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
inline void solve()
{
	double n;cin>>n;
	printf("%.6lf\n",n*PI*2);

}
int main()
{
	solve();
	return 0;
}




Measured memory_bytes: 3788
#include<iostream>
#include<cctype>
#include<cstdio>
#include<string>
using namespace std;
int main(){
	string str;
	int i;
	getline(cin,str);
	for(i=0;i<str.size();i++){
		if(str[i]>='a'&& str[i]<='z'){
			str[i]+='A'-'a';
		}
		else if(str[i]>='A' && str[i]<='Z'){
			str[i]+='a'-'A';
		}
		cout<<str[i];

	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3136
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
int H, W;
bool visited[20][20];
int calc(vector<string> &vs, int y, int x) {
  if(y < 0 || y >= H || x < 0 || x >= W) return 0;
  if(visited[y][x] || vs[y][x] == '#') return 0;
  visited[y][x] = true;
  int ret = 1;
  ret += calc(vs, y+1,x);
  ret += calc(vs, y-1,x);
  ret += calc(vs, y,x+1);
  ret += calc(vs, y,x-1);
  return ret;
}

int main()
{
  while(cin >> W >> H) {
    if(W == 0) return 0;
    vector<string> vs(H);
    FOR(i,0,H) cin >> vs[i];
    int sx, sy;
    FOR(y,0,H) {
      FOR(x,0,W) {
        if(vs[y][x] == '@') {
          sx = x;
          sy = y;
        }
      }
    }
    FOR(i,0,H) FOR(j,0,W) visited[i][j] = false;
    cout << calc(vs, sy, sx) << endl;
  }
  return 0;
}

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

int Par[100001];
ll diff_weight[100001];


void init(int n)
{
	for(int i = 0;i<n;i++)
	{
		Par[i] = i;
	}
}

int find(int x)
{
	if(Par[x]==x)return x;
	int f = find(Par[x]);
	diff_weight[x] += diff_weight[Par[x]];//親全部足す
	return Par[x] = f;
}

int weight(int x)
{
	find(x);
	return diff_weight[x];
}

int diff(int x,int y)
{
	if(find(x)!=find(y))return INT_MIN;
	return weight(y)-weight(x);
}

void unite(int x,int y,int w)//yはxよりw大きくする。
{
	w += weight(x); w-=weight(y);
	x = find(x); y = find(y);
	if(x==y)return;
	Par[y]=x;
	diff_weight[y] = w;
}



int main()
{
	int n,q;
	cin >> n >> q;
	//cin >> n >> q;
	init(n+1);
	while(q--)
	{
		int op;
		cin >> op;
		if(op)
		{
			int x,y;
			cin >> x >> y;
			if(diff(x,y)!=INT_MIN)cout<<diff(x,y)<<'\n';
			else cout<<'?'<<endl;
		}
		else
		{
			int x,y,w;
			cin >> x >> y >> w;
			unite(x,y,w);
		}
		
	}
}


Measured memory_bytes: 4256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;

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

const ll mod = 1000000007;
const ll INF = 1000000000000;

ll n, q;

ll a, b, p, x;

ll cnt[200010];
vector<ll> G[200010];

bool flg[200010];

void dfs(ll t)
{
	flg[t] = true;

	for (int i = 0; i < G[t].size(); i++)
	{
		if (flg[G[t][i]]) continue;
		cnt[G[t][i]] += cnt[t];
		dfs(G[t][i]);
	}
}

int main()
{
	cin >> n >> q;

	for (int i = 1; i < n; i++)
	{
		cin >> a >> b;

		G[a].push_back(b);
		G[b].push_back(a);
	}

	for (int i = 0; i < q; i++)
	{
		cin >> p >> x;

		cnt[p] += x;
	}

	dfs(1);

	for (int i = 1; i <= n; i++)
	{
		cout << cnt[i];
		if (i == n)
		{
			cout << endl;
		}
		else
		{
			cout << ' ';
		}
	}

	int www;
	cin >> www;
}


Measured memory_bytes: 24448
#include<bits/stdc++.h>
#define ll long long int 
#define RD(v,n) for(ll i =0;i<n;i++ ) cin>>v[i]
#define bolt ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
	bolt;
    string s;
    cin>>s;
    ll n = s.length();
    ll count = 0;
    for(ll i=0;i<n/2;i++ ){
        if( s[i] != s[n-1-i]  ){
            count++;
        }
    }
    cout<<count<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
int n;
int arr[N];
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll x;
cin>>x;
ll ans=0;
ll cnt=1;
if(x%2)
cout<<0;
else{
ll y=0;
  x/=2;
while(x)
{

	x/=5;
	ans+=x;


	
}
cout<<ans;}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stack>
using namespace std;
int main()
{
	char s[200010];
	scanf("%s",&s);
	int x=strlen(s);
	stack<int> a;
	for(int i=0;i<x;i++)
	{
		if(a.empty())
		{
			if(s[i]=='S')
			a.push(0);
			else
			a.push(1);
			continue;
		}
		if(a.top()==0&&s[i]=='T')
		a.pop();
		else{
			if(s[i]=='S')
			a.push(0);
			else
			a.push(1);
		}
		
	}
	cout << a.size() << endl;
}


Measured memory_bytes: 1280
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val (A,B,m) = readints()
    val a = readints()
    val b = readints()
    var ans = a.min()!! + b.min()!!
    repeat(m){
        val (x,y,c) = readints()
        ans = Math.min(ans, a[x - 1] + b[y - 1] - c)
    }
    println(ans)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

Measured memory_bytes: 90000
N = int(input())
p = [i for i in range(1,N+1)]
q = list(map(int,input().split()))
list = []
re_list = []

for p,q in zip(p,q):
  x = [p,q]
  list.append(x)

new_list = sorted(list,key=lambda x:x[1])
for j in range(len(new_list)):
  re_list.append(str(new_list[j][0]))
print(" ".join(re_list))

Measured memory_bytes: 28556
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int MOD = 1e9 + 7;
 const int INF = 2147000000;
 // const ll INF = 1000000000000000000LL;
 
 int main(){
     int k;
     cin >> k;
     string ans;
     rep(i,k){
         ans+="ACL";
     }
     cout << ans << endl;
     return 0;
 }

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n;
	cin>>n;
	cout<<n/3<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (n, c) = readLine()!!.split(" ").map { it.toInt() }
  val chList = (0..c).map { mutableListOf<Pair<Int, Int>>() }

  for (i in 0 until n) {
    val (s, t, c) = readLine()!!.split(" ").map { it.toInt() }
    chList[c]!!.add(s to t)
  }

//  println(chList)

  val mergedChList = (0..c).map { mutableListOf<Pair<Int, Int>>() }
  for (i in 1..c) {
    val ch = chList[i].sortedBy { it.first }
    if (ch.isEmpty()) continue
//    print("ch>")
//    println(ch)
    mergedChList[i].add(ch[0])
    for (j in 1 until ch.size) {
      val last = mergedChList[i].last()
      if (last.second == ch[j].first) {
        mergedChList[i][mergedChList[i].lastIndex] = mergedChList[i][mergedChList[i].lastIndex].first to ch[j].second
      } else {
        mergedChList[i].add(ch[j])
      }
    }
  }

  val timeline = (0..100000).map { 0 }.toMutableList()

//  println(mergedChList)

  mergedChList.forEach {
    it.forEach {
      (it.first..it.second).forEach { timeline[it]++ }
    }
  }

  for (i in 0 until 100) {
//    println("$i ${timeline[i]}")
  }

  println(timeline.maxBy { it })
}


Measured memory_bytes: 86620
n=int(input())

cnt=0
import math

result=set([])

for i in range(1,int(math.sqrt(n-1))+1):
    if (n-1)%i==0:
        for item in [i,(n-1)//i]:
            if item!=1:result.add(item)

for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
        for item in [i,n//i]:
            if item!=1:
                N=n
                while N%item==0:N=N//item
                if N==1:result.add(item)
                elif N%item==1:result.add(item)

print(len(result))

        


Measured memory_bytes: 40940
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
using namespace std;

    const ll N = 1e2 + 7;
    const ll mod = 1e9 + 7;



void solve(){
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2];
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**

**/


Measured memory_bytes: 3652
n,m=gets.split.map &:to_i
a=[]
(1..n).each{|i|
  a[i]=Array.new
}
m.times{|i|
  x,y=gets.split.map &:to_i
  a[x] << y
  a[y] << x
}
sum=0
(2..n).to_a.permutation(n-1).each{|i|
  flag=true
  [1,i].flatten.each_cons(2){|x,y|
   flag &= a[x].include?(y)
  }
  if(flag);sum+=1;end
}
puts sum


Measured memory_bytes: 2044
function prime(max){
   var arr=[];
   for(var i=0;i<=max;i++)arr[i]=i;
   arr[0]=false;
   arr[1]=false;
   var sqrt=Math.floor(Math.sqrt(max));
   for(var i=2;i<=sqrt;i++){
      if(arr[i]==false)continue;
      for(var j=i+i;j<=max;j+=i){
         arr[j]=false;
      }
   }
   var result=[];
   for(var i=0;i<=max;i++){
      if(arr[i]!==false)result.push(arr[i]);
   }
   return result;
}
var p=prime(1299709);
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
for(var i=0;i<Arr.length;i++){
   var a=Arr[i];
   if(a==0)break;
   for(var j=0;j<p.length;j++){
      if(p[j]==a){console.log(0);break;}
      if(p[j]>a){console.log(p[j]-p[j-1]);break;}
   }
}

Measured memory_bytes: 29552