akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
std::vector<std::vector<long long>> combTableByPascalsTriangle(
    int n) { /*パスカルの三角形を利用した組合せの前計算。O(N^2)。 * arg... *
                int n: 組合せ計算したい要素の個数。nCrで指定しうる最大のn *
                return... *  vector<vector<long long>> c :
                組合せ計算nCrの結果がc[n][r]に入っている。 */
  auto c = std::vector<std::vector<long long>>(
      n + 1, std::vector<long long>(n + 1, 0));
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (j == 0 or j == i) {
        c[i][j] = 1LL;
      } else {
        c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]);
      }
    }
  }
  return c;
}
#include <iostream>
// http://drken1215.hatenablog.com/entry/2018/06/08/210000
using namespace std;

const int MAX = 1e6+1;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  int X, Y;
  cin >> X >> Y;
  int a = (2 * X - Y) / 3;
  int b = X - 2 * a;
  if ((2 * X - Y )% 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  COMinit();
  cout<<COM(a+b,a)<<endl;

  return 0;
}


Measured memory_bytes: 23680
#include <cstdio>
#include <cstdlib>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

int N;
bool fl = true;

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

  int pt = 0, px = 0, py = 0;
  rep( i, N )
  {
    int t, x, y;
    scanf( "%d%d%d", &t, &x, &y );

    int diff = (t-pt)-abs(x-px)-abs(y-py);
    
    fl &= diff >= 0 && diff % 2 == 0;

    pt = t;
    px = x;
    py = y;
  }

  puts( fl ? "Yes" : "No" );

  return 0;
}

Measured memory_bytes: 128
from collections import defaultdict

n = int(input())

a = [0] + [int(x) for x in input().split()]

d = defaultdict(int)

tmp = 0

for x in a:
    tmp += x
    d[tmp] += 1

ans = 0

for k,v in d.items():
    if v >= 2:
        ans += v * (v - 1) // 2

print(ans)

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

int main() {
    int n, max2;
    cin >> n;
    vector <int> v(n);
    for (int i=0; i<n; i++)
        cin >> v[i];
    vector <int> w = v;
    sort(v.begin(), v.end());
    int max1Index = max_element(v.begin(), v.end()) - v.begin();
    int max1 = v[max1Index];
    if (max1Index==0)
        max2 = max1;
    else
        max2 = v[max1Index-1];
    
    int nbmax = v.size()-max1Index;

    for (int i=0; i<n; i++)
    {
        if (w[i]==max1 && nbmax==1)
            cout << max2 << "\n";
        else
            cout << max1 << "\n";
    }
    return 0;
}

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

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

  if (A == B == K) {
    cout << "OK" << endl;
  }
  //else if (B - (B % K) != K){
  else if ((B - (B % K)) >= A && (B - (B % K)) <= B) {
    cout << "OK" << endl;
  }
  else {
    cout << "NG" << endl;
  }

}

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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N, D, ans, tmp;
    cin >> N >> D >> ans;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        ans += (D - 1) / tmp + 1;
    }
    cout << ans;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int D, G;
int p[10], c[10];
int min_n = 1000;

vector<int> toVec(int c){
    VI res;
    REP(i,D){
        res.PB(c%2);
        c /= 2;
    }
    return res;
}

int toBit(int c){
    int res = 1;
    REP(i,c-1) res <<= 1;
    return res;
}

void dfs(int d, int sum, int num, int count){

    if(d > D) return;

    dfs(d+1, sum, num, count);
    dfs(d+1, sum + 100*(d+1)*p[d]+c[d], num + p[d], count + toBit(d+1));

    if(d == D){
        if(sum >= G && min_n > num) min_n = num;
        VI v = toVec(count);
        REP(i,D){
            if(v[i] == 0){
                int n = ceil((G-sum)/(100*(i+1)));
                if(n > 0 && n < p[i] && min_n > num+n){
                    min_n = num+n;
                }
            }
        }
    }

    return;
}

