akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;
bool cmp(ii &a,ii &b){
    return a.fi-a.se>b.fi-b.se;
}
int main() {
    cs
    vector<ii> ahh;
    int n,tl=0,tr=0;cin>>n;
    vector<string> v(n);
    for(auto &i:v) cin>>i;
    for(auto i:v) {
        int le=i.size(),a=0,b=0,l=0,r=0;
        Repp(j,le-1,0) {
            if(i[j]==')') {
                a++;
            }
            else {
                if(a==0) l++;
                else a--;
            }
        }
        a=0;b=0;
        rep(j,le) {
            if(i[j]=='(') {
                a++;
            }
            else {
                if(a==0) r++;
                else a--;
            }
        }
        if(!l&&!r) continue;
        else if(!l) tr+=r;
        else if(!r) tl+=l;
        else {
            ahh.push_back({l,r});
        }
    }
    sort(ahh.begin(),ahh.end(),cmp);
    for(auto i:ahh) {
        tl-=i.se;
        if(tl<0) bye("No")
        tl+=i.fi;
    }
    if(tl==tr) bye("Yes")
    bye("No")
}

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

#define vi vector<int>

int main() {

    stack<int> si;
    string line;
    int a, b;

    while (cin.good()) {
        cin >> line;
        if (cin.eof()) break;
        if (line == "+") {
            a = si.top();
            si.pop();
            b = si.top();
            si.pop();
            si.push(b + a);
        }
        else if (line == "-") {
            a = si.top();
            si.pop();
            b = si.top();
            si.pop();
            si.push(b - a);
        }
        else if (line == "*") {
            a = si.top();
            si.pop();
            b = si.top();
            si.pop();
            si.push(b * a);
        }
        else {
            si.push(stoi(line));
        }
    }

    cout << si.top() << endl;

    return 0;
}



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

using namespace std;

int n, c;
int distances[30][30];
int colors[500][500];

int distance_table[3][30];

int distance(int r, int c)
{
    int d = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            if((i + j) % 3 == r) {
                d += distances[colors[i][j]][c];
            }
        }
    }

    return d;
}

int func(int c0, int c1, int c2)
{
    int d = 0;

    d += distance_table[0][c0];
    d += distance_table[1][c1];
    d += distance_table[2][c2];

    return d;
}

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

    for(int i = 0; i < c; ++i) {
        for(int j = 0; j < c; ++j) {
            int d;
            cin >> d;
            distances[i][j] = d;
        }
    }

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            int c;
            cin >> c;
            colors[i][j] = c - 1;
        }
    }

    for(int ci = 0; ci < c; ++ci) {
        for(int r = 0; r < 3; ++r) {
            distance_table[r][ci] = distance(r, ci);
        }
    }

    // inf
    int ans = 500 * 500 * 1000;

    for(int c0 = 0; c0 < c; ++c0) {
        for(int c1 = 0; c1 < c; ++c1) {
            for(int c2 = 0; c2 < c; ++c2) {
                if(c0 == c1 || c1 == c2 || c2 == c0) {
                    continue;
                }

                ans = min(ans, func(c0, c1, c2));
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1280
N,M = map(int,input().split())
Lamp = [list(map(lambda x:int(x)-1,input().split()))[1:]
        for _ in range(M)]
p = list(map(int,input().split()))

ans = 0
for i in range(2**N):#スイッチONの全探索
    judge = True
    for l in range(M): #電球点灯チェック
        cnt = 0
        for j in range(N):#スイッチのj番目について
            if (i >> j) & 1 and (j in Lamp[l]):
            #スイッチがONの時 and スイッチと電球がつながっているか
                cnt += 1
        if cnt % 2 != p[l]:#一個でも点灯しなければNG
            judge = False
            break
    if judge:#pの条件を全てクリアするスイッチの状態を追加
        ans += 1

print(ans)




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll,ll> T;


ll i,j,k;


int main(){
  ll N,K;
  cin>>N>>K;
  V A(N);
  rep(i,N)cin>>A[i];
  ll roop=0;
  vector<bool> trip(N,false);
  V nankai(N);
  ll now=0;
  ll kiroku;
  while(true){
      if(trip[now]==false&&roop<K){
          trip[now]=true;
          roop++;
          nankai[now]=roop-1;
          now=A[now]-1;
          

      }
      else{
          kiroku=now;
          break;
      }
  }
  ll ans=0;
  rep(i,roop){
      ans=A[ans]-1;
  }
  ll amari=(K-roop)%(roop-nankai[kiroku]);
  rep(i,amari){
      ans=A[ans]-1;
  }
      
  cout<<ans+1<<endl;

}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vll a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    RSORT(a); RSORT(b); RSORT(c);
    vll abc;
    rep(i, x) rep(j, y) {
        if ((i+1)*(j+1)>k) break;
        rep(h, z) {
            if ((i+1)*(j+1)*(h+1)>k) break;
            abc.pb(a[i]+b[j]+c[h]);
        }
    }
    RSORT(abc);
    rep(i, k) cout << abc[i] << endl;
    return 0;
}


Measured memory_bytes: 1404
N,M,X=map(int,input().split())

# a = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S=[[0 for j in range(M+1)] for i in range(N)]
for i in range (N):
    S[i]=list(map(int,input().split()))


skill=[0]*(M)

ans=10000000




for i in range(2 **N):
    skill=[0]*M
    cost=0
    for j in range(N):
        if ((i >> j) & 1):
            #print(i,j)
            for k in range(1,M+1):
                skill[k-1]+=S[j][k]
                
            cost+=S[j][0]    
            #print(cost)
            #print(skill)
    for j in range(M):
        if skill[j]<X:
            break
        if j==M-1:
            if ans>cost:
                ans=cost
                
    
if ans==10000000:
    print(-1)
else:
    print(ans)
    


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

int main(){
  int N, K;
  int S = 1;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    if(S < K){
      S *= 2;
    }else{
      S += K;
    }
  }
  cout << S << endl;
}

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

int n, A[50];
struct Point { double x,y;};

void koch(int n, Point a, Point b) {
	if (n == 0) return;
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;// 1/3pi

	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;//内分
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;//回転行列
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}

int main(){
	Point a,b;
	int n;

	scanf("%d", &n);

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n", a.x, a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n", b.x, b.y);
	return 0;
}



