akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    n*=100;
    vector<pair<ll,ll>> v(4);
    v[0]=make_pair(8*q,25);
    v[1]=make_pair(4*h,50);
    v[2]=make_pair(2*s,100);
    v[3]=make_pair(d,200);
    sort(ALL(v));
    ll ans=0;
    for(auto x:v){
        if(x.second==25){
            ans+=q*(n/25);
            n%=25;
        }
        if(x.second==50){
            ans+=h*(n/50);
            n%=50;
        }
        if(x.second==100){
            ans+=s*(n/100);
            n%=100;
        }
        if(x.second==200){
            ans+=d*(n/200);
            n%=200;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if ((a - b) % 2 == 0)cout << (a + b) / 2 << endl;
	else cout << "IMPOSSIBLE" << endl;
}

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

int main(int argc, char *argv[]) {
	int a,b,i,sum,count;
	while((scanf("%d %d", &a,&b))!=EOF)	{
		for(i=1; i<=11; i++)	{
				sum=a+b;
				if(sum<(pow(10,i)))	{
				break;
			}
		}
		printf("%d\n",i);
	}
	return 0;
}


Measured memory_bytes: 2024
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
 
	int n, a, b;
	cin >> n >> a >> b;

	if (a % 2 == b % 2)
		cout << "Alice" << endl;
	else
		cout << "Borys" << endl;
 
	return 0;
}

Measured memory_bytes: 384
///*Bismillahir Rahmanir Rahim***///
/***Stay_Home_Stay_Safe***/
///**Author Thasin Sheikh**///
#include<bits/stdc++.h>
using namespace std;
#define MAX 1e6+10
#define MOD 1000000007
#define PI 3.14159265359
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
const int N = 2e5 + 10;
ll aarray[200000+10];
ll magic[101][101];
vector<ll>primes;
bool prime[1000001];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    makefast__
    string str;
    ll a,b,c,d,e,f,x,y,k,t,A=0,mod,B=0,L,j,i,l,r,m,n,C=0,ans=0,sum=0,sum1=0;
    vector<ll>v,v1;
    queue<ll>qu;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(i=1; i<n; i++)
    {
        A+=v[i/2];
        //else break;
        //cout<<y<<" ";
    }
    cout<<A<<endl;


    return 0;
}


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

int main(int argc, char const *argv[])
{
    int n,m,X,Y;cin>>n>>m>>X>>Y;
    vector<int> x(n);
    vector<int> y(m);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<m;i++){
        cin>>y[i];
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    // cout<<x[n-1]<<" "<<y[0]<<endl;
    if(x[n-1]<y[0] && y[0]>X && y[0]<=Y){
        cout<<"No War"<<endl;
    }
    else cout <<"War"<< endl;
    return 0;
}


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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX
#define pow POW

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

void fast() {
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(0);
}

bool compare(int &a, int &b) {
	return a > b;
}

ll numOfDigits(ll n) {
	if (!n)
		return 1;
	return (ll) (log10(n)) + 1;
}

ull POW(ll a, ll b);

/*

 */

ll BN();

ll mn  = LLMAX;

int main() {
	JULEE_DO_THE_THING;
	//freopen("test cases\\.txt", "r", stdin) ;
	ll q, h, s, d, n;
    cin>>q>>h>>s>>d>>n;
    ll sum = 0;
    if(!isOdd(n) && n>=2){
        sum += (n/2)*d;
        mn = min({sum, s*n, 2*h*n, 4*q*n});
        cout<<mn;
    }else if(n-1>0){
        n--;
        sum = (n/2)*d;
        sum+= min({s, 2*h, 4*q});
        n++;
        mn = min({sum, s*n, 2*h*n, 4*q*n});
        cout<<mn;
    }else{
        sum = 0;
        sum+= min({s, 2*h, 4*q});
        cout<<sum;
    }
	return 0;
}

ll BN() {
	ll low = 0;
	ll up = 0;
	ll ans = 0;
	while (low <= up) {
		ll mid = ((low + up) / 2);
		if (mid) {
			ans = mid;
			low = mid + 1;
		} else
			up = mid - 1;
	}
	return ans;
}

ull POW(ll a, ll b) {
	ull res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i) {return 2*i+1;}

int main(){
    int H,i,A[MAX+1];
    
    cin>>H;
    for(i=1;i<=H; i++){
        cin>>A[i];
    }
    
    for(i=1;i<=H;i++){
        cout<<"node "<<i<<": key = "<<A[i]<<", ";
        if(parent(i) >= 1) cout<<"parent key = "<<A[parent(i)]<<", ";
        if(left(i)<=H) cout<<"left key = "<<A[left(i)]<<", ";
        if(right(i)<=H) cout<<"right key = "<<A[right(i)]<<", ";
        cout<<endl;
    }
    return 0;
}


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

