akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <assert.h>
#include <map>
#include <set>
#include <bitset>
#include <iomanip>
#include <stack>
// #include <unordered_map>
#include <cmath>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
// #define INF 0x7f7f7f7f  //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.14159265358979323846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
#define IOS                      \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m, n) for (int i = m; i < n; i++)
#define PII pair<int, int>
#define PLL pair<long, long>
#define ft first
#define sd second
#define pb push_back
#define ST(x, y, z) sort(x + y, x + z);
#define lson o << 1, l, mid
#define rson o << 1 | 1, mid + 1, r
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define ROF(i, a, b) for (int i = (a); i >= (b); i--)
#define MEM(x, v) memset(x, v, sizeof(x))
#define rep(i, a, b) for (register int i = a; i <= b; i++)
#define rrep(i, a, b) for (register int i = a; i >= b; i--)
#define PIII pair<int, PII>
#define re read()
#define case  \
    int T;    \
    cin >> T; \
    rep(_, 1, T)
// #define int ll
#define LL long long
#define int ll
inline int read()
{
    char tempt = getchar();
    int x = 0, f = 0;
    while (tempt < '0' || tempt > '9')
        f |= tempt == '-', tempt = getchar();
    while (tempt >= '0' && tempt <= '9')
        x = x * 10 + tempt - '0', tempt = getchar();
    return f ? -x : x;
}

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