int main(void){

    cin >> D >> G;
    REP(i,D) cin >> p[i] >> c[i];

    dfs(0, 0, 0, 0);
    cout << min_n << endl;

    return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin>>n;

    map<string,int> subs;

    vector<int> freq(26,100);

    rep(i,n){
        string si;
        cin>>si;

        vector<int> tmp(26,0);
        
        rep(j,si.length()){
            tmp[ (si[j])-('a') ]++;
        }

        rep(j,26)chmin(freq[j],tmp[j]);
    }

    bool exAns=false;
    rep(i,26)if(freq[i]>0)exAns=true;

    string ansS="";
    if(exAns){
        rep(i,26)rep(j,freq[i]){
            ansS += ('a'+i);
        }
    }
    cout<<ansS<<endl;
    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
res = 0
l = [0 for i in range(N)]
for i in range(N):
    l[i] = int(input())
    if i > 0 and l[i] >= 1 and l[i - 1] % 2 == 1:
        res += 1
        l[i] -= 1
    res += l[i] // 2
print(res)


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

using namespace std;
const int INF = 1e9;
const int MAXN = 2005;
vector<int> G[MAXN];
int n, x, y;

vector<int> bfs(int start) {
  queue<int> q;
  vector<int> dist(n, INF);
  dist[start] = 0;
  q.push(start);
  while (!q.empty()) {
    int cur = q.front(); q.pop();
    for (int next: G[cur]) {
      if (dist[next] == INF) {
	q.push(next);
	dist[next] = dist[cur] + 1;
      }
    }
  }
  return dist;
}

int main() {
  cin >> n >> x >> y;
  x--;
  y--;
  for (int i = 0; i < n - 1; ++i) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  G[x].push_back(y);
  G[y].push_back(x);

  map<int, int> m;
  for (int i = 1; i < n; ++i) {
    m[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    vector<int> dist = bfs(i);
    
    for (int j = i + 1; j < n; ++j) {
      m[dist[j]]++;
    }
  }

  for (auto &e: m) {
    cout << e.second << '\n';
  }
  return 0;
}



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

#define ll long long
#define endl "\n"
#define int ll

signed main ()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin >> s;

	int a = 0, b = 0;
	for (char c : s) {
		a += (c == 'A');
		b += (c == 'B');
	}

	if (a and b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}


Measured memory_bytes: 3608
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
#include<fstream>
const ll INF=9223372036854775807;
const ll mod=998244353
;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
int main()
{
    fastio;
    int n;
    cin>>n;
    map<string,int> g;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        string str;
        cin>>str;
        sort(all(str));
        ans+=g[str];
        g[str]++;
    }
    cout<<ans;
}


Measured memory_bytes: 11264
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        System.out.println( solve(X) );
    }

    private static int solve(int X) {
        int max = 1;
        int B = (int)Math.floor(Math.sqrt(X));

        loop: for (int b = 2; b <= B ; b++) {
            for (int p = 2; p < 100; p++) {
                int r = (int)Math.pow(b, p);
                if( r > X ) {
                    continue loop;
                }
                max = Math.max((int)Math.pow(b, p), max);
            }
        }
        return max;
    }
}


Measured memory_bytes: 23764
A, B, M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(M)]

ans = [min(a) + min(b)]
for x in X:
    a_idx, b_index, c = x
    ans.append(a[a_idx - 1] + b[b_index - 1] - c)

print(min(ans))

Measured memory_bytes: 42448
// alds1_2_a bubble sort
#include <iostream>
using namespace std;

int cnt = 0;

void printline(int a[], int n, int cnt){
    // cout << cnt << " > " ;
    for(int i=0; i<n; i++){
        cout << a[i] ;
        if (i != n-1){ cout << " ";}
    }
    cout << endl;
}

void selectionSort(int a[], int n){
    int minj, temp;
    for(int i=0; i<n; i++){
        minj = i;
        for(int j=i; j<n; j++){
            if(a[j] < a[minj]){ minj = j; }
        }
        temp = a[i];
        a[i] = a[minj];
        a[minj] = temp;

        if(i != minj){cnt++;}
    }
    printline(a,n,cnt);
}