int main() {
    vector<vector<int>> table(10, vector<int>(10));
    for(int i=0; i<10; ++i) {
        for(int j=0; j<10; ++j) {
            cin >> table[i][j];
        }
    }
    auto cd = [&table](string const& n, int len) -> char {
        int res = 0;
        for(int i=0; i<len; ++i) {
            res = table[res][n[i]-'0'];
        }
        return (char)(res + '0');
    };
    vector<bool> error(10000, false);
    for(int i=0; i<10000; ++i) {
        string n = to_string(i);
        while(n.size() < 4) {
            n = '0' + n;
        }
        n += cd(n, 4);

        for(int j=0; j<5; ++j) {
            string tmp = n;
            for(int k=0; k<10; ++k) {
                tmp[j] = '0' + k;
                if(tmp == n) {
                    continue;
                }
                char c2 = cd(tmp, 5);
                if(c2 == '0') {
                    error[stoi(n.substr(0, 4))] = true;
                }
            }
        }

        for(int j=0; j<4; ++j) {
            if(n[j] == n[j+1]) {
                continue;
            }
            swap(n[j], n[j+1]);
            if(cd(n, 5) == '0') {
                error[i] = true;
            }
            swap(n[j], n[j+1]);
        }
    }

    cout << count(error.begin(), error.end(), true) << endl;
}


Measured memory_bytes: 3264
n = input()
ps = [map(int, raw_input().split()) for i in xrange(n)]
for i in xrange(n):
    ps[i] = (ps[i][1], ps[i][0])
ps.sort()

def cross(a, b, c):
    return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])
def convex_hull(ps):
    qs = []
    n = len(ps)
    for p in ps:
        while len(qs)>1 and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    t = len(qs)
    for i in xrange(n-2, -1, -1):
        p = ps[i]
        while len(qs)>t and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    return qs

qs = convex_hull(ps)
print len(qs)-1
for i in xrange(len(qs)-1, 0, -1):
    y, x = qs[i]
    print x, y

Measured memory_bytes: 22348
#include<iostream>
#include<string>
using namespace std;
int main(){
  int d[]={31,29,31,30,31,30,31,31,30,31,30,31};
  string s[]={"Thursday",
	      "Friday","Saturday","Sunday","Monday","Tuesday","Wednesday",};
  int i,j,a,b;cin>>a>>b;
  while(a!=0){
    int o=0;
    for(i=1;i<a;i++) o+=d[i-1];
    o+=b-1;
    cout << s[o%7] << endl;cin>>a>>b;
  }
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  int n;
  vector<int> a;
  
  cin >> n;
  a = vector<int>(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  cout << (*max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end())) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    int a1, a2, a3;
    std::cin >> a1 >> a2 >> a3;
    a1 += a2 + a3;
    if(a1 >= 22) {
        std::cout << "bust";
    }
    else {
        std::cout << "win";
    }
}

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

