akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <stdio.h>
int n, sqrtN;
long long ans, d;
char buf[8],out[20];
k;
i;
s;
X;
int main() {
    s = read(0, buf, 8);
    for(;;) {
        k = buf[i++];
        if(k < '0') break;
        n = n * 10 + k - '0';
    }
    if(n == 1) {
        putchar(49);
    } else {
        const int sqrtN = sqrt(n);
        ans = -(long long)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
        for(int i = 1; i <= sqrtN; ++i) {
            const int a = n / i;
            ans += ((long long)i * (i + a) * (a + 1 - i));
        }
        i = 20;
        do{
            out[--i]=ans%10+'0';
            ans/=10;
        }while(ans);
        write(1,out+i,20-i);
    }
}

Measured memory_bytes: 1952
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdint>
#include<unordered_map>
#include<sstream>
#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool ps2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool ps3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool ps4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}


int main()
{
	int n;
	cin >> n;
	vector<pair<int, int>>xy(n);
	rep(i, n) {
		cin >> xy[i].first >> xy[i].second;
	}
	int cnt = 0;
	vector <vector<pair<int,int>>>map(n,vector<pair<int,int>>(n));
	rep(i, n) {
		rep(j, n) {
			//cout << i << " " << j << endl;
			map[i][j].first=xy[i].first - xy[j].first;
			map[i][j].second = xy[i].second - xy[j].second;
		//	cout <<"map"<< map[i][j].first << " " << map[i][j].second << endl;
		}
	}
	rep(i, n)rep(j, n) {
		int p = map[i][j].first;
		int q = map[i][j].second;
		//cout << p << " " << q << endl;
		int count = 0;
		if (!(p == 0 && q == 0)) {
			rep(k, n) {
				bool flag = false;
				rep(l, n) {
					if (map[k][l].first == p &&
						map[k][l].second == q) {
						flag = true;
					}
				}
				if (flag) {
					count++;
				}
			}
		}
		//cout << count << endl;
		cnt = max(cnt, count);
	}
	cout << n - cnt << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, B, C;
  cin >> A >> B >> C;

  if(A==B && B==C) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    double A, B;
    cin >> A >> B;

    if(floor(A / 0.08 * 0.1) != B && floor(B / 0.1 * 0.08) != A){
        cout << "-1" << endl;
    }else{
        double idx = 1;
        while(true){
            if(floor(idx * 0.08) == A && floor(idx * 0.1) == B){
                cout << idx << endl;
                return 0;
            }
            idx++;
        }
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int>
#define pb push_back
#define LL long long
#define mp make_pair
#define pii pair<int,int>
using namespace std;
string S;
int n;
int main(){
	cin>>n>>S;
	int m = S.length();
	for(int i = 0; i < m; i++){
		S[i] = (S[i]-'A'+n)%26 + 'A';
	}
	printf("%s\n", S.c_str());
	return 0;
}

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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int N, H, W; cin >> H >> W >> N;
	cout << min((N+H-1)/H, (N+W-1)/W) << endl;
}


Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
    val a = readLine()!!.trim().toDouble()
    val b = readLine()!!.trim().toDouble()
    val mid = normalize((a + b) / 2)
    if (maxOf(a, b) - mid > 90){
        println(normalize(mid + 180))
    }else{
        println(mid)
    }
}
fun normalize(a:Double):Double{
    var res = a
    if (a < 0){
        while (res < 0){
            res += 360
        }
    }else{
        while(res > 360){
            res -= 360
        }
    }
    return res
}