int main(){
    int i,n;
    int a[100];

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

    selectionSort(a, n);
    
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    deque<int> ans;
    if (n % 2 != 0)
    {
        rep(i, n)
        {
            if (i % 2 == 0)
            {
                ans.push_front(a[i]);
            }
            else
            {
                ans.push_back(a[i]);
            }
        }
    }
    else
    {
        rep(i, n)
        {
            if (i % 2 == 0)
            {
                ans.push_back(a[i]);
            }
            else
            {
                ans.push_front(a[i]);
            }
        }
    }
    rep(i, n)
    {
        cout << ans.front();
        ans.pop_front();
        if (ans.empty())
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}

void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    go();
    return 0;
}
/****************ackun*********************/
void go(){
    vi a;
    rep(i,1,5){
        int x;
        R(x);
        a.pb(x);
    }
    sort(a.begin(),a.end());
    int k;
    R(k);
    if(a[4]-a[0]>k){
        W(":(");
    }else{
        W("Yay!");
    }
}


Measured memory_bytes: 256
S = input()
Ans = 0
box = []

for i in range(2 ** (len(S)-1)):  # 文字の間に挿入するので、len(S)-1
    for j in range((len(S)-1)):
        box.append(S[j])
        
        if (i >> j) & 1:
            Ans += int("".join(box))
            box.clear()
            
    box.append(S[-1])
    Ans += int("".join(box))
    box.clear()

print(Ans)

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

int main(){
	int H, W;
	
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++){
			for (int k = 0; k < W; k++){
				if ((i + k) % 2 == 0){
					cout << '#';
				}
				else{
					cout << '.';
				}
			
			}
			cout << endl;
		}
		cout << endl;
	}
	

	return 0;
}