int main() {
  int l,r,ans=2019;
  cin>>l>>r;
  for(long long i=l;i<=r;i++){
    for(long long j=i+1;j<=r;j++){
      int a=i*j%2019;
      ans=min(a,ans);
      if (ans==0) break;
    }
    if(ans==0)break;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1e8;
typedef long long ll;
ll mod = 998244353;
long long fast_exp(long long a, long long b)
{
    if(b == 0)
	   return 1;
    else
    {
	   long long res = 1;
	   res = fast_exp(a,b/2);
	   res = (res*res)%mod;
	   if(b%2 == 1)
		  res = (res*a)%mod;
	   return res;
 
    }
}
const ll N = 1e6;
 
 
 
 
int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	int n,x;
	cin>>n>>x;
	int l[n];
	int cnt = 0;
	int cur  = 0;
	if(x>=cur)
		cnt++;
	for(int i = 0; i<n ; i++)
	{
		cin>>l[i];
		cur+=l[i];
		if(x>=cur)
			cnt++;
	}
 
	cout<<cnt<<endl;
	return 0;
	
}

Measured memory_bytes: 256
// Created by Manuver
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << " : " << x << endl;


int main() {
    long long x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector <pair<int, int>> p(a + b + c);
    for (long long i=0; i<a; i++) {
        cin >> p[i].first;
        p[i].second = 0;
    }
    for (long long i=a+0; i<a+b; i++) {
        cin >> p[i].first;
        p[i].second = 1;
    }
    for (long long i=a+b+0; i<a+b+c; i++) {
        cin >> p[i].first;
        p[i].second = 2;
    }
    sort(begin(p), end(p), [](pair<int, int> a, pair<int, int> b){
        if (a.first == b.first) {
            return a.second > b.second;
        }
        return a.first > b.first;

    });
    long long i=0, j = 0, ca=0, cb=0, cc = 0, fa=1, fb=1;
    long long ans = 0;
    while (true) { 
        // deb(p[i].first)
        if (p[i].second == 0 && fa) {
            ca++;
            ans += p[i].first;
        } else if (p[i].second == 1 && fb) {
            cb++;
            ans += p[i].first;
        } else if (p[i].second == 2){
            cc++;
            ans += p[i].first;
        }
        if (ca >= x) {
            fa = 0;
        }
        if (cb >= y) {
            fb = 0;
        }
        if ((ca + cb + cc) >= (x + y)) {
            break;
        }
        i++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
//using Graph = vector<vector<ll> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;

ll h,w;
char a[1010][1010];

int dist[1010][1010];

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

vector<P>start;

void bfs(){
    queue<P> que;
    rep(i,start.size()){
        que.push(start[i]);
        dist[start[i].first][start[i].second]=0;
    }
    while(!que.empty()){
        P p = que.front();que.pop();
        rep(dir,4){
            int nx = p.first + dx[dir];
            int ny = p.second + dy[dir];
            if(nx<0||ny<0||nx>=h||ny>=w)continue;
            if(dist[nx][ny]>=0)continue;
            que.push(P(nx,ny));
            dist[nx][ny]=dist[p.first][p.second]+1;
        }   
    }
    return;
}

int main(){
    cin >> h >> w;
    rep(i,h)rep(j,w){
        cin>>a[i][j];
        if(a[i][j]=='#')start.push_back(P(i,j));
    }
    rep(i,h)rep(j,w)dist[i][j]=-1;
    bfs();
    int ans = 0;
    rep(i,h)rep(j,w)chmax(ans,dist[i][j]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 40240
#include "bits/stdc++.h"
using namespace std;

int main() {
  int N;
  cin >> N;
  map<int, int> num;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    if(num.count(tmp)){
      num.at(tmp)++;
    }else{
      num[tmp] = 1;
    }
  }
  int res = 0;
  for(auto p : num){
    if(p.second & 1){
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    vector<int> v[4];

    ll n, limit;
    cin >> n >> limit;
    ll val, w1;
    cin >> w1 >> val;
    v[0].push_back(val);
    rep(i, n - 1)
    {
        ll w;
        cin >> w >> val;
        v[w - w1].push_back(val);
    }
    rep(i, 4) sort(ALL(v[i]), greater<int>());
    ll maxv = 0;

    rep(i, v[0].size() + 1)
    {
        ll v0 = (!v[0].empty() ? accumulate(v[0].begin(), v[0].begin() + i, 0) : 0);
        rep(j, v[1].size() + 1)
        {
            ll v1 = (!v[1].empty() ? accumulate(v[1].begin(), v[1].begin() + j, 0) : 0);
            rep(k, v[2].size() + 1)
            {
                ll v2 = (!v[2].empty() ? accumulate(v[2].begin(), v[2].begin() + k, 0) : 0);
                rep(l, v[3].size() + 1)
                {
                    ll v3 = (!v[3].empty() ? accumulate(v[3].begin(), v[3].begin() + l, 0) : 0);
                    if (i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3) <= limit)
                        maxv = max(maxv, v0 + v1 + v2 + v3);
                }
            }
        }
    }

    OP(maxv);

    return 0;
}

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


/* Raiyan Noory Rady,CSE'17,RUET
Email:raiyannooryrady@gmail.com
Smile->Desire->Unity->Effort->Struggle->Success->Again smile :)
*/

#define ll long long int
#define pf push_front
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define sortarr(a) sort(a,a+n)
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define prf printf
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()
#define forl(n) for(i=0;i<n;i++)


using namespace std;

int main()
{
    ll a,b,ans;
    cin>>a>>b;
    ans=min(a,b);
    if(ans==a)
    {
        while(b--)
            cout<<a;
        cout<<endl;
    }
    else
    {
        while(a--)
            cout<<b;
        cout<<endl;
    }
    return 0;
}






Measured memory_bytes: 256
// Problem : B - Homework
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

int  main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long int  d,n;
	cin>>d>>n;
	vector <long long int > ele(n);
	for(long long int  j = 0 ; j < n; j++)
	{
		cin>>ele[j];
	}
	long long int  sum = 0;
	for(long long int  j = 0 ; j < n; j++)
	{
		sum += ele[j];
	}
	if(sum > d)
	{
		cout<<"-1"<<"\n";
	}
	else
	{
		long long int  ans = d - sum;
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;


int main()
{
    int n;
    cin >> n;
    vector<int> p;
    rep(i, n){ int tmp; cin >> tmp; p.push_back(tmp);}

    int minn = MOD;
    int ans = 0;
    rep(i, n){
        if (minn >= p[i]){
            ans++;
            minn = p[i];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1400
S = input()
if S == 'hi':
  print('Yes')
elif S == 'hihi':
  print('Yes')
elif S == 'hihihi':
  print('Yes')
elif S == 'hihihihi':
  print('Yes')
elif S == 'hihihihihi':
  print('Yes')
else:
  print('No')

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, K, X, Y;

  cin >> N >> K >> X >> Y;

  cout << X * min(K, N) + Y * max(N-K, 0) << endl;


  return 0;
}


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

namespace Task {

const int MAXN = 100000;
#define long long long

std::multiset<long> setL, setR;
long a[MAXN + 1], b[MAXN + 1], f[MAXN + 1];

inline void solve() {
    std::ios::sync_with_stdio(false), std::cin.tie(NULL), std::cout.tie(NULL);
    register int n;
    std::cin >> n;
    for (register int i = 1; i <= n; i++) std::cin >> a[i] >> b[i];
    setL.insert(a[1]), setR.insert(a[1]);
    register long tl = 0, tr = 0, ans = 0, nl, nr;
    for (register int i = 2; i <= n; i++) {
        tl += b[i] - a[i], tr += b[i - 1] - a[i - 1];
        nl = *setL.rbegin(), nr = *setR.begin();
        if (nl - tl > a[i]) {
            ans += std::abs(nl - tl - a[i]), setL.erase(setL.find(nl));
            setL.insert(setL.insert(a[i] + tl), a[i] + tl);
            setR.insert(nl - tl - tr);
        } else if (a[i] > nr + tr) {
            ans += std::abs(nr + tr - a[i]), setR.erase(setR.find(nr));
            setR.insert(setR.insert(a[i] - tr), a[i] - tr);
            setL.insert(nr + tr + tl);
        } else {
            setL.insert(a[i] + tl), setR.insert(a[i] - tr);
        }
    }
    std::cout << ans;
}

#undef long
}

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

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

int main() {
  long long n,m;
  cin>>n>>m;
  long long ans=0;
  vector<pair<long long, long long>>e(n);
  for(int i=0;i<n;i++) cin>>e[i].first>>e[i].second;
  sort(e.begin(),e.end());
  for(int i=0;i<n;i++){
    if(e[i].second>=m){
      ans+=e[i].first*m;
      break;
    }
    else{
      ans+=e[i].first*e[i].second;
      m-=e[i].second;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;
#define ll long long

int d = 365;
vector<vector<int>> s(d, vector<int>(26, 0));
vector<ll> c(26);

void init() {
    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];
        }
    }
    return;
}

ll calc(vector<int> out) {
    ll score = 0;
    vector<ll> last(26, 0);
    for(int i = 0; i < out.size(); i++) {
        last[out[i]] = i+1; // タイプ番号
        //cout << "out[" << i << "] " << out[i] << " ";
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i+1)-last[j]);
        }
        score += s[i][out[i]];
        //cout << "score : " << score << endl;
    }

    for(int i = out.size(); i < d; i++) {
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i+1)-last[j]);
        }
    }
    return score;
}


int main() {
    init();
    vector<int> out;
    ll ans = 0;
    //ll tmp = 0;
    ll max_v = -1;
    for(int i = 0; i < d; i++) {
        //max_v = -100000000000;
        max_v = LLONG_MIN;
        int best = 0;
        for(int j = 0; j < 26; j++) {
            out.push_back(j);
            ll tmp = calc(out);
            if(max_v < tmp) {
                max_v = tmp;
                best = j;
            }
            out.pop_back();
        }
        out.push_back(best);
    }
    
    for(int i = 0; i < d; i++) {
        cout << out[i]+1 << endl;
    }
    //cout << max_v << endl;
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;




int main(){
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll C;
    cin >> C;
    if(A+B+C>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;


return 0;


}  



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n, m; cin >> n >> m;
	vector<pair<ll, ll>> v[n];
	for(ll i = 0; i < m; i++){
		ll l, r, d; cin >> l >> r >> d;
		v[l - 1].push_back(pair<ll, ll>(r - 1, d));
		v[r - 1].push_back(pair<ll, ll>(l - 1, -d));
	}
	map<ll, ll> ma;
	ma[0] = 0;
	set<ll> s;
	for(ll i = 0; i < n; i++) s.insert(i);
	stack<ll> st;
	st.push(0);
	bool no[n] = {1};
	while(s.size()){
		ll i;
		if(!st.empty()){
			i = st.top();
			st.pop();
		}else{
			i = *s.begin();
		}
		s.erase(s.find(i));
		if(ma.find(i) == ma.end()){
			ma[i] = 0;
		}
		ll koko = ma[i];
		for(auto info : v[i]){
			ll po = koko + info.second;
			if(s.find(info.first) != s.end()){
				if(!no[info.first]){
					st.push(info.first);
					no[info.first] = 1;
				}
			}
			auto ite = ma.find(info.first);
			if(ite == ma.end()){
				ma[info.first] = po;
			}else{
				if(po != ite->second){
					cout << "No\n";
					return 0;
				}
			}
		}
	}
	cout << "Yes\n";
	return 0;
}

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)

#define int long long
/*
signed mainnn(){
	int n,k;
	cin>>n>>k;
	int a[1000];
	lp(i,n) cin>>a[i];
	vector<int> ans;
	lp(i,n){
		lp(j,n-i){
			int bea=0;
			lps(k,j,j+i+1){
				bea+=a[k];
			}
			ans.push_back(bea);
		}
	}
	sort(ans.begin(),ans.end());
	reverse(ans.begin(),ans.end());
	int sum=0;
	vector<int> ls;
	int stp=digi(a[k-1]);
	lp(i,n){
		if(i<k) ls.push_back(a[i]);
		else{
			if(digi(a[i])==stp) ls.push_back(a[i]);
			else break;
		}
	}
	lp(i,ls.size()-k){
		sum=0;
		lps(j,i,k){
			if(j-i==0) sum=ls[j];
			else{sum=(ls[j]&sum)}
		}
	}
}*/

vector<char> s;
int task(int g){
	int cd=0,cm=0,ans=0,cntm=0;
	lp(i,s.size()){
		if(g-i-1<0){
			//cout<<"    "<<s[i-g]<<endl;
			if(s[i-g]=='D'){
				cd--;
				cm-=cntm;
			}
			if(s[i-g]=='M'){
				cntm--;
			}

		}
		//cout<<s[i]<<endl;
		if(s[i]=='D'){
			cd++;
		}
		if(s[i]=='M'){
			cntm++;
			cm+=cd;
		}
		if(s[i]=='C'){
			ans+=cm;
		}
		//cout<<cd<<" "<<cm<<" "<<ans<<" "<<cntm<<endl;
	}
	return ans;
}

signed main(){
	int n;
	cin>>n;
	lp(i,n){
		char c;
		cin>>c;
		s.push_back(c);
	}
	int q;
	cin>>q;
	lp(i,q){
		int hoge;
		cin>>hoge;
		cout<<task(hoge)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

LL mod = 998244353;
LL pot(int a, int n)
  {
  if(n == 0)return 1;
  if(n % 2 == 0)return pot((LL)a * a % mod, n/2);
  return pot(a, n-1) * (LL)a % mod;
  }
const int MXN = 2e5+5;
LL sil[MXN];
LL inv[MXN];
int npok(int n, int k)
  {
  return sil[n] * inv[k] % mod * inv[n-k] % mod;
  }


int main()
  {
  ios_base::sync_with_stdio(0); 
  int n, m, k;
  cin >> n >> m >> k;
  sil[0] = 1;
  FOR(i, 1, n)sil[i] = sil[i-1] * i % mod;
  FOR(i, 0, n)inv[i] = pot(sil[i], mod-2);

  LL res = 0;

  FORD(i, n, n-k)
    {
    int takie_same = n - i;

    LL ways = m;
    ways *= pot(m-1, i-1);
    debug(ways);
    ways %= mod;
    ways *= npok(n-1, takie_same);
    debug(ways);
    ways %= mod;
    res += ways;
    res %= mod;
    }
  cout << res << endl;
  }


Measured memory_bytes: 6732
/*
author: orthodoxparadox
27-Aug-2018
00:14:54
*/

#include <bits/stdc++.h>

using namespace std;
#define dbl long double
#define int ll
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define fup(i, a, n) for (ll i = a; i < n; i++)
#define fdw(i, a, n) for (ll i = n-1; i >= a; i--)
#define fnu for(ll i = 0; i < n; i++)
#define fnd for(ll i = n-1; i >= 0; i--)
#define fau(i, v) for(auto i:v)
#define rev(s) reverse(all(s))
#define oill ostream_iterator<ll>(cout, " ")
#define oiint ostream_iterator<int>(cout, " ") 
#define pb emplace_back
#define push_back emplace_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define zero(a) memset(a, 0, sizeof(a))
#define onlyunique(v) v.erase(unique(all(v)), v.end()); //only for sorted vector
// #define x real()
// #define y imag()
typedef complex<double> point;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#ifdef __APPLE__
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " : " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);
}
#else
#define dbg(...)
#endif

int __gcd(int a, int b)
{
	return b ? __gcd(b, a%b) : a;
}

// for set of pairs
struct pair_hash {
    inline std::size_t operator()(const std::pair<int,int> & v) const {
        return v.first*31+v.second;
    }
};

const int mod = 1e9 + 7;

vector<int> binarycut(int x){
	vector<int> v;
	while(x){
		if(x&1) v.pb(1);
		else v.pb(0);
		x>>=1;
	}
	reverse(all(v));
	return v;
}

int takemod(int a){
	return ((a%mod)+mod)%mod;
}

int fast_exp(int base, int expo) {
	int res=1;
	while(expo>0) {
		if(expo&1) res=(res*base)%mod;
		base=(base*base)%mod;
		expo>>=1;
	}
	return res;
}

int modinv(int a){
	return takemod(fast_exp(takemod(a), mod-2));
}

// void siev(int n)
// {
// 	sieve[0]=false;
// 	sieve[1]=false;
// 	for(int i=2; i<=sqrtl(n); i++)
// 	{
// 		if(sieve[i])
// 		{
// 			for(int j=i; i*j<=n; j++)
// 			{
// 			sieve[i*j]=false;
// 			}
// 		}
// 	}
// }

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	#ifdef __APPLE__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
	#endif
	time_t t1, t2;
	t1 = clock();

	int n;
	cin >> n;
	int a[n];
	fnu cin >> a[i];
	cout << *max_element(a, a+n) - *min_element(a, a+n);

	t2 = clock();
	cerr << "time taken: " << t2-t1;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<cstdio>
    using namespace std;
     
    inline int read(){
    	int k=0,f=1;char ch=getchar();
    	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
    	return k*f;
    }
     
    inline void write(int x){
    	if(x<0)x=-x,putchar('-');
    	if(x>9)write(x/10);putchar(x%10+'0');
    }
     
    inline void writeln(int x){
    	write(x);puts("");
    }
     
    int n,m,l,r,vi,fa[100005],v[200005];
     
    inline int get(int x){
    	if(x==fa[x])return x;
    	int f=get(fa[x]);
    	v[x]+=v[fa[x]];
    	return fa[x]=f;
    }
     
    int main(){
    	n=read();m=read();
    	for(int i=1;i<=n;i++)fa[i]=i;
    	for(int i=1;i<=m;i++){
    		l=read();r=read();vi=read();
    		int li=get(l),ri=get(r);
    		if(li!=ri){
    			v[ri]=vi-v[r]+v[l];
    			fa[ri]=li;
    		}else{
    			if(v[r]-v[l]!=vi){
    				cout<<"No\n";
    				return 0;
    			}
    		}
    	}
    	cout<<"Yes\n";
    	return 0;
    }

Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
char a[105],b[105];
int main(){
    int t,i,s,n,m=0,x=0;
    scanf("%s",a);
    scanf("%s",b);
    t=strlen(a);
    s=strlen(b);
    n=t+s;
    for(i=0;i<n;i++){
        if(i%2==0)
            printf("%c",a[m++]);
        else
            printf("%c",b[x++]);

    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1 << 30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << p.first << " " << p.second;
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < (int)v.size(); i++)
        os << v[i] << (i + 1 != v.size() ? " " : "");
    return os;
}

void solve()
{
    ll x;
    cin >> x;
    ll num = 100LL;
    int ans = 0;
    while (num < x)
    {
        num += (num * 0.01);
        ans++;
    }
    cout << ans << endl;
}

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

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

int main() {
  string s, a;
  int ans=0;
  cin >> s;
  for(int bit=0; bit<(1<<3); ++bit) {
    if(bit&(1<<0)){
      ans=(s[0]-'0')+(s[1]-'0');
    }else{
      ans=(s[0]-'0')-(s[1]-'0');
    }
    if(bit&(1<<1)){
      ans= ans+(s[2]-'0');
    }else{
      ans= ans-(s[2]-'0');
    }
    if(bit&(1<<2)){
      ans= ans+(s[3]-'0');
    }else{
      ans= ans-(s[3]-'0');
    }
    if(ans==7) {
      if(bit&(1<<0)){
        cout <<s[0]<<"+"<<s[1];
      }else{
        cout <<s[0]<<"-"<<s[1];
      }
      if(bit&(1<<1)){
        cout <<"+"<<s[2];
      }else{
        cout <<"-"<<s[2];
      }
      if(bit&(1<<2)){
        cout <<"+"<<s[3];
      }else{
        cout <<"-"<<s[3];
      }
      cout <<"=7"<<endl;
      break;
        }
        }
        }


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

ans = 0

while max(A) >= N:
    maxIndex = A.index(max(A))
    cnt = A[maxIndex] // N
    for i in range(N):
        if i == maxIndex:
            A[i] -= N * cnt
        else:
            A[i] += cnt
    ans += cnt

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int a = scan.nextInt();

		int ans = 0;
		if(h % a == 0) {
			ans = h/a;
		}else {
			ans = h/a + 1;
		}


		System.out.println(ans);

	}

}

Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
  int x;
  cin >> x;
  if(x == 0)cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
	char arr[3];
	int i = 3, temp_a=0, temp_b=0;
	cin>>arr;
	for(i=0; i<3; i++){
		if(arr[i]=='A') temp_a=1; 
		if(arr[i]=='B') temp_b=1;
	}
	if(temp_a==1&&temp_b==1)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
