akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

ll dp[41][501][501];

const int inf = 1e9+7;

signed main() {
  ios::sync_with_stdio(false);
  ll n, A, B;
  cin >> n >> A >> B;
  REP(i, 41) {
    REP(j, 501) {
      REP(k, 501) {
        dp[i][j][k] = inf;
      }
  }
  }
  
  dp[0][0][0] = 0;
  REP(k, n) {
    int a,b,c;
    cin >> a >> b >> c;
    REP(i, 400) {
      REP(j, 400) {
        dp[k+1][i][j] = min(dp[k+1][i][j], dp[k][i][j]);
        dp[k+1][i+a][j+b] = min(dp[k+1][i+a][j+b], dp[k][i][j] + c);
      }
    }
  }
  ll ans = inf;
  int i = 1;
  while(i*max(A, B) < 401) {
      ans = min(ans, dp[n][i*A][i*B]);
      i++;
  }
  // REP(i, 5) {
  //   REP(j, 10) {
  //     REP(k, 10) {
  //       cout << dp[i][j][k] << " ";
  //     }
  //     cout << endl;
  //   }
  //   cout << "--------------" << endl;
  // }

  if(ans != inf) {
    cout << ans << endl;
  }
  else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 80768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

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

ll sub(ll a, ll b) {
	return ((a - b) + mod) % mod;
}

void solve() {
	int n; cin >> n;
	vector<ll> v(n);
	for (ll &i : v)cin >> i;
	ll sum = accumulate(v.begin(), v.end(), 0ll) % mod;
	sum = sum * sum % mod;
	for (ll i : v)sum = sub(sum, i * i % mod);
	cout << sum*power(2, mod - 2) % mod;

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();

}

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

int main() {
    vector<int> vec(3);
    rep(i, 3) cin >> vec[i];
    sort(vec.begin(), vec.end());
    cout << vec[0] + vec[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int x, y, s;
	while(cin >> x >> y >> s, x){
		int res = 0;
		for(int i=1;i<s;i++){
			for(int j=1;j<s;j++){
				if(i*(100+x)/100 + j*(100+x)/100 == s){
					res = max(res, i*(100+y)/100 + j*(100+y)/100);
				}
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;



int main(){
	int q;
	cin>>q;
	priority_queue<ll,vector<ll>,greater<ll>> que1;
	priority_queue<ll> que2;
	ll sum1=0,sum2=0;
	ll sum=0;
	rep(i,q){
		int t;
		cin>>t;
		if(t==2){
			ll x=que2.top();
			cout<<x<<" ";
			cout<<sum+(sum1-x*(ll)que1.size())+(x*(ll)que2.size()-sum2)<<endl;
		}
		else {
			ll x,y;
			cin>>x>>y;
			sum+=y;
			if(que2.empty()||x<=que2.top()){
				que2.push(x);
				sum2+=x;
				if(que2.size()>que1.size()+1){
					x=que2.top();que2.pop();
					que1.push(x);
					sum2-=x;
					sum1+=x;
				}
			}
			else {
				que1.push(x);
				sum1+=x;
				if(que1.size()>que2.size()){
					x=que1.top();que1.pop();
					que2.push(x);
					sum2+=x;
					sum1-=x;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3828
#include <cstdio>
#include <algorithm>
#include <limits>
#include <cstring>
#define maxn 2000+10
#define P pair <int,int >
#define _1 first
#define _2 second

using namespace std;
#define INF numeric_limits<int >::max()
char A[maxn],B[maxn];
int t1,n,cnt,g,l[maxn],r[maxn],ans,pos,top;
P st[maxn];

int cal()
{
	if (!top) return 0;
	sort(st+1,st+1+top);
	int X=st[top]._1,Y=0,tmp=X+Y;
	for (int i=top;i;--i)
	{
		X=st[i-1]._1;
		Y=max(Y,st[i]._2);
		tmp=min(tmp,X+Y);
	}
	return tmp;
}

int solve(char * A,char *B)
{
	for (int i=0;i<n;++i)
	  {
	  	 for (r[i]=0;B[(i+r[i])%n]!='1';++r[i]);
	  	 for (l[i]=0;B[(i-l[i]+n)%n]!='1';++l[i]);
	  }
	int tmp=INF;
	for (int d=0;d<n;++d)
	{
		int count=0;
		top=0;
		for (int i=0;i<n;++i)
		  if (A[i]!=B[(i+d)%n])
		  {
		  	++count;
		  	if (r[i]>d) st[++top]=(P){l[i],r[i]-d};
		  }
		tmp=min(tmp,2*cal()+d+count);
	}
	return tmp;
}

signed main()
{
	scanf("%s%s",A,B);
	n=strlen(A);
	for (int i=0;i<n;++i) cnt+=B[i]=='1',t1+=A[i]=='1';
	if (cnt==0)
	{
		t1==0?printf("0\n"):printf("-1\n");
		return 0;
	}
	ans=solve(A,B);
	reverse(A,A+n);
	reverse(B,B+n);
	ans=min(ans,solve(A,B));
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;

ll dp[100];

int main(int argc, char* argv[])
{
  ll N;
  std::cin >> N;

  dp[0] = 2;
  dp[1] = 1;
  for (int i = 2; i <= N; i++) {
    dp[i] = dp[i-1] + dp[i-2];
  }

  std::cout << dp[N] << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = "";
    if (a + b == 15) {
      s = "+";
    } else if (a * b == 15) {
      s = "*";
    } else {
      s = "x";
    }
    System.out.println(s);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> h(2*n+3, INF);
    rep(i, n) cin >> h[i];
    vector<ll> dp(2*n+3, INF);
    dp[0] = 0;
    rep(i, n){
        rep(j, k+1){
            if (j==0) continue;
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
int MOD = 1e9+7;
using namespace std;


int inf = 1e9 + 5;
 
int main()
{
	int n; cin>>n;
	int k;cin>>k;
	vector<int> height(n);
	for(int i=0; i<n; i++)
	{
		cin>>height[i];
	}

	vector<int> dp(n,inf);dp[0] = 0;
	for(int i=0; i<n; i++)
		for(int j=1; j<=k; j++)
		{
			if(i+j < n)
			dp[i+j]= min(dp[i]+abs(height[i]-height[i+j]),dp[i+j]);
			
		}
		cout<<dp[n-1];



    
    return 0;
    
}    


	





Measured memory_bytes: 1024
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 600000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000 大きいとワ―シャルフロイドでオーバーフローを起こす
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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



int main(void) {

	while (1) {
		int M, T, P, R;

		cin >> M >> T >> P >> R;
		if (M == 0) {
			break;
		}
		int pena[51][11] = {};// ペナルティ回数　iチームのj問題に対する回数
		int ans[51] = {};//正答数
		int time[51] = {};//時間
		int m, t, p, j;

		FOR(i, 1, R) {
			cin >> m >> t >> p >> j;
			if (j == 0) {
				ans[t]++;
				time[t] += m + (pena[t][p] * 20);
			}
			else {
				pena[t][p]++;
			}
		}

		vector< pair< pair<int, int>, int> > pa(T);
		FOR(i, 0, T-1) {
			pa[i].first.first = -ans[i + 1];
			pa[i].first.second = time[i + 1];
			pa[i].second = -(i + 1);
		}

		sort(pa.begin(), pa.end());

		int nowa, nowt;

		FOR(i, 0, T-1) {
			if (i == 0) {
				nowa = pa[i].first.first;
				nowt = pa[i].first.second;
				cout << -pa[i].second;
			}
			else {
				if (pa[i].first.first == nowa && pa[i].first.second == nowt) {
					cout << "=" << -pa[i].second;
				}
				else {
					cout << "," << -pa[i].second;
					nowa = pa[i].first.first;
					nowt = pa[i].first.second;
				}
			}
		}
		cout << endl;
		
	}

	return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>
int main(void){
    int n,k;
    int a[100001]={0};
    int i,j;
    int sum;
    int mem=0;
    while(1){
        for(i=0;i<10000;i++){
            a[i]=0;
        }
        scanf("%d%d",&n,&k);
        if(n==0&&k==0){
            break;
        }
        mem=0;
        for(i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        sum=0;
        for(i=0;i<n;i++){
            if(i<k){
                sum=sum+a[i];
            }
            else if(i>=k){
                sum=sum+a[i];
                sum=sum-a[i-k];
            }
            if(i==k-1){
                mem=sum;
            }
            if(i>=k-1){
                if(mem<sum){
                    mem=sum;
                }
            }
        }
        printf("%d\n",mem);
    }
    return 0;
}

Measured memory_bytes: 3032
#include <stdio.h>
#include <string.h>
#define max(a, b) a>b?a:b
#define min(a, b) a<b?a:b
#define num(a, b) a=='\0'?b:a

char d1[101], d2[101], ans[102];

void add();
void rev();

int main(void)
{
    int i, j, len1, len2, n;
    for (scanf("%d", &n); n > 0; n--) {
        memset(d1, 0, sizeof(char) * 101);
        memset(d2, 0, sizeof(char) * 101);
        memset(ans, 0, sizeof(char) * 102);
        scanf("%s %s", d1, d2);
        len1 = strlen(d1);
        len2 = strlen(d2);
        rev(d1);
        rev(d2);
        add(d1, d2);
        len1 = strlen(ans);
        if (len1 <= 80) {
            for (i = len1-1; i >= 0; i--) {
                printf("%c", ans[i]);
            }
            puts("");
        } else {
            puts("overflow");
        }
    }
    return 0;
}

void add(a, b)
char *a, *b;
{
    int i, j, x, n;
    n = min(strlen(a), strlen(b));
    x = max(strlen(a), strlen(b));
    for (i = 0; i < n; i++) {
        ans[i] += a[i] + b[i] - '0';
        ans[i+1] += (ans[i] - '0') / 10;
        ans[i] = ((ans[i] - '0') % 10) + '0';
    }
    for (; i < x; i++) {
        ans[i] += num(a[i], b[i]);
        ans[i+1] += (ans[i] - '0') / 10;
        ans[i] = ((ans[i] - '0') % 10) + '0';
    }
    if (ans[x]) {
        ans[x] += '0';
    }
}

void rev(a)
char *a;
{
    int i, len;
    char tmp;
    len = strlen(a);
    for (i = 0; i < len/2; i++) {
        tmp = a[i];
        a[i] = a[len-1-i];
        a[len-1-i] = tmp;
    }
}

Measured memory_bytes: 584
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result % (10 ** 9 + 7)
ab = input().split()
a, b = int(ab[0]), int(ab[1])
sum = a + b
if a>(2*b) or b>(2*a):
	print("0")
elif sum % 3 == 0:
    n = int(sum / 3)
    m = b - n
    print(cmb(n, m))
else:
	print("0")

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

int main() {
  int n;
  double ans=0;
  cin>>n;
  vector<double> x(n);
  vector<string> u(n);
  for(int i=0;i<n;i++){
    cin>>x.at(i);
    cin>>u.at(i); 
    if(u.at(i)=="BTC"){
      ans+=x.at(i)*380000;
    }
    else{
      ans+=x.at(i);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
ll n;
  cin>>n;
  if(n%2==1){
    cout<<0<<endl;
    return 0;}
  
  ll t=n;
  t/=2;
  ll cnt=0;
  
  while(t>=1){
    t/=5;
  cnt+=t;}
  
  cout<<cnt<<endl;
  
  
  

}


Measured memory_bytes: 256
#include  <stdio.h>

int main(void)
{
   int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a+b+c >= 22)
    {
        printf("bust\n");
    }

    else printf("win\n");
    
    return 0;
}

Measured memory_bytes: 1648
#include <string.h>
#include <stdio.h>
int main(void)
{
	char s[200];
	int len;

	while(scanf("%[^\n]%*c",s) != EOF){
		len = strlen(s);
		for(int i = 0; i < len; i++){
			if(s[i] == '@'){
				for(int j = 0; j < s[i + 1] - '0'; j++){
					printf("%c",s[i + 2]);
				}
				i += 2;
			}else{
				printf("%c",s[i]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 932
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
static const int giga = pow(10,9);

int main(void){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  char& a = s1.back();
  char& b = s2.front();
  char& c = s2.back();
  char& d = s3.front();
  if(a == b && c == d){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int n,m,rem[200007],u,v,col[200007],cnt[2][200007];
vector <int> edge[200007];
string s;
queue <int> q;
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>m;
	cin>>s;
	for(int i=1;i<=n;i++) col[i]=s[i-1]-'A';
	for(int i=1;i<=m;i++){
		cin>>u>>v;
		edge[u].pb(v);
		edge[v].pb(u);
	}
	for(int i=1;i<=n;i++){
		for(int v:edge[i]) cnt[col[v]][i]++;
		//cout<<cnt[0][i]<<" "<<cnt[1][i]<<endl;
		if(cnt[0][i]==0 || cnt[1][i]==0) rem[i]=1, q.push(i);
	}
	while(!q.empty()){
		int u=q.front();
		//cout<<u<<endl;
		q.pop();
		for(int v:edge[u]){
			if(rem[v]==1) continue;
			cnt[col[u]][v]--;
			if(cnt[col[u]][v]==0) rem[v]=1, q.push(v);
		}
	}
	for(int i=1;i<=n;i++){
		if(rem[i]==0) return cout<<"Yes", 0;
	}
	cout<<"No";
}


Measured memory_bytes: 13904
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
        for (int i=0; i<n; i++) d[i] = sc.nextInt();
        int count = 0;
        for (int i=0; i<n; i++) {
            for (int j=i+1; j<n; j++) {
                count += d[i] * d[j];
            }
        }
        System.out.print(count);
    }
}

Measured memory_bytes: 35868
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
	string s;
    cin>>s;
    string target="keyence";
    if(s==target){
        cout<<"YES\n";
        return;
    }
    int n=s.size();
    rep(i,n){//iは取り除く区間の始点、jは終点
        for(int j=i;j<n;++j){
            string str="";
            rep(k,i){
                str.pb(s[k]);
            }
            for(int k=j+1;k<n;++k)str.pb(s[k]);
            if(str==target){
                cout<<"YES\n";
                return;
            }
        }
    }
    cout<<"NO\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

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

int main() {

int N;
int d=0;
int n=0;

    cin>>N;
    vector<int> vec(N);
    for (int i = 0; i <N; i++) {
    cin>>vec.at(i);
   }

  sort(vec.begin(), vec.end());
/*
  for(int i=0; i<N; i++){
  cout<<vec.at(i);
  }
cout<<endl;
*/

for(int i=0; i<N; i++){
   if(vec.at(i)>d){
   n+=1;
   d=vec.at(i);
   }
}//for

cout<<n<<endl;

}//main;p

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

using namespace std;

int main() {
    string s;
    cin >> s;
    bool y = false, m = false;
    if(s[2] == '0') {
        if(s[3] != '0') y = true;
    } else if(s[2] == '1') {
        if(s[3] == '0' || s[3] == '1' || s[3] == '2') y = true;
    }
    if(s[0] == '0') {
        if(s[1] != '0') m = true;
    } else if(s[0] == '1') {
        if(s[1] == '0' || s[1] == '1' || s[1] == '2') m = true;
    }
 
    if(m == true && y == true) cout << "AMBIGUOUS" << endl;
    else if(m == true && y == false) cout << "MMYY" << endl;
    else if(m == false && y == true) cout << "YYMM" << endl;
    else cout << "NA" << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N,A[112345];

int main() {

	scanf("%d", &N);
	rep(i, N) scanf("%d", &A[i]);

	vector<pair<int, int>> s;
	rep(i, N) s.push_back({ A[i], i });

	sort(all(s));

	rep(i,N)
	printf("%d ", s[i].second+1);

	return 0;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <math.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define str string
#define deb_arr(arr,n) for(ll i=0;i<(n);i++){ cout << (arr)[i] << " ";}
#define in_arr0(arr,n) for(ll i=0;i<(n);i++){ cin >> (arr)[i]; }
#define in_arr1(arr,n) for(ll i=1;i<=(n);i++){ cin >> (arr)[i];}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define vll vector<ll> 
#define fr(n) for(i=0;i<(n);i++)
#define fr1(n) for(i=1;i<=(n);i++)
#define pll pair<ll,ll>
#define f first
#define s second
#define vpll vector<pll>
#define ump unordered_map
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define IN(a,b) ((a).find(b)!=(a).end())
#define pb push_back
#define mkp make_pair
#define PI M_PI
#define INF 1e18
#define deb(x) if(ON) cout << #x <<" : " << x << endl
#define fast ios_base::sync_with_stdio(false)
#define io cin.tie(NULL),cout.tie(NULL)
#define ON !false
ll dx[]={0,-1,0,1};
ll dy[]={1,0,-1,0};
const ll mod=1e9+7;
inline ll add(ll a,ll b){
    return  ((a%mod)+(b%mod)+mod)%mod;
}
inline ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)+mod)%mod;
}
void pause(ll id){
    cout << "Waiting " << id << endl;
    cin >> id;
}

const int mxn=1e5+10;


void init(){

    return ;
}


signed main(){
    fast;
    io;
    if(!true){
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    }
    init();
    ll i,j;
    str s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
   
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,k;
    cin>>a>>b>>k;
    if((b-a+1)<=2*k){
        for(int i=0;i<b-a+1;i++){
            cout<<a+i<<endl;
        }
    }
    else{
        for(int i=0;i<k;i++){
            cout<<a+i<<endl;
        }
        for(int i=0;i<k;i++){
            cout<<b-k+1+i<<endl;
        }
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,ans=0,i=0;
int main(){
    cin>>a;
    int b[a];
    for(int i=0;i<a;i++) cin>>b[i];
    while(1){
        i=b[i]-1;
        ans++;
        if(i==1) break;
        if(ans>=a){cout<<"-1"; return 0;}
    }
    cout<<ans<<endl;
}


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

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = Integer.parseInt(sc.next());
		int H = Integer.parseInt(sc.next());
		int[] spcs = new int[N];
		int maxAtk = 0;
		for (int i = 0; i < N; i++) {
			maxAtk = Math.max(maxAtk, Integer.parseInt(sc.next()));
			spcs[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(spcs);
		long sum = 0;
		int count = 0;
		for (int i = N - 1; i >= 0; i--) {
			if (sum >= H) break;
			if (spcs[i] <= maxAtk) break;

			sum += spcs[i];
			count += 1;
		}
		System.out.println(count + -Math.floorDiv(-Math.max(H - sum, 0), maxAtk));
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 51316
#-*-coding:utf-8-*-
import numpy as np
 
def main():
    n = int(input())
    ashiba=np.array((input().split()),int)
    dp=np.zeros(n,dtype=int)
    k=2
    for i in range(1,n):
        start=max(0,i-k)
        dp[i]=min(dp[start:i]+abs(ashiba[i]-ashiba[start:i]))
    print(dp[n-1])
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 21952
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
// fold was added in D 2.071.0.
template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
        static if (S.length < 2) {
            return reduce!fun(seed, r);
        } else {
            return reduce!fun(tuple(seed), r);
        }
    }
}

void main() {
    int H, W;
    readf("%d %d\n", &H, &W);
    H.times!(() => readln.chomp.repeat.take(2).each!writeln);
}


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

typedef long long ll;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define LL(n) ll n;assert(0<scanf("%lld",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); INT(q);
  vector<vector<int>> gr(n + 1);
  vector<int> visited(n + 1, 0);
  vector<ll> ctr(n + 1, 0);
  REP(n - 1){INT(a); INT(b); gr[a].PB(b); gr[b].PB(a);}
  REP(q){INT(p); LL(x); ctr[p] += x;}
  queue<int> que;
  que.push(1);
  while(!que.empty()){
    int p = que.front(); que.pop();
    visited[p] = 1;
    for(int c: gr[p]){
      if (visited[c] == 0){
        ctr[c] += ctr[p];
        que.push(c);
      }
    }
  }
  REP(i, 1, n + 1){
    printf("%lld", ctr[i]);
    if (i == n){
      printf("\n");
    } else {
      printf(" ");
    }
  }
  return 0;
}

Measured memory_bytes: 17140
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll X;cin>>X;ll N;cin>>N;
    vector<bool> P(101);REPS(i,100)P[i]=true;
    REP(i,N){
        int p;cin>>p;
        P[p]=false;
    }
    ll idx,ans;
    if(101-X>=X-0){
        idx=0;
        ans=X;
    }else{
        idx=101;
        ans=101-X;
    }
    REPS(i,100){
        if(!P[i])continue;
        if(ans>abs(i-X) or (i<idx and ans==abs(i-X))){
            idx=i;
            ans=abs(i-X);
        }
    }
    cout<<idx<<"\n";
}

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

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int n;
    int k;
    cin >> n >> k;
    int ans = 0;
    int x;
    for (int i = 0; i < n; i++) {
        cin >> x;
        ans += std::min(x, k - x);
    }
    cout << ans * 2 << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;

typedef pair<string,int> p;

int main()
{
    string s;
    vector<p> a(3);
    a[0]=p("Sunny",1);
    a[1]=p("Cloudy",2);
    a[2]=p("Rainy",0);

    cin>>s;
    int index=-1;
    rep(i,3)
    {
        if(s==a[i].first)
        {
            index=a[i].second;
        }
    }
    cout<<a[index].first<<endl;

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

int div(int n)
{
   int div=0;
   for(int i=1;i<=sqrt(n+1);i++)
   {
      if(n%i==0)
      {
         if(i*i==n)
            div++;
         else
            div+=2;
      }
   }
   return div;
}

void f()
{
  int n;
  cin>>n;
  if(n<105)
    cout<<0<<nl;
  else
  {
    int cnt=0;
    for(int i=105;i<=n;i+=2)
    {
      if(div(i)==8)
        cnt++;
    }
    cout<<cnt<<nl;
  }
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b,c,s;
    cin>>a>>b;c=b;b=1;s=c-1;
    for(int i=1;;++i)
    {
        if(a<=s) {cout<<i;return 0;}
        b=b*c;s+=b*(c-1);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
int n,a,b;
ld dp[150000],dp2[150000],ch[150000],par[150000];
vector<int> v[150000],u;
void dfs(int a){
    ld tmp=0.0;
    for(int x:v[a]){
        if(ch[x]!=0)continue;
        ch[x]=1;
        par[x]=a;
        dfs(x);
        tmp+=dp[x]+1.0;
    }
    if(a==0)dp[a]=tmp/(ld)v[a].size();
    else if(v[a].size()>1)dp[a]=tmp/ld(v[a].size()-1.0);
    else u.push_back(a);
    return ;
}
void dfs2(int a){
    if(dp2[a]>0)return ;
    if(a==0)return ;
    if(dp2[(int)par[a]]==0)dfs2(par[a]);
    int b=par[a];
    ld p=v[b].size();
    //cout<<"P"<<p<<" "<<b<<endl;
    if(p==1)dp2[a]=1;
    else if(b==0)dp2[a]=((dp[b]+1)*p-(dp[a]+2))/(p-1);
    else if(p>1)dp2[a]=((dp2[b]+1)+(dp[b]+1)*(p-1)-(dp[a]+2))/(p-1);
    //cout<<a<<" "<<dp2[a]<<endl;
    //cout<<a<<" "<<dp2[a]<<"W"<<endl;
    return ;
}
int main(void){
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<n;i++)ch[i]=0;
    ch[0]=1;
    par[0]=-1;
    dfs(0);
    //cout<<"W"<<endl;
  	//for(int i=0;i<n;i++)dp2[i]=0;
    for(auto x:u){
        dfs2(x);
    }
    for(int i=0;i<n;i++){
        //cout<<dp[i]<<" "<<dp2[i]<<endl;
        if(i==0)cout<<setprecision(15)<<dp[i]<<endl;
        else cout<<setprecision(15)<<(dp[i]*ld(v[i].size()-1)+dp2[i])/(ld)v[i].size()<<endl;
    }
}


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

int main()
{
  int n,k;
  cin >> n >> k;
  vector<long int> a(n);
  rep(i,n) cin >> a[i];
  for(int i=k;i<n;i++){
    if(a[i-k]<a[i])
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 4816
#include <queue>
#include <utility>
#include <cstdio>
using namespace std;

typedef pair<int, int> P;

char map[16][16];

void bfs(int y, int x)
{
	queue<P> q;
	
	q.push(P(y, x));
	while (!q.empty()){
		P p = q.front();
		q.pop();
		
		if (map[p.first][p.second] == '1'){
			q.push(P(p.first - 1, p.second));
			q.push(P(p.first + 1, p.second));
			q.push(P(p.first, p.second - 1));
			q.push(P(p.first, p.second + 1));
		}
		map[p.first][p.second] = 0;
	}
}

int main()
{
	while (scanf("%s", &map[1][1]) != EOF){
		int cnt = 0;
		for (int i = 2; i <= 12; i++) scanf("%s", &map[i][1]);
		for (int i = 1; i <= 12; i++){
			for (int j = 1; j <= 12; j++){
				if (map[i][j] == '1'){
					bfs(i, j);
					cnt++;
				}
			}
		}
		printf("%d\n", cnt);
	}
	
	return 0;
}

Measured memory_bytes: 1028
import sys
sys.setrecursionlimit(1000000) # 再帰上限を増やす

def main():
    input = sys.stdin.readline  # 文字列に対してinputした場合は、rstripするのを忘れずに！
    N = int(input())
    act_list = []
    for _ in range(N):
        a, b, c = map(int, input().split())
        act_list.append((a, b, c))

    # dp[i][j] = i日目までにjを最後に行って得られる最大の幸福度
    dp = [[0] * 3 for _ in range(N)]
    dp[0][0] = act_list[0][0]
    dp[0][1] = act_list[0][1]
    dp[0][2] = act_list[0][2]

    for i in range(1, N):
        for j in range(3):
            dp[i][j] = max(dp[i-1][(j+1) % 3], dp[i-1][(j+2) % 3]) + act_list[i][j]
    print(max(dp[N-1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 69980
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

#define INF (1000000000)

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

int N, K;

void solve_main()
{
	double ans = 0;

	cin >> N >> K;

	REP(dice, 1, N + 1) {
		double tempAns =(double) 1 / N;
		DWORD  now = dice;
		while (now < K) {
			now *= 2;
			tempAns /= 2;
		}
		ans += tempAns;
	}


	printf("%.12lf\n", ans);
}

int main()
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s,p;
	string r;
	int slen, plen;
	getline(cin, s);
	getline(cin, p);
	slen = s.size();
	plen = p.size();
	int i, j;
	bool success;
	for(i = 0; i < slen; i++) {
		success = true;
		for(j = 0; j < plen; j++) {
			if(p[j] != s[(i + j) % slen]) {
				success = false;
				break;
			}
		}
		if(success) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 3176
int main(){
int n,a[100],i,x;
scanf("%d",&n);
for(i=0; i<n; i++){
scanf("%d",&a[i]);
}

for(x=0; x<n; x++){
printf("%d",a[i-x-1]);
if(x<n -1)printf(" ");

}
printf("\n");
return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(){
	int w,n;
	int net[30][2];
	
	int N[30];
	
	int i,j;
	int num;
	
	scanf("%d",&w);
	scanf("%d",&n);
	
	for(i = 0;i < n;i++){
		scanf("%d,%d",&net[i][0],&net[i][1]);
		if(net[i][0] > net[i][1]){
			j = net[i][0];
			net[i][0] = net[i][1];
			net[i][1] = j;
		}
	}
	
	for(i = 1;i <= w;i++){
		num = i;
		for(j = 0;j < n;j++){
			if(net[j][0] == num){
				num = net[j][1];
			}else if(net[j][1] == num){
				num = net[j][0];
			}
		}
		N[num] = i; 
	}
	
	for(i = 1;i <= w;i++){
		printf("%d\n",N[i]);
	}
	
	return 0;
}

Measured memory_bytes: 596
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    k,q=MI()
    dd=LI()
    dd=np.array(dd,dtype="i8")
    for _ in range(q):
        n,x,m=MI()
        cc=dd%m
        zall=np.sum(cc==0)
        zlast=np.sum(cc[:(n-1)%k]==0)
        s=np.sum(cc)*((n-1)//k)
        r=np.sum(cc[:(n-1)%k])
        last=x%m+s+r
        no=last//m
        print(n-1-no-zall*((n-1)//k)-zlast)

main()


Measured memory_bytes: 13184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>

template <class T> inline bool chmin(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template <class T> inline bool chmax(T& a, T b) { if (a > b) { a = b; return true; }return false; }

int main()
{
	int N;
	std::cin >> N;
	int a[20];
	for (int i = 0; i < N; i++) {
		std::cin >> a[i];
	}
	int counter;
	counter = 0;
	for (int i = 2; i < N; i++) {
		std::vector<int> v;
		v.push_back(a[i - 2]);
		v.push_back(a[i - 1]);
		v.push_back(a[i]);
		if ((*std::max_element(v.begin(), v.end()) != a[i - 1]) and (*std::min_element(v.begin(), v.end())!=a[i-1])) {
			counter++;
		}
	}
	std::cout << counter;
	std::cin >>N;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class10
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long pmsum = 0;
            for(int i = 0; i < N; i++)
            {
                if (i % 2 == 0) pmsum += a[i];
                else pmsum -= a[i];
            }
            long[] ans = new long[N];
            ans[0] = pmsum;
            for(int i = 0; i < N-1; i++)
            {
                ans[i+1] = Math.Abs(ans[i] - 2 * a[i]);
            }
            Console.WriteLine(string.Join(" ", ans));
        }
    }
}


Measured memory_bytes: 36144
while 1:
    s = input()
    n, i, j = map(int, s.split())

    if n==0:
        break

    updown = [None for _ in range(n+1)];

    whole = 2**n
    fold = n
    from_top = i
    while 1:
        if whole == 1:
            assert fold == 0
            break

        half = whole // 2
        if from_top <= half:
            updown[fold] = 0
        else:
            updown[fold] = 1
        
        fold -= 1
        whole = half

        if half >= from_top:
            from_top = half - from_top + 1
        else:
            from_top = from_top - half

    whole = 2**n
    from_left = j
    output = ""
    for i in range(1, n+1):
        half = whole // 2

        if from_left <= half:
            is_right = 0
        else:
            is_right = 1

        if (updown[i] + is_right) % 2 == 0:
            output += "L"
            if half >= from_left:
                from_left = half - from_left + 1
            else:
                from_left = from_left - half
        else:
            output += "R"
            if half < from_left:
                from_left = whole - from_left + 1

        whole = half

    print(output)




Measured memory_bytes: 5612
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		boolean not[] = new boolean[100000];
		
		not[0] = true;
		not[1] = true;
		
		for (int i = 2; i * i < 100000; i++)
		{
			if (not[i]) continue;
			for (int x = (i << 1); x < 100000; x += i)
			{
				if (not[x]) continue;
				not[x] = true;
			}
		}
		Scanner sc = new Scanner(System.in);
		
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			for (int i = n; i > 3; i--)
			{
				if (!(not[i] || not[i - 2]))
				{
					System.out.printf("%d %d\n", i-2, i);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 13000
#include<stdio.h>

int main(){
        int n, m;
        scanf("%d %d", &n, &m);

        int able[n], cnt[n];
        for(int i=0; i<n; i++){
                able[i]=0;
                cnt[i]=1;
        }
        able[0] = 1;

        for(int i=0; i<m; i++){
                int x, y;
                scanf("%d %d", &x, &y);
                x--; y--;

                if(able[x]){
                        able[y]=1;
                        if(cnt[x]==1) able[x]=0;
                }
                cnt[x]--;
                cnt[y]++;
        }

        int sm = 0;
        for(int i=0; i<n; i++) sm+=able[i];
        printf("%d\n", sm);
        return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b && b<c && a<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1008
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
        int K = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();

        if(s.Length <= K)
        {
            Console.WriteLine(s);
        }
        else
        {
            Console.WriteLine("{0}...",s.Substring(0,K));
        }
    }
}

Measured memory_bytes: 27484
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    int n;
    cin >> n;
    map<string, int>a;
    Fori(i, 0, n) {
        string s;
        getline(cin >> ws, s);
        a[s]++;
    }
    cout << "AC x " << a["AC"] << endl;
    cout << "WA x " << a["WA"] << endl;    
    cout << "TLE x " << a["TLE"] << endl;    
    cout << "RE x " << a["RE"] << endl;    
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX 1000

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    int N;
    cin >> N;
    string S[N];
    Rep(i,N)cin >> S[i];
    int ans = 0;
    Rep(i,N){
        if(S[i] == "E869120")ans++;
    }
    cout << ans << endl;
    //cin >> N;
}


Measured memory_bytes: 3276
#include <stdio.h>

int main(){
	
int a,b,c,d,e,f;
int sum=0;

scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);

sum=a+b*5+c*10+d*50+e*100+f*500;

if( sum>=1000 ){
	puts("1");
}
else{
	puts("0");

}
return 0;


}

Measured memory_bytes: 584
from math import ceil

n = int(input())

trains = [tuple(map(int, input().split())) for _ in range(n - 1)]

buf = []
for i, (c, s, f) in enumerate(trains):
    t = s + c
    for cj, sj, fj in trains[i + 1: n]:
        if t < sj:
            t = sj
        else:
            t = ceil(t / fj) * fj
        t += cj
    buf.append(t)
buf.append(0)

print('\n'.join(map(str, buf)))


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a := nextInts(n)

	ans := 0
	for i := 1; i < n; i++ {
		if a[i] >= a[i-1] {
			continue
		}
		ans += a[i-1] - a[i]
		a[i] = a[i-1]
	}

	puts(ans)
}


Measured memory_bytes: 5984
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    int n = 0 ; 
    cin >> n ; 
    vector<int> height(n+1), cost(n+1) ;
    for(int i = 1 ; i <= n ; i++)
        cin >> height[i] ;
    cost[1] = 0 , cost[2] = abs(height[2]-height[1]) ;
    for(int i = 3 ; i <= n ; i++)
        cost[i] = min(cost[i-2] + abs(height[i]-height[i-2]) , cost[i-1] + abs(height[i]-height[i-1])) ;
    cout << cost[n] ;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数（ll）
ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

//素因数分解？
vector<pair<ll, int>>factorize(ll n){
  vector<pair<ll, int>> res;
  for(ll i = 2; i * i <= n; ++i){
    if(n % i) continue;
    res.emplace_back(i, 0);
    while(n % i == 0){
      n /= i;
      res.back().second++;
    }
  }
if(n != 1) res.emplace_back(n, 1);
return res;

}



int main() {
    int H, W; cin >> H >> W;
    int count = 0;
    for (int i = 0; i < H; ++i) {
        string S; cin >> S;
        for (int j = 0; j < S.size(); j++) if (S.at(j) == '#') ++count;
    }
    if (count == H + W - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
    int n;
    cin>>n;
    vector<string> s(n);
    rep(i,0,n) cin>>s[i];
    sort(s.begin(),s.end());
    int m;
    cin>>m;
    vector<string> t(m);
    rep(i,0,m) cin>>t[i];
    vector<int> cnt(n);
    rep(i,0,n){
        rep(j,0,n){
            if(s[i]==s[j]) cnt[i]++;
        }
        rep(j,0,m){
            if(s[i]==t[j]) cnt[i]--;
        }
    }
    int maxi=0;
    rep(i,0,n){
        maxi=max(maxi,cnt[i]);
    }
    cout<<maxi;
}

Measured memory_bytes: 764
import java.util.*;

class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int min = 30;
	int count = 0;
	for(int i=0; i<N; i++) {
		int[] A = new int[201];
		A[i] = sc.nextInt();
		int a = A[i];
		while(a % 2 == 0) {
			a /= 2;
			count++;
		}
		if(count<min) {
			min = count;
		}
		count = 0;
	}

	System.out.println(min);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int i = 0; i < (n); i++)

template <class T = int>
T in() { T x; std::cin >> x; return x; }
#define output(e) std::cout << e << '\n'

#ifdef LOCAL
#define db std::cout << "L" << __LINE__
#define de << "\n"
#define dv(x) << " " << #x << "->" << x
#else
#define db
#define de
#define dv(x)
#endif

//
// Implementation
//

int main() {
  int m = in();
  int f = in();
  int b = in();
  if (b - m > f) {
    output("NA");
  } else {
    output(max(b - m, 0));
  }
}



Measured memory_bytes: 3092