akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second;
#define F first;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end));i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000009
#define MAX 100005
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define rf(i,a,b) for(int i=(a);i>=b;i--)
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
#define vpshVar() int main()


//n==target m=coins
/**
number of ways of gathering coins:::::::::::
**/
ll Wayscoin(ll arr[],ll m,ll n ){
	 ll i, j, x, y;
    ll table[n + 1][m];
    for (j = 1; j < m; j++)
        table[0][j] = 1;
    table[0][0]=1;
    for (i = 1; i < n + 1; i++)
    {
        for (j = 0; j < m; j++)
        {
            x=0,y=0;
            //including
            if(i-arr[j]>=0)
            	x=table[i-arr[j]][j];
            //excluding
            if(j>0)
            	y=table[i][j-1];
            table[i][j]=x+y;
        }
    }
    return table[n][m - 1];
}


/***
    Minimum Number of Coins and actual coins to print:
***/



vpshVar(){
    ll test,N;
     N=3;
     ll arr[3];
     for(ll i=0;i<N;i++){
        sl(arr[i]);
     }
     ll target;
     sl(target);
     //pl(coin(target,arr,N));
     //BottomUp(target,arr,N);
     cout<<Wayscoin(arr,N,target)<<endl;
return 0;
}



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

using namespace std;
int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main()
{
	int a, b;
	char s[100];
	top = 0;
	while(scanf("%s",s)!=EOF){
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a*b);
		}
		else {
			push(atoi(s));
		}
	}
	cout << pop() << endl;
    return 0;
}

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

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}

Measured memory_bytes: 256
# ITP1_11_A: Dice 1

class Dice
  Side = Struct.new :neighbors

  class << self
    #     n
    # w center e (back)
    #     s
    def layout_sides(center, n, e, s, w)
      back = ( (1..6).to_a - [center, n, e, s, w] ).first
      Hash.new.tap do |sides|
        sides[center] = Side.new [n, e, s, w]
        sides[back]   = Side.new [s, e, n, w]
        sides[n]      = Side.new [center, w, back, e]
        sides[e]      = Side.new [center, n, back, s]
        sides[s]      = Side.new [center, e, back, w]
        sides[w]      = Side.new [center, s, back, n]
      end
    end
  end

  # Each side has four neighbor sides.
  SIDES = layout_sides(1, 5, 3, 2, 4)

  def initialize(labels, number = 1, neighbors = SIDES[number].neighbors)
    @labels       = labels
    @upper_number = number
    @neighbors    = neighbors
  end

  def upper_side
    @labels[@upper_number]
  end

  def roll_to(direction)
    dir_id      = dir_to_id direction
    next_number = opposite_side dir_id
    neighbors   = spin_neighbors_of next_number, @upper_number, dir_id
    Dice.new @labels, next_number, neighbors
  end

  private

  # Rotate the neighbors of +center+.
  def spin_neighbors_of(center, a_side, dir_id)
    neighbors = SIDES[center].neighbors
    org_dir   = neighbors.index(a_side)
    step = (org_dir - dir_id) % neighbors.size
    neighbors.map.with_index do |n, idx|
      neighbors[ (idx + step) % neighbors.size ]
    end
  end

  def opposite_side(dir_id)
    di_rid = (dir_id + 2) % @neighbors.size
    @neighbors[di_rid]
  end

  def dir_to_id(dir_id)
    case dir_id
    when 'N' then 0
    when 'E' then 1
    when 'S' then 2
    when 'W' then 3
    end
  end
end


labels = gets.chomp.split
label_map = Hash[ *(1..6).to_a.zip(labels).flatten ]
directions = gets.chomp.split('')

dice = Dice.new label_map, 1
dice = directions.inject dice do |dice, direction|
  dice.roll_to direction
end