Measured memory_bytes: 3120
#include<stdio.h>
#include<string.h>
#define Max(x,y) ((x>y)?x:y)
#define min(x,y) ((x<y)?x:y)
int r[105][105],v[105],u[105],x,y;
int main(){
	int i,j,k,n,s,a,b,c;
	while(1){
		scanf("%d%d",&n,&k);
		if(n==0)break;
		for(i=1;i<=n;i++)for(j=1;j<=n;j++)r[i][j]=1000000000;
		while(k--){
			scanf("%d",&s);
			if(s==0){
				scanf("%d%d",&a,&b);
				for(i=1;i<=n;i++)v[i]=1000000000,u[i]=-1;
				v[a]=0;
				y=a;
				while(1){
					x=-1;
					for(i=1;i<=n;i++){
						if(u[i]==-1 && (x==-1 || v[i]<v[x]))x=i;
					}
					if(x==-1)break;
					u[x]=0;
					for(i=1;i<=n;i++){
						v[i]=min(v[i],v[x]+r[x][i]);
					}
				}
				printf("%d\n",(v[b]==1000000000)?-1:v[b]);
			}else{
				scanf("%d%d%d",&a,&b,&c);
				r[a][b]=r[b][a]=min(c,r[a][b]);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 456
n,h=map(int,input().split())
a=[]
b=[]
for i in range(n):
  a_,b_=map(int,input().split())
  a.append(a_)
  b.append(b_)
  
use_a=max(a)
kouho=[]
for i in b:
  if i>=use_a:
    kouho.append(i)
kouho.sort(reverse=True)

ans=0
cnt=0
for i in kouho:
  cnt+=i
  ans+=1
  if cnt>=h:
    print(ans)
    exit()
    
if (h-cnt)%use_a==0:
  print(ans+(h-cnt)//use_a)
else:
  print(ans+(h-cnt)//use_a+1)
  
  
  
  
  
  
  
  
  

Measured memory_bytes: 91992
while line = gets
  n, x = line.chomp.split.map(&:to_i)
  break if n == 0 && x == 0
  answer = 0
  (1..(n-2)).each do |i|
    ((i+1)..(n-1)).each do |j|
      ((j+1)..n).each do |k|
        if i + j + k == x
          answer += 1
        end
      end
    end
  end
  puts answer
end



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

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

typedef long long LL;

int main(){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
i<jでjが左に落ちるならiも必ず落ちる
落ちる場所で２分探索する。
壁を逆から辿る嘘解法は反例あり
*/

ll n,q,ans=0;
string s;
char t[200010],d[200010];

bool f(ll p,ll a){
	bool ok=false;
	rep(i,q){
		if(t[i]==s[p]){
			if(d[i]=='R'){
				p++;
			}else{
				p--;
			}
		}
		if((a==0 && p==0)||(a==1 && p==n+1)){
			ok=true;
			break;
		}
	}
	return ok;
}

int main(void){
	cin>>n>>q>>s;
	s=" "+s;
	rep(i,q)cin>>t[i]>>d[i];
	if(f(1,0)){
		if(f(n,0)){
			ans=n;
		}else{
			ll ok=1,ng=n;
			while(ng-ok>1){
				ll mid = (ng+ok)/2;
				if(f(mid,0)){
					ok=mid;
				}else{
					ng=mid;
				}
			}
			ans+=ok;
		}
	}
	if(f(n,1)){
		if(f(1,1)){
			ans=n;
		}else{
			ll ok=n,ng=1;
			while(ok-ng>1){
				ll mid = (ng+ok)/2;
				if(f(mid,1)){
					ok=mid;
				}else{
					ng=mid;
				}
			}
			ans+=n+1-ok;
		}
	}
	cout<<n-min(n,ans)<<endl;
	return 0;
}
/*
3 4
ABC
B R
C R
B L
A L
*/

Measured memory_bytes: 984
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);
typedef pair<ll, pair<ll, ll>> piii;
int main() {
    // record dp[city][silver_coins], dijkstra to find shortest path
    int n, m, s;
    map<pair<int, int>, int> dp;
    int u, v, a, b, c, d;
    cin >> n >> m >> s;
    vector<vector<int>> cost_t(n, vector<int>(n, -1));
    vector<vector<int>> cost_c(n, vector<int>(n, INT_MAX));
    int a_max = 50;
    for(int i = 0; i < m; i++) {
        cin >> u >> v >> a >> b;
        cost_c[u-1][v-1] = cost_c[v-1][u-1] = a;
        cost_t[u-1][v-1] = cost_t[v-1][u-1] = b;
    }
    for(int i = 0; i < n; i++) {
        cin >> c >> d;
        cost_c[i][i] = -c;
        cost_t[i][i] = d;
    }
    vector<ll> ans(n, 1e15);
    ll upper = a_max*(n-1);
    priority_queue<piii, vector<piii>, greater<piii>> pq;
    pq.push({0ll, {0ll, min(ll(s), ll(upper))}});
    int visit_cnt = 0;
    while(!pq.empty()) {
        auto [cost, state] = pq.top();
        auto city = state.first;
        auto coin = state.second;
        pq.pop();
        if (dp.count({city, coin}) > 0) {
            continue;
        }
        dp[{city, coin}] = cost;
        if (ans[city] == 1e15) {
            ans[city] = cost;
            if (++visit_cnt == n)
                break;
        }
        for(int i = 0; i < n; i++) {
            ll nxt_coin = min(upper, coin - cost_c[city][i]);
            if (cost_t[city][i] != -1 && nxt_coin >= 0) {
                ll nxt_time = cost+cost_t[city][i];
                if (dp.count({i, nxt_coin}) == 0) {
                    pq.push({nxt_time, {i, nxt_coin}});
                }
            }
        }
    }
    for(int i = 1; i < n; i++)
        cout << ans[i] << endl;
    return 0;
}




Measured memory_bytes: 13988
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef int ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())  // find in a vector
#define findsm(u, x) (u.find(x) != u.end())       // find in a set / map
#define findstr(s, x) (s.find(x) != string::npos) // find in a string
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e5, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
char c;

//<<-----Implement Functions Here---->>//
void solve()
{
    in(c)
	if (islower(c))
        out('a')
    else
        out('A')
}

//<<----------Start of Main---------->>//
int main()
{
    fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int a, b;
    cin >> a >> b;
    if(a+b < 10){
        cout << a + b << endl;
    } else {
        cout << "error" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){


ll int unko;
unko = 0;
ll int N;

cin >> N;
unsigned long long int A[N+1];
unsigned long long int ans;
ans =1;
ll int keta,keta2;
ll int a;


rep(i,N){
	keta =0;
	keta2=0;
	cin >> A[i];
	a = A[i];
	if(A[i]==0){
		cout << "0";
		return 0;
	}
	else{
	 while(a!=0){
		 a = a/10;
		 keta+=1;
	 }
	 if(keta>=19){
		 unko = 1;
	 }
	}
	a=ans;
        while(a!=0){
		a=a/10;
		keta2+=1;
	}

	if(keta+keta2>19){
		unko = 1;
	}

	else {
	}
	ans = ans * A[i];
}



	if(unko==0 && ans>0 && ans<1000000000000000000){
		cout << ans;
	}
	else if(ans == 1000000000000000000){
		cout << ans;
	}
	else{
		cout << "-1";
	}







	return 0;

}



Measured memory_bytes: 4380
def main(arg):
    arg = str(arg)
    numbers = [int(x)for x in arg.split(" ")]
    a,b = numbers[0],numbers[1]
    if a > b:
        return "a > b"
    elif a < b:
        return "a < b"
    elif a == b:
        return "a == b"
    return False


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

Measured memory_bytes: 7692
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP((i),0,(n))
#define ALL(v) (v).begin(),(v).end()

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * a - b << endl;
}

Measured memory_bytes: 256
var x = require('fs').readFileSync('/dev/stdin', 'utf8');

var array = x.split(" ").map(Number);

var a = array[0];
var b = array[1];
var c = array[2];

var count = 0;

for ( var i = a; i <= b; i++) {
    if(c % i === 0) count++;
}

console.log(count);



Measured memory_bytes: 15148
use proconio::{input, fastout};

fn answer(links: std::vec::Vec<std::vec::Vec<bool>>, n: usize) {
    for i in 0..n {
        for j in (i+1)..n {
            if links[i][j] {
                println!("{} {}", i+1, j+1);
            }
        }
    }
}

fn main() {
    input!{
        (n, k): (usize, usize)
    };

    let mut cnt = (n-1) * (n-2) / 2;
    let mut m = 0;
    if k>cnt {
        println!("-1");
        return;
    }

    let mut links = vec![vec![false; n]; n];
    for j in 0..(n-1) {
        m += 1;
        links[n-1][j] = true;
        links[j][n-1] = true;
    }

    'all: for i in 0..(n-1) {
        for j in (i+1)..(n-1) {
            if cnt==k {
                break 'all;
            } else {
                links[i][j] = true;
                links[j][i] = true;
                cnt -= 1;
                m += 1;
            }
        }
    }

    println!("{}", m);
    answer(links, n);
}

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

int main() {
    string date;
    cin >> date;
    
    string year_s = date.substr(0, 4);
    string month_s = date.substr(5, 2);
    string day_s = date.substr(8, 2);

    int year = stoi(year_s);
    int month = stoi(month_s);
    int day = stoi(day_s);

    if(month > 4) {
        cout << "TBD" << endl;
    } else {
        cout << "Heisei" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define BMAX 31
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  int L;
  cin >> L;
  vector<vector<int>> grh(BMAX, vector<int>(n));
  int j = 0;
  for (int i = 0; i < n; i++) {
    while (j < n && x[i] + L >= x[j]) j++;
    grh[0][i] = j - 1;
  }
  for (int p = 1; p < BMAX; p++) {
    for (int i = 0; i < n; i++) {
      grh[p][i] = grh[p - 1][grh[p - 1][i]];
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    int ret = 0;
    for(int p = BMAX - 1; p >= 0; p--) {
      if (grh[p][a] < b) {
        a = grh[p][a];
        ret += (1 << p);
      }
    }
    ret++;
    cout << ret << '\n';
  }
  return 0;
}

Measured memory_bytes: 13432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
  int N;
  cin >> N;
  for(int i = 1; i < 10; i++) {
    for(int j = 1; j < 10; j++) {
      if(i * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = [input() for i in range(N)]

M = int(input())
t = [input() for j in range(M)]

str_list = set(s + t)

X = 0

for i in str_list:
  tmp = 0
  for j in s:
    if i == j:
      tmp += 1
  for j in t:
    if i == j:
      tmp -= 1
  if tmp > X:
    X = tmp

print(X)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read() {
	int x(0),neg(1);char ch(getchar());
	while(ch<'0'||ch>'9') {
		if (ch=='-') neg=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*neg;
}
int a,b,cnt=1,ans;
signed main() {
	a=read(),b=read();
	while(cnt<b) {
		++ans;
		cnt+=a-1;
	}
	cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

struct UnionFind{
    int sz;     // vertex number
    vector<int> par;
    vector<int> rank;

    UnionFind(int n) : sz(n) {
        par.resize(sz);
        rank.assign(sz, 0);
        for(int i = 0; i < sz; ++i){
            par[i] = i;
        }
    }

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

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y)  return;
        if(rank[x] < rank[y])   par[x] = y;
        else{
            par[y] = x;
            if(rank[x] == rank[y])  ++rank[x];
        }
    }
};

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

    int N, K, L;
    cin >> N >> K >> L;
    UnionFind uf(N), uf2(N);
    for(int i = 0; i < K; ++i){
        int p, q;
        cin >> p >> q;
        --p, --q;
        uf.unite(p, q);
    }
    for(int i = 0; i < L; ++i){
        int r, s;
        cin >> r >> s;
        --r, --s;
        uf2.unite(r, s);
    }
    map<P, int> c;
    for(int i = 0; i < N; ++i){
        ++c[P(uf.find(i), uf2.find(i))];
    }
    for(int i = 0; i < N; ++i){
        cout << c[P(uf.find(i), uf2.find(i))];
        cout << ((i == N - 1) ? '\n' : ' ');
    }
}

Measured memory_bytes: 17544
// ALDS1_2_B 選択ソート

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  int *A = new int[N];
  for (int i = 0; i < N; i++)
    cin >> A[i];

  int xCount = 0;
  for (int i = 0; i < N; i++){
    int minj = i;
    for (int j = i; j < N; j++){
      if (A[j] < A[minj]){
        minj = j;
      }
    }
    if (i != minj){
      swap(A[i], A[minj]);
      xCount++;
    }
  }

  for (int i = 0; i < N; i++){
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << xCount << endl;

  delete[] A;
  return 0;
}



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

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define gcd(x, y) __gcd((x), (y))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 3e3+5;

int n;
ld p[N], dp[N][N], ans;

int main () {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%Lf", &p[i]);
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        dp[i][0] = dp[i-1][0]*(1-p[i]);
        for (int j = 1; j <= i; j++) {
            dp[i][j] = dp[i-1][j-1]*p[i] + dp[i-1][j]*(1-p[i]);
        }
    }
    for (int j = n; 2*j > n; j--) ans += dp[n][j];
    printf("%.10Lf\n", ans);
    return 0;
}


Measured memory_bytes: 139264
n,m,x = list(map(int,input().split()))

l = [list(map(int,input().split())) for i in range(n)]

ans=10**9
for i in range(2**n):
    s = str(bin(i))
    s = s[2:]
    s = "0"*(n-len(s))+s

    flag=True
    tmp=0
    p = [0]*m
    for j in range(n):
        if s[j]=="0":
            continue
        tmp+=l[j][0]
        for k in range(m):
            p[k]+=l[j][k+1]
    for j in p:
        if j<x:
            flag = False
            break
    if flag:
        ans = min(tmp,ans)

if ans==10**9:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9244
from collections import defaultdict

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

di = defaultdict(lambda: 0)

for i in d:
    di[i] += 1
      
ans = "YES" 
      
for i in t:
    if (i not in di) or (di[i] == 0):
        ans = "NO"
        break
    else:
        di[i] -= 1
         
print(ans)

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

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;

    if ((x - a <= b) && a <= x) 
        cout << "YES" << endl;
    else
        cout << "NO" << endl;


    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int cnt[N + 1];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n, k, q;
    cin >> n >> k >> q;
    int a[n + 1];
    int res = 0;
    FOR(i, 1, q)
    {
        int x;
        cin >> x;
        cnt[x]++;
    }
    FOR(i, 1, n)
    {
        if(k - (q - cnt[i]) > 0) cout << "Yes";
        else cout << "No";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
n = int(input())

count = 0
for i in range(1, n + 1):
  check = 0
  if(i % 2 == 1):
    for j in range(1, i + 1):
      if(i % j == 0):
        check += 1
  
  if(check == 8):
    count += 1

print(count)


Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
long long int a[200001],n,k,b[200001],maxs;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        b[a[i]]+=1;
    }
    sort(b,b+200001);
    reverse(b,b+200001);
    int de=n;
    for(int i=0;i<k;i++){
        de-=b[i];

    }



    cout<<de<<endl;;



}


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

int main() {
  string s, t, u;
  cin >> s >> t;
  
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  
  if(s < t) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
N,X,Y = map(int,input().split())
Alist = [[0 for i in range(N)] for j in range(N)]
p = [0 for i in range(N)]
for i in range(N):
    for j in range(i,N):
        k = min(j-i,abs(X-1-i)+abs(Y-1-j)+1)
        p[k] = p[k] + 1        
for s in range(1,N):
    print(p[s])

Measured memory_bytes: 35828
#include<stdio.h>
int main()
{
    int c[501],s[501],f[501];
    int n,i,j;
    scanf("%d",&n);
    for(i=1;i<n;i++){
        scanf("%d%d%d",&c[i],&s[i],&f[i]);
    }
    for(i=1;i<=n;i++){
        int x=0;
        for(j=i;j<n;j++){
            if(x<s[j])
                x=s[j];
            if(x%f[j]!=0)
                x=x+f[j]-x%f[j];
            x+=c[j];
        }
        printf("%d\n",x);
    }
}

Measured memory_bytes: 128
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][][] x = new int[N][N][2];
        int[] A=new int[N];
        int max=0;
        
        for(int i=0;i<N;i++) {
        	A[i] = sc.nextInt();
        	for(int j=0;j<A[i];j++) {
        		x[i][j][0]= sc.nextInt()-1;
        		x[i][j][1]= sc.nextInt();
        	}
        }
        int[] p = new int[N];
        
        for(int i=0;i<Math.pow(2, N);i++) {
    		int tmp=i;
        	for(int j=0;j<N;j++) {
        		if(tmp%2==0) {
        			p[j]=0;
        		} else {
        			p[j]=1;
        		}
        		tmp=tmp/2;
        	}
        	
    		boolean flg=true;
        	for(int j=0;j<N;j++) {
        		if(p[j]==1) {
        			for(int k=0;k<A[j];k++) {
        				if(p[x[j][k][0]]!=x[j][k][1]) {
        					flg=false;break;
        				}
        				
        			}
        			
        		}
        	}
    		if(flg==true) {
    			int cnt=0;
    			for(int k=0;k<N;k++) {
    				if(p[k]==1) {
    					cnt++;
    				}
    			}
    			max=Math.max(max, cnt);
    		}
        	
        }
        
        
        System.out.println(max);
        		
    }
}

Measured memory_bytes: 23380
#include <stdio.h>
#include <vector>
#include <utility>

#define ii pair<int, int>
#define iiii pair<ii, ii>
#define pb push_back
#define mp make_pair

using namespace std;

int main() {
	int h, w, a[510][510];
	vector<iiii> daftar;
	scanf("%d %d", &h, &w);
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			scanf("%d", &a[i][j]);
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j < w; j++)
			if (a[i][j] & 1) {
				a[i][j]--;
				a[i][j + 1]++;
				daftar.pb(mp(mp(i, j), mp(i, j + 1)));
			}
		if ((i < h) && (a[i][w] & 1)) {
			a[i][w]--;
			a[i + 1][w]++;
			daftar.pb(mp(mp(i, w), mp(i + 1, w)));
		}
	}
	printf("%d\n", (int) daftar.size());
	for (int i = 0; i < (int) daftar.size(); i++)
		printf("%d %d %d %d\n", daftar[i].first.first, daftar[i].first.second, daftar[i].second.first, daftar[i].second.second);
	return 0;
}

Measured memory_bytes: 5232
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static bool compare(const char *s, const char *t, size_t len)
{
    for (int i = len - 1; 0 <= i; i--) {
        if (*s != t[i]) return false;
        s--;
    }
    return true;
}

int main(int argc, char **argv)
{
    char s[100002] = {'\0'};
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    for (char *i = s + n; *i; i--) {
        if (compare(i, "dream", 5)) {
            i -= 4;
        } else if (compare(i, "dreamer", 7)) {
            i -= 6;
        } else if (compare(i, "erase", 5)) {
            i -= 4;
        } else if (compare(i, "eraser", 6)) {
            i -= 5;
        } else {
            printf("NO\n");
            return EXIT_SUCCESS;
        }
    }
    printf("YES\n");
    return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}
int lcm(int c,int d){
  int e=gcd(c,d);
  return c/e*d;
}

signed main(){
  int n;
  cin>>n;
  int ans=1;
  rep(i,n){
    int t;
    cin>>t;
    ans=lcm(ans,t);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int height,width,h,w;
    char block;

    for(;;){
        scanf("%d%d",&height,&width);
        if(width == 0 && height == 0)break;

        for(h = 1; h <= height; h++){
            for(w = 1; w <= width; w++){
                if((h != 1 && h != height) && (w != 1 && w != width))block = '.';
                else block = '#';

                printf("%c",block);
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, double> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

void dijkstra(int s, int g, vector<vector<P>> &G){
    vector<int> pv(110, 0);
    vector<double> dist(110, 1e9);
    pv[s] = -1;
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        ll ccost = que.top().first;
        ll cv = que.top().second;
        que.pop();
        if(dist[cv] < ccost) continue;

        for(auto x : G[cv]){
            ll nv = x.first;
            ll ncost = x.second;
            if(dist[nv] > dist[cv] + ncost){
                dist[nv] = dist[cv] + ncost;
                pv[nv] = cv;
                que.push(P(dist[nv], nv));
            }
        }
    }

    if(dist[g] == 1e9){
        cout << "NA" << endl;
    }
    else{
        vector<int> ans;
        for(int i=g; i!=-1; i=pv[i]){
            ans.eb(i+1);
        }

        for(int i=ans.size()-1; i>=0; i--){
            cout << ans[i] << " \n"[i == 0];
        }
    }
}

int main(){
    while(1){
        int n; cin>>n;
        if(n == 0) return 0;

        vector<int> b(n), x(n), y(n);
        for(int i=0; i<n; i++){
            cin>>b[i]>>x[i]>>y[i];
            b[i]--;
        }

        vector<vector<P>> G(110);
        for(int i=0; i<n; i++){
            for(int j=i+1; j<n; j++){
                double cost = sqrt(abs(y[i] - y[j]) * abs(y[i] - y[j]) + abs(x[i] - x[j]) * abs(x[i] - x[j]));

                if(50.0 < cost) continue;

                G[b[i]].eb(P(b[j], cost));
                G[b[j]].eb(P(b[i], cost));
            }
        }

        int m; cin>>m;
        while(m--){
            int s, g; cin>>s>>g;
            s--, g--;
            dijkstra(s, g, G);
        }
    }
}


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

Measured memory_bytes: 256