const int N = 2e5 + 10;
bool st[N];
signed main()
{
    //STDIN
    int n; cin >> n;
    cout << (1000 - n % 1000)%1000 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <utility>
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define ld long double
// #define loop(i,a,b) for(ll i=a;i<b;i++)
// #define inll(n) ll n;cin>>n;
// #define instr(s)  string s;cin>>s;
// #define inarr(a,n)  ll*a = new ll[n];loop(i,0,n)cin>>a[i]; 
// #define invec(v,n)  vector<ll> v(n);loop(i,0,n)inll(v[i])
// #define arr(a,n) ll*a = new ll[n];
// #define outarr(a,n) loop(i,0,n)cout<<a[i]<<" ";cout<<endl;
#define pb push_back
#define mp make_pair
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector <int>
#define vb vector <bool>
#define vll vector <ll>
#define vc vector <char>
#define clr(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define infd 1e+18
#define inf 101901199101
#define mod 1000000007
using namespace std;
inline ll min(ll a,ll b)
{
    return (a<b?a:b);
}
inline ll max(ll a,ll b)
{
    return (a<b?b:a);
}


void swap(ll*a,ll*b)
{
    ll t  = *a;
    *a =*b;
    *b = t;
}
void revere(string &s)
{
    for(ll i = s.length()-1;i>=ceil(s.length()/2);i--)
     swap(s[i],s[s.length()-1-i]);
}
bool isValidParenthesis(string s)
{
    int c = 0;
    for(char i:s)c = (i=='('?c+1:c-1);
    if(c!=0)return 0;
    return 1;
}


string substr(string s,int i,int j)
{
    if(i>j)return "";
    string n;
    for(int k = i;k<j;k++)
    {
        n+=s[k];
    }
    return n;
}

int ans(string s, int i,int j)
{
    if(i==j||j>s.length()||i>j||s.length()==0||s.length()==1)return 0;
    if(substr(s,i,j)=="()")return 1;
    if(isValidParenthesis(substr(s,i+1,j-1))) return 2*ans(s,i+1,j-1);
    int ind = i;
    for(int k = i+1;k<j;k++)
    {
        if(isValidParenthesis(substr(s,i,k+1)))
        {
            ind = k+1;
            break;
        }
    }
    return ans(s,i,ind) + ans(s,ind,s.length());
}

int main()
{
    char c;
    cin>>c;
    char d = c+1;
    cout<<d<<endl;
}

/*
ll n,weights;cin>>n>>weights;
    ll w[n], p[n];
    vector<pair<ll,ll>> pel;
    for(ll i = 0;i<n;i++){cin>>w[i]>>p[i];pel.insert(make_pair(w[i],p[i]));}
    sort(pel.begin(),pel.end());
    for(ll i = 0;i<n;i++){w[i] = pel[i].first;p[i] = pel[i].second;}
    if(n<weights[0])cout<<0<<endl;
    else
    {
        dp[weights + 1] = {0};
        for(ll i = 0;i<weights + 1;i++)
        {
            if(i-w[i]>=0)
                dp[i] = dp[i - w[i]] + p[i];
        }
    }
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>>vec(100010);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		vec[a].emplace_back(b);
		vec[b].emplace_back(a);
	}
	bool b[100010] = { false };
	queue<int> que;
	int ans[100010];
	que.push(1);
	int co = 0;
	while (!que.empty()) {
		int x = que.front();
		for (int i = 0; i < vec[x].size(); i++) {
			if (b[vec[x][i]] == false) {
				que.push(vec[x][i]);
				ans[vec[x][i]] = x;
				b[vec[x][i]] = true;
				co++;
			}
		}
		que.pop();
	}
	if (co == n) {
		cout << "Yes" << endl;
		for (int i = 2; i <= n; i++) {
			cout << ans[i] << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 10288
#include <bits/stdc++.h>
 
using namespace std;
 
int A, B, C, X, Y;
 
int main(){
	scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
	C *= 2;
	bool ok = (C < (A + B));
	int res = 0;
	if(ok){
		int k = min(X, Y);
		res += k * C;
		X -= k, Y -= k;
	}
	int val = (C < A) ? C : A;
	res += X * val;
	val = (C < B) ? C : B;
	res += Y * val;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int N, sum = 0;
	cin >> N;
	VI a(N);
	rep(i, N){
		cin >> a[i];
		sum ^= a[i];
	}

	rep(i, N){
		cout << (sum ^ a[i]);
		if(i != N-1) cout << " ";
	}
	cout << endl;

}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


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

const int N = 1000500;

char buf[N];
bool was[256];

int main() {
    scanf("%s", buf);
    int n = strlen(buf);
    for (int i = 0; i < n; i++) {
        was[buf[i]] = true;
    }
    bool ans = was['N'] == was['S'] && was['E'] == was['W'];
    puts(ans ? "Yes" : "No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ss second
#define ff first
vector<vector<ll>> dp;ll it=0,f=0;
ll knapsack(ll i,ll wi[],ll vi[],ll w)
{
    if(dp[i][w]!=-1)
    {f++;
    return dp[i][w];}
    if(w==0 || i==0)
    {
        dp[i][w]=0;
        return 0;
    }
    else if(w>=wi[i-1])
    {
        dp[i][w]=max(vi[i-1]+knapsack(i-1,wi,vi,w-wi[i-1]),knapsack(i-1,wi,vi,w
        ));it+=2;
    }
    else
        dp[i][w]=knapsack(i-1,wi,vi,w);
        it++;
        return dp[i][w];
}
int main() 
{
    ll n,i,j,k,x,y,w,flag=0;
    cin>>n>>w;
    ll wi[n],vi[n];
    for(i=0;i<n;i++)
    {
        cin>>wi[i]>>vi[i];
    }
    dp.resize(n+1);
    for(i=0;i<n+1;i++)
    dp[i].resize(w+1);
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=w;j++)
        {
            dp[i][j]=-1;
        }
    }
    ll ans=knapsack(n,wi,vi,w);
    cout<<ans;//<<it<<" "<<f;
    return 0;
}


Measured memory_bytes: 79488
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const int N = 12805;

char dp[85][85][28005] = {0};
int x[85][85],y[85][85],del[85][85];

int main(){
	int n,m;
	cin >> n >> m;
	for(int i = 1;i <= n;i ++){
		for(int j = 1;j <= m;j ++){
			cin >> x[i][j];
		}
	}
	for(int i = 1;i <= n;i ++){
		for(int j = 1;j <= m;j ++){
			cin >> y[i][j];
			del[i][j] = abs(x[i][j] - y[i][j]);
		}
	}
	dp[1][1][N - del[1][1]] = 1; dp[1][1][N + del[1][1]] = 1;
	for(int i = 1;i <= n;i ++){
		for(int j = 1;j <= m;j ++){
			for(int k = 0;k <= N * 2;k ++){
				dp[i][j + 1][k + del[i][j + 1]] |= dp[i][j][k];
				dp[i + 1][j][k + del[i + 1][j]] |= dp[i][j][k];
				dp[i][j + 1][k - del[i][j + 1]] |= dp[i][j][k];
				dp[i + 1][j][k - del[i + 1][j]] |= dp[i][j][k];
			}
		}
	}
	for(int i = 0;i <= N;i ++){
		if(dp[n][m][i]) cout << i << endl;
		if(dp[n][m][N + i] || dp[n][m][N - i]){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 190848
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RLFOR(i,b,a) for(ll i=(b)-1;i>=(a);--i)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
#define dump2(x,y) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x)\
			<< " , " << #y << " = " << (y) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int n,a,b;
ll v[50];
string s;

ll Comb(int a, int b){
	ll c = 1;
	ll k = (1ll<<b) - 1ll;
	RFOR(i, 2, a + 1){
		if((a - b) < i) c *= i;
		if(k){
			REP(h, 50)if(k & (1ll<<h)){
				if(c%(h+1)==0){
					c/=h+1;
					k &= ~(1ll<<h);
				}
			}
		}
	}
	return c;
}


int main() {
	cin >> n >> a >> b;
	REP(i, n) cin >> v[i];
	sort(v, v + n);
	ll sumM = 0, sums[n + 1];
	int ans = -1;
	FOR(j, a, b + 1){
		sums[j] = 0;
		FOR(i, n - j,n){
			sums[j] += v[i];
		}
		if(ans == -1 || sums[j] * ans > sumM * j){
			sumM = sums[j];
			ans = j;
		}
	}
	cout << fixed << setprecision(7) << (double)sumM / ans << endl;
	ll c = 0;

	FOR(j, a, b + 1){
		if(sums[j] * ans != sumM * j) continue;
		int i=n-j;
		ll f = 1;
		while(i<n){
			int u = upper_bound(v, v + n, v[i]) - v;
			int l = lower_bound(v, v + n, v[i]) - v;
			f *= Comb(u - l, u - max(n - j, l));
			dump(c);
			dump(j);
			dump2(u - l, u - max(n - j, l));
			i = u;
		}
		c += f;
	}
	cout << c;
	cout << endl;
}


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

int fa[200005], tim[200005];

int find(int a) {
    if (a == fa[a]) return a;
    return fa[a] = find(fa[a]);
}

int main(){
    for (int i = 1; i <= 200000; i++) fa[i] = i;
    int n, m; scanf("%d%d", &n, &m);
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        int a, b; scanf("%d%d", &a, &b);
        int aa = find(a), bb = find(b);
        if (aa != bb) fa[aa] = bb;
    }
    for (int i = 1; i <= n; i++) {
        int k = find(i); tim[k]++;
        if (tim[k] > ans) ans = tim[k];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10696
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 2010

int N;

char SS[SIZE];

int query(vector<int> &vec) {
  char res[10];
  assert(vec.size() == N);

  printf("?");
  for (auto p : vec) {
    printf(" %d", p + 1);
  }
  puts("");
  fflush(stdout);

#ifdef LOCAL
  int counterR = 0;
  for (int i=0; i<N; i++) {
    counterR += SS[vec[i]] == 'R';
  }
  return counterR >= N/2 + 1;
#else
  scanf("%s", res);
#endif

  return res[0] == 'R';
}

void gen(int N) {
  for (int i=0; i<N; i++) {
    SS[i] = 'R';
    SS[i+N] = 'B';
  }

  random_shuffle(SS, SS+N*2);
}

int main(){

  cin >> N;

#ifdef LOCAL
  srand(time(NULL));
  gen(N);
#endif

  vector<int> A;
  vector<int> B;

  for (int i=0; i<N; i++) {
    A.push_back(i);
    B.push_back(i+N);
  }

  int isRed = query(A);

  if (!isRed) {
    swap(A, B);
  }

  int index = -1;

  bool ans[SIZE] = {};

  int l = 0, r = N;

  while(r - l >= 2) {
    int mid = (r + l) / 2;

    for (int i=l; i<mid; i++) {
      swap(A[i], B[i]);
    }

    int isRed = query(A);

    if (!isRed) {
      for (int i=l; i<mid; i++) {
        swap(A[i], B[i]);
      }
      r = mid;
    } else {
      // do nothing
      l = mid;
    }
  }

#ifdef LOCAL
  assert(query(A));
  swap(A[l], B[l]);
  assert(!query(A));
  swap(A[l], B[l]);
  debug(SS[A[l]]);
  debug(SS[B[l]]);
#endif

  for (int i=0; i<N; i++) {
    swap(A[l], B[i]);
    ans[A[l]] = query(A);
    swap(A[l], B[i]);
    debug(SS[B[i]]);

    swap(A[i], B[l]);
    ans[B[l]] = query(B);
    swap(A[i], B[l]);
  }

  string ansS;

  for (int i=0; i<N*2; i++) {
    if (ans[i]) ansS += "R";
    else ansS += "B";
  }

#ifdef LOCAL
  string strSS = SS;
  cout << SS << endl;
  cout << (SS == ansS ? "AC" : "WA") << endl;
#endif

  cout << "! " << ansS << endl;

  return 0;
}


Measured memory_bytes: 724
#include <stdio.h>
 
int main(void){
 
  char S[4], T[4];
  int i, count;
 
  scanf("%s", &S);
  scanf("%s", &T);
  for(i = 0; i <= 2 ;i++)
  {
    if(S[i] == T[i])
    count++;
  }
  printf("%d", count);
return 0;
}

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

int main(){
  int N , K ; 
  cin >> N >> K ;
  vector<int> C(N);
  for(int i = 0 ; i < N ; i++){
    int A ; 
    cin >> A ; 
    A-- ; 
    C.at(A)++ ; 
  }

  //cout << C.at(1)
  sort(C.begin(),C.end()) ;
  reverse(C.begin(),C.end()) ;
  int ans = 0 ; 
  int cnt = 0 ; 
  for( int p : C ){
    if(K > cnt){
      ans += p ; 
      cnt++ ; 
    }
    else break ; 
  }
  
  cout << N - ans << endl ; 
}

Measured memory_bytes: 3964
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n;
    scan(n);
    auto ans = 180 * (n - 2);
    writeln(ans);
}

















int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int a[100],n;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=9;i++)
		for (int j=1;j<=9;j++) a[i*j]=1;
	if (n<=81 && a[n]) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define X first
#define Y second
#define vsort(v) sort(v.begin(), v.end())
#define vrev(v) reverse(v.begin(), v.end())
#define vmax_p(v) max_element(v.begin(), v.end())
#define vmin_p(v) min_element(v.begin(), v.end())
#define vmax_idx(v) distance(v.begin(), vmax_p(v))
#define vmin_idx(v) distance(v.begin(), vmin_p(v))
#define vcopy(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define P pair

// stoi(s): string to int
// stod(s): string to double

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

// floor(x): truncate

// 2進数変換
// string s = bitset<20>(x).to_string();

using namespace std;
using ll = long long;

void displayVec(vector<int> v)
{
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i] << endl;
    }
    cout << endl;
}

int binarySearch(vector<int> v, int target)
{
    int left = -1;
    int right = v.size();

    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (v[mid] >= target)
        {
            right = mid;
        }
        else
        {
            left = mid;
        }
    }

    if (right < v.size() && v[right] == target)
    {
        return right;
    }
    return -1;
}

int main(int argc, const char *argv[])
{
    string s, a, b;
    cin >> s;
    a = s.substr(0, 2);
    b = s.substr(2, 2);

    int y, m;
    y = stoi(a);
    m = stoi(b);
    // cout << y << " " << m << endl;
    if (y >= 1 && y <= 12 && m >= 1 && m <= 12)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (y >= 1 && y <= 12)
    {
        cout << "MMYY" << endl;
    }
    else if (m >= 1 && m <= 12)
    {
        cout << "YYMM" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;

void input() {
  cin >> n;
}

void solve() {
  if (n == 1) {
    cout << "Hello World";
  } else {
    int a;
    int b;
    cin >> a >> b;

    cout << a + b;
  }
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	using namespace std;
	int main(int argc, char const *argv[])
	{
		string s;
		int r = 0,b = 0;
		int n;
		cin>>n>>s;
		for (int i = 0; i < s.size(); ++i)
		{
			if(s[i] =='R') r++;
			else b++;
		}
		if (r>b) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		return 0;
	}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.typecons;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto ai = readln.split.map!(rd => card(rd[0], rd[1..$].to!int)).array;

  auto bi = bubbleSort(ai, n);
  auto si = selectionSort(ai, n);

  writeln(bi.map!(a => a.suite.to!string ~ a.value.to!string).join(" "));
  writeln("Stable");
  writeln(si.map!(a => a.suite.to!string ~ a.value.to!string).join(" "));
  writeln(bi == si ? "Stable" : "Not stable");
}

card[] bubbleSort(card[] ai, size_t n)
{
  auto bi = ai.dup;
  foreach (i; 0..n)
    foreach_reverse (j; i+1..n)
      if (bi[j].value < bi[j-1].value)
        swap(bi[j], bi[j-1]);
  return bi;
}

card[] selectionSort(card[] ai, size_t n)
{
  auto bi = ai.dup;
  foreach (i; 0..n) {
    auto minJ = i;
    foreach (j; i..n)
      if (bi[j].value < bi[minJ].value)
        minJ = j;
    swap(bi[i], bi[minJ]);
  }
  return bi;
}

alias Tuple!(char, "suite", int, "value") card;

Measured memory_bytes: 2548
import math

line = list(input().split(" "))
a = int(line[0])
b = int(line[1])
x = int(line[2])

s = 2*b-2*x/(a**2)
if s <= b:
    print(math.degrees(math.atan(s/a)))
    exit()
s = 2*x/(b*a)
print(math.degrees(math.atan(b/s)))

Measured memory_bytes: 38384
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int N,K;
int d[100005];
int ans[2005];
int MOD=1000000007;
struct Combination{
    int MAX_N;
    int MOD;
    int *fac, *finv, *inv;
    Combination(int max_n,int mod): MAX_N(max_n+1),MOD(mod){ //make table
        fac = new int[MAX_N];finv = new int[MAX_N];inv = new int[MAX_N];
        fac[0]=fac[1]=1;
        finv[0]=finv[1]=1;
        inv[1]=1;
        for (int i = 2; i < MAX_N; 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;
        }
    }
    int 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;
    }
    void free_COM(){
        delete[] fac;
        delete[] finv;
        delete[] inv;
    }
    
};
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

signed main(){
    scanf("%lld %lld",&N,&K);
    Combination CB(N,MOD);
    rep(i,K)ans[i]=0;
    int sum=0;
    rep(i,K+1){
        if(i==0)continue;
        if(N-K+1>=i)ans[i]=CB.COM(N-K+1,i)*CB.COM(K-1,i-1) ;
        printf("%lld\n",ans[i]%MOD);
    }
    CB.free_COM();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <stdio.h>
using namespace std;

int main()
{
    int n, m, a, b;
    cin >> n >> m;
    int ma[n + 1], h[n + 1];
    int i;
    for(i = 1; i <= n; i++){
        cin >> h[i];
        ma[i] = 0;
    }
    int ans = 0;

    for(i = 0; i< m; i++){
        cin >> a >> b;
        ma[a] = max(ma[a], h[b]);
        ma[b] = max(ma[b], h[a]);
    }

    for(i = 1; i <= n; i++){
        ans += h[i] > ma[i];
    }

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

Measured memory_bytes: 4368
b_ifo = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    b_ifo[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(" " + str(b_ifo[i][j][k]), end = "")
        print()
    if i != 3:
        print("#" * 20)

Measured memory_bytes: 7680
a=[0]*5
index=0
index_0=0
count=9
s=0
j=0
for i in range(5):
    a[i]=int(input())
    if a[i]%10==0:
        index_0+=1
    else:
        count=min(a[i]%10,count)
        j+=1
    s+=a[i]//10
if j!=0:
    print(s*10+count+(4-index_0)*10)
else:
    print(sum(a))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int num;
		Scanner sc = new Scanner(System.in);
		num = sc.nextInt();
		TreeNode[] node = new TreeNode[num];
		for(int i=0;i<num;i++) {
			node[i] = new TreeNode();
		}
		for(int i=0;i<num;i++) {
			int parent =sc.nextInt();
			int left = sc.nextInt();
			int right = sc.nextInt();
			node[parent].left = left;
			node[parent].right = right;
			if(left!=-1) {
				node[left].parent = parent;
			}
			if(right!=-1) {
				node[right].parent = parent;
			}
			
		}
		for(int i=0;i<num;i++) {
			System.out.println("node "+i+": parent = "+node[i].parent+", sibling = "+getSibling(node, i)+", degree = "+getDegree(node[i])
			+", depth = "+getDepth(node,i)+", height = "+getHeight(node,i)+", "+getType(node, i));
		}
		
	}	
	
	public static int getSibling(TreeNode[] node,int i) {
		int parent = node[i].parent;
		if(parent==-1)
			return -1;
		if(node[parent].left==i) 
			return node[parent].right;
		else
			return node[parent].left;
		
	}
	
	public static int getDegree(TreeNode node) {
		if(node.left!=-1&&node.right!=-1) {
			return 2;
		}else if(node.left!=-1||node.right!=-1) {
			return 1;
		}else {
			return 0;
		}
	}
	
	public static int getDepth(TreeNode[] node,int i) {
		int parent = node[i].parent;
		if(parent==-1) {
			return 0;
		}
		return getDepth(node,parent)+1;
	}
	
	public static int getHeight(TreeNode[] node,int i) {
		int left = node[i].left;
		int right = node[i].right;
		int leftValue=0;
		int rightValue=0;
		if(left!=-1) {
			leftValue = getHeight(node,left)+1;
		}
		if(right!=-1) {
			rightValue = getHeight(node,right)+1;
		}
		return leftValue>rightValue?leftValue:rightValue;
	}
	
	public static String getType(TreeNode[] node,int i) {
		if(node[i].parent==-1) {
			return "root";
		}else if(node[i].left>-1||node[i].right>-1) {
			return "internal node";
		}else {
			return "leaf";
		}
	}
	
		
}

class TreeNode {
	public int parent;
	public int left;
	public int right;

public TreeNode() {
	parent = -1;
}
}



Measured memory_bytes: 26540
INF=10**30
N=list(map(int,list(input())))[::-1]
l=len(N)
dp=[[INF,INF] for i in range(l+1)]
dp[0][0]=0
for i in range(l):
    dp[i+1][0]=min(dp[i][0]+N[i],dp[i][1]+N[i]+1)
    dp[i+1][1]=min(dp[i][0]+(10-N[i]),dp[i][1]+(9-N[i]))
print(min(dp[l][0],dp[l][1]+1))

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

string S;

void solve() {
  int n = S.size();
  ll cntA = 0;
  ll res = 0;
  for (int i = 0; i < n; i++) {
    if (S[i] == 'A') {
      cntA++;
      continue;
    }
    if (i < n - 1 && S.substr(i, 2) == "BC") {
      res += cntA;
      i++;
      continue;
    }
    if (S[i] != 'A') {
      cntA = 0;
    }
  }
  cout << res << "\n";
}

int main() {
  cin >> S;
  solve();
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class combination{
private:
    vector<mint> fact,finv;
public:
    combination(int N){
        fact = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            finv[i] = fact[i].inv();
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};

int main(){
    ll N,M;
    cin >> N >> M;
    combination c(N+3*M);
    mint ans = c.hcomb(N,3*M);
    for(int k=M+1;k<=min(N,3*M);k++){
        if((3*M-k)%2==0){
            ans -= c.comb(N,k)*c.hcomb(N,(3*M-k)/2);
        }
    }
    ans -= c.hcomb(N,M-1)*N;
    cout << ans.x << endl;
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    rep(i, 0, 5) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll A, B, N;

    cin >> A >> B >> N;

    ll x = (N >= B) ? (B-1) : N;
    ll Ax = A*x;

    ll ans = (Ax/B) - (A * (x/B));
    cout << ans << endl;
}


Measured memory_bytes: 3596
n,m = map(int,input().split())
a_b = {}
for i in range(n):
    x,y = map(int,input().split())
    if x in a_b.keys():
        a_b[x] += y
        continue
    a_b[x] = y
a_b = sorted(a_b.items(), key=lambda x:x[0])

#print(a_b)
c = 0
ans = 0
t = 0
for i in range(int(len(a_b))):
    c += a_b[i][1]
    if c > m:
        ans += a_b[i][0] * (m - t)
        break
    else:
        ans += a_b[i][0] * a_b[i][1]
        t += a_b[i][1]

print(ans)


Measured memory_bytes: 95352
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}
 
int main() {
	ll N;
	cin >> N;
	vector<ll> Ais;
	for (ll i = 0; i < 3 * N; i++) {
		ll Ai;
		cin >> Ai;
		Ais.push_back(Ai);
	}
	struct TermInfo {
		ll idx;
		ll value;
		static bool comp(TermInfo lhs, TermInfo rhs) {
			return lhs.value < rhs.value || (lhs.value == rhs.value && lhs.idx < rhs.idx);
		}
	};
	set<TermInfo, decltype(&TermInfo::comp)> left_large(&TermInfo::comp);
	set<TermInfo, decltype(&TermInfo::comp)> left_small(&TermInfo::comp);
	set<TermInfo, decltype(&TermInfo::comp)> right_small(&TermInfo::comp);
	set<TermInfo, decltype(&TermInfo::comp)> right_large(&TermInfo::comp);
	ll left_large_sum = 0;
	ll right_small_sum = 0;
	for (ll i = 0; i < N; i++) {
		left_large.insert(TermInfo{i, Ais[i]});
		left_large_sum += Ais[i];
	}
	vector<TermInfo> right;
	for (ll i = N; i < 3 * N; i++) {
		right.push_back(TermInfo{i, Ais[i]});
	}
	sort(right.begin(), right.end(), TermInfo::comp);
	for (ll i = 0; i < N; i++) {
		right_small.insert(right[i]);
		right_small_sum += right[i].value;
	}
	for (ll i = N; i < 2 * N; i++) {
		right_large.insert(right[i]);
	}
	ll ans = numeric_limits<ll>::min();
	ll left_end = N;
	while (true) {
		ans = max(ans, left_large_sum - right_small_sum);
		if (left_end == 2 * N) {
			break;
		}
		TermInfo le{left_end, Ais[left_end]};
		if (right_small.find(le) != right_small.end()) {
			right_small_sum -= right_small.find(le)->value;
			right_small.erase(right_small.find(le));
			right_small_sum += right_large.begin()->value;
			right_small.insert(*right_large.begin());
			right_large.erase(right_large.begin());
		} else {
			assert(right_large.find(le) != right_large.end());
			right_large.erase(right_large.find(le));
		}
		left_large_sum += le.value;
		left_large.insert(le);
		left_small.insert(*left_large.begin());
		left_large_sum -= left_large.begin()->value;
		left_large.erase(left_large.begin());
		left_end++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 26984
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;

int main() {
	int N, x; cin >> N;
  	map<int,int> mp;
	for(int i = 0; i < N; i++){
		cin >> x;
      	mp[x]++;
	}	


	int ans = 0;
	for (auto p: mp) {
		int x = p.first;
		int n = p.second;
		if (n < x) ans += n;
		else ans += n - x;
	}

	cout << ans << endl;
}


Measured memory_bytes: 4736
n = int(input())
a = list(map(int, input().split()))

ans = 0

for i in range(n):
  ai = a[i]
  if ai % 2 == 0:
    if (ai % 3) * (ai % 5) != 0:
      ans += 1
      
if ans >= 1:
  print('DENIED')
else:
  print('APPROVED')

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

const ll MOD=1000000007;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b){
  ll p=1;
  for(int i=0;i<b;i++){
    p*=a;
  }
  return p;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  string s="";
  string lc,rc;
  cout<<0<<endl;
  cin>>rc;
  if(rc=="Vacant")return 0;
  int left=0,right=n;
  cnt=1;j=-1;
  while(1){
    i=(left+right)/2;
    if(i==j)i++;
    cout<<i<<endl;
    j=i;
    cin>>s;
    if(s=="Vacant")return 0;
    if(rc==s){
      if((right+i)%2==1)left=i;
      else right=i;
    }else{
      if((right+i)%2==1){
        right=i;
        rc=s;
      }
      else left=i;
    }
    cnt++;
  }
}


Measured memory_bytes: 852
def g;gets.to_i;end
r=0..7
g.times{|n|gets
m=r.map{gets}
q=[[g-1,g-1]]
(x,y=q.pop;r===x|y&&m[y][x]>?0&&(m[y][x]=?0;(-3..3).map{|i|q<<[x,y+i];q<<[x+i,y]}))while q!=[]
puts"Data #{n+1}:",m}

Measured memory_bytes: 6112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;



signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    char memo[112345] = {};
    cout << 0 << endl;
    string s; cin >> s;
    if(s == "Male"){
        memo[0] = 'M';
    }else if(s == "Female"){
        memo[0] = 'F';
    }else{
        return 0;
    }
    int l = 0, r = N;
    while(r - l > 1){
        int mid = (l+r)/2;
        cout << mid << endl;
        string tmp; cin >> tmp;
        if(tmp == "Male"){
            if((mid-l)%2 == 0){
                if(memo[l] == 'M'){
                    l = mid;
                }else{
                    r = mid;
                }
            }else{
                if(memo[l] == 'F'){
                    l = mid;
                }else r = mid;
            }

            memo[mid] = 'M';
        }else if(tmp == "Female"){
            if((mid-l)%2 == 0){
                if(memo[l] == 'F') l = mid;
                else r = mid;
            }else{
                if(memo[l] == 'M') l = mid;
                else r = mid;
            }

            memo[mid] = 'F';
        }else{
            return 0;
        }
    }

}


Measured memory_bytes: 980
// AtCoder 第二回全国統一プログラミング王決定戦予選
// A - Sum of Two Integers
// 2019.11.10 bal4u

#include <stdio.h>

int main()
{
	int N, ans;
	
	scanf("%d", &N);
    ans = N / 2;
    if ((N & 1) == 0) ans--;
    printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int		main(void)
{
	int h,w;
	scanf("%d%d", &h, &w);
	char s[h + 1][w + 1];
	int i = 0;
	int j;
	while (i < h)
	{
		scanf("%s", s[i]);
		i++;
	}
	i = 0;
	int count;
	int k;
	int n;
	char c;
	while (i < h)
	{
		j = 0;
		while (j < w)
		{
			if (s[i][j] == '.')
			{
				k = i - 1;
				count = 0;
				while (k <= i + 1)
				{
					n = j - 1;
					while (n <= j + 1)
					{
						if (s[k][n] == '#')
							count++;
						n++;
					}
					k++;
				}
				s[i][j] = '0' + count;
			}
			j++;
		}
		i++;
	}
	i = 0;
	while (i < h)
	{
		printf("%s\n", s[i]);
		i++;
	}
	return (0);
}


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

int SumOfDigit(int n) {
	int k = n % 10;
	while (n >= 10) {
		n /= 10;
		k += n % 10;
	}
	return k;
}
int main() {
	int N;
	cin >> N;
	int fN = SumOfDigit(N);
	if (N % fN == 0) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+7;
const ll inf_l = 1e18;
const int MAX = 1e6;

int main() {
    string s, t; cin >> s >> t;
    int ans = 0;
    rep(i,s.size()) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3856
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a < b || a == b)
    {
        for (int i = 0; i < b; i++)
            cout << a;
    }
    else for (int i = 0; i < a; i++)
        cout << b;
}

Measured memory_bytes: 3648
#a=list(map(int,input().split(" ")))
a=input()
yy=int(a[:2])
mm=int(a[2:])

def isYM(yy,mm):
    if(0<mm and mm<=12):
        return True
    return False
        
def isMY(yy,mm):
    return isYM(mm,yy)


ym=isYM(yy,mm)
my=isMY(yy,mm)
if ym==True and my==True:
    print("AMBIGUOUS")
elif ym==False and my==True:
    print("MMYY")
elif my==False and ym==True:
    print("YYMM")
else:
    print("NA")


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define foru(i, n) for(int i = 1; i <= n; i++)
#define foru0(i, n) for(int i = 0; i < n; i++)
#define ford(i, n) for(int i = n; i >= 1; i--)
#define ford0(i, n) for(int i = n - 1; i >= 0; i--)
#define fors(i, a, b) for(int i = a; i <= b; i++)

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vii;
typedef vector<pll> v2l;
typedef pair<char, int> pci;
typedef vector<pci> vci;

const int N = 1e6 + 1;
const int NN = 1e3 + 1;
const ll MOD = 1e9 + 7;
const ll oo = 1e18 + 7;

void solve() {
    int n;
    cin >> n;
    vll a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<vector<long long> > dp(n + 2, vector<long long>(n + 2));
    for (int i = n; i; i--) {
        for (int j = i; j <= n; j++) {
            int rem = (n - j) + (i - 1);
            if (rem % 2 == 0) {
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j]);
            } else {
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j]);
            }
        }
    }
    // for (int i = 1; i <= n; i++) {
    //     for (int j = 1; j <= n; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[1][n];
}

int main() {
    #ifdef DEBUG
        freopen("solve.inp", "r", stdin);
        freopen("solve.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(10);
    solve();
    cerr << "Time elapsed: " << 1.0 * clock() << " ms.\n";
}


Measured memory_bytes: 70784
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        new Main().run();
    }

    void run() {
        int n = sc.nextInt();
        int d = sc.nextInt();
        int a = sc.nextInt();
        int[][] arr = new int[n][2];

        for (int i=0; i<n; i++) {
            arr[i][0] = sc.nextInt();
            arr[i][1] = sc.nextInt();
        }

        Arrays.sort(arr, (x, y) -> x[0] - y[0]);

//        System.out.println(arr[2][0]);

        Queue<Pair> queue = new ArrayDeque<>();

        int i = 0;
        long ans = 0;
        long accD = 0;

        while (i < n) {
            while (!queue.isEmpty()) {
                Pair p = queue.peek();
                if (p.x >= arr[i][0]) break;
                accD -= p.damage;
                queue.poll();
            }

            arr[i][1] -= accD;
//            System.out.println(accD);

            if (arr[i][1] > 0) {
                long attack = (long)(arr[i][1] + a - 1) / (long) a;
                ans += attack;
                queue.add(new Pair((arr[i][0] + 2 * d), attack * a));
                accD += attack * a;
            }
            i++;
//            System.out.println(ans);
//            System.out.println(accD);
        }

        System.out.println(ans);


    }

    class Pair {
        long x;
        long damage;
        public Pair(long x, long d) {
            this.x = x;
            this.damage = d;
        }
    }

}


Measured memory_bytes: 125100
/* ex3_4
   YSK722 */

#include <stdio.h>

int main(void){
    int i, number;
    scanf("%d", &number);
    if(number < 1 || 100 < number){  // numberが定義域外のとき
        return 1;                    // 処理終了
    }
    i = 9;
    while(number % i != 0){  // numberの10未満の約数を大きい方から探す
        i--;
    }
    if(number / i < 10){  // 他方の約数が10未満のとき
        printf("Yes\n");  // "Yes"と出力
    }
    else{                // 他方の約数が10以上のとき
        printf("No\n");  // "No"と出力
    }
    return 0;
}

Measured memory_bytes: 128