num = gets.split.map(&:to_i)
heights = gets.split.map(&:to_i)
routes = []
num[1].times do
  routes << gets.split.map(&:to_i)
end

losers = []
routes.each do |r|
  if heights[r[0] - 1] > heights[r[1] - 1]
    losers << r[1]
  elsif heights[r[0] - 1] < heights[r[1] - 1]
    losers << r[0]
  else
    losers << r[0]
    losers << r[1]
  end
end
puts num[0] - losers.uniq.length

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

namespace ConsoleApp74
{
    class Program
    {
        static void Main(string[] args)
        {
            string[]abx = Console.ReadLine().Split(' ');
            long a = long.Parse(abx[0]);
            long b = long.Parse(abx[1]);
            long x = long.Parse(abx[2]);

            long count= 0;
            long c = b / x - a / x;
            if (a % x == 0)
            {
                Console.WriteLine(c + 1);
            }
            else
            {
                Console.WriteLine(c);
            }
        }
    }
}

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

using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    int n; cin >> n;
    vector<int> a(n); for (int& x : a) cin >> x;

    multiset<int> s;
    s.insert(-INT_MAX);
    for (int i = 0; i < n; i++) {
        auto it = s.lower_bound(a[i]);
        if (it == s.begin()) {
            s.insert(a[i]);
        } else {
            it--;
            s.erase(it);
            s.insert(a[i]);
        }
    }
    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 5376
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << "\n";
	} else if (a == b) {
		cout << "a == b" << "\n";
	} else if (a < b) {
		cout << "a < b" << "\n";
	}
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        String s = sc.next();

        char c1 = s.charAt(k-1);
        String c2 = (String.valueOf(c1)).toLowerCase();

        String before = s.substring(0, k-1);
        String after = s.substring(k, s.length());

        System.out.println(before + c2 + after);

    }

}

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