Measured memory_bytes: 3212
a,b=map(int,input().split())
J=0
if (a==1 and b!=1):
    J=1
elif (b==1 and a!=1):
    J=2
elif a<b:
    J=2
elif a>b:
    J=1
print("Alice" if J==1 else "Bob" if J==2 else "Draw")

Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(len(A)):
        ans += B[A[i] - 1]
        if i == len(A) - 1:
                continue
        else:
                if A[i] + 1 == A[i+1]:
                        ans += C[A[i] - 1]

print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <string>
#include <locale>
using namespace std;

int main(){
	string s;
	getline(cin, s);
	for (int i = 0; i < s.length(); i++){
		printf("%c", toupper(s[i]));
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1168
(function() {
    const str = require('fs').readFileSync('/dev/stdin', 'utf-8').trim().replace(/\n/g, '');
    // const str = 'dreameraser'
    let i = 0;
    while (i < str.length) {
        // console.log(str.slice(i, i+7));
        if(str.substring(i, i+11) == 'dreameraser') {
            i += 11;
        } else if (str.substring(i, i+10) == 'dreamerase') {
            i += 10;
        } else if(str.substring(i, i+7) == 'dreamer') {
            i += 7;
        } else if (str.substring(i, i+6) == 'eraser') {
            i += 6;
        } else if (str.substring(i, i+5) == 'erase' || str.substring(i, i+5) == 'dream') {
            i += 5;
        } else {
            console.log('NO');
            return
        }
    }
    console.log('YES');
})()

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

int main(){
  int N; cin >> N;
  vector<ll> A(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<N;i++){
    ll x; cin >> x;
    A[i] = x - A[i];
  }
  sort(A.begin(),A.end());
  ll minus = 0;
  ll block = 0;
  for(int i=0;i<N;i++){
    if(A[i]<0){
      minus += (-A[i]);
    }else{
      block += (A[i]/2);
    }
  }
  if(minus>block){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

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

using namespace std;
#define lli long long int
#define ff first
#define ss second
#define lld long double
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef pair<int, int> pii;
typedef pair<long long int,long long int> pll;
const int nax=1000*1007;
#define INF 2e18
lli pow(lli x, lli y) { lli res = 1;while (y > 0) { if (y & 1) res = (res * x);  y = y >> 1; x = (x * x); } return res; } 

int find(int rem)
{
    int sq = sqrt(rem);
    int co=0;
    for(int i=1;i<sq;i++)
    {
        if(rem%i==0)
            co++;
    }
    co =2*co;
    if(sq*sq==rem)
        co++;
    else if(rem%sq==0)
        co=co+2;
   // cout<<rem<<" "<<co<<endl;
    return co;
}
int main()
{
	IOS;
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<n;i++)
    {
        int rem = n-i;
        ans = ans + find(rem);
    }
    cout<<ans<<endl;
}

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

int main()
{
	int n=3;
	int *b1, *a;
	scanf("%d", &n);
	
	a = new int[n];
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);

	b1 = new int[n];
	int Head = 0, End = n-1,flag=1;
	for (int i = 0; i < n; i++)
	{
		if (flag)
		{
			b1[Head] = a[i];
			Head++;
			flag = 0;
		}
		else
		{
			b1[End] = a[i];
			End--;
			flag = 1;
		}
	}
	if (flag)
	{
		for (int i = 0; i < n; i++)
			printf("%d ", b1[(Head+ i) % n]);
	}
	else
	{
		for (int i = 0; i < n; i++)
			printf("%d ", b1[(End - i + n) % n]);
	}
	return 0;
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define cpresent(c,x) ((c).find(x) != (c).end()) 
#define vpresent(c,x) (find(all(c),x) != (c).end())
#define endl '\n'
#ifdef LOCAL
#include "/home/iggaboi/Desktop/CP/debug.h"
#else
#define debug(Args...)
#endif
using ll = long long;
using namespace __gnu_pbds;
using namespace std;
template<class T>
using indexed_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

ll n, m, k;

void shit() {
	cin >> n >> m >> k;
    vector<ll> a(n + 1), b(m + 1);
    a[0] = 0, b[0] = 0;
    for(ll i = 1; i <= n; ++i) {
        ll x; cin >> x;
        a[i] = a[i - 1] + x;
    }
    for(ll i = 1; i <= m; ++i) {
        ll x; cin >> x;
        b[i] = b[i - 1] + x;
    }
    ll ans = 0, cnt = m;
    debug(a, b);
    for(ll i = 0; i <= n; ++i) {
        if(a[i] > k) break;
        while(b[cnt] + a[i] > k) --cnt;
        ans = max(ans, i + cnt);
    }
    cout << ans << endl;

}

int32_t main() {
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
	// int t; cin >> t;
	// while(t--)
		shit();
	return 0;
}


Measured memory_bytes: 6268
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
 
template <typename T>
void cetak(T t){cout << t << ')' << endl;}
template <typename T, typename... V>
void cetak(T t, V... v) {cout << t; if (sizeof...(v)) cerr << ", "; cetak(v...);}
 
#define debug(x...) cout<< '(' << #x << ") = ("; cetak(x) 
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())

const int MOD = 1e9 + 7;
const int mx = 50 + 10;

int l[mx][mx], r[mx][mx], sudah[mx][mx];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int w, d, n;
    cin >> w >> d >> n;
    vector<int> x(n), y(n), z(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];
    for(int i = 1; i <= w; i++) for(int j = 1; j <= d; j++) l[i][j] = -1e9, r[i][j] = 1e9;
    for(int i = 0; i < n; i++) l[x[i]][y[i]] = r[x[i]][y[i]] = z[i];
    queue<pair<int, int>> q;
    while(1){
        if(q.empty()){
            for(int i = 1; i <= w; i++) for(int j = 1; j <= d; j++) if(l[i][j] == r[i][j] && !sudah[i][j]) sudah[i][j] = 1, q.push({i, j});
            if(q.empty()) break;
        }
        int X = q.front().f, Y = q.front().s; q.pop();
        for(int i = 1; i <= w; i++){
            for(int j = 1; j <= d; j++){
                if(i == 2 && j == 2){
                    // debug(i, j, l[i][j], r[i][j], X, Y);
                }
                l[i][j] = max(l[i][j], l[X][Y] - abs(X - i) - abs(Y - j));
                r[i][j] = min(r[i][j], l[X][Y] + abs(X - i) + abs(Y - j));
            }
        }
    }
    int jaw = 0;
    for(int i = 1; i <= w; i++){
        for(int j = 1; j <= d; j++){
            if(l[i][j] > r[i][j]){
                // debug(i, j, l[i][j], r[i][j]);
                cout << "No\n";
                return 0;
            }
            jaw += l[i][j];
        }
    }
    cout << jaw << endl;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
 
#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);
 
using namespace std;
 
int main()
{
	IOS;
	char s[200];
	cin>>s;
	int n=strlen(s);
	bool f1=0,f2=0;
	for (int j=0;j<n;++j)
	{
		if (s[j]=='C') f1=1;
		if (s[j]=='F'&&f1==1) f2=1;
	}
	if (f2) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int main() {

    int N, M;
    std::cin >> N >> M;
    std::vector<unsigned long long int> A(N);
    for (auto& v : A)std::cin >> v;
    std::sort(A.begin(), A.end());
    std::vector<std::pair<int, unsigned long long int>> BC(M);
    for (auto& v : BC)std::cin >> v.first >> v.second;
    std::sort(BC.begin(), BC.end(), [](const auto& a, const auto& b) {return b.second < a.second; });
    int64_t ans = 0;
    int index = 0;
    for (int i = 0; i < M && index < N; ++i) {
        for (int j = 0; j < BC[i].first && index < N; ++j, ++index) {
            ans += std::max(A[index], BC[i].second);
        }
    }
    for (int i = index; i < N; ++i)ans += A[i];
    std::cout << ans << std::endl;
}

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<vector>
#define inf 2147483647
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define  rr read()
#define ll long long
#define repb(i,a,b) for(int i=a;i<=b;i++)
#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int read()
{
    char ch = getchar();
	int x = 0, f = 1;
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int main()
{
  int a;
  string s;
  cin>>a>>s;
  string ans=(a<3200)?"red":s;
  cout<<ans;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		for ( ; n > 0 ; n--) {
			String cipher = br.readLine();
			System.out.println(decrypt(cipher));
		}
	}

	public static String decrypt(String cipher) {
		char[] cipherdata = cipher.toCharArray();
		char[] decryptdata = new char[cipherdata.length];
		for (int a = 0; a < 26; a++) {
			if (a % 2 == 0 || a % 13 == 0) continue;
			for (int b = 0; b < 26; b++) {
				for (int i=0; i < cipherdata.length; i++) {
					if (cipherdata[i] == ' ') {
						decryptdata[i] = ' ';
					} else {
						decryptdata[i] =
								f_inverse(cipherdata[i], a, b);
					}
				}
				String decryption = String.valueOf(decryptdata);
				if (decryption.indexOf("that") != -1
						|| decryption.indexOf("this") != -1) {
					return decryption;
				}
			}
		}
		return "hoge";
	}

	private static char f_inverse(char y, int a, int b) {
//		y = f(x) = (a * x + b) % 26;
		y = (char) (y - 'a');
		char x;
		for (x = 0; x < 26; x++) {
			int fx = (a * x + b) % 26;
			if (y == fx) break;
		}
		return (char) (x + 'a');
	}
}

Measured memory_bytes: 25296
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;


int dp[105][105];
char c[105][105];

int main(){
    int h, w;
    cin >> h >> w;
    rep(i, h) rep(j, w) cin >> c[i][j];

    rep(i, h) rep(j, w) dp[i][j] = INF;


    if (c[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;
    rep(i, h - 1) {
        if (c[i+1][0] == '#' && c[i][0] == '.') dp[i+1][0] = dp[i][0] + 1;
        else dp[i+1][0] = dp[i][0];
    }
    rep(j, w - 1) {
        if (c[0][j+1] == '#' && c[0][j] == '.') dp[0][j+1] = dp[0][j] + 1;
        else dp[0][j+1] = dp[0][j];
    }

    rep(i, h - 1){ 
        rep(j, w - 1){
            int p, q;
            if (c[i+1][j+1] == '#'){
                p = dp[i+1][j];
                q = dp[i][j+1];
                if (c[i+1][j] == '.') p++;
                if (c[i][j+1] == '.') q++;
                dp[i+1][j+1] = min(p, q);
            }
            else dp[i+1][j+1] = min(dp[i+1][j], dp[i][j+1]);
        }
    }

    // rep(i, h){
    //     rep(j, w) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    cout << dp[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <queue>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#define ll long long
using namespace std;
const ll maxn=1e5+111;
char a[maxn][12]={0};
ll m=0,p[200],c[200];
void divide(ll n){
    for(ll i=2;i*i<=n;++i){
        if(n%i==0){
            p[++m]=i,c[m]=0;
            while(n%i==0) n/=i,c[m]++;
        }
    }
    if(n>1) p[++m]=n,c[m]=1;
}
int main(){
	ll n;
	scanf("%lld",&n);
	if(n==2){
		puts("1");
		return 0;
	}
	if(n==3){
		puts("2");
		return 0;
	}
	divide(n-1);
	ll ans=1,ans2=0;
	for(ll i=1;i<=m;++i){
		ll tp=n;
		ans*=(c[i]+1);
	}ans-=1;
	m=0;
	for(ll i=2;i*i<=n;++i){
		if(n%i==0){
			ll tp=n;
			while(tp%i==0) tp/=i;
			if(tp==1||tp%i==1) ++ans2;
		}
	}
	printf("%lld\n",ans+1+ans2);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
    int n;
    cin>>n;
    if(100<=n && n<=111)cout<<111<<endl;
    else if(112<=n && n<=222)cout<<222<<endl;
    else if(223<=n && n<=333)cout<<333<<endl;
    else if(334<=n && n<=444)cout<<444<<endl;
    else if(445<=n && n<=555)cout<<555<<endl;
    else if(556<=n && n<=666)cout<<666<<endl;
    else if(667<=n && n<=777)cout<<777<<endl;
    else if(778<=n && n<=888)cout<<888<<endl;
    else if(889<=n && n<=999)cout<<999<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size
#define inf 1e9+5


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string str;
    cin>>str;
    ll i=0,j=str.length()-1;
    ll ans=0;
    while(i<=j){
      if(str[i]!=str[j])
        ans++;
      i++;
      j--;
    }
    cout<<ans;

    return 0;  
}

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

int main() {
  int N;
  cin >> N;
  vector<int> students(N);
  for (int i = 0; i < N; i++) {
    int order;
    cin >> order;
    students.at(order - 1) = i + 1;
  }
  for (int i = 0; i < N - 1; i++) {
    cout << students.at(i) << " ";
  }
  cout << students.at(N - 1);
}


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

using namespace std;

int main()
{
   int a,b,t,i;
   cin>>a>>b;
   int emp,c=1;
    t=a;
   if(b==1)
   {
      cout<<"0";
      return 0;
   }
   else
   {
      for(i=0;;i++)
      {
         if(t<b)
         {
            t=t+a-1;
            c++;
         }
         else
         {
            cout<<c;
            return 0;
         }
      }
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    _LL n, d, a;
    cin >> n >> d >> a;
    vector<_LL> x(n); vector<_LL> h(n);   
    vector<pair<_LL, _LL>> enemy(n); 
    rep(i, n)
    {
        _LL x, h;
        cin >> x >> h;
        h = (h - 1) / a + 1;
        enemy[i].first = x;
        enemy[i].second = h;
    }

    queue<pair<_LL, _LL>> q;
    sort(enemy.begin(), enemy.end());
    _LL damage = 0;
    _LL ans = 0;
    rep(i, n)
    {
        while( !q.empty() )
        {
            if( q.front().first >= enemy[i].first ) break;
            damage -= q.front().second;
            q.pop();
        }
        _LL hp = enemy[i].second - damage;
        if( hp > 0 )
        {
            damage += hp;
            ans += hp;
            q.push(make_pair(enemy[i].first + d + d, hp));
        }
    }
    cout << ans;
}

Measured memory_bytes: 11112
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#include<vector>
#include<algorithm>
#include<string>
using ll=long long;
using P =pair<int,int>;


int main(){
  int n;
  cin >> n;
  vector<int>p(n);
  rep(i,n)cin >> p[i];
  int cnt=0,m=n+1;
  rep(i,n){
    if(p[i]<=m){
      m=p[i];
      cnt++;
    }
  }
  cout << cnt << endl;
}






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

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

void solve(void) {
  int a, b, c, d; cin >> a >> b >> c >> d;

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

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

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  
  int total = 0, abroad = 1;
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'a') {
      if (total < a + b) {
        cout << "Yes\n";
        total++;
      }
      else {
        cout << "No\n";
      }
    }
    else if (s.at(i) == 'b') {
      if (total < a + b && abroad <= b) {
        cout << "Yes\n";
        total++;
        abroad++;
      }
      else {
        cout << "No\n";
        abroad++;
      }
    }
    else {
      cout << "No\n";
    }
  }
}

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

static const int N = 1000;

int main()
{
    int n, p[N + 1];
    vector<vector<int>> m(N + 1, vector<int>(N + 1));
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> p[i - 1] >> p[i];
    }
    for (int i = 1; i <= n; i++)
    {
        m.at(i).at(i) = 0;
    }
    for (int l = 2; l <= n; l++)
    {
        for (int i = 1; i <= n - 1; i++)
        {
            int j = i + l - 1;
            m.at(i).at(j) = (1 << 21);
            for (int k = i; k <= j - 1; k++)
            {
                m.at(i).at(j) = min(m.at(i).at(j), m.at(i).at(k) + m.at(k+1).at(j) + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    cout << m[1][n] << endl;
    return 0;
}


Measured memory_bytes: 6664
#include<stdio.h>

#define N 8
#define NOT -1
#define FR -2

int row[N], col[N], drop[N*2 -1], dneg[N*2-1], X[N][N];

void Print(int n){
  int i, j;
  
   for(i=0 ; i<N ; i++){
     for(j=0 ; j<N ; j++){
       if(X[i][j] == 1){
	 if(row[i] != j) return;
       }
     }
   }
 
    for(i=0 ; i<N ; i++){
      for(j=0 ; j<N ; j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
      printf("\n");
    }
    
  
  return;
}

void PutQ(int i){
  int j;
  //printf("%d\n",i);
  
  if(i == N){
    Print(i);
    return ;
  }
   
  
  
  for(j=0 ; j<N ; j++){
   
    if(col[j] == NOT || drop[i+j] == NOT || dneg[i-j+N-1] == NOT)continue;
    //printf("%d\n",j);
    row[i] = j;
    col[j] = drop[i+j] = dneg[i-j+N-1] = NOT;

    PutQ(i+1);

   row[i] = col[j] = drop[i+j] = dneg[i-j+N-1] = FR;
    
  }
 
}


int main(){
  int i, k, r, c, j;

    for(i=0 ; i<N ; i++){
      row[i] = FR;
	col[i] = FR;
    }
     for(i=0 ; i<N*2 - 1 ; i++){
       drop[i] =FR;
	 dneg[i] = FR;
    }
     for(i=0 ; i<N ; i++){
       for(j=0 ; j<N ; j++)X[i][j] = 0;
     }
    
  scanf("%d",&k);
  for(i=0 ; i<k ; i++){
    scanf("%d%d",&r,&c);
    X[r][c] = 1;
   
  }

  PutQ(0);

  /*for(i=0 ; i<N ; i++){
     Print(i);
     }*/
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007

using namespace std;

int main(void){

  int n;
  cin >> n;
  map<int, int> a;

  int ok = 1;
  int b;
  for (int i = 0; i < n; i++){
    cin >> b;
    if (a[b] == 0)
      a[b]++;
    else
      ok = 0;

  }
  

  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 9600
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int sum = 0;
        int[][] numlist = new int[m][n+1];
        List<Integer> plist = new ArrayList<>();
        for(int i=0;i<m;i++){
            int k = in.nextInt();
            numlist[i][0]=k;
            for(int j=0;j<k;j++){
                numlist[i][j+1] = in.nextInt();
            }
        }
        for(int i=0;i<m;i++)
            plist.add(in.nextInt());

        for(int i=0;i< 1<<n;i++){
            int att = 0,z=0;
            for(int j=0;j<m;j++){
                att = 0;
               for(int k=0;k<numlist[j][0];k++){
                   z = numlist[j][k+1]-1;
                   att ^= (i>>z & 1);
               }
               if(att != plist.get(j))  break;
               else if(j==m-1){
                   sum++;
               }
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
#define pi acos(-1)
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
ll power(ll x,ll y){
	if(y==0)
		return 1;
	ll res=power(x,y/2);
	res=(res*res);
	if(y&1)
		res=(res*x);
	return res;
}
 
ll powermod(ll x,ll y,ll mod){
	if(y==0)
		return 1;
	ll res=powermod(x,y/2,mod);
	res=(res*res)%mod;
	if(y&1)
		res=(res*x)%mod;
	return res;
}
/*ll binarysearch(ll va)
{
	ll n=1;
	ll l=va+1,u=n;
	ll st=num.order_of_key(va);
	while(l+1<u)
	{
		m=(l+u)/2;
		ll in=num.order_of_key(m);
		if(in-st==m-va)
		{
			l=m;
		}
		else
		{
            u=m;
		}
	}
	if(num1.find(l)==num1.end())
		return l;
	return u;
}*/
void solve(){
	int l,r,d;
	cin>>l>>r>>d;
	int ans=0;
	for(int i=l;i<=r;i++){
		if(i%d==0) ans++;
	}
	cout<<ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
 
    for(int i=1;i<=t;i++)
    {//cout<<"Case #"<<i<<": ";
    solve();}
    return 0;
}


Measured memory_bytes: 3652
# coding: utf-8
# Your code here!
import sys
input=sys.stdin.readline

N=int(input())

q=[]

l=[[] for i in range(N)]

ans=[1]*N
ans[0]=0
#print(l)

for i in range(N-1):
    a,b=map(int,input().split())
    q.append([a-1,b-1])
    l[a-1].append(b-1)

mx=0
for index,item in enumerate(l):
    color=1
    while item:
        temp=item.pop(-1)
        if color==ans[index]:
            color+=1
        ans[temp]=color
        color+=1
    mx=max(color-1,mx)

print(mx)
for _,item in q:
    print(ans[item])
    

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

//#define DEBUG

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;



int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	double x, y;
	cin >> x >> y;
	cout << setprecision(10) << fixed << x/y;
	return 0;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int M1, D1; cin >> M1 >> D1;
	int M2, D2; cin >> M2 >> D2;

	if(M1 != M2) cout << 1 << endl;
	else cout << 0 << endl;
	


	return 0;

}


Measured memory_bytes: 768
#include"bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)

signed main() {
	for (int N; cin >> N && N;) {
		vector<vector<bool>> v(N, vector<bool>(N));

		rep(i, 0, N) {
			int M; cin >> M;
			rep(j, 0, M) {
				int p; cin >> p;
				p--;
				v[i][p] = true;
			}
		}
		int K; cin >> K;
		vector<int> l(K); rep(i, 0, K) {
			cin >> l[i];
			l[i]--;
		}

		set<int> st;
		rep(i, 0, N) {
			st.insert(i);
		}

		rep(i, 0, K) {
			rep(j, 0, N) {
				if (!v[j][l[i]])
					st.erase(j);
			}
		}

		if (st.size() == 1) {
			cout << *st.begin() + 1 << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
	

	return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
using namespace std; 
int main(){
	char s[202];
	char p[101];
	char x[101];
	cin>>s>>p;
	strcpy(x,s);
	strcat(s,x);
	//cout<<"www"<<endl;
	if(strstr(s,p)!=NULL){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define ENDL '\n'
#define all(a) begin(a), end(a)
#define sz(a) (int)(a.size())
#define deb(a) cout << #a << ": " << a << ENDL
#define fore(i, a, b) for(int i(a), ThkMk(b); i < ThkMk; ++i)
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

typedef long long lli;
typedef long double ld;
typedef unsigned long long ulli;
typedef pair<lli, lli> ii;
typedef vector<lli> vi;


vector<vi> g;
vector<bool> vis;

void dfs(int u) {
    vis[u] = true;
    for(auto it : g[u]) if(!vis[it]) dfs(it);
}

int main()
{   _
    lli n, m, u, v; cin >> n >> m;
    g.resize(n + 1);
    vis.assign(n + 1, false);
    while(m--) {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int cnt = 0;
    fore(i, 1, n + 1) {
        if(!vis[i]) {
            ++cnt;
            dfs(i);
        }
    }
    cout << cnt - 1 << ENDL;
    return 0;
}


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

#define Uni All right
#define REP(i,a,b) for(int i=(a),i##_end_=(b);i<i##_end_;++i)
#define DREP(i,a,b) for(int i=(a),i##_end_=(b);i>i##_end_;--i)
#define LREP(i,a) for(int i=Head[a];i;i=Next[i])
#define LL long long
#define Mod 1000000007 

static const int M=(1<<17)+4;
int n,A,B;
int Cnt[M];
void Work(int f,int a,int b){
	if(Cnt[f]==1)printf("%d %d ",a,b);
	else{
		int p=1,q=1;
		while(!(f&p) || !((a^b)&p))p<<=1;
		while(!(f&q) || p==q)q<<=1;
		Work(f^p,a,a^q);
		Work(f^p,a^q^p,b);
	}
}
int main(){
	scanf("%d%d%d",&n,&A,&B);
	
	int t=0;
	REP(i,0,1<<n)Cnt[i]=Cnt[i>>1]+(i&1);
	if(!(Cnt[A^B]&1))return puts("NO"),0;
	
	puts("YES");
	Work((1<<n)-1,A,B);
	puts("");
	
	return 0;
}

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

class Program
{
    static string InputPattern = "InputX";

    static IEnumerable<string> GetInputEnum()
    {
        if (InputPattern == "Input1") {
            yield return "10";
            yield return "...*....**";
            yield return "..........";
            yield return "**....**..";
            yield return "........*.";
            yield return "..*.......";
            yield return "..........";
            yield return ".*........";
            yield return "..........";
            yield return "....*..***";
            yield return ".*....*...";
            yield return "10";
            yield return "****.*****";
            yield return "*..*.*....";
            yield return "****.*....";
            yield return "*....*....";
            yield return "*....*****";
            yield return "..........";
            yield return "****.*****";
            yield return "*..*...*..";
            yield return "****...*..";
            yield return "*..*...*..";
            yield return "0";
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) yield return wkStr;
        }
    }

    static int UB;

    static void Main()
    {
        IEnumerable<string> InputEnum = GetInputEnum();

        int CurrY = -1;

        char[,] BanArr = null;

        foreach (string EachStr in InputEnum) {
            if (CurrY == -1) {
                int n = int.Parse(EachStr);
                if (n == 0) return;
                UB = n - 1;

                CurrY = 0;
                BanArr = new char[UB + 1, UB + 1];
                continue;
            }

            for (int X = 0; X <= UB; X++) {
                BanArr[X, CurrY] = EachStr[X];
            }
            if (++CurrY > UB) {
                EachSolve(BanArr);
                CurrY = -1;
            }
        }
    }

    static void EachSolve(char[,] pBanArr)
    {
        int[,] CntArr = new int[UB + 1, UB + 1];

        Func<int, int, int> wkFunc = (pX, pY) =>
        {
            if (pX < 0 || UB < pX) return 0;
            if (pY < 0 || UB < pY) return 0;

            return CntArr[pX, pY];
        };

        for (int LoopX = 0; LoopX <= UB; LoopX++) {
            for (int LoopY = 0; LoopY <= UB; LoopY++) {
                if (pBanArr[LoopX, LoopY] == '*') //印のついているマスの場合
                    CntArr[LoopX, LoopY] = 0;
                else {
                    int Cnt1 = wkFunc(LoopX - 1, LoopY - 1);
                    int Cnt2 = wkFunc(LoopX, LoopY - 1);
                    int Cnt3 = wkFunc(LoopX - 1, LoopY);

                    int wkMin = Math.Min(Cnt1, Cnt2);
                    wkMin = Math.Min(wkMin, Cnt3);

                    CntArr[LoopX, LoopY] = wkMin + 1;
                }
            }
        }
        Console.WriteLine(CntArr.Cast<int>().Max());
    }
}

Measured memory_bytes: 23244
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    double H, A;
    cin >> H >> A;
    cout << ceil(H / A) << endl;
}

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

#define max(a, b) ((a) > (b) ? (a) : (b))

int main(void) {
  FILE *fp = stdin;
  char line[15];
  if(!fgets(line, 15, fp)) return 0;
  int konst, sum;
  sscanf(line, "%d %d", &konst, &sum);
  
  int i;
  int ans = 0;
  for(i = 0; i <= konst; i++) {
    int rem = sum - i;
    if(rem<0) continue;
    rem = (rem >=konst) ? max(0, konst*2+1 - rem) : rem+1;
    ans += rem;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

void drop1(int s[][14] , int x , int y){
	s[x][y]++;
	s[x-1][y]++;
	s[x][y-1]++;
	s[x+1][y]++;
	s[x][y+1]++;
}

void drop2(int s[][14] , int x , int y){
	drop1(s , x , y);
	s[x-1][y-1]++;
	s[x+1][y-1]++;
	s[x-1][y+1]++;
	s[x+1][y+1]++;
}

void drop3(int s[][14] , int x , int y){
	drop2(s , x , y);
	s[x-2][y]++;
	s[x][y-2]++;
	s[x+2][y]++;
	s[x][y+2]++;
}


int main(){
	int square[14][14]={0};
	int x , y , s , mx=0 ,cnt=0;
	char c;
	while(cin >> x >> c >> y >> c >> s){
		switch(s){
			case 1:
			drop1(square , x+2 , y+2);
			break;
			case 2:
			drop2(square , x+2 , y+2);
			break;
			case 3:
			drop3(square , x+2 , y+2);
		}
	}
		for(int i=2;i<12;++i){
			for(int j=2;j<12;++j){
				if(square[i][j]==0) cnt++;
				mx=max(mx , square[i][j]);
			}
		}
		cout << cnt << endl << mx << endl;	
	return 0; 
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);
#define FOR(n) for(int i(0);i<n;++i)
#define ASC(i,a,b) for(int i(a); i <=b; ++i)
#define DESC(i,a,b) for(int i(a);i>=b;i--)
#define WL(t) while(t--)
#define forr(i,n) for(int i(0);i<n;++i)
#define SZ(a) int((a).size())
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define BB begin()
#define EE end()
#define all(c) c.BB, c.EE
#define present(container, element) (container.find(element) != container.end())
// ^^for set,map etc
#define cpresent(container, element) (find(all(container), element) != container.end())
// for vector,array etc
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
#define count(x) __builtin_popcount(x) 
typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;
const float INF = numeric_limits<float>::infinity();
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
const LL big=998244353;
 
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
 
int main(){
	int n;
	cin >> n;
	int arr[n];
	forr(i,n) cin >> arr[i];
	int m1=0;
	forr(i,n){
		if(i&1) m1-=arr[i];
		else m1+=arr[i];
	}
	int go[n];
	go[0]=m1;
	for(int i(1);i<n;++i){
		go[i]=2*arr[i-1]-go[i-1];
	}
	for(int i(0);i<n;++i){
		cout << go[i] << " ";
	}
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int n=0;
  bool f=false;
  string c="\0";
  cin>>c;
  while(c[n+1] != '\0'){
    if(c[n] == 'A' && c[n+1] == 'C')
      f=true;
    n++;
  }
  if(f)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return(0);
}
  


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

void solve()
{
   char a;
    cin>>a;
    if(a>=97&&a<=122)cout<<'a'<<endl;
    else cout<<'A'<<endl;
}


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

Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	ll H, W;
	cin >> H >> W;
	vector<string> a(H);
	rep(i, H) {
		cin >> a[i];
	}
	rep(i, W + 2) cout << "#";
	cout << endl;
	rep(i, H) cout << "#" << a[i] << "#" << endl;
	rep(i, W + 2) cout << "#";
	cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, vector<llint> > T;

llint D;
llint c[30], csum;
llint s[400][30];
vector<llint> ans;
vector<T> vec;

llint score(vector<llint> ans, llint n)
{
	llint last[26];
	for(int i = 0; i < 26; i++) last[i] = 0;
	
	llint ret = 0, sub = 0;
	for(int i = 0; i < n; i++){
		llint x = ans[i];
		ret += s[i][x];
		sub -= (i-last[x]) * c[x];
		sub += csum;
		ret -= sub;
		last[x] = i;
	}
	return ret;
}

void search(vector<llint> &ret)
{
	llint cur = score(ret, D);
	for(int t = 0; t < 2; t++){
		llint x = rand() % D, y = rand() % D;
		swap(ret[x], ret[y]);
		llint nxt = score(ret, D);
		if(nxt < cur) swap(ret[x], ret[y]);
		else cur = nxt;
		
		x = rand() % D, y = rand() % 26;
		llint tmp = ret[x];
		ret[x] = y;
		nxt = score(ret, D);
		if(nxt < cur) ret[x] = tmp;
		else cur = nxt;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	srand(time(NULL));
	
	cin >> D;
	for(int i = 0; i < 26; i++) cin >> c[i];
	for(int i = 0; i < D; i++){
		for(int j = 0; j < 26; j++){
			cin >> s[i][j];
		}
	}
	for(int i = 0; i < 26; i++) csum += c[i];
	
	ans.resize(D);
	for(int i = 0; i < D; i++){
		llint max_val = -inf, max_j;
		for(int j = 0; j < 26; j++){
			ans[i] = j;
			llint res = score(ans, i+1);
			if(res > max_val){
				max_j = j;
				max_val = res;
			}
		}
		ans[i] = max_j;
	}
	search(ans);
	
	const int M = 20;
	llint res = score(ans, D);
	for(int i = 0; i < M; i++) vec.push_back(T(res, ans));
	
	for(int t = 0; t < 16000; t++){
		vector<T> nvec;
		for(int i = 0; i < vec.size(); i++){
			vector<llint> tmp = vec[i].second;
			search(tmp);
			nvec.push_back(vec[i]);
			nvec.push_back(T(score(tmp, D), tmp));
		}
		sort(nvec.rbegin(), nvec.rend());
		nvec.resize(M);
		vec = nvec;
	}
	ans = vec.front().second;
	
	for(int i = 0; i < D; i++) cout << ans[i]+1 << endl;
	
	return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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() {
  ll N, K;
  cin >> N >> K;
  ll ans = K;
  rep(i, N - 1) {
    ans *= (K - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc066/tasks/abc066_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int isss(string s)
{
  if (s.substr(0, s.length() / 2) == s.substr(s.length() / 2))
    return s.length();
  else
    return isss(s.substr(0, s.length() - 2));
}

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  string s;

  cin >> s;

  int lm = isss(s.substr(0, s.length() - 2));

  cout << lm << '\n';

  return 0;
}


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

int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q);
  for(int i = 0; i < q; i++){
    cin >> a[i];
  }	//input
  
  for(int i = 0; i < q; i++){
    a[i]--;
  }	//0-index
  
  vector<int> imos(n, 0);
  for(int i = 0; i < q; i++){
    imos[0]--;
    imos[a[i]]++;
    /*if(a[i]+1 < q)*/ imos[a[i]+1]--;
  }		
  for(int i = 1; i < n; i++){
     imos[i] += imos[i-1];
     //cout << imos[i] << endl;
  }	//imos method
  
  for(int i = 0; i < n; i ++){
    if(imos[i] <= -k){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
}
  
  
  

Measured memory_bytes: 4032