puts dice.upper_side

Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
int main(){
 string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();
  int ans=n;
  for(int i=0;i<=n-m;i++){
    int a=0;
    for(int j=0;j<m;j++){
      if(s[i+j]!=t[j])
        a++;     
    }
    ans =min(a,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a == b  && b != c){
        cout << "Yes" << endl;
        return 0;
    }
    if(c == b  && b != a){
        cout << "Yes" << endl;
        return 0;
    }
    if(a == c  && b != c){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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

const int mod = 1000000007;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int power(int a, int b){ int S = 1; while(b--)S *= a; return S;}

int32_t main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	int s = 0;
	for(int i = 0; i < n; i++){
		s += a[i];
	}
	s /= n;
	int b = 0;
	for(int i = 0; i < n; i++){
		b = b + (a[i] - s - 1)*(a[i] - s - 1);
	}
	int B = 0;
	for(int i = 0; i < n; i++){
		B = B + (a[i] - s)*(a[i] - s);
	}
	cout << min(B , b);

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N, P, Q;
  cin >> N >> P >> Q;
  vector<ll> C(N);
  REP(i, 0, N) cin >> C[i];

  vector<ll> d(N);
  REP(i, 0, N) d[i] = C[i] + P * i;
  sort(d.begin(), d.end(), greater<ll>());

  ll x = Q * P * N + P * N * (N - 1) / 2;
  ll ans = x;
  REP(i, 0, N) {
    x += d[i] - 2 * P * (N - i - 1) - P * Q;
    ans = max(ans, x);
  }
  cout << ans << endl;
}


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

int main() {
    int x, y;
    cin >> x >> y;
    int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    if (a[x] == a[y])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int sort(int A[],int N){
  
  int i,j,t,sw=0,minj;
  
  for(i=0;i<N-1;i++){
    minj=i;
    
    for(j=i;j<N;j++){
      if(A[j]<A[minj]) minj=j;
    }
    
    t=A[i];
    A[i]=A[minj];
    A[minj]=t;
    
    if(i!=minj)
      sw++;
  }
  return sw;
}


int main(){
  int A[100],N,i,sw;

  scanf("%d",&N);
  
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  
  sw=sort(A,N);
  
  for(i=0;i<N;i++){
    
    if(i>0)
      printf(" ");
    
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",sw);

  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<stdio.h>
using namespace std;
static const int MAX = 100;

void printStack(int exp[], int l)
{
    for (int i = 0; i < l; i++) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", exp[i]);
    }
    printf("\n");
}

int main()
{
    int stack[MAX];
    for (int i = 0; i < MAX; i++) {
        stack[i] = 0;
    }

    int operand = 0;
    int head = 0;
    char c;
    while (scanf("%c", &c) != EOF) {
        // 文字が改行の場合 -> 終了
        if(c == '\n') {
            break;
        } 
        
        // 文字が空白の場合
        if (c == ' ') {
            // オペランド構成中の場合 -> スタックに追加
            if (operand > 0) {
                stack[head] = operand;
                head++;
                operand = 0;
            }
            continue;
        }
        
        // 文字が演算子以外の場合 -> オペランドを構成
        if (c != '+' && c != '-' && c != '*') {
            if (operand == 0) {
                operand = c - '0'; // atoi
            } else {
                operand *= 10; // 桁繰り上げ
                operand += c - '0'; // 下の桁に追加
            }
            continue;
        }

        // 文字が演算子の場合
        head--;
        int t1 = stack[head - 1];
        int t2 = stack[head];
            
        if (c == '+') {
            stack[head-1] = t1 + t2;
        } else if (c == '-') {
            stack[head-1] = t1 - t2;
        } else if (c == '*') {
            stack[head-1] = t1 * t2;
        }
        stack[head] = 0;
    }
    printf("%d\n", stack[head - 1]);
    
    return 0;
}



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

int main(){
    int n,r;
    while(cin>>n>>r){
        if(n==0 and r==0) return 0;
        vector<int> card(n);
        for(int i=0;i<n;i++) card[i] = n-i;
        for(int count=0;count<r;count++){
            int p,c;cin>>p>>c;
            p--;
            //card[p] ... card[p+c-1]????????????????????£?????????
            vector<int> tmp(c);
            for(int i=0;i<c;i++) tmp[i] = card[p+i];

            vector<int> cash;
            for(int i=0;i<c;i++) cash.push_back(tmp[i]);
            for(int i=0;i<p;i++) cash.push_back(card[i]);
            for(int i=p+c;i<n;i++) cash.push_back(card[i]);
            card = cash;
        }
        cout << card[0] << endl;
    }
}

Measured memory_bytes: 1220
#include <cstdio>
using namespace std;

int main() {
  int N; scanf("%d", &N);
  int lo = 0, hi = N;
  while(hi - lo > 1) {
    int mid = (hi + lo) / 2;
    if((long long)(mid + 1) * mid / 2 >= N) {
      hi = mid;
    } else {
      lo = mid;
    }
  }
  int K = hi;
  int sum = (long long)(K + 1) * K / 2;
  int rem = sum - N;
  for(int i = 1; i <= K; ++i) {
    if(i != rem) {
      printf("%d\n", i);
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{
    int n;
    cin >> n;
    int dp[n+1] = {0};
    rep2(i,1,n+1)
    {
        int min_cnt = dp[i-1] + 1;
        rep(j,10)
        {
            int a = pow(6,j);
            if(a > i) break;
            min_cnt = min(min_cnt, dp[i-a] + 1);
        }
        rep(j,10)
        {
            int a = pow(9,j);
            if(a > i) break;
            min_cnt = min(min_cnt, dp[i-a] + 1);
        }
        dp[i] = min_cnt;
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 768
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
ans = 0
for i in range(N-1):
	for j in range(i+1, N):
		ans = max(ans, abs(A[i]-A[j]))

print(ans)

Measured memory_bytes: 5456
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int W, H, N;
VI x, y, a;

int main(void) {
	scanf("%d%d%d", &W, &H, &N);
	x.resize(N);
	y.resize(N);
	a.resize(N);
	int miH = 0, miW = 0;
	int maH = W, maW = W;
	REP(i, N) {
		scanf("%d%d%d", &x[i], &y[i], &a[i]);
		if (a[i] == 1) {
			miW = max(miW, x[i]);
		} else if (a[i] == 2) {
			maW = min(maW, x[i]);
		} else if (a[i] == 3) {
			miH = max(miH, y[i]);
		} else {
			maH = min(maH, y[i]);
		}
	}
	if (miH <= maH && miW <= maW) {
		cout << (maH - miH) * (maW - miW) << endl;
	} else {
		cout << 0 << endl;
	}
}


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

int main(){
    string s1,s2,s3;
    int n,m;
    cin>>s1>>s2;
    cin>>n>>m;
    cin>>s3;
    if(s1==s3)
        cout<<n-1<<" "<<m;
    else
        cout<<n<<" "<<m-1;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
vector<vector<pair<int, int>>> s(100030);
long long int seen[100020] = {};
long long int value[100020] = {};
int main() {
	long long int n;
	cin >> n;
	long long int ans = 1000000;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0) {
			long long int k = n / i;
			long long int f = i;
			long long int ksum = 0;
			long long int fsum = 0;
			while (k > 0) {
				k = k / 10;
				ksum = ksum + 1;
			}
			while (f > 0) {
				f = f / 10;
				fsum = fsum + 1;
			}
			ans = min(ans, max(ksum,fsum));
		}
	}
	cout << ans;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

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

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

	ll n,ans=0;
	cin>>n;
	vector<ll>v;
	for(ll i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	for(ll mid=n-1;mid>=0;mid--)
	{
		for(ll low=mid-1;low>=0;low--)
		{
			auto itr=lower_bound(v.begin(),v.end(),v[low]+v[mid]);
			ll ng=distance(itr,v.end());
			ans+=(n-1-mid)-ng;
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
/*
 * Welcome to my code!
 * -------------------------------------------- *
 * author : lynmisakura(twitter : @andoreiji11)
 */

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

//Simple Array Input
#define SAI int n;cin >> n;vi a(n);ain(a)
//Simple Graph Input
#define SGI(m) for(int i=0;i<m;i++){int a,b;cin >> a >> b;g[--a].pb(--b);g[b].pb(a);}
//Simple Tree Input
#define STI SGI(n-1)

typedef long long ll;
typedef long long integer;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){
    for(int i=0;i<a.size();i++)cout << a[i] << (i < a.size()-1 ? ' ' : '\n');
}


int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,w;cin >> h >> w;
  vector<int> cnt(26,0);
  rep(i,h){
    string s;cin >> s;
    for(char x : s)cnt[x - 'a']++;
  }

  int four = (h / 2) * (w / 2);  

  int odd = 0;
  rep(i,26){
    if(cnt[i] % 2 == 1){
      if(++odd > 1){
        cout << "No" << '\n';
        return 0;
      }
      cnt[i]--;
    }
    if(cnt[i] >= 4){
      four -= cnt[i] / 4;
    }
  }  

  if(four <= 0){
    cout << "Yes" << '\n';
  }else{
    cout << "No" << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define NMAX 1000

int main() {
  int m, g, n, s;
  int a[7], b[7], dp[2][NMAX+1];
  while (1) {
    scanf("%d", &m);
    if (!m) break;
    for (int i=0; i<m; i++) {
      scanf("%d %d", &a[i], &b[i]);
    }

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    s = 0;
    for (int i=0; i<m; i++) {
      memcpy(dp[!(i&1)], dp[i&1], sizeof(dp[0]));
      for (int j=0; j<=s; j++) {
        if (!dp[i&1][j]) continue;
        for (int k=0,l=j+a[i]; k<b[i] && l<=NMAX; k++,l+=a[i]) {
          dp[!(i&1)][l] += dp[i&1][j];
        }
      }
      s += a[i]*b[i];
      s = min(s, NMAX);
    }

    scanf("%d", &g);
    for (int i=0; i<g; i++) {
      scanf("%d", &n);
      printf("%d\n", dp[m&1][n]);
    }
  }

  return 0;
}

Measured memory_bytes: 1036
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,k=mp()
s=list(input())
s[k-1]=str.lower(s[k-1])
print(*s,sep="")

Measured memory_bytes: 77424
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGCDOnBlackboard solver = new CGCDOnBlackboard();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGCDOnBlackboard {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }

            int[] prefix = new int[n + 1];
            prefix[0] = 0;
            for (int i = 0; i < n; i++) {
                prefix[i + 1] = NumberTheory.gcd(prefix[i], a[i]);
            }

            int[] suffix = new int[n + 1];
            suffix[n] = 0;
            for (int i = n - 1; i >= 0; i--) {
                suffix[i] = NumberTheory.gcd(suffix[i + 1], a[i]);
            }

            int answer = 0;
            for (int i = 0; i < n; i++) {
                answer = Math.max(answer, NumberTheory.gcd(prefix[i], suffix[i + 1]));
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class NumberTheory {
        public static int gcd(int a, int b) {
            int c;
            while (a != 0) {
                c = a;
                a = b % a;
                b = c;
            }
            return b;
        }

    }
}



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

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007



void solve() {
	
	int n , m, k;
	
	cin >> n >> m >> k;
	
	int a[n];
	int b[m];
	
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	for(int i = 0; i < m; ++i) {
		cin >> b[i];
		
		if(i != 0) {
			b[i] += b[i-1];
		}
	}
	
	int mx = 0;
	int sm = 0;
	
	for(int i = 0; i <= n; ++i) {
		
		if(i != 0)  {
			sm += a[i-1];
		}
		
		if(sm > k) {
			break;
		}
		
		auto u = upper_bound(b,b+m, k - sm) - b;
		
		mx = max(mx , i + u);
	}
	
	cout<< mx;
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,m,q,ans;
vector<vector<int>>v;
int a[55],b[55],c[55],d[55];
void dfs(vector<int>h){
    if(h.size()==n){
        v.pb(h);
        return;
    }
    for(int i=(h.empty()?1:h.back());i<=m;i++){
        h.pb(i);
        dfs(h);
        h.pop_back();
    }
}
signed main(){
    cin>>n>>m>>q;
    dfs({});
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--,b[i]--;
    }
    for(vector<int>h:v){
        int sum=0;
        rep(i,q){
            if(h[b[i]]-h[a[i]]==c[i])sum+=d[i];
        }
        chmax(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 13932
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::string s;
    cin >> s;
    cout << s[0] << s.length() - 2 << s[s.length() - 1];

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main
 {
   public static void main(String[] args)
      {
      Scanner sc = new Scanner(System.in);
      int m, f,e;

      while(true){
        m = sc.nextInt();
        f = sc.nextInt();
        e = sc.nextInt();

        if(m == -1 && f == -1 && e == -1)break;
        if     ( m == -1 || f == -1 )     System.out.println("F");
        else if( e >= 50 )                System.out.println("C");
        else if( m + f >= 80 )            System.out.println("A");
        else if( m + f >= 65 )            System.out.println("B");
        else if( m + f >= 50 )            System.out.println("C");
        else if( m + f >= 30 )            System.out.println("D");
        else if( m + f < 30 )             System.out.println("F");

       }
      }
 }


Measured memory_bytes: 26428
#include<iostream>
#include<cstdio>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
int main() {
  while(1){
    int i;
    char a[5][5]={};
    bool ans=false;
    cin>>a[0];
    if(a[0][0]=='0')break;
    cin>>a[1];
    cin>>a[2];
    rep(i,3)
      if(a[i][0]==a[i][1] && a[i][1]==a[i][2] && a[i][0]!='+'){
        cout<<a[i][0]<<endl;
        ans=true;
        break;
      }else if(a[0][i]==a[1][i] && a[1][i]==a[2][i] && a[0][i]!='+'){
        cout<<a[0][i]<<endl;
        ans=true;
        break;
      }
    if(ans)continue;
    if((a[0][0]==a[1][1] && a[1][1]==a[2][2] && a[1][1]!='+')||
       (a[0][2]==a[1][1] && a[1][1]==a[2][0] && a[1][1]!='+'))
      cout<<a[1][1]<<endl;
    else
      cout<<"NA"<<endl;
  }
}

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

int N;
int dp[5005][5005];
string S;

int main()
{
	cin >> N >> S;
	for(int i=N-1;i>=0;--i){
		for(int j=N-1;j>=0;--j){
			if(S[i]!=S[j]) dp[i][j]=0;
			else{
				dp[i][j]=dp[i+1][j+1]+1;
			}
		}
	}
	int ans = 0;
	for(int i=0;i<N;++i)for(int j=i+1;j<N;++j){
		int now = min(dp[i][j], j-i);
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 98048
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]

ans=[[0]*w for i in range(h)]

for i in range(h):
  for j in range(w):
    if l[i][j]=='#':
      ans[i][j]='#'
    else:
      for p in range(-1,2):
        for q in range(-1,2):
          if 0<=i+p<h and 0<=j+q<w and l[i+p][j+q]=='#':
            ans[i][j]+=1
            
for i in range(h):
  print(*ans[i],sep='')


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

using namespace std;

vector<int> money;
void del(int,int);
int add ();

int main() {
	int n,m,p,sum;
	
	while ( cin >> n, cin >> m, n, m ) {
		//初期化
		money.clear();
		
		
		for ( int i = 0; i < n; i++ ) {
			cin >> p;
			money.push_back ( p );
		}
		
		sort( money.begin() , money.end() , greater<int>() );
		del (n / m , m);
		sum = add ();
		
		cout << sum << endl;
	}
	return 0;
}

void del(int hoge , int m) {
	vector<int>::iterator it = money.begin();
	for( int i = 1; i <= hoge; i++ ) {
		money.erase( money.begin() +  (i * m - i) );
	}
}

int add () {
	int sum = 0;
	
	vector<int>::iterator it = money.begin();
	while( it != money.end() ) {
		sum += *it;
		it++;
	}
	return sum;
}

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

int main() {
    int n;
    cin >> n;
    int a[n+1] = {};
    rep(i,n) cin >> a[i];
    int64_t ans = 0;
    rep(i,n) {
        ans += a[i]/2;
        a[i] %= 2;
        if (a[i+1] > 0 && a[i] == 1) {
            ans++;
            a[i+1]--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b=INTM()
    if (a*b)%2==0:
        print('No')
    else:
        print('Yes')
if __name__ == '__main__':
    do()

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

ll n, ans;
vector<ll> v;
string s;
int main() {
    cin >> s;
    ll now = 1;
    v.push_back(0);
    for (int i = 1; i < s.size(); i++) {
        if (s[i - 1] != s[i]) {
            v.push_back(now);
            ans += (now) * (now - 1) / 2;
            now = 1;
        } else {
            now++;
        }
    }
    v.push_back(now);
    v.push_back(0);
    ans += (now) * (now - 1) / 2;
    if (s[0] == '<') {
        for (int i = 1; i < v.size() - 1; i += 2) {
            ans += max(v[i], v[i + 1]);
        }
    } else {
        for (int i = 0; i < v.size() - 1; i += 2) {
            ans += max(v[i], v[i + 1]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6104
#include <stdio.h>
#include <stdlib.h>
#define START(a) (a>0?a:0)
int s,ans,a;
int main(void){
	while(scanf("%d",&s)!=EOF){
		ans=0;
		for(a=START(s-2000);a<=2000 && s>=a;a++){
			ans+=(1001-abs(1000-(s-a)))*(1001-abs(1000-a));
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;

  ll ans=0;
  for(ll i=1;i<=N;i++){
    if(i%3==0 || i%5==0)  continue;
    ans+=i;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[N - 1] - a[0]);
  }
}

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

class Main {
	public static void main(String[] args){
		Scanner cin = new Scanner(System.in);
		int[] x = new int[10];
		
		int i;
		for(i = 0; i < 10; i++){
			x[i] = cin.nextInt();
		}
		
		Arrays.sort(x);
		
		for  (i = 9; i > 6; i--){
			System.out.println(x[i]);
		}
	}
}

Measured memory_bytes: 26240
#include<stdio.h>
int main()
{
	int tensu[2];
	int a,b,c,d,i;

	for(i=0;i<2;i++)
	{
		scanf("%d %d %d %d",&a,&b,&c,&d);
		tensu[i]=a+b+c+d;
	}

	if(tensu[0]<tensu[1])
	{
		printf("%d",tensu[1]);
	}
	else if(tensu[0]>tensu[1])
	{
		printf("%d",tensu[0]);
	}
	else
	{
		printf("%d\n",tensu[0]);
	}
	return 0;
}

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

using namespace std;

int main(){
    int n;
    long int tmp;
    long int ans=1;
    long int limit = pow(10,18);
    cin >> n;
    vector<long int> a(n);

    for(int i=0;i<n;i++){
        cin >> tmp;
        if(tmp==0){
            cout << 0 << endl;
            return 0;
        }
        a[i]=tmp;
    }
    for(int i=0;i<n;i++){
        if(LONG_MAX/ans < a[i]){
            cout << -1;
            return 0;
        }
        ans*=a[i];
    }
    if(ans > limit){
        cout << -1;
    }else{
        cout << ans;
    }
    
    return 0;
}


Measured memory_bytes: 4048
# nCk ( O(N) )
N_MAX = 100
MOD = 10**9 + 7
fac, finv, inv = [0]*N_MAX ,[0]*N_MAX, [0]*N_MAX
def com_init():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, N_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

def com(n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


n,p = map(int, input().split())
al = list(map(int, input().split()))
zero = 0
one = 0
com_init()
for a in al:
    if a%2 == 0: zero+=1
    else: one+=1


zero_comb = pow(2,zero)
one_comb = 0
if p == 0:
    for i in range(0,one+1,2):
        one_comb += com(one,i)
else:
    for i in range(1,one+1,2):
        one_comb += com(one,i)

print(zero_comb*one_comb)

Measured memory_bytes: 62220
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int k,n;cin >>k>> n;
  int ans=0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }

  sort(all(a));
  int m=-1;
  for(int i=0;i<n-1;i++){
    int x = a[i+1] - a[i];
    if(x>m) m=x;
  }
  int x = a[0] +  k-a[n-1];
  if(x>m) m=x;

  ans = k-m ;

  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //This code is not meant for understanding, proceed with caution
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int r = ni(), g = ni(), b = ni(), n = ni();
        long ans = 0;
        for(int i = 0; i*r<= n; i++){
            for(int j = 0; j*g<= n-i*r; j++){
                if((n-i*r-j*g)%b==0)ans++;
            }
        }
        pn(ans);
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long mod = (long)998244353, IINF = (long)1e18;
    final int INF = (int)1e9, MX = (int)1e5+1;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }  
            return str;
        }
    }
}

Measured memory_bytes: 21716
a = list(input())
b = list(input())

n = len(a)
m = len(b)
s = n - m
check = 0
while s >= 0:
    count = 0
    for i in range(m):
        if a[s + i] == '?' or a[s + i] == b[i]:
            count += 1
        else:
            s -= 1
            break
    #print(a[s:s + m], count)
    if count == m:
        for i in range(m):
            a[s + i] = b[i]
        print(''.join(a).replace('?', 'a'))
        exit()

print('UNRESTORABLE')


Measured memory_bytes: 3064
#include <stdio.h>
#define M 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 i,n,A[M+1];

    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&A[i]);
    }
     for(i=1;i<=n;i++){
         printf("node %d: key = %d, ",i,A[i]);
         if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
         if(left(i)<=n)printf("left key = %d, ",A[left(i)]);
         if(right(i)<=n)printf("right key = %d, ",A[right(i)]);
         printf("\n");
     }
     return 0;
}



Measured memory_bytes: 2052
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main(){
    string a,b;
    cin >> a >> b;
    double c = stoi(a + b);
    int d = sqrt(c);
    if (pow(d,2) == c) cout <<"Yes\n";
    else cout <<"No\n";
    
}

Measured memory_bytes: 256
grid = [0] * 6

result = 'Yay!'

for i in range(len(grid)):
  grid[i] = int( input() )

  
for i in range(len(grid)-2):
  for j in range(i+1,len(grid)-1):
    #print( "{:d}, {:d},".format(grid[i], grid[j]))
    if grid[j] - grid[i] > grid[len(grid)-1]:
      result = ':('
      break

print( result )
#print( grid )

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int a, b, x;
	cin >> a >> b >> x;
	if (x >= a && (a + b) >= x)print("YES");
	else print("NO");
}

Measured memory_bytes: 3648
#include<stdio.h>

int main(void){

  int x[10002],n,i;

  x[1]=2;
  for(i=2;i<=10000;i++)
    x[i]=i+x[i-1];
  
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",x[n]);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int n;
    cin >> n;
    cout << n*n*n << endl;
}


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

std::string str;

int main() {
    int n;
    std::cin>>n;

    std::cin>>str;

    int cnt=0;

    for(int i=0;i<str.size();++i){
        if(str[i]=='(')
            ++cnt;
        else
            --cnt;

        if(cnt<0){
            str.insert(str.begin(),'(');
            ++i;
            ++cnt;
        }

    }
    std::cout<<str;
    for(int i=0;i<cnt;++i)
        std::cout<<')';
    std::cout<<std::endl;
    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
n=int(input())
A=[int(i) for i in input().split()]
AA=[]
for i in range(n):
  ai=A[i]
  for j in range(ai):
    AA.append(i+1)
for i in range(h):
  AAA=AA[i*w:(i+1)*w]
  if i%2!=0:
    AAA=AAA[::-1]
  print(*AAA)

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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846


const int MOD=1e9+7;
    ll mod(ll x){
        return (x%MOD + MOD)%MOD;
    }
    ll mmod(ll a , ll b){
        return mod(mod(a)*mod(b));
    }

int main()
{
    ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
    ll n,k;
    cin>>n>>k;
    ll ans=1;
    vector<ll> pos,neg,db;
    for(ll i=0;i<n;i++){
        ll a;
        cin>>a;
        if(a>0) pos.push_back(a);
        else neg.push_back(a);
    }
    if(pos.size()){
        if(k%2==1){
            sort(pos.begin(),pos.end());
            ans=mmod(ans,pos[pos.size()-1]);
            pos.pop_back();
            k-=1;
        }
        sort(pos.begin(),pos.end(),greater<>());
        sort(neg.begin(),neg.end());
        for(ll i=0;i+1<pos.size();i+=2){
            db.push_back((pos[i]*pos[i+1]));
        }
        for(ll i=0;i+1<neg.size();i+=2){
            db.push_back((neg[i]*neg[i+1]));
        }
        if(pos.size()%2 && neg.size()%2){
            db.push_back((pos.back()*neg.back()));
        }
        sort(db.begin(),db.end(),greater<>());
        for(ll i=0;i<(k/2);i++){
            ans=mmod(ans,db[i]);
        }
        cout<<ans<<endl;
        return 0;
    }
    else{
        sort(neg.begin(),neg.end());
        if(k%2==1)reverse(neg.begin(),neg.end());
        for(ll i=0;i<k;i++){
            ans=mmod(ans,neg[i]);
        }
        cout<<ans<<endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 6612
import sys 
input = sys.stdin.readline

h, w = map(int,input().split())

hw = []

for i in range(h):
  line = list(map(int,input().split()))
  line.append(0) # 簡単のために列を増やす
  hw.append(line)
  
n = 0
xy = []
  
for i in range(h-1):
  for j in range(w):
    if hw[i][j] % 2 == 1:
      if hw[i][j+1] % 2 == 1:
        hw[i][j] -= 1
        hw[i][j+1] += 1
        n += 1
        xy.append([i+1,j+1,i+1,j+2])
      else:
        hw[i][j] -= 1
        hw[i+1][j] += 1
        n += 1
        xy.append([i+1,j+1,i+2,j+1])

for i in range(w-1):
  if hw[h-1][i] % 2 == 1:
    hw[h-1][i] -= 1
    hw[h-1][i+1] += 1
    n += 1
    xy.append([h,i+1,h,i+2])
    
print(n)
for i in xy:
  print(' '.join(map(str,i)))
  # join()を使うリストはstr型
  # map([適用関数], [対象リスト])

Measured memory_bytes: 29672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000000 + 7;

bool debug = 0;

void solve() {
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    sort(t.begin(), t.end());
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int time = t[i];
        for (int j = 0; j < c; j++) {
            if (t[i + j] > time + k) {
                i += j - 1;
                break;
            }
            if (j == c - 1) i += j;
        }
        cnt++;
    }
    cout << cnt << endl;
}

int main() {
    if (debug) {
        while (true) {
            cout << "********" << endl;
            solve();
        }
    } else {
        solve();
    }
    return 0;
}

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

int main()
{
  char s1[3001],s2[3001];
  cin>>s1;
  cin>>s2;
  
  int m,n,i,j;
  
  n=strlen(s1);
  m=strlen(s2);
  int a[n+1][m+1];
  memset(a,0,sizeof(a));
  int k=0;
  vector<vector<string>> v(2,vector<string> (m+1));
  for(i=0;i<n;i++)
  {
    k=i%2;
    for(j=0;j<m;j++)
    {
       if(s1[i]==s2[j])
       { 
           a[i+1][j+1]=a[i][j]+1;
           v[(k+1)%2][j].push_back(s1[i]);
           v[k][j+1]=v[(k+1)%2][j];
           v[(k+1)%2][j].pop_back();
       }
      else
      {
        a[i+1][j+1]=max(a[i][j+1],a[i+1][j]);
        
         if(a[i+1][j+1]==a[i][j+1])
         {
            v[k][j+1]=v[(k+1)%2][j+1];
         }
         else
         {
            v[k][j+1]=v[k][j];
         }
      }
    }
  }
  cout<<v[k][m];
  
  
  return 0;
}


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

int main()
{
  string s;
    cin >> s;
    
    int result = 700;
    if (s.at(0) == 'o') result += 100;
    if (s.at(1) == 'o') result += 100;
    if (s.at(2) == 'o') result += 100;

    cout << result << endl;
}

Measured memory_bytes: 256
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N, X;
    cin >> N >> X;
    vector<int> D(N+1, 0);
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        D[i+1] = D[i] + x;
    }

    int ans = 0;
    for (int i = 0; i <= N; i++) {
        if (D[i] <= X) ans++;
        else break;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
s = [0]
for i in range(N):
    s.append(s[i] + a[i])
y = s[N] - s[1]
min = abs(s[1] - y)
for i in range(1,N):
    y = s[N] - s[i]
    ans = abs(s[i]-y)
    if ans < min:
        min = ans
print(min)

Measured memory_bytes: 24812