int main(){
	int res,a;
	while(true){
		cin>>res;
		if(res==0) break;
		for(int i=0;i<9;i++){
			cin>>a;
			res-=a;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
M,z,s=998244353,1,0
d=[1]+[0]*7**6
e=d[:]
for _ in'_'*input():
 a=input();s+=a;i=s;z*=3
 while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1
print(z+~s%2*e[s//2]*3-3*sum(d[-~s//2:]))%M

Measured memory_bytes: 157860
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s;
	string c;
	int na[26]={0};
	int ans=-1;
	int i=0,j=0;
	cin>>s;
	for(i=0;i<s.length();i++)
	{
		na[s[i]-'a']=1;
	}
	if(s.length()<26)
	{
		for(i=0;i<26;i++)
		{
			if(na[i]==0)
			{
				c=char('a'+i);
				break;
			}
		}
		cout<<s<<c;
	}
	else
	{
		for(i=25;i>=0;i--)
		{
			for(j=int(s[i]-'a');j<26;j++)	
			{
				if(na[j]==0)
				{
					s[i]=char('a'+j);
					ans=0;
					break;
				}
			}
			if(ans==-1)
			{
				na[s[i]-'a']=0;
			}
			else if(ans==0)
			{
				break;
			}
		}
		if(i==-1)
		{
			cout<<ans;
		}
		else
		{
			for(j=0;j<=i;j++)
			{
				cout<<s[j];
			}
		}		
	}
	
	return 0;
}

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

int main(void)
{
    using namespace std;
    double r;
    double pi = 3.141592653589;
    scanf("%lf", &r);
    printf("%lf %lf\n", (r * r * pi), (2 * r * pi));
    // これでも円周率出せる printf("%lf", M_PI);
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100003;
typedef pair<int,int> PII;
int n;
struct Vec{
	int x,y,id;
}a[MaxN];
inline bool cmp_x(const Vec& a,const Vec& b) { return a.x<b.x; }
inline bool cmp_y(const Vec& a,const Vec& b) { return a.y<b.y; }
struct Edge{
	int u,v,cost;
	inline bool operator < (const Edge& o) const { return cost<o.cost; }
}e[MaxN*2];
int tot;

int fa[MaxN],rk[MaxN];
int getfa(int x) {
	if (fa[x]!=x) fa[x]=getfa(fa[x]);
	return fa[x];
}

inline void uni(int a,int b) {
	a=getfa(a),b=getfa(b);
	if (a!=b) {
		if (rk[a]<rk[b]) {
			fa[a]=b;
			rk[b]+=a;
		} else {
			fa[b]=a;
			rk[a]+=b;
		}
	}
}

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) {
		int x,y;
		scanf("%d%d",&x,&y);
		a[i].x=x,a[i].y=y,a[i].id=i;
	}
	sort(a+1,a+n+1,cmp_x);
	for (int i=2;i<=n;++i) {
		tot++;
		e[tot].u=a[i-1].id,e[tot].v=a[i].id,e[tot].cost=abs(a[i-1].x-a[i].x);
	}
	sort(a+1,a+n+1,cmp_y);
	for (int i=2;i<=n;++i) {
		tot++;
		e[tot].u=a[i-1].id,e[tot].v=a[i].id,e[tot].cost=abs(a[i-1].y-a[i].y);
	}
	for (int i=1;i<=n;++i) fa[i]=i,rk[i]=1;
	sort(e+1,e+tot+1);
	long long ans=0;
	for (int i=1;i<=tot;++i) {
		int u=e[i].u,v=e[i].v,c=e[i].cost;
		if (getfa(u)!=getfa(v)) {
			ans+=c;
			uni(u,v);
		}
	}
	printf("%I64d\n",ans);
	return 0;
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

int main(){
    int R, G, B, n; cin >> R >> G >> B >> n;
    int ans = 0;
    REP(i, 0, n/R+1){
        REP(l, 0, n/G+1){
            int k = i * R + l * G;
            if(n-k >= 0 && (n-k)%B == 0){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

int main(){

    int n;
    cin >> n;
    // vector<long long int> A(n);
    map<long long int, long long int> L;

    long long int tmp = 0;
    long long int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> tmp;
        long long int R = i + 1 - tmp;
        auto itr = L.find(R);
        if (itr != L.end())
        {
            ans += L[R];
        }
        L[i + 1 + tmp]++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16116
#include <stdio.h>
#include <algorithm>
#include <limits.h>
#define SIZE 100005

   long long int dp[SIZE], h[SIZE];
   int main(void) {
        int n,k;
        scanf("%d %d",&n,&k);
        for(int i=1; i<=n; i++) {
             scanf("%lld",&h[i]);
             dp[i] = INT_MAX;
        }

        dp[0] = INT_MAX, dp[1] = 0;
        for(int i=2; i<=n; i++) {
              long long int min = INT_MAX;
              for(int j=1; j<=k; j++) if(i-j>=0) min = std::min(min,dp[i-j]+std::abs(h[i]-h[i-j]));

              dp[i] = min;
        }

        printf("%lld",dp[n]);
        return 0;
   }






Measured memory_bytes: 1664
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

cnt = defaultdict(int)
for a in A:
    cnt[a] += 1

if cnt[0] == N:
    print('Yes')
    exit()
if N % 3:
    print('No')
    exit()

nums = []
for p, q in cnt.items():
    for i in range(q // (N // 3)):
        nums.append(p)

if len(nums) == 3 and (nums[0] ^ nums[1] ^ nums[2] == 0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N ;
  cin >> N ;
  int A[210];

  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int count = 0;
  while(true){  
    bool b = false;
    for(int i = 0; i< N; i++){
    if(A[i]%2 == 1)b = true;
    }
    if(b)break;
    
     for(int i = 0; i< N; i++){
       A[i]= A[i]/2;
     }
     count = count + 1;  
   }

  
  cout << count <<endl;
}

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

// a[n]を求める問題

int f(int n){   //再帰関数
    if(n == 1) return 1;
    if(n == 2) return 2;
    if(n == 3) return 4;
    // f(n) = f(n-1) + f(n-2) + f(n-3)
    return f(n-1) + f(n-2) + f(n-3);
}
int main(void){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << (f (n) / 3650)+1 << endl;
    }
}



Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, A[100005];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> A[i];
  
  int cnt = 0;
  bool flag = false;
  rep(i, N) {
    if (A[i]==i+1) {
      if (flag) {
        cnt++;
        flag =false;
      } else flag =true;
    } else {
      if (flag) cnt++;
      flag = false;
    }
  }
  if (flag) cnt++;

  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int64 N, W, w[100], v[100];

int main() {

    cin >> N >> W;
    for (int j = 0; j < N; ++j) {
        cin >> w[j] >> v[j];
    }

    vector<int> vs[4];
    for (int j = 0; j < N; ++j) {
        vs[w[j] - w[0]].push_back(v[j]);
    }
    for (int j = 0; j < 4; ++j) {
        sort(begin(vs[j]), end(vs[j]));
        reverse(begin(vs[j]), end(vs[j]));
    }

    int64 ans = 0;
    for (int u = 0; u <= vs[0].size(); ++u) {
        for (int x = 0; x <= vs[1].size(); ++x) {
            for (int y = 0; y <= vs[2].size(); ++y) {
                for (int z = 0; z <= vs[3].size(); ++z) {
                    int64 weight = u * w[0] + x * (w[0]+1) + y * (w[0]+2) + z * (w[0]+3);
                    if (weight > W) continue;

                    int64 sv = 0;
                    for (int j = 0; j < u; ++j) { sv += vs[0][j]; }
                    for (int j = 0; j < x; ++j) { sv += vs[1][j]; }
                    for (int j = 0; j < y; ++j) { sv += vs[2][j]; }
                    for (int j = 0; j < z; ++j) { sv += vs[3][j]; }

                    ans = max(ans, sv);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

// Union-Find木
template<typename Abel>//加減可能のアーベル群
class UnionFind{
protected:
    vector<int> par;//親ノード
    vector<Abel> pod;//ポテンシャル
    Abel O=0;
public:
    UnionFind(int n,Abel zero=0) : par(n,-1),pod(n,zero){
        O=zero;
    }

    //根を求める（同時に経路圧縮）
    int root(int x){
        if(par[x]<0) return x;
        int r = root(par[x]);
        pod[x] +=pod[par[x]];
        return par[x]=r;
    }

    //根が等しいか判定
    bool issame(int x,int y){
        return root(x)==root(y);
    }

    //マージ
    bool unite(int base,int x){
        return unite(base,x,O);
    }
    bool unite(int base,int x,Abel pd){
        pd -=p(x) - p(base);
        base=root(base);x=root(x);
        if(base==x)return false;
        if(par[base]>par[x]) std::swap(base,x),pd=-pd;
        //baseがxの親になる
        par[base] +=par[x];//根は-(size)
        par[x]=base;
        pod[x]=pd;
        return true;
    }

    //属す根のサイズ
    int size(int x){
        return -par[root(x)];
    }

    //要素のポテンシャル
    Abel p(int x){
        root(x);//経路圧縮
        return pod[x];
    }

    //要素の相対ポテンシャル
    Abel diff(int base,int x){
        if(issame(base,x)) return pod[x]-pod[base];
        return 0;//同箇所にない場合は未定義
    }
};

int main() {
    int N,M,L;
    cin >>N>>M;

    UnionFind<int> hito(N);
    int l,r,d;
    rep(i,M){
        cin >> l>>r>>d;
        l--;r--;
        if(hito.issame(l,r)){
            int diff=hito.diff(l,r);
            if(diff!=d){
                cout <<"No"<<endl;
                return 0;
            }
        }else{
            hito.unite(l,r,d);
        }
    }
    //-----------------------------------
    cout << "Yes" <<endl;
    return (0);
}

Measured memory_bytes: 1024