Measured memory_bytes: 28904
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef __int128_t lll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
int rd(int s, int e) { return rand()%(e-s+1) + s; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

ll A, B, C;
ll Ans = INFLL;

int main() {
	cin >> A >> B >> C;

	{
		ll m = A/2;
		upmin(Ans, B*C*(A-m-m));
	}

	{
		ll m = B/2;
		upmin(Ans, A*C*(B&1));
	}

	{
		upmin(Ans, A*B*(C&1));
	}

	cout << Ans << endl;
	return 0;
}

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

int N;
vector<int> T, X, Y;

int main(void) {
	cin >> N;
	T.resize(N + 1, 0);
	X.resize(N + 1, 0);
	Y.resize(N + 1, 0);
	for (int i = 1; i <= N; ++i)
		cin >> T[i] >> X[i] >> Y[i];

	bool ans = true;
	for (int i = 1; i <= N; ++i) {
		int dt = T[i] - T[i - 1];
		int dx = abs(X[i] - X[i - 1]);
		int dy = abs(Y[i] - Y[i - 1]);
		if (dx + dy > dt) {
			ans = false;
			break;
		}
		if ((dx + dy) % 2 != dt % 2) {
			ans = false;
			break;
		}
	}

	if (ans)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 1536
import sys

s = sys.stdin.readline().rstrip()

def main():
    l = len(s)
    t = s[:-1] if l & 1 else s
    l = len(t)
    while True:
        t = t[:-2]
        l -= 2
        if t[:l//2] * 2 == t:
            return l

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int r=0,b=0;
	for(int i = 0; i < n; i++){
		if(s[i]=='R')r++;
		else b++;
	}
	cout<<(r>b?"Yes":"No")<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; j < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int N,M;
  cin >> N >> M;
  if(N == M) {
    cout << 1 << endl;
    return 0;
  }
  int ans = 1;
  for(int i = 1;i * i <= M;i++) {
    if(M % i == 0) {
      if(M / i >= N) {
        ans = max(ans,i);
      }
      int j = M / i;
      if(M / j >= N) {
        ans = max(ans,j);
        
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int h,n,a;
  int i;

  scanf("%d %d", &h, &n);

  for(i = 0; i<n; i++){
    scanf("%d", &a);
    h = h - a;
  }

  if(h<=0) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<int, int> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)1000000000000

int memo[100000][3];
vector<vector<int>>G(100000);
int N,M,S,T;
void solve(int from,int pp){
  queue<P>qu;
  qu.push(P(from,pp));
  while(!qu.empty()){
    auto t=qu.front();
    qu.pop();
    int x=t.first;
    int y=(t.second+1)%3;
    for(auto k:G[x]){
      if(memo[k][y]!=-1){continue;}
      memo[k][y]=memo[t.first][t.second]+1;
      qu.push(P(k,y));
    }
  }
  return;
}
int main() {
  cin>>N>>M;
  rep(i,100000){rep(j,3){memo[i][j]=-1;}}
  rep(i,M){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].push_back(b);
  }
  cin>>S>>T;S--;T--;
  memo[S][0]=0;
  solve(S,0);
  if(memo[T][0]!=-1){memo[T][0]/=3;}
  cout<<memo[T][0];
}


Measured memory_bytes: 9868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int d,g;
  cin >> d >> g;
  vpii a(d);
  rep(i,d){
    int p,q;
    cin >> p >> q;
    a[i] = make_pair(p,q);
  }
  int ans = inf;
  for(int tmp=0;tmp<(1<<d);tmp++){
    int cnt = 0;
    int sum = 0;
    rep(i,d){
      if(tmp & (1<<i)){
        cnt+= a[i].first;
        sum+= a[i].first*(i+1)*100+a[i].second;
      }
    }
    if(g>sum){
      for (int i= d-1;i>=0;i--){
        if(!(tmp & (1<<i))){
          rep(j,a[i].first){
            if(sum>=g) break;
            cnt++;
            sum+=(i+1)*100;
          }
        }
      }
    }
    if(sum>=g) ans = min(ans,cnt);
  }
  cout << ans << endl;
            
        
}






Measured memory_bytes: 256
n = input()
dp = [[0]*8 for _ in range(2)]
if int(n[0])==3:
    dp[0][4] = 1
if int(n[0])==5:
    dp[0][2] = 1
if int(n[0])==7:
    dp[0][1] = 1
if int(n[0])>3:
    dp[1][4] = 1
if int(n[0])>5:
    dp[1][2] = 1
if int(n[0])>7:
    dp[1][1] = 1
for i in range(1, len(n)):
    newdp = [[0]*8 for _ in range(2)]
    if n[i]=='3':
        newdp[0][4] = dp[0][4]
        newdp[0][5] = dp[0][1] + dp[0][5]
        newdp[0][6] = dp[0][2] + dp[0][6]
        newdp[0][7] = dp[0][3] + dp[0][7]
    elif n[i]=='5':
        newdp[0][2] = dp[0][2]
        newdp[0][3] = dp[0][1] + dp[0][3]
        newdp[0][6] = dp[0][4] + dp[0][6]
        newdp[0][7] = dp[0][5] + dp[0][7]
    elif n[i]=='7':
        newdp[0][1] = dp[0][1]
        newdp[0][3] = dp[0][2] + dp[0][3]
        newdp[0][5] = dp[0][4] + dp[0][5]
        newdp[0][7] = dp[0][6] + dp[0][7]
    newdp[1][1] = dp[1][1] + dp[0][1]*(int(n[i])>7) + 1
    newdp[1][2] = dp[1][2] + dp[0][2]*(int(n[i])>5) + 1
    newdp[1][4] = dp[1][4] + dp[0][4]*(int(n[i])>3) + 1
    newdp[1][3] = dp[1][1] + dp[1][2] + dp[1][3]*2 + (dp[0][1] + dp[0][3])*(int(n[i])>5) + (dp[0][2] + dp[0][3])*(int(n[i])>7)
    newdp[1][5] = dp[1][1] + dp[1][4] + dp[1][5]*2 + (dp[0][1] + dp[0][5])*(int(n[i])>3) + (dp[0][4] + dp[0][5])*(int(n[i])>7)
    newdp[1][6] = dp[1][2] + dp[1][4] + dp[1][6]*2 + (dp[0][2] + dp[0][6])*(int(n[i])>3) + (dp[0][4] + dp[0][6])*(int(n[i])>5)
    newdp[1][7] = dp[1][3] + dp[1][5] + dp[1][6] + dp[1][7]*3 + (dp[0][3]+ dp[0][7])*(int(n[i])>3) + (dp[0][5]+ dp[0][7])*(int(n[i])>5) + (dp[0][6]+ dp[0][7])*(int(n[i])>7)
    dp = newdp
print(dp[0][7]+dp[1][7])

Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	string S;
	cin >> S;
	Cout(Yes(S[0] == '9' || S[1] == '9'));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

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

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi a(n);
    int mi, maxi=-1;
    rep(i,n){
        cin>>a[i];
        if (abs(a[i])>maxi){
            maxi = abs(a[i]);
            mi = i;
        }
    }
    cout<<2*n-2<<endl;
    rep(i,n){
        if (i==mi) continue;
        cout<<(mi+1)<<" "<<(i+1)<<endl;
    }
    if (a[mi]>0){
        rep(i,n-1)
            cout<<(i+1)<<" "<<(i+2)<<endl;
    }else{
        RFOR(i,n-2,0)
            cout<<(i+2)<<" "<<(i+1)<<endl;
    }
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    if (a % 2 == 1) {
      cout<<"first"<<endl;
      return 0;
    }
  }
  cout<<"second"<<endl;
}

Measured memory_bytes: 256
import heapq

def generate_graph(K):
    return [{(i + 1) % K: 1, (i * 10) % K: 0} for i in xrange(K)]

def dijkstra(start, goal, graph):
    answer = [float("inf")] * len(graph)
    answer[start] = 0
    remains = sorted([[v, i] for i, v in enumerate(answer)])

    while remains:
        _, i = heapq.heappop(remains)
        for j, cost in graph[i].items():
            if answer[j] > answer[i] + cost:
                answer[j] = answer[i] + cost
                heapq.heappush(remains, [answer[j], j])

    return answer[goal] + 1

K = int(input())
graph = generate_graph(K)
print dijkstra(1, 0, graph)


Measured memory_bytes: 56432
/*
    	Samrat De
    	NIT Durgapur
    	A Noob Coder
    */
     
    /*#include<iostream>
    #include<functional>
    #include<ext/pb_ds/assoc_container.hpp>
    #include<ext/pb_ds/tree_policy.hpp>*/
    #include<bits/stdc++.h>
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define ll long long int
    #define vec(x) vector<x> 
    #define st(x) set<x> 
    #define mpp(x,y) map<x,y>
    #define qq(x) queue<x>
    #define pqq(x) priority_queue<x> 
    #define min_heap(x) priority_queue<x, vector<x>, greater<x> >
    #define pi(x,y) pair<x,y>
    #define rep(i,x,y) for(ll i=x;i<y;i++)
    #define rel(i,x,y) for(ll i=x-1;i>=y;i--)
    #define rev(x) reverse(x.begin(),x.end())
    #define mem(x,a) memset(x,a,sizeof(x))
    #define mod 1000000007
    #define nxt_per(x) next_permutation(x.begin(),x.end())
    #define pb push_back
    #define pf push_front
    #define vp(x,y) vec(pi(x,y) )
    #define all(x) x.begin(),x.end()
    #define indexof order_of_key
    #define valueat find_by_order
    #define myds tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 
     
    int dx[4]={0,0,1,-1};
    int dy[4]={1,-1,0,0};
    int dxx[8]={0,0,1,-1,-1,-1,1,1};
    int dyy[8]={1,-1,0,0,-1,1,1,-1};
     
    /*
    unordered_map<ll,ll> um
    um.reserve(1<<15);
    um.max_load_factor(0.25);
    */
     
    using namespace std;
    //using namespace __gnu_pbds;
     
    int32_t main()
    {
    	fastio;
    // best of luck don't loose hope man	
     
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        cout<<a*b-c*b-a*d+c*d;
    	return 0;
    }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		
		int antennas[] = new int[5];
		for (int i = 0; i < 5; i++){
			antennas[i] = scan.nextInt();
		}
		int k = scan.nextInt();
		
		if (antennas[4] - antennas[0] <= k) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
using pii = pair<int, int>;
using vi = vector<int>;
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b)
{return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0


bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second < b.second;
}


