akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long X) {
   cout << 8 - (X-400)/200 <<endl;

}

signed main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


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

typedef long long int ll;

int main()
{
	ll i,j,k,l,m,n,t;

	ll u,v;

	cin >> t;

	if(t == 0)
	{
		cout << 1 << '\n';
	}
	else
	{
		cout << 0 << '\n';
	}


}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;

    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');

    cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
    cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';

    cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<cstdio>
using namespace std;

int main()
{
	char prime[999999];
	for (int i = 0; i <= 999999; i++)prime[i] = '1';
	prime[0] = '0';
	prime[1] = '0';
	for (int i = 2; i*i <= 999999; i++)
	{
		if (prime[i] == '1')
		{
			int j = i * 2;
			while (j <= 999999)
			{
				prime[j] = '0';
				j += i;
			}
		}
	}
	int n;
	while (cin >> n)
	{
		int sum = 0;
		for (int i = 0; i <= n; i++)
		{
			if (prime[i] == '1')sum++;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 2136
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		String[] numStrArr = sc.nextLine().split(" ");
		long[] numArr = new long[numStrArr.length];
		sc.close();
		
		for(int i = 0 ; i < numStrArr.length; i++) {
			numArr[i] = Long.parseLong(numStrArr[i]);
		}
		
		long notInterested = numArr[0];
		for(int i = 1; i < numStrArr.length; i++) {
			notInterested ^= numArr[i];
		}
		
		long interest = ~notInterested;
		long[] interestBitArr = new long[numArr.length];
		for(int i = 0; i < numArr.length; i++) {
			interestBitArr[i] = numArr[i] & interest;
		}
		
		int rank = 0;
		for(int i = 59; i >= 0; i--) {
			long nowBit = (1L << i);
			int j;
			for(j = rank; j < n; j++) {
				if((interestBitArr[j] & nowBit) > 0) {
					break;
				}
			}
			
			if(j == n) {
				continue;
			}
			
			if(j != rank) {
				interestBitArr[rank] ^= interestBitArr[j]; 
			}
			
			for(int k = rank + 1; k < n;k++) {
				if((interestBitArr[k] & nowBit) > 0) {
					interestBitArr[k] = interestBitArr[k] ^ interestBitArr[rank];
				}
			}
			rank++;
		}
		
		long interestXor = 0;
		
		for(int i = 0; i < interestBitArr.length; i++) {
			if(interestXor < (interestXor ^ interestBitArr[i])) {
				interestXor ^= interestBitArr[i];
			}
		}
		
		long maxPoint = 2 * interestXor + notInterested;
		
		System.out.println(maxPoint);
		
	}
}


Measured memory_bytes: 56844
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
int INF=1<<29;

class Unionfind{
public:
	vector<int> par;
	vector<int> size;

	Unionfind(int n){
		par=vector<int>(n);
		size=vector<int>(n,1);
		for(int i=0;i<n;i++) par[i]=i;
	}

	int root(int x){
		if(par[x]==x) return x;
		return par[x]=root(par[x]);
	}

	void merge(int x,int y){
		x=root(x);
		y=root(y);
		if(par[x]==par[y]) return;
		if(size[y]>size[x]) swap(x,y);
		par[y]=x;
		size[x]+=size[y];
		size[y]=size[x];
		return;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N,K,L;
	cin>>N>>K>>L;
	vector<pair<int,int>> q(K),r(L);
	for(int i=0;i<K;i++){
		cin>>q[i].first>>q[i].second;
		q[i].first--;
		q[i].second--;
	}
	for(int i=0;i<L;i++){
		cin>>r[i].first>>r[i].second;
		r[i].first--;
		r[i].second--;
	}
	Unionfind road(N),train(N);
	for(int i=0;i<K;i++) road.merge(q[i].first,q[i].second);
	for(int i=0;i<L;i++) train.merge(r[i].first,r[i].second);

	vector<pair<int,int> > com(N);
	map<pair<int,int> ,int> s;
	for(int i=0;i<N;i++){
		com[i].first=road.root(i);
		com[i].second=train.root(i);
		s[com[i]]++;
	}

	for(int i=0;i<N;i++){
		cout<<s[com[i]]<< " ";
	}


	return 0;
}

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

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

using namespace std;
using ll = long long;

void solve();

int main(void){
    int N; cin >> N;
    int div2 = 0, div4 = 0; //div2: 4で割り切れないが2で割り切れる数の個数 div4: 4で割り切れる数の個数
    rep(i, N){
        int temp; cin >> temp;
        if(temp % 4 == 0) div4++;
        else if(temp % 2 == 0) div2++;
    }
    if(div4 == 0){
        if(div2 == N) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        if((div2 == 0 && div4*2+1 >= N) || (div4*2 + div2 >= N)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

void solve(){}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < ((int)(b)); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define sz(c) ((int)c.size())
#define all(c) c.begin(), c.end()

signed main() {
    int X, A, B;
    cin >> X >> A >> B;
    X -= A;
    X -= X / B * B;
    cout << X << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int* A = new int[N];
    int* B = new int[N];
    int* C = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
//        cout << A[i];
    }
//    cout << endl;
    for (int i = 0; i < N; i++) {
        cin >> B[i];
//        cout << B[i];
    }
//    cout << endl;
    for (int i = 0; i < N - 1; i++) {
        cin >> C[i];
//        cout << C[i];
    }
//    cout << endl;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += B[A[i]-1];
//        cout << ans << endl;
        if (i != 0)
        {
//            cout << A[i-1] << endl;
//            cout << A[i] << endl;
            if (A[i-1] + 1 == A[i])
            {
                ans += C[A[i-1]-1];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//~#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//~#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//~#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=2000002;

void solve(){
	int n;
	cin>>n;
	vector<string>a(n);
	cin>>a;
	map<string,int>st;
	for(auto i:a){
		st[i]++;
	}
	int mx=0;
	for(auto i:st){
		mx=max(mx,i.S);
	}
	set<string>st2;
	for(auto i:st){
		if(i.S==mx){
			st2.insert(i.F);
		}
	}
	for(auto i:st2){
		cout<<i<<'\n';
	}
}  
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


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

struct z_algorithm {
  string s;
  vector<long long> ary;
  z_algorithm(string s = "") {
    int i = 1, j = 0, ssize = s.size();
    ary.resize(s.size());
    ary[0] = ssize;
    while(i < ssize) {
      while(i + j < ssize && s[j] == s[i + j]) ++j;
      ary[i] = j;
      if(j == 0) {
        ++i;
        continue;
      }
      int k = 1;
      while(i + k < ssize && k + ary[k] < j)
        ary[i + k] = ary[k], ++k;
      i += k, j -= k;
    }
  }
  inline const long long &operator[](int k) const {
    return (ary[k]);
  }
};

long long n;
vector<long long> a, b;
vector<z_algorithm> v[2];

void solve();

int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];
  solve();
  return 0;
}

void solve() {
  for(int i = 0; i < 30; ++i) {
    string s, t;
    for(int j = 0; j < n; ++j) s += '0' + (b[j] >> i & 1);
    s += "#";
    t = s;
    for(int j = 0; j < n; ++j) {
      s += '0' + (a[j] >> i & 1);
      t += '0' + 1 - (a[j] >> i & 1);
    }
    for(int j = 0; j < n; ++j) {
      s += '0' + (a[j] >> i & 1);
      t += '0' + 1 - (a[j] >> i & 1);
    }
    v[0].push_back(z_algorithm(s));
    v[1].push_back(z_algorithm(t));
  }
  for(int i = 0; i < n; ++i) {
    bool ch = 1;
    for(int j = 0; j < 30; ++j)
      if(v[0][j][i + n + 1] < n && v[1][j][i + n + 1] < n)
        ch = 0;
    if(ch) cout << i << " " << (a[i] ^ b[0]) << endl;
  }
}

Measured memory_bytes: 288632
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll power(ll x, ll y){ll out = 1;while (y > 0){if (y & 1) out=(out*x)%mod;y = y>>1;x = (x*x)%mod;}return out%mod;}
ll inverse(ll a){return power(a,mod-2)%mod;}
void comp() {
	ll i,j,k,m,n;
	cin>>n;
	cout<<(1000-n%1000)%1000<<"\n";
}
int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

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


int main (){
    int x = 0;
    scanf ("%d",&x);
    int h = 0, m = 0, s = 0;
    s = x % 60;
    m = x / 60 % 60;
    h = x / 3600 % 24;
    printf ("%d:%d:%d\n",h , m, s);
    return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#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(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007



int main() {
  string S;
  cin >> S;
  if(S=="SSS")
    cout << 0 << endl;
  else if(S=="RRR")
    cout << 3 << endl;
  else if(S=="SRR")
    cout << 2 << endl;
  else if(S=="RRS")
    cout << 2 << endl;
  else
    cout << 1 << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//void quick(int *,long long,long long);
//int comp(char *a,char *b);
long long gcd(long long a,long long b);

int main(){
	
	long long a,b;
	
	while(scanf("%lld %lld",&a,&b)!=EOF){
		printf("%lld %lld\n",gcd(a,b),a*b/gcd(a,b));
	}
	//for(i=0;i<=10000000000;i++);
	return 0;
}

long long gcd(long long a,long long b){
	
	if(b==0)
		return a;
	return gcd(b,a%b);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
int main(){
    lint N, K;
    lint H[200002];
    lint count = 0;
    cin >> N >> K;
    for(lint i=0;i<N;i++) cin >> H[i];
    sort(H, H+N);
    for(int i=0;i<N-K;i++){
        count += H[i];
    }
    cout << count << endl;
    return 0;
}

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

const ll INF = ll(1e18)+1;

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -INF, r = INF;
  while (l+1 < r) {
    ll x = (l+r)/2;
    bool ok = [&]{
      ll tot = 0;
      rep(i,n) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) r = c; else l = c;
          }
          tot += n-r;
        } else {
          int l = -1, r = n;
          while (l+1<r) {
            int c = (l+r)/2;
            if (a[c]*a[i] < x) l = c; else r = c;
          }
          tot += r;
        }
        if (a[i]*a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    if (ok) l = x; else r = x;
  }
  cout << l << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int lca(int x,int y){return x*y/__gcd(x,y);}
signed main()
{
	int x=read();
	cout<<lcm(360,x)/x<<endl;
	return 0;
}




Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1e15;
ll MOD = 1e9 + 7;
ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}
ll mod_pow(ll x, ll y)
{
    ll res = 1;
    while(y > 0)
    {
        if(y & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}
int main()
{
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll h1 = t1 * a1 + t2 * a2;
    ll h2 = t1 * b1 + t2 * b2;
    if(h1 == h2)
    {
        cout << "infinity" << endl;
        return 0;
    }
    if(a1 < b1)
    {
        ll diff = h2 - h1;
        if(diff > 0)
        {
            cout << 0 << endl;
            return 0;
        }
        ll one = b1 * t1 - a1 * t1;
        one *= -1;
        ll cnt;
        if(one % diff == 0)
        {
            cnt = one / diff;
            cnt = 2 * cnt - 1;
        }
        else
        {
            cnt = one / diff * 2;
        }
        cout << 1 + max(0LL, cnt) << endl;
    }
    else
    {
        ll c1 = b1;
        ll b1 = a1;
        ll a1 = c1;
        ll x = h1;
        ll h1 = h2;
        ll h2 = x;
        ll diff = h2 - h1;
        if(diff > 0)
        {
            cout << 0 << endl;
            return 0;
        }
        ll one = b1 * t1 - a1 * t1;
        one *= -1;
        ll cnt;
        if(one % diff == 0)
        {
            cnt = one / diff;
            cnt = 2 * cnt - 1;
        }
        else
        {
            cnt = one / diff * 2;
        }
        cout << 1 + max(0LL, cnt) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;




int main(){
ll N;
cin >> N;
Map a;
string S;
for(int i=0;i<N;i++){
    cin>>S;a[S]++
;}
ll Max=0;
for(auto p:a){
    Max=max(p.second,Max);
}
vector<string> ans(0);
for(auto p:a){
    if(p.second==Max){ans.emplace_back(p.first);}
;}
for(auto p:ans){
    cout<<p<<endl
;}

return 0;
}  



Measured memory_bytes: 26868
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  string s, t; cin >> s >> t;
  s += s;
  if (s.find(t) != string::npos) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <string>
using namespace std;
#define rep(i,b) for(int i=0; i<int(b); i++)

string tos(int n){
    string res;
    char c[]="ixcm";
    rep(i,4){
        int k=n%10;
        n/=10;
        if(k==0) continue;
        res.push_back(c[i]);
        if(k!=1) res.push_back(k+'0');
    }
    rep(i,res.size()/2) swap(res[i],res[res.size()-i-1]);
    return res;
}

int toi(string a) {
    int d[256]={};
    d['m'] = 1000;
    d['c'] = 100;
    d['x'] = 10;
    d['i'] = 1;
    int res=0;
    int n=1;
    rep(i,a.size()){
        char c=a[i];
        if(d[c]){
            res += n*d[c];
            n=1;
        }
        else n=c-'0';
    }
    return res;
}

int main(){
    int n; cin>>n;
    while(n--){
        string s,t; cin>>s>>t;
        cout << tos(toi(s)+toi(t)) << endl;
    }
}

Measured memory_bytes: 1204
open System

let n = int64(stdin.ReadLine())
let sq = int64(Math.Sqrt(double(n)))

let mutable x = n
let mutable cnt = 0

for i in 2L .. sq do
    let mutable k = i
    while x % k = 0L do
        x <- x / k
        cnt <- cnt + 1
        k <- k * i
    
    while x % i = 0L do
        x <- x / i

if x > 1L then
    cnt <- cnt + 1
   
printfn "%i" cnt


Measured memory_bytes: 30072
#include <stdio.h>          // printf(), scanf()

void
east(int dice[6])
{
	int t = dice[2];
	dice[2] = dice[0]; /* 3 ??? 1 */
	dice[0] = dice[3]; /* 1 ??? 4 */
	dice[3] = dice[5]; /* 4 ??? 6 */
	dice[5] = t;       /* 6 ??? 3 */
}

void
south(int dice[6])
{
	int t = dice[1];
	dice[1] = dice[0]; /* 2 ??? 1 */
	dice[0] = dice[4]; /* 1 ??? 5 */
	dice[4] = dice[5]; /* 5 ??? 6 */
	dice[5] = t;       /* 6 ??? 2 */
}

void
rotate(int dice[6])
{
	int t = dice[3];
	dice[3] = dice[1]; /* 4 ??? 2 */
	dice[1] = dice[2]; /* 2 ??? 3 */
	dice[2] = dice[4]; /* 3 ??? 5 */
	dice[4] = t;       /* 5 ??? 4 */
}

int
main(int argc, char** argv)
{
	int dice[6];
	int u, v;
	int q;
	int i, j;

	for (i = 0; i < 6; ++i)
		scanf("%d", &dice[i]);

	scanf("%d", &q);
	for (i = 0; i < q; ++i)
	{
		scanf("%d %d", &u, &v);
		for (j = 0; j < 4; ++j)
		{
			if (dice[1] == v)
				break;

			south(dice);
		}

		if (dice[1] != v) /* dice[2]????????¢???????????????????????? */
		{
			for (j = 0; j < 4; ++j)
			{
				if (dice[1] == v) /* dice[2]????????¢??? */
					break;

				rotate(dice);
			}
		}

		for (j = 0; j < 4; ++j)
		{
			if (dice[0] == u) /* dice[1]????????¢??? */
				break;

			east(dice);
		}

		printf("%d\n", dice[2]); /* dice[3]????????´??¢ */
	}

	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
// #include"testlib.h"

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)1e5 + 10;
// const int mod = (int)1e9 + 7;

int nck(int n, int k){
    if(n == k || k == 0) return 1;
    if(n < k) return 0;
    return nck(n - 1, k) + nck(n - 1, k - 1);
}

int main(int argc, char* argv[]){

    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);

    int r, b, g, n;
    cin >> r >> g >> b >> n;

    ll res = 0;
    for(int i = 0; i <= n; ++i){
        for(int j = 0; j <= n; ++j){
            int here = r * i + g * j;
            int rem = n - here;
            if(rem >= 0 && rem % b == 0) res++;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int > c(n-1,0), s(n - 1,0), f(n - 1,0);
  REP(i,n - 1){
    cin >> c[i] >> s[i] >> f[i];
  }
  vector<int > ans(n, 0); // time from stat. i  -> i + 1;
  REP(i, n - 1){
    int time = s[i];
    for(int j = i; j < n - 1; j ++ ){
      if(time <= s[j]){
	time = s[j] + c[j];
      }else{
	int k = time/f[j] - s[j]/f[j] + (!(time%f[j] == 0));
	time = s[j] + k*f[j] + c[j];
      }
    }
    ans[i] = time;
  }
  ans[n - 1] = 0;
  REP(i, n){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n, k; cin >> n >> k;
	vi cnt(111111);
	REP(i, n)
	{
		int a, b; cin >> a >> b;
		cnt[a] += b;
	}
	ll tmp = 0;
	REP(i, 111111)
	{
		tmp += cnt[i];
		if (tmp >= k)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    ll N;
    string S;
    cin >> N>> S;
    ll count = 0;
    for(int i = 2;i< N;i++){
        if (S[i-2] == 'A' && S[i-1] == 'B' && S[i] == 'C'){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU
import Data.ByteString.Char8 as B
import Data.Char
import Control.Monad

solve vec a b i
    | i == 1 = diff
    | otherwise = min diff (solve vec (a-v) (b+v) (i-1))
    where
        v = vec VU.! i
        diff = abs $ (a-v) - (b+v)

main = do
    n <- readLn :: IO Int
    xs <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    print $ solve xs (VU.sum xs) 0 (n-1)

Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;

template <int M, bool IsPrime = false> class Modulo {
  int n;
  static typename std::enable_if<IsPrime, ll>::type inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
  }

public:
  Modulo() : n(0) { ; }
  Modulo(int m) : n(m) {
    if (n >= M)
      n %= M;
    else if (n < 0)
      n = (n % M + M) % M;
  }
  Modulo(ll m) {
    if (m >= M)
      m %= M;
    else if (m < 0)
      m = (m % M + M) % M;
    n = m;
  }
  explicit operator int() const { return n; }
  explicit operator ll() const { return n; }
  bool operator==(const Modulo &a) const { return n == a.n; }
  Modulo &operator+=(const Modulo &a) {
    n += a.n;
    if (n >= M) n -= M;
    return *this;
  }
  Modulo &operator-=(const Modulo &a) {
    n -= a.n;
    if (n < 0) n += M;
    return *this;
  }
  Modulo &operator*=(const Modulo &a) {
    n = (ll(n) * a.n) % M;
    return *this;
  }
  Modulo operator+(const Modulo &a) const {
    Modulo res = *this;
    return res += a;
  }
  Modulo operator-(const Modulo &a) const {
    Modulo res = *this;
    return res -= a;
  }
  Modulo operator-() const { return Modulo(0) - *this; }
  Modulo operator*(const Modulo &a) const {
    Modulo res = *this;
    return res *= a;
  }

  Modulo operator^(ll m) const {
    if (m == 0) return Modulo(1);
    const Modulo a = *this;
    Modulo res = (a * a) ^ (m / 2);
    return m % 2 ? res * a : res;
  }
  typename std::enable_if<IsPrime, Modulo>::type
  operator/(const Modulo &a) const {
    return *this * inv(ll(a), M);
  }
  typename std::enable_if<IsPrime, Modulo>::type operator/=(const Modulo &a) {
    return *this *= inv(ll(a), M);
  }

  friend bool is_zero(const Modulo &x) { return int(x) == 0; }
  friend int abs(const Modulo &x) { return int(x); }

  static Modulo fact(int n, bool sw = true) {
    static std::vector<Modulo> v1 = { 1 }, v2 = { 1 };
    if (n >= (int)v1.size()) {
      const int from = v1.size(), to = n + 1024;
      v1.reserve(to);
      v2.reserve(to);
      for (int i = from; i < to; ++i) {
        v1.push_back(v1.back() * Modulo<M, true>(i));
        v2.push_back(v2.back() / Modulo<M, true>(i));
      }
    }
    return sw ? v1[n] : v2[n];
  }
  static Modulo comb(int a, int b) {
    if (b < 0 || b > a) return 0;
    return Modulo::fact(a, true) * Modulo::fact(b, false) *
           Modulo::fact(a - b, false);
  }
};
using Mod = Modulo<1000003, true>;

int main(void)
{
  ll q;
  cin >> q;
  vector<Mod> f(1000003);
  f[0] = Mod(1);
  FOR(i,1,1000004) f[i] = f[i-1]*i;
  REP(i,q) {
    ll x, d, n;
    cin >> x >> d >> n;
    if(!d) {
      cout << (ll)(Mod(x)^n) << endl;
      continue;
    }
    if(n >= 1000003) {
      cout << 0 << endl;
      continue;
    }
    ll ans = 1;
    Mod lm = Mod(x) / d - 1;
    ll l = (ll)lm;
    ll r = l+n;
    if(r%1000003 < n-1) {
      cout << 0 << endl;
      continue;
    }
    ll answer = (ll)(f[r%1000003] / f[l] * (Mod(d)^n));
    cout << answer << endl;
  }
  return 0;
}



Measured memory_bytes: 4736
function Main(input) {
    tmp = input.split("\n");
    s = tmp[0];
    t = tmp[1];
    num = s.length;
    check = t.substr(0, num);
    if (s == check) {
        console.log("Yes");
    }else {
        console.log("No");
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29452
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define begin begin()
#define end end()

void _main(){
    int a,b;
    int h,m;
    cin >> a >> b >> h >> m;
    double t = abs(h*30+m*0.5-m*6);
    double s = max(t,360-t)*M_PI/180;
    double c = sqrt(a*a+b*b-2*a*b*cos(s));
    cout << c << endl;
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 3668
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define RREP(i,x,y) for(int i=(int)(x);i>(int)(y);i--)
#define all(x) (x).begin(),(x).end()

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

typedef long long ll;

using namespace std;

const int MOD = 1e9 + 7;
const int MAX_N = 1000;
int N;
int A,B,C,D;

int F[MAX_N+1];
int P[MAX_N+1][MAX_N+1];
int K[MAX_N+1][MAX_N+1];

// k!
int factorial(int i){
    if(F[i]){
        return F[i];
    }

    int f = 1;
    REP(l, 1, i+1) f = (1ll * f * l) % MOD;
    F[i] = f;
    return f;
}

// a x + b y = gcd(a, b)
int extgcd(int a, int b, int &x, int &y) {
    int g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

int invmod(int a, int m) {
    int x, y;
    if (extgcd(a, m, x, y) == 1) return (x + m) % m;
    else return 0; // unsolvable
}

// the number of combinations to create groups(each group has just i people) from j people.
int combination(int i,int j,int k){
    // combination = nPr / (i!)^k / k!
    int combination = 1;

    // nPr
    int n = N - (j - i * k);
    int r = i * k;
    if(P[n][r]) combination = P[n][r];
    else {
        RREP(l, n, n - r) {
            combination = (1ll * combination * l) % MOD;
        }
        P[n][r] = combination;
    }

    // (i!)^k
    int ik = 1;
    int ii = factorial(i);
    if(K[i][k]) ik = K[i][k];
    else {
        REP(l, 0, k) {
            ik = (1ll * ik * invmod(ii, MOD)) % MOD;
        }
        K[i][k] = ik;
    }
    combination = (1ll * combination * ik) % MOD;

    // k!
    combination = (1ll * combination * invmod(factorial(k), MOD)) % MOD;

    eprintf("combination: %d (N,i,j,k: %d,%d,%d,%d)\n",combination,N,i,j,k);

    return combination;
}

int solve() {
    // dp[i][j]: the number of combinations with these conditions.
    //   1. the number of people of all groups is less than i.
    //   2. the total number of people of all groups is j.
    int dp[N+1][N+1];
    fill(dp[0], dp[0] + (N+1)*(N+1), 0);
    REP(i,0,A) dp[i][0] = 1;

    // all groups must have more than A people.
    REP(i,A,N+1){
        REP(j,0,N+1){
            // k: the number of groups whose number of people is i.
            dp[i][j] += dp[i-1][j]; // this is equivalent to the case k == 0;
            if(i > B) continue;
            REP(k,C,D+1){
                if(0 > j - i * k) break;
                eprintf("--dp[i-1][j-i*k]: %d\n",dp[i-1][j-i*k]);
                dp[i][j] = (dp[i][j] + 1ll * dp[i-1][j-i*k] * combination(i,j,k)) % MOD;
            }
            eprintf("dp[%d][%d]: %d\n",i,j,dp[i][j]);
        }
    }
    return dp[N][N];
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> A >> B >> C >> D;
    eprintf("N,A,B,C,D: %d,%d,%d,%d,%d\n",N,A,B,C,D);
    cout << solve() << "\n";
    return 0;
}


Measured memory_bytes: 12032
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
    cin >> a >> b >> c >> d >> e >> f;
    vector<int> water;
    for (int i=0; i<=30/a; i++) {
        for (int j=0; j<=40/b; j++) {
            water.push_back(100*(a*i+b*j));
        }
    }
    vector<int> suger;
    for (int i=0; i<=30*e/c; i++) {
        for (int j=0; j<=30*e/d; j++) {
            suger.push_back(c*i+d*j);
        }
    }
    sort(water.begin(), water.end());
    sort(suger.begin(), suger.end());
    double maxi = -1.0;
    int ans0 = 0, ans1 = 0;
    for (int a : water) {
        for (int b : suger) {
            if (a+b > f) {
                break;
            }
            if ((double)b*100/a > e) {
                continue;
            }
            double buf = (double)b/(a+b);
            if (buf > maxi) {
                maxi = buf;
                ans0 = a+b, ans1 = b;
            }
        }
    }
    cout << ans0 << " " << ans1 << endl;
    return 0;
}


Measured memory_bytes: 34412
#include "iostream"
#include "map"
#include "vector"
#include "algorithm"
#define MAX 200005

typedef long long llint;

using namespace std;

int n;
int a[MAX];
int cnt = 0;
llint cumsum[MAX];
llint cumxor[MAX];

int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }


    cumsum[0] = a[0];
    cumxor[0] = a[0];

    for (int i = 1; i < n; i++) {
        cumsum[i] = cumsum[i - 1] + a[i];
        cumxor[i] = cumxor[i - 1] ^ a[i];
    }

    int r = 0;
    llint ans = 0;
    for (int l = 0; l < n; l++) {
        while (r < n) {
            if ((cumsum[r] - (l == 0 ? 0: cumsum[l - 1])) != (cumxor[r] ^ (l == 0 ? 0: cumxor[l - 1]))) {
                r--;
                break;
            }
            r++;
        }
        if (r == n) {
            r = n - 1;
        } else if (r < l) {
            r = l;
        }

        // cout << l << ":" << r << endl;
        ans += r - l + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4096
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
typedef long long int ll;

int main()
{
	int N, dp[1000000] = {};
	cin >> N;
	vector<int>h(N);
	for (int i = 0; i < N; i++)cin >> h[i];
	dp[1] = abs(h[1] - h[0]);
	for (int i = 0; i < N; i++)
	{
		if (i > 1)dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[N - 1];
}

Measured memory_bytes: 4480
a, b, c, d= [int(i) for i in input().strip().split(' ')]
if c>=b or d<=a:
  print(0)
elif c>=a and c<=b:
  if d<=b:
    print(d-c)
  else:
    print(b-c)
elif d>=a:
  if d<=b:
    print(d-a)
  else:
      print(b-a)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char const* argv[])
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if(abs(a - c) <= d) {
        cout << "Yes" << endl;
        return 0;
    }

    if(abs(a - b) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int A, P;
	cin >> A >> P;

	int total = A * 3 + P;

	int ans = total / 2;


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;      
int main() {
ll n;
cin>>n;
ll f=0;
ll counter=0;
ll a[n]={};
ll b[n]={};
for(ll i=0; i<n; i++){
cin>>a[i];
b[i]=a[i];}
sort(a,a+n);
ll c[n]={};
for(ll i=0; i<n; i++){
 ll key = b[i];
    auto iter = lower_bound(a, a+n, key);
    if (*iter == key) {
        c[i]=distance(a, iter);}
    }
   
for(ll i=0; i<n; i++){
if(c[i]%2==i%2){
continue;}
else{
counter++;}}
counter/=2;
cout<<counter<<endl;}


Measured memory_bytes: 2560
def main():
    n, *a, = map(int, open(0).read().split())
    a = [x - i for i, x in enumerate(a, 1)]
    a.sort()
    if n % 2 == 0:
        ans = sum(a[n // 2:]) - sum(a[:n // 2])
    else:
        ans = sum(a[n // 2 + 1:]) - sum(a[:n // 2])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25180
#include <cstdio>

int main() {
  int N;
  char S[256], T[256];
  scanf("%d", &N)+1;
  scanf("%s%s", S, T)+1;
  
  for (int i = 0; i < N; i++) {
    printf("%c%c", S[i], T[i]);
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <vector>

// constexpr std::int64_t INF = 1ull << 50;
constexpr int INF = 1 << 20;

auto main() -> int {
  std::string S;
  std::cin >> S;

  const auto L = S.length();

  int ans = INF;
  for (auto i = 0u; i < (L - 2); ++i) {
    const auto X = std::stoi(S.substr(i, 3));
    ans = std::min(std::abs(X - 753), ans);
  }
  std::cout << ans << std::endl;
}


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

int n, m;
int w[110][110];
int p[60][60];
int tmp[60][60];
int ans_x, ans_y;

void rotate() {
    for (int i=0; i<m; i++) {
        for (int j=0; j<m; j++) {
            tmp[j][m-1-i] = p[i][j];
        }
    }
    
    for (int i=0; i<m; i++) {
        for (int j=0; j<m; j++) {
            p[i][j] = tmp[i][j];
        }
    }
}

void check() {
    for (int i=0; i<=n-m; i++) {
        for (int j=0; j<=n-m; j++) {
            bool flag = true;
            
            for (int k=0; k<m; k++) {
                for (int l=0; l<m; l++) {
                    if (p[k][l]==-1) {
                        continue;
                    }
                    
                    if (p[k][l]!=w[i+k][j+l]) {
                        flag = false;
                    }
                }
            }
            
            if (flag) {
                for (int k=0; k<m; k++) {
                    for (int l=0; l<m; l++) {
                        if (p[k][l]!=-1) {
                            if (ans_x>i+k) {
                                ans_x = i+k, ans_y = j+l;
                            }
                            else if (ans_x==i+k && ans_y>j+l) {
                                ans_y = j+l;
                            }
                        }
                    }
                }
            }
        }
    }
}

int main() {
    while (true) {
        cin >> n >> m;
        
        if (n==0 && m==0) {
            break;
        }
        
        for (int i=0; i<n; i++) for (int j=0; j<n; j++) cin >> w[i][j];
        for (int i=0; i<m; i++) for (int j=0; j<m; j++) cin >> p[i][j];
        
        ans_x = 1000, ans_y = 1000;
        
        for (int i=0; i<4; i++) {
            check();
            rotate();
        }
        
        if (ans_x==1000) {
            cout << "NA" << endl;
        }
        else {
            cout << ans_y+1 << " " << ans_x+1 << endl;
        }
    }
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int mxN = 1e5 + 6;
vector<Pll> adj[mxN];
vector<ll> dis;

void dfs(int i = 0){
    for(auto e : adj[i]) {
        ll u = e.first;
        ll v = e.second;
        if(dis[u] == 1e18) {
            dis[u] = dis[i] + v;
            dfs(u);
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    dis.assign(n, 1e18);
    rep(i, n-1) {
        ll u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        adj[u].push_back(Pll(v, w));
        adj[v].push_back(Pll(u, w));
    }
    dis[0] = 0;
    dfs();
    rep(i, n) {
        if(dis[i] & 1) cout << 1 << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 12956
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
long long GCD(long long a,long long b){
    if(b==0)return a;
    return GCD(b,a%b);
}
long long LCM(long long a,long long b){
    return a*b/GCD(a,b);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    V vec(n+1);
    rep3(i,1,n+1)cin>>vec[i];
    V dp(n+10,1e18);
    dp[1]=0;
    dp[2]=abs(vec[2]-vec[1]);
    rep3(i,3,n+1){
        dp[i]=min(dp[i-1]+abs(vec[i]-vec[i-1]),dp[i-2]+abs(vec[i-2]-vec[i]));
    }
    cout<<dp[n]<<endl;
}


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

int main() {
	int h, w;

	std::cin >> h >> w;

	std::string s;

	for (int i = 0; i < h; i++)
	{
		std::cin >> s;

		std::cout << s << "\n" << s << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main() {
	int a = 0;
	int b = 0;
	int c = 0;
	int stock = 0;
	int time = 0;
	std::cin >> a >> b >> c;
	for (int i = 0; i < 10000;i++) {
		if (a>stock) {
			time += c;
			stock += b;
			
		}
		else {
			break;
		}
	}
	std::cout << time;
}

Measured memory_bytes: 3108
#include<stdio.h>

int main(){
  int i;
  int W,H,N,sum=0;
  int x,y,dx,dy,px,py;
  scanf("%d %d %d",&W,&H,&N);
  scanf("%d %d",&x,&y);

  for(i=0;i<N-1;i++){
    scanf("%d %d",&px,&py);
    dx=px-x;
    dy=py-y;
    if(0<=dx&&0<=dy){
      if(dx>dy){
	sum=sum+dx;
      }else{
	sum=sum+dy;
      }
    }else if(dx<=0&&0<=dy){
      dx=-dx;
      sum=sum+dx+dy;
    }else if(dx<=0&&dy<=0){
      dx=-dx;
      dy=-dy;
      if(dx>dy){
	sum=sum+dx;
      }else{
	sum=sum+dy;
      }
    }else if(0<=dx&&dy<=0){
      dy=-dy;
      sum=sum+dx+dy;
    }
    x=px;
    y=py;
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map(String::toInt)      // 1≤ai≤4800

    /** 400ごとなのでwhen不要
     * @return 0-8 */
    fun color(score: Int): Int {
        // 3600を超えた場合でも8
        return listOf(score / 400, 8).min()!!
    }

    val colors = a.map(::color)
    val counts = (0..8).map { colors.count { color -> it == color }  }
    val count = (0..7).count { counts[it] != 0 }
    val highScores = counts[8]
    // 全員3200以上ならcountは0だが、minは1
    val min = listOf(1, count).max()!!
    val max = count + highScores    //「好きな色」は8色以外の色も選べる?// listOf(8, count + highScores).min()!!

    print(min)
    print(" ")
    println(max)
}


Measured memory_bytes: 37812
a11,a12,a13 = map(int,input().split())
a21,a22,a23 = map(int,input().split())
a31,a32,a33 = map(int,input().split())
n = int(input())
b = [int(input()) for i in range(n)]
a = [a11,a12,a13,a21,a22,a23,a31,a32,a33]
A = []
a.sort()


for i in b:
    if i in a:
        A.append(i)
    else:
        pass
    
if a11 in A and a12 in A and a13 in A:
    print('Yes')
elif a21 in A and a22 in A and a23 in A:
    print('Yes')
elif a31 in A and a32 in A and a33 in A:
    print('Yes')
elif a11 in A and a21 in A and a31 in A:
    print('Yes')
elif a12 in A and a22 in A and a32 in A:
    print('Yes')
elif a13 in A and a23 in A and a33 in A:
    print('Yes')
elif a11 in A and a22 in A and a33 in A:
    print('Yes')
elif a13 in A and a22 in A and a31 in A:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<stdlib.h>
#include<iostream>
#include<cstdio>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<map>
#include<string.h>
#include<random>
#include<queue>
#define int long long
#define P pair<int,int>
using namespace std;

//同じ場所にいるときはぶつかったことにする
P a[100000];//最初
P l[100000];//最後
int b, c, d;
int K(int x, int y) {//時計回り　反時計回り 何回ぶつかるか
	if (x > y)y += c;
	if (2 * d <= y - x)return 0;
	int e = d * 2;
	e -= y - x;
	int f = e / c + 1;
	if (e%c == 0)f--;
	return f;
}
signed main() {
	cin >> b >> c >> d;
	for (int e = 0; e < b; e++) {
		int f, g; scanf("%lld%lld", &f, &g);
		a[e] = { f,g };
		if (g == 1) {
			l[e] = { (f + d) % c,g };
		}
		else {
			l[e] = { (f - d) % c,g };
			if (l[e].first < 0)l[e].first += c;
		}
	}
	int sum = 0;
	for (int i = 1; i < b; i++) {
		if (a[0].second == 1 && a[i].second == 2) {
			sum += K(a[0].first, a[i].first);
		}
		else if (a[0].second == 2 && a[i].second == 1) {
			sum -= K(a[i].first, a[0].first);
		}
	}
	if (a[0].second == 1) {
		sum %= b;
	}
	else {
		sum %= b;
		if (sum < 0)sum += b;
	}
	//sumは0がつけているゼッケンの番号
	P S = l[0];
	sort(l, l + b);
	for (int i = 0; i < b; i++) {
		if (l[i] == S) {
			for (int j = 0; j < b; j++) {
				cout << l[(i+j + b - sum) % b].first << endl;
			}
		}
	}
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  //direction arrays
  int dx[8]={0,0,-1,+1,+1,-1,+1,-1};
  int dy[8]={+1,-1,0,0,+1,-1,-1,+1};
  
  int32_t main()
  { 
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
    
    IOS
    string s;
    cin>>s;
    if(s=="ABC")
      cout<<"ARC";
    else
      cout<<"ABC";
   
    return 0;
  }
    

Measured memory_bytes: 3636