int main() {
    //cast caution
    //look constraints always
    cin.tie(0); ios::sync_with_stdio(false);
    
    
    
    
    
    
    
    
    int n; cin >> n;
    
    vector<pair<ll, ll> > v;
    rep(i, n) {
        ll a, b; cin >> a >> b;
        v.eb(a, b);
    }
    if (n == 1) {
        if (v[0].F > v[0].S) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
        return 0;
    }
    sort(all(v), comp);
    //rep(i, SZ(v)) cout << v[i].F << " " << v[i].S << endl;
    /*
    rep3(i, 1, SZ(v)) {
        if (v[i].S == v[i - 1].S) {
            v[i].F += v[i - 1].F;
            v.erase(v.begin() + i - 1);
        }
    }
     */
    //rep(i, SZ(v)) cout << v[i].F << " " << v[i].S << endl;
    rep3(i, 1, SZ(v)) {
        v[i].F += v[i - 1].F;
        if (v[i].F > v[i].S) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
//cast caution



Measured memory_bytes: 6536
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll a,b;
  cin>>a>>b;
  cout<<(a%b!=0)<<endl;
  return 0;
}

Measured memory_bytes: 256
function Main(input) {
  var input = input.split("\n")[0];
  var len =input.length
  var count = 0
  for (var i=0;i < len/2;i++){
    if(input[i] != input[len - i - 1]){
      count++
    }
  }

  console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
a  = input()
x = int(a[0])
y = int(a[1])
z = int(a[2])
w = int(a[3])
o = ["+","-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 0 and j == 0 and k == 0:
                if x + y + z + w == 7: p = [i,j,k]
            elif i == 0 and j == 0 and k == 1:
                if x + y + z - w == 7: p = [i,j,k]
            elif i == 0 and j == 1 and k == 0:
                if x + y - z + w == 7: p = [i,j,k]
            elif i == 1 and j == 0 and k == 0:
                if x - y + z + w == 7: p = [i,j,k]
            elif i == 1 and j == 1 and k == 0:
                if x - y - z + w == 7: p = [i,j,k]
            elif i == 0 and j == 1 and k == 1:
                if x + y - z - w == 7: p = [i,j,k]
            elif i == 1 and j == 0 and k == 1:
                if x - y + z - w == 7: p = [i,j,k]
            elif i == 1 and j == 1 and k == 1:
                if x - y - z - w == 7: p = [i,j,k]
print(str(x)+o[p[0]]+str(y)+o[p[1]]+str(z)+str(o[p[2]])+str(w)+"=7")

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




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin>>s;

    int sum=0;

    for(int i=0;i<s.size();i++)
    {

        sum= sum +(s[i]-48);

    }



    if(sum%9==0)
        cout<<"Yes"<<endl;

    else
        cout<<"No"<<endl;


    return 0;
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i];

    map<pii, int> mp;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            pii d = pii(x[i] - x[j], y[i] - y[j]);
            if(d.first == 0 && d.second == 0) continue;
            mp[d]++;
        }
    }

    int mx = -1;
    for(auto e: mp) {
        mx = max(mx, e.second);
    }

    if (N == 1) cout << 1 << endl;
    else cout << N - mx << endl;

    return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int A, B;

int main() {
    cin >> A >> B;
    cout << max(A + B, max(A - B, A * B)) << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
lis = []
clis = set()
for _ in range(m):
    x, y = input().split()
    x = int(x)
    if y == "AC":
        clis.add(x)
    elif x in clis:
        continue
    else:
        lis.append(x)
count = 0
for i in lis:
    if i in clis:
        count += 1
print(len(clis), count)

Measured memory_bytes: 11884
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 5e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, k;
map<ll, vi> m;
sl s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n){
    ll x, y;
    cin >> x >> y;
    s.insert(y);
    if(m.find(x) == m.end()) m[x] = vi();
    m[x].pb(y);
  }
  ll ans = linf;
  each(yl, s){
    for(sl::iterator yr = yl; yr != s.end(); yr++){
      ll c = 0;
      map<ll, vi>::iterator l = m.begin(), r = m.begin();
      while(true){
        while(r != m.end()){
          each(itr, r->se){
            if(*yl <= *itr && *itr <= *yr) c++;
          }
          if(c >= k) break;
          r++;
        }
        if(c >= k){
          while(c >= k){
            mins(ans, (*yr - *yl) * (r->fi - l->fi));
            each(itr, l->se) if(*yl <= *itr && *itr <= *yr) c--;
            l++;
          }
          r++;
        }else{
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
[abc138] E - Strings of Impurity
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_S = 1e5;
const int INF = 1e9;

string s, t;
int d['z' - 'a' + 1][MAX_S];

ll solve() {
    int sl = s.length();
    string ss = s + s;

    for (char c = 'a'; c <= 'z'; c++) {
        for (int i = 0; i < sl;) {
            size_t idx = ss.find(c, i);
            if (idx == string::npos) {
                fill(d[c - 'a'], d[c - 'a'] + sl, INF);
                break;
            }
            for (; i < sl && i <= (int)idx; i++) {
                d[c - 'a'][i] = idx - i;
            }
        }
    }

    ll ans = 0;
    for (char c : t) {
        int dd = d[c - 'a'][ans % sl];
        if (dd >= INF) {
            return -1;
        }
        ans += dd + 1;
    }

    return ans;
}

int main() {
    cin >> s;
    cin >> t;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 10880
#include <stdio.h>
int main(){
    int n;
    double tmp,x;
    int i;
    char u[5];
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%lf %s",&x,u);
        if(u[0]=='J'){
            tmp=tmp+x;
        }
        else{
            tmp=tmp+x*380000;
        }
    }
    printf("%lf\n",tmp);
    
    return 0;
}

Measured memory_bytes: 128
def main():
    from fractions import gcd
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = [i//2 for i in a]
    g = a[0]

    s = set()
    for i in a:
        cnt = 0
        while i % 2 == 0:
            i //= 2
            cnt += 1
        s.add(cnt)
    if len(s) == 1:
        for i in a[1:]:
            g = (g*i)//gcd(g, i)

        print((m//g+1)//2)
    else:
        print(0)


main()

Measured memory_bytes: 16280
N, K, Q = map(int, input().split())
B = []

for i in range (0, N+1):
    B.append(K)

for i in range (0, Q):
    A = int(input())
    plus = A
    B[plus-1] += 1

for i in range (0, N):
    B[i] -= Q
    if B[i] <= 0:
        print('No')
    else:
        print('Yes')

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

#define task "D"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
ll n;
int main()
{
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#else
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#endif
    cin >> n;
    int ans = 0;
    rep(i, 2, sqrt(n)) if (n % i == 0)
    {
        int cnt = 0;
        while (n % i == 0) n /= i, cnt++;
        rep(i, 1, cnt)
        {
            if (cnt < i) break;
            ans++;
            cnt -= i;
        }
    }
    if (n != 1) ans++;
    cout << ans;
    return 0;
}


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

int main(){
	int x;
	scanf("%d", &x);
	for(int i = x; i <= 100003; i++) {
		bool flag = true;
		for(int j = 2; j * j <= i; j++) {
			if(i % j == 0) {
				flag = false;
				break;
			}
		}
		if(flag) {
			printf("%d\n", i);
			return 0;
		}
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
    	Scanner sn = new Scanner(System.in);
        Long a = sn.nextLong();
      	Long b = sn.nextLong();
      	Long c = sn.nextLong();
      	Long d = sn.nextLong();
        Long max1 = (Long) a * c; 
      	Long max2 = (Long) a * d;
      	Long max3 = (Long) b * c;
      	Long max4 = (Long) b * d;
      	Long max11 = Math.max(max1, max2);
      	Long max22 = Math.max(max3, max4);
      	System.out.println(Math.max(max11, max22));
    }
}
 

Measured memory_bytes: 35692
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    for(int n, res; res = INF, cin >> n, n /= 100; cout << res << endl)
        for(int c = 0; c <= n; c += 5)
            for(int b = 0, a; (b + c) <= n; b += 3)
                if(!((a = n - b - c) % 2))
                    res = min(res, int((c / 5 * 0.88+ c / 5 % 3 * 0.12) * 850
                                     + (b / 3 * 0.85+ b / 3 % 4 * 0.15) * 550
                                     + (a / 2 * 0.8 + a / 2 % 5 * 0.20) * 380));

    return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> prices(N);
    for(int i = 0; i < N; i++)
    {
        cin >> prices.at(i);
    }
    sort(prices.begin(), prices.end(), greater<ll>());
    prices.at(0) /= 2;
    ll answer = 0;
    for(int i = 0; i < N; i++)
    {
        answer += prices.at(i);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
data class Item(val to: Int, val cost: Int)
fun main(args: Array<String>) {
    val N = nextInt()
    var G = Array(N) { mutableListOf<Item>() }
    for (n in 0 until N - 1) {
        var (u, v, w) = listOfInt()
        u -= 1; v -= 1; w %= 2
        G[u].add(Item(v, w))
        G[v].add(Item(u, w))
    }
    val ans = Array(N) { -1 }
    ans[0] = 0
    val Q = Queue<Int>()
    Q.enqueue(0)
    while (!Q.isEmpty()) {
        val v = Q.dequeue()!!
        G[v].forEach {
            val u = it.to
            if (ans[u] == -1) {
                ans[u] = ans[v] xor it.cost
                Q.enqueue(u)
            }
        }
    }
    println(ans.joinToString("\n"))
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
class Queue<T> {
    val elements = mutableListOf<T>()
    fun isEmpty() = elements.isEmpty()
    fun count() = elements.size
    fun enqueue(item: T) = elements.add(item)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
    fun peek() = if (!isEmpty()) elements[0] else null
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int res = 0;
    rep (i, n / r + 1) {
        rep (j, n / g + 1) {
            int num = r * i + g * j;
            if ((n - num) % b == 0 && n >= num) res++;
        }
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>
#include <climits>

using namespace std;

int selectionSort(int *A,int N){
  int count=0;
  for(int i=0;i<N-1;i++){
      int minj=i;
      for(int j=i;j<N;j++){
        if(A[j] < A[minj]) {
          minj = j;
        }
      }
      if(i!=minj){
        int tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp;
        count++;
      }
  }
  return count;
}

int main(){
  int n,*A;

  scanf("%d\n",&n);

  A=(int *)malloc(n*sizeof(int));

  for(int i=0;i<n;i++){
    scanf("%d ",&A[i]);
  }
  int count = selectionSort(A,n);
  for(int i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1)
      putchar(' ');
  }
  printf("\n%d\n",count);
}


Measured memory_bytes: 3204
class dice:
    def __init__(s, i):
        s.d1,s.d2,s.d3,s.d4,s.d5,s.d6 = map(int, i)
    
    def W(s):
        tmp = s.d1
        s.d1 = s.d3
        s.d3 = s.d6
        s.d6 = s.d4
        s.d4 = tmp
        
    def E(s):
        tmp = s.d1
        s.d1 = s.d4
        s.d4 = s.d6
        s.d6 = s.d3
        s.d3 = tmp
        
    def N(s):
        tmp = s.d1
        s.d1 = s.d2
        s.d2 = s.d6
        s.d6 = s.d5
        s.d5 = tmp
        
    def S(s):
        tmp = s.d1
        s.d1 = s.d5
        s.d5 = s.d6
        s.d6 = s.d2
        s.d2 = tmp
        
    def L(s):
        tmp = s.d2
        s.d2 = s.d3
        s.d3 = s.d5
        s.d5 = s.d4
        s.d4 = tmp
        
    def isSame(s, d):
        flg = False
        
        #1つのダイスを基準に6面回す
        for i in range(6):
            #2つ目のダイスを6面全て上部に設定し、総当たり
            for j in range(6):
                if s.d1 == d.d1 and s.d6 == d.d6:
                    #上部、下部が一致した場合、左周りに回転させ側面が全て一致するか確認
                    for j in range(3):
                        if s.d2 == d.d2 and s.d3 == d.d3 and s.d4 == d.d4 and s.d5 == d.d5:
                            #全部の面が一致した場合、Trueを返し判定終了
                            return True
                        else:
                            #一致しない場合は左周り
                            d.L()
                    
                #一致するケースが無い場合、2つ目のダイスを回転させる
                if j <= 3:
                    d.N()
                elif j == 4:
                    d.E()
                else:
                    d.E()
                    d.E()
            
            #一致するケースが無い場合、基準のダイスを回転させる
            if i <= 3:
                s.N()
            elif i == 4:
                s.E()
            else:
                s.E()
                s.E()
        
        #全ケース一致する場合が無ければFalseを返す
        return False
        
dice1 = dice(input().split())
dice2 = dice(input().split())
if dice1.isSame(dice2):
    print("Yes")
else:
    print("No")


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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

void solve(void) {

	int n, k;
	cin >> n >> k;

	vi A(n);
	for(int& x : A) cin >> x;

	vector<bool> dp(k+1);
	dp[0] = false;

	for(int i = 0; i < k; i++) {
		if(dp[i] == false) {
			for(int x : A) {
				if(i + x <= k) dp[i+x] = true;
			}
		}
	}

	cout << (dp[k] ? "First" : "Second") << '\n';
}

int main(void) {

	solve();
	return 0;
}


Measured memory_bytes: 256
fun main() {
  val N = readInt()
  println((1000 - N % 1000) % 1000)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 34400
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector

int main(void)
{
	ll n;
	cin >> n;
	
	int keta = 0;
	while(1) {
		if (n < (1LL << (keta + 1)) - 1) break;
		keta++;
	}

	vec<int> p(keta);
	rep(i, keta) p[i] = i + 1;
	int use = keta;
	n -= (1LL << keta) - 1;

	for (int i = keta - 1; i >= 0; i--) {
		if (n < (1LL << i)) continue;
		use++;
		p.insert(p.begin() + i, use);
		n -= (1LL << i);
	}
	cout << 2 * p.size() << endl;
	cout << p[0];
	rep(i, p.size() - 1) cout << " " << p[i + 1];
	rep(i, p.size()) cout << " " << i + 1;
	cout << endl;
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N, Q; cin >> N >> Q;
  string s; cin >> s;
  vector<int> v(s.size()), b(s.size() + 1);
  REP(i, N-1) {
    if (s[i]=='A' && s[i+1]=='C') v[i] = 1;
  }
  REP(i, N) {
    b[i+1] = b[i] + v[i];
  }
  REP(q, Q) {
    int l, r; cin >> l >> r;
    int ans = b[r-1] - b[l-1];
    printf("%d\n", ans);
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1792
N=int(input())
B=list(map(int, input().split()))

A=[0]*N

MIN = float('inf')
for i in reversed(range(N)):
    if (i == N-1):
        A[i] = B[N-2]
    elif (i == 0):
        A[i] = B[0]
    else:
        A[i] = min(B[i], B[i-1])

print(sum(A))

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	ans := 0
	a := 0
	for i := 0; i < len(s)-1; i++ {
		if s[i] == 'A' {
			a++
		} else if s[i] == 'B' && s[i+1] == 'C' {
			ans += a
			i++
		} else {
			a = 0
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define v vector<ll>
#define vv vector<v>
ll MOD=1e9+7;
int main() 
{ 
	int n;
	cin>>n;
	vv matrix(18,v(18,0));
	for (int i=0; i<n; i++)
		for (int j=0; j<n; j++)
			cin>>matrix[i][j];
	v dp(1<<(n),0);
	for (int i=1; i<(1<<n); i++)
	{
		ll sum=0;
		int msb=(31-__builtin_clz(i));
		for (int j=0; j<msb; j++)
			sum+=matrix[msb][j]*((i& (1<<j))!=0);
		dp[i]=dp[i^(1<<msb)]+sum;
	}
	v ans(1<<(n),0);
	for (int mask=0; mask<(1<<n); mask++)
	{
		ans[mask]=dp[mask];
		for (int j=mask; j>0; j=(j-1)&mask)
			ans[mask]=max(ans[mask],ans[j]+dp[mask^j]);
	}
	cout<<ans[(1<<n)-1];
    return 0;
} 

Measured memory_bytes: 1280
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	string s;
	while (cin >> s) {
		string a = s.substr(0, 4);
		string b = s.substr(4);
		cout << a << " " << b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	a=(int)s1[0]-32;
	cout<<(char)a;
	b=(int)s2[0]-32;
	cout<<(char)b;
	c=(int)s3[0]-32;
	cout<<(char)c<<"\n";
}



Measured memory_bytes: 256
require "prime"

class Integer
  def divisors
    prime_division.inject([1]) do |ary, (p, e)|
      (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
    end.sort
  end
end

n, m = gets.split.map(&:to_i)

m.divisors.each do |k|
  next if k < n
  puts m / k
  exit
end

Measured memory_bytes: 2172