akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<sstream>
using namespace std;
typedef long long ll;
string i2s(ll x){
  if(x==0) return "0";
  string y;
  ll k=1;
  while(x>=k) k*=10;
  k/=10;
  for(ll i=k;i>0;i/=10){
    y+=(x/i)%10+'0';
  }
  return y;
}
ll s2i(string x){
  for(ll i=0;i<x.size();i++) if(x[i]=='.') x[i]=' ';
  stringstream ss(x);
  ll y;
  ss >> y;
  return y;
}
int main(){
  //cout << i2s(100) << endl;
  ll n;
  
  while(cin>>n,n){
    string buf;
    vector<string> v;
    vector<ll> d;
    ll i,j,k;
    for(i=0;i<n;i++){
      cin >> buf;
      j=0;
      while(buf[j]=='.') j++;
      v.push_back(buf);
      d.push_back(j);
    }
    while(v.size()!=1){
      //for(i=0;i<v.size();i++) cout << v[i] << endl;
      //cout << endl;
      //cout << v.size() << endl;
      k=1;
      for(i=0;i<v.size();i++){
        if(d[k]<d[i]) k=i;
      }
      //cout << k << ":" << v[k-1][v[k-1].size()-1] << endl;
      if(v[k-1][v[k-1].size()-1]=='+'){
        i=0;j=0;
        while(1) {
          if(d[k]!=d[k+i]) break;
          //j*=(v[k+i][v[k+i].size()-1]-'0');
          j+=s2i(v[k+i]);
          i++;
          if(k+i==d.size()) break;
        }
        //cout << i << ":" << j << endl;
        v[k-1]=v[k-1].substr(0,v[k-1].size()-1);
        v[k-1]+=i2s(j);
        v.erase(v.begin()+k,v.begin()+k+i);
        d.erase(d.begin()+k,d.begin()+k+i);
      }
      if(v[k-1][v[k-1].size()-1]=='*'){
        i=0;j=1;
        while(1) {
          if(d[k]!=d[k+i]) break;
          //j*=(v[k+i][v[k+i].size()-1]-'0');
          j*=s2i(v[k+i]);
          i++;
          if(k+i==d.size()) break;
        }
        //cout << i << endl;
        v[k-1]=v[k-1].substr(0,v[k-1].size()-1);
        v[k-1]+=i2s(j);
        v.erase(v.begin()+k,v.begin()+k+i);
        d.erase(d.begin()+k,d.begin()+k+i);
      }
        
    }
    cout << v[0] << endl;
  }
  return 0;
}

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

vector<long long> num;
string s;
stack<long long> st, ans, memonum, memoid, memoh;

void solve();

int main() {
  cin >> s;
  solve();
  return 0;
}
void solve() {
  long long height = 0, n = s.size(), now = 0;
  ans.push(0);
  memonum.push(0);
  memoid.push(1);
  memoh.push(0);
  num.assign(n + 1, 0);
  for(int i = 0; i < n; ++i) {
    if(s[i] == '(') {
      st.push(s[i]);
      height = max(height + 1, 1LL);
      memoh.push(height);
      memoid.push(height);
      memonum.push(num[height]);
      ++num[height];
      ans.push(ans.top());
    }
    else if(s[i] == ')') {
      st.push(s[i]);
      now = ans.top();
      if(height > 0) now += num[height];
      memoid.push(height + 1);
      if(height + 1 > 0)
        memonum.push(num[height + 1]);
      else
        memonum.push(0);
      if(height + 1 > 0) num[height + 1] = 0;
      --height;
      memoh.push(height);
      ans.push(now);
    }
    else {
      if(memoid.top() > 0)
        num[memoid.top()] = memonum.top();
      else
        num[1] = 0;
      memoid.pop();
      memonum.pop();
      st.pop();
      ans.pop();
      memoh.pop();
      height = memoh.top();
    }
    cout << ans.top() << endl;
  }
}


Measured memory_bytes: 12804
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
ans = 0
for x in range(1, n+1):
    y = n // x
    ans += y * (y + 1) * x // 2
print(ans) 

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

int main() {
	int n, q;
	long long sum = 0;
	int check[100001] = { 0, };
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		sum += a;
		check[a]++;
	}

	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		int b, c;
		scanf("%d %d", &b, &c);
		sum -= (long long)check[b] * b;
		sum += (long long)check[b] * c;
		check[c] += check[b];
		check[b] = 0;
		printf("%lld\n", sum);
	}

	return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n, d;
    cin>>n>>d;
    int mat[10][10];
    for(int i=0; i< n; i++){
        for(int j = 0; j< d; j++){
            cin>>mat[i][j];
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j = i+1; j< n; j++){
            int sum = 0;
            for(int k= 0; k< d; k++){
                sum+= (mat[i][k] - mat[j][k]) *(mat[i][k] - mat[j][k]);
            }
            int dist = sqrt(sum);
            if(dist * dist == sum){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_11_D: Connected Components

#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>

using uint = unsigned int;

class Graph {
  std::vector<std::vector<uint>> g_;
  std::vector<int> root_;
  enum { NIL = -1, IN_STACK= -2 };

public:
  Graph(uint n)
  {
    g_.resize(n);
    root_.resize(n);
  }

  void add(uint from, uint to)
  {
    g_[from].push_back(to);
    g_[to].push_back(from);
  }

  void setup()
  {
    std::fill(root_.begin(), root_.end(), NIL);
    for (auto i = 0u; i < g_.size(); ++i ) {
      if (root_[i] == NIL) {
        dfs(i);
      }
    }
  }

  bool reachable(uint from, uint to) const
  {
    return root_[from] == root_[to];
  }

private:
  void dfs(uint root)
  {
    std::stack<uint> s;
    s.push(root);
    while (!s.empty()) {
      auto i = s.top();
      s.pop();
      root_[i] = root;
      for (auto j : g_[i]) {
        if (root_[j] == NIL) {
          root_[j] = IN_STACK;
          s.push(j);
        }
      }
    }
  }
};

int main()
{
  uint n, m;
  std::scanf("%u %u", &n, &m);

  Graph g(n);

  uint s, t;
  for (auto i = 0u; i < m; ++i) {
    std::scanf("%u %u", &s, &t);
    g.add(s, t);
  }
  g.setup();

  uint q;
  std::scanf("%u", &q);
  for (auto i = 0u; i < q; ++i) {
    std::scanf("%u %u", &s, &t);
    std::puts(g.reachable(s, t) ? "yes" : "no");
  }
}

// eof

Measured memory_bytes: 8172
/*Program from Luvwgyx*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define int long long
using namespace std;
char s[10];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
void query(int x){printf("? %lld\n",x);fflush(stdout);scanf("%s",s);}
signed main()
{
    int x=1e9;query(x);
    if (s[0]=='Y')
    {
        for(int i=9;i;i--)
        {
            query(x-1);
            if (s[0]=='N') break;
            x/=10;
        }
        printf("! %lld\n",x);
        return 0;
    }
    for (int i=9;i;i--)
    	{
        x/=10;
        query(x);
        if (s[0]=='Y')
        {
            break;
        }
    }
    int l=x+1,r=x*10-1,ans;
    while(l<=r)
    {
        ll mid=(l+r)>>1;
        query(mid*10);
        if (s[0]=='Y') ans=mid,r=mid-1;
        else l=mid+1;
    }
    printf("! %lld\n",ans);
    return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	const int M = 256;
	int N;
	while (cin >> N && N) {
		int I[256];
		for (int i=1; i<=N; ++i) cin >> I[i];
		double Hmin = 1000.0;
		int s, a, c, upper = N;
		for (int S=0; S<=15; ++S) {
			for (int A=0; A<=15; ++A) {
				for (int C=0; C<=15; ++C) {
					int x[256] = {0};
					int R = S;
					int O;
					int cnt = 0;
					for (int i=1; i<=N; ++i) {
						R = (A * R + C) % M;
						O = (I[i] + R) % M;
						cnt += x[O] == 0;
						if (upper < cnt) break;
						x[O] ++;
					}
					if (cnt <= upper) {
						upper = cnt;
						double H = 0;
						for (int i=0; i<256; ++i) {
							if (x[i]) H -= (double)x[i] / N * log((double)x[i] / N);
						}
						if (H + 1e-9 < Hmin) {
							Hmin = H;
							s = S;
							a = A;
							c = C;
						}
					}
				}
			}
		}
		cout << s << " " << a << " " << c << endl;
	}
	return 0;
}

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

map<int, long> mp;
int main() {
    int N, M; cin >> N >> M;
    long R[100010];
    cin >> R[0];
    for(int i=1; i<N; ++i){
        cin >> R[i];
        R[i] += R[i-1];
    }
    for(int i=0; i<N; ++i) ++mp[R[i]%M];
    long ans=0;
    for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
        long t=itr->second;
        if(itr->first<1) ans += t*(t+1)/2;
        else ans += t*(t-1)/2;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
const int maxm=1e6+5;
string s[maxm];
int ans;
int n;
struct Trie{
    int a[maxm][26],tot;
    int type[maxm];
    int val[maxm];
    int ed[maxm][26];
    void add(string s){
        int len=s.size();
        int node=0;
        for(int i=len-1;i>=0;i--){
            int v=s[i]-'a';
            if(!a[node][v]){
                a[node][v]=++tot;
                type[tot]=v;
            }
            node=a[node][v];
        }
        val[node]++;
    }
    void dfs(int x){
        for(int i=0;i<26;i++){
            int v=a[x][i];
            if(!v)continue;
            dfs(v);
            val[x]+=val[v];
            for(int j=0;j<26;j++){
                ed[x][j]+=ed[v][j];
            }
        }
        ed[x][type[x]]=val[x];
    }
    void cal(string s){
        int len=s.size();
        int node=0;
        for(int i=len-1;i>=1;i--){
            int v=s[i]-'a';
            node=a[node][v];
        }
        for(int i=0;i<26;i++){
            int v=a[node][i];
            if(!v)continue;
            ans+=ed[v][s[0]-'a'];
        }
    }
}T;
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
        T.add(s[i]);
    }
    T.dfs(0);
    for(int i=1;i<=n;i++){
        T.cal(s[i]);
    }
    ans-=n;
    cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 544064
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=4e5+10;
typedef long long LL;
const LL INF=1e15+10;

int n;
LL x[maxn],e,t;
int ll[maxn],rr[maxn];
LL mini1[maxn],mini2[maxn];
LL dp[maxn];

void build(int p,int l,int r)
{
	ll[p]=l;rr[p]=r;
	mini1[p]=mini2[p]=INF;
	if (l==r) return;
	build(p<<1,l,(l+r)>>1);
	build((p<<1)|1,((l+r)>>1)+1,r);
	return;
}

void update(int p,int pos,LL val,int tp)
{
	if (!tp) mini1[p]=min(mini1[p],val);
	else mini2[p]=min(mini2[p],val);
	if (ll[p]==rr[p]) return;
	if (pos<=rr[p<<1]) update(p<<1,pos,val,tp);
	else update((p<<1)|1,pos,val,tp);
	return;
}

LL getmini(int p,int l,int r,int tp)
{
	if (l>r) return INF;
	if (r<ll[p] || rr[p]<l) return INF;
	if (l<=ll[p] && rr[p]<=r) 
	{
		if (!tp) return mini1[p];
		else return mini2[p];
	}
	return min(getmini(p<<1,l,r,tp),getmini((p<<1)|1,l,r,tp));
}

int main()
{
	scanf("%d%lld%lld",&n,&e,&t);
	for(int i=1;i<=n;i++) scanf("%lld",&x[i]);
	x[n+1]=e;
	
	dp[0]=x[1];
	build(1,0,n);
	update(1,0,dp[0]-x[1],0);
	update(1,0,dp[0]-x[1]*3ll,1);
	for(int i=1;i<=n;i++)
	{
		int tmp=lower_bound(x+1,x+n+1,x[i]-(t>>1))-x;
		dp[i]=min(getmini(1,0,tmp-2,1)+3ll*x[i],getmini(1,tmp-1,i-1,0)+t+x[i]);
		dp[i]+=x[i+1]-x[i];
		update(1,i,dp[i]-x[i+1],0);
		update(1,i,dp[i]-x[i+1]*3ll,1);
		//printf("%d %d\n",tmp,dp[i]);
	}
	printf("%lld\n",dp[n]);
	return 0;
}

Measured memory_bytes: 13184
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(void){
    int n, A, B, a = 0, b = 0;
    string s;
    cin >> n >> A >> B;
    cin >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a') {
            a++;
            if (a + b <= A + B) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
        else if (s[i] == 'b') {
            b++;
            if (a + b <= A + B && b <= B) cout << "Yes" << endl;
            else {cout << "No" << endl; b--;}
        }
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    cin >> x >> y;
    while(x % y != 0){
        if(y > x){
            int temp = x;
            x = y;
            y = temp;
        }
        x = x % y;
    }
    cout << y << endl;
    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=998244353;
const ll inf=1e17;
const ll ms=(2e5)+5;

vector<ll> a;
vector<ll> b;

ll sa[ms]={0};
ll sb[ms]={0};

int main()
{
    idfc;
    int n,k;
    cin>>n>>k;
    int i;
    int gc=0;
    int e;
    int fl=0;
    while(n--)
    {
        cin>>e;
        if(e>=k)fl=1;
        gc=__gcd(gc,e);
    }
    if(!fl||(k%gc))cout<<"IMPOSSIBLE";
    else cout<<"POSSIBLE";
    return 0;
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    vi a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    cin  >> k;

    cout << a[k-1] << "\n";
    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;

    cin >> k;

    cout << arr[k-1] << endl;

    return 0;
}

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

int main(){
  int n,m,ans,low,hi;
  cin >> n >> m;
  vector<int>L(m),R(m);
  for(int i = 0;i < m;i++){
    cin >> L.at(i) >> R.at(i);
  }
  low = L.at(0);hi = R.at(0);
  for(int i = 1;i < m;i++){
    if(L.at(i) > low){
      low = L.at(i);
    }
    if(R.at(i) < hi){
      hi = R.at(i);
    }
  }
  ans = hi - low +1;
  if(ans >= 0){
  cout << ans << endl;
  }else{
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

void swap(int *nx, int *ny)
{
    int temp = *nx;
    *nx = *ny;
    *ny = temp;
}


void sort3(int *n1, int *n2, int *n3)
{
    if (*n1 > *n2) swap(n1, n2);
    if (*n2 > *n3) swap(n2, n3);
    if (*n1 > *n2) swap(n1, n2);
}

int main(void)
{
    int na, nb, nc;
    
   
    scanf("%d %d %d", &na, &nb, &nc);
    
    sort3(&na, &nb, &nc);
    

    printf("%d %d %d\n", na, nb, nc);
    
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  char a,b;
  cin >> a >> b;
  if(a=='H'&&b=='H')puts("H");
  if(a=='D'&&b=='H')puts("D");
  if(a=='H'&&b=='D')puts("D");
  if(a=='D'&&b=='D')puts("H");
  return 0;
}

Measured memory_bytes: 256
s = input()
len_s = len(s)

if s[-1] == "1":
	print(-1)
	exit()
for i in range((len_s - 1)//2):
	if s[i] != s[len_s - 2 - i]:
		print(-1)
		exit()
if s[0] != '1':
	print(-1)
	exit()

num = 1
for i in range(len_s - 1):
	if s[i] == '1':
		print('{0} {1}'.format(num, i + 2))
		num = i + 2
	else:
		print('{0} {1}'.format(num, i + 2))

Measured memory_bytes: 45400
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 10000;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int c = 0;
			while(a%2==0) {
				a/=2;
				c++;
			}
			min = Math.min(min, c);
		}
		System.out.println(min);
	}
}

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

int main(){
  string s;
  cin >> s;
  int difnum = 0;
  for(int i=0;i<s.length()/2;i++){
    if(s.at(i)!=s.at(s.length()-1-i))
      difnum++;
  }
  cout << difnum << endl;
  return 0;
}

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

using namespace std;

int main() {
  long long int n;
  cin >> n;
  string s = to_string(n);
  vector<int> sum(s.size(), 0);
  sum[0] = s[0] - '0';
  for (int i = 1; i < s.size(); ++i) {
    sum[i] = sum[i - 1] + s[i] - '0';
  }
  /*for (int i = 0; i < s.size(); ++i) {
    cout << sum[i] << endl;
  }*/
  int max_sum = sum[s.size() - 1];
  for (int i = 0; i < s.size(); ++i) {
    int temp = s[i] - '1' + ((int)(s.size()) - i - 1) * 9;
    if(i != 0)
    {
      temp += sum[i - 1];
    }
    max_sum = max(max_sum, temp);
  }
  cout << max_sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl;
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;



int main() {
  ll x, y; cin >> x >> y;
  
  ll ans = INF;

  Rep(i, 0, 1){
    Rep(j, 0, 1){
      ll a = pow(-1, i)*x;
      ll b = pow(-1, j)*y;
      if(b >= a) chmin(ans, i+j+b-a);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
i,w;main(c){
  for(;(c=getchar_unlocked())>10;)w=c==32?0:w*10+c-48;
  for(;i++<w+2;)putchar_unlocked('#');
  putchar_unlocked(10);
  putchar_unlocked('#');
  for(;~(i=getchar_unlocked());){
    if(i==10)putchar_unlocked('#');
    putchar_unlocked(i);
    if(i==10)putchar_unlocked('#');
  }
  for(;i++<w;)putchar_unlocked('#');
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (Math.abs(a - b) % 2 == 0) {
      os.println(Math.min(a, b) + Math.abs(a - b) / 2);
    } else {
      os.println("IMPOSSIBLE");
    }
  }
}

Measured memory_bytes: 22608
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;
int main()
{
    int n;

    cin >> n;

    if (n == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    else if (n == 23) {
        cout << "Christmas Eve Eve" << endl;
    }
    else if (n == 24) {
        cout << "Christmas Eve" << endl;
    }
    else {
        cout << "Christmas" << endl;
    }
    return 0;
}



Measured memory_bytes: 3628
/*input
4
5 13 8 1000000000
*/

#include <bits/stdc++.h>

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	int g = 0;
	for (int i = 0; i < n; i++) {
		int num;
		scanf("%d", &num);
		g = __gcd(g, num);
	}
	printf("%d\n", g);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define N 21
int main(){
	int n,p[N]={};
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> p[i];
	}
	int ct=0;
	for(int i=1;i<n-1;i++){
		if((p[i]>p[i-1] && p[i]<p[i+1]) || (p[i]<p[i-1] && p[i]>p[i+1])){
			ct++;
		}
	}
	cout << ct << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,p;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> k >> p;
		if(k%p==0){
			cout << p << endl;
		}else{
			cout << k%p << endl;
		}
	}
}  


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

int main()
{
	string s; cin >> s;
	
	vector<int> c(s.size()); for (int i = 0; i < s.size(); i++) c[i] = (int)(s.at(i) - '0');

	vector<char> d(s.size() - 1);

	for (int bit = 0; bit < (1<<s.size() - 1); bit++) {

		int tmp_sum = c[0];		
		for (int i = 0; i < s.size() - 1; i++) {

			if (bit & (1 << i)) {
				tmp_sum += c[i + 1];
				d[i] = '+';
			}
			else {
				tmp_sum -= c[i + 1];
				d[i] = '-';
			}	

		}
		if (tmp_sum == 7) break;

	}	

	cout << s[0] << d[0] << s[1] << d[1] << s[2] << d[2] << s[3] << "=7" << endl;

	return 0;
}

Measured memory_bytes: 256
<?php
//$N = (int)trim(fgets(STDIN));
$S = trim(fgets(STDIN));
//list($A,$B,$N) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

if ($S=="ARC") {
  printf("ABC\n");
}
else {
  printf("ARC\n");
}


Measured memory_bytes: 16208
#include<stdio.h>
int main()
{
  int n,x[400],y[400],i,m,j,k,x1,y1,l,t;
  char d;
  while(1){
    x1=10;
    y1=10;
    t=0;
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d%d",&x[i],&y[i]);
    }
    scanf("%d",&m);
    for(j=0;j<m;j++){
      scanf("%c",&d);
      scanf("%c",&d);
      scanf("%d",&l);

      for(k=0;k<l;k++){
	if(d=='N'){y1=y1+1;}
	else if(d=='E'){x1=x1+1;}
	else if(d=='S'){y1=y1-1;}
	else if(d=='W'){x1=x1-1;}


	for(i=0;i<n;i++){
	  if(x[i]==x1&&y[i]==y1){
	    t=t+1;
	    x[i]=-100;
	    y[i]=-100;
	}
      }	
    
  
      }
     
     
    }
    if(t==n){printf("Yes\n");}
    else{printf("No\n");}
  }
  return 0;
  }

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int count_ones(int n)
{
    int ans = 0;
    while (n != 0) {
        if (n & 1) ans++;
        n >>= 1;
    }
    return ans;
}

bool check(int pattern, vector<vector<pair<int, int>>>& answers)
{
    for (int i = 0; i < answers.size(); i++) {
        if ((pattern >> i) & 1) {
            for (auto& p : answers[i]) {
                if (((pattern >> p.first) & 1) != p.second)
                   return false;
            }
        }
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> answers(n);
    for (int i = 0; i < n; i++) {
        int A;
        cin >> A;
        for (int j = 0; j < A; j++) {
            int x, y;
            cin >> x >> y;
            answers[i].push_back(make_pair(x - 1, y));
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        if (check(i, answers)) {
            ans = max(ans, count_ones(i));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# 各桁についての13で割ったあまりを足し合わせると5になる
# "??"の場合、
# 1桁目が"3"だと、13で割ったあまりは3
# 2桁目が"8"だと、13で割ったあまりは2
# 従い83を13で割ったあまりは5
# 下から数えてN桁目までに、あまりの合計がP(0〜12)になっている数がそれぞれいくつあるかをDPする
# dp[i桁目(下から数える)][あまりの合計]

S = input()
N = len(S)
S = S[::-1] # 逆順にしたほうがやりやすい
dp = [[0] * 13 for i in range(N)]
if S[0] != "?":
  dp[0][int(S[0])] = 1 # 指定の数をとりあえずカウント
else:
  for i in range(10):
    dp[0][i] = 1 # 1桁目は、あまり0〜9になる数が一つずつある
     
# あまりリストの管理 桁数が一つ増えるごとに、各数に対しての13で割ったあまりを計算する
amari = [i for i in range(10)]
amarimap = {1:10,10:9,9:12,12:3,3:4,4:1,2:7,7:5,5:11,11:6,6:8,8:2,0:0}

DIV = 10 ** 9 + 7

# 各桁のあまりの数を更新する
# これにより、桁が増えたときに更新すべきあまりの種類（あまり13種類に対して
# ひと桁は10種類しかない）を管理できる
def update_amari():
  for i in range(len(amari)):
    amari[i] = amarimap[amari[i]]

# 2桁目以降をDP
for i in range(1,N):
  update_amari() # 各桁のあまりをアップデート
  if S[i] == "?":
    # あらゆる数が入る
    # i-1桁目の各数のループと、i桁目のあまりの各数のループ
    for j in range(len(dp[i-1])):
      # 前の桁であまりがjだったとき
      for k in amari:
        dp[i][(j + k) % 13] += dp[i-1][j]
        dp[i][(j + k) % 13] %= DIV
  else:
    # 数が決まっている
    for j in range(len(dp[i-1])):
      # あまりが決まっている
      am = amari[int(S[i])]
      dp[i][(j + am) % 13] += dp[i-1][j]
      dp[i][(j + am) % 13] %= DIV
        
# 最終桁までいったときにあまりが5になる数が必要なので、dp[N-1][5]が答え
print(dp[N-1][5])


Measured memory_bytes: 62300
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const double inf = 1e9;

const long double eps = 1e-8;

struct TDsu {
    vector<i64> dsu;

    void init(i64 size) {
        dsu.resize(size);

        for (i64 i = 0; i < size; i++) {
            dsu[i] = i;
        }
    }

    i64 find_set(i64 v) {
        if (v == dsu[v]) {
            return v;
        }
        return dsu[v] = find_set(dsu[v]);
    }

    void union_sets(i64 a, i64 b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            dsu[b] = a;
        }
    }
};


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    i64 n, m;
    cin >> n >> m;

    vector<pair<i64, i64>> qs(m);

    for (i64 i = 0; i < m; i++) {
        cin >> qs[i].first >> qs[i].second;
    }

    TDsu dsu;
    dsu.init(n + 1);

    for (i64 i = 0; i < m; i++) {
        dsu.union_sets(qs[i].first, qs[i].second);
    }

    vector<i64> z(n + 1);
    for (i64 i = 1; i <= n; i++) {
        z[dsu.find_set(i)] += 1;
    }

    i64 R = 0;
    for (i64 i = 1; i <= n; i++) {
        R = max(R, z[i]);
    }

    cout << R << endl;


    return 0;
}

Measured memory_bytes: 9532
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

map<string, string> mp, mpg,mpa;

/*--------------------template--------------------*/


int main()
{
	set<ll> st;
	cin >> n >> m >> k;

	REP(i, m)
	{
		st.insert(n*(i + 1));
	}
	REP(i, n)
	{
		st.insert(m*(i + 1));
	}
	REP(i, m)
	{
		ll a = n*(i + 1);
		REP(j, n)
		{
			a += m - (i + 1) - (i + 1);
			st.insert(a);
			st.insert(n*m - a);
		}
	}
	REP(i, n)
	{
		ll a = m*(i + 1);
		REP(j, m)
		{
			a += n - (i + 1) - (i + 1);
			st.insert(a);
			st.insert(n*m - a);
		}
	}

	st.insert(sum);
	if (st.count(k) != 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 13056
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,sys.stdin.readline().split())

n=int(input())
a=list(intinput())
t=1
ans=[]
tmp=0
for i in range(n):
    tmp+=t*a[i]
    t*=-1
ans.append(tmp)
for j in range(n-1):
    ans.append((a[j]-ans[j]//2)*2)
print(" ".join(map(str,ans)))

Measured memory_bytes: 80228
import sys 
def sieves(m):
    N = range(1,m+1,2)
    r = int(m**.5)
    h = len(N)
    N[0] = 0
    for i in range(h):
        x = N[i]
        if x>r: break
        if x and i+x<h: N[i+x:h:x] = [0]*((h-1-i-x)/x+1)
    N[0] = 2
    return N

S = sieves(50100)
for s in sys.stdin:
    n = int(s)
    p1 = n/2-1
    p2 = (n+1)/2
    while S[p1]==0: p1 -=1
    while S[p2]==0: p2 +=1
    print S[p1],S[p2]

Measured memory_bytes: 5816
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 二 10/ 3 19:57:21 2017
 * Ended  Time*  : 四 10/ 5 14:17:39 2017
*********************************************/
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

int n;
LL k;
LL a[MaxN + 5], b[MaxN + 5];

int main(){
	while(~scanf("%d %lld", &n, &k)){
		k++;
		for(int i = 1; i <= n; i++) scanf("%lld %lld", &a[i], &b[i]);
		LL now = 0, ans = 0;
		for(int t = 30; t >= 0; t--){
			now = now ^(1 << t);
			if(k &(1 << t)){
				LL tmp = 0;
				for(int i = 1; i <= n; i++) 
					if((a[i] & now) == 0) tmp += b[i];
				ans = max(ans, tmp);
				now = now ^(1 << t);
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1664
N = int(input())
A = list(map(int, input().split()))
count = 0
A.sort(key=lambda x: abs(x))
for x in A:
    if x < 0:
        count += 1
A = [abs(x) for x in A]
ans = 0
if count % 2 == 0:
    ans = sum(A)
else:
    ans = sum(A[1:]) - A[0]

print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 998244353

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


ll N;
ll fac[10000010],finv[10000010];

ll comb(ll n,ll r){
  if(n<0||r<0||n<r) return 0;
  else return (fac[n]*finv[n-r]%mod)*finv[r]%mod;
}

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

  fac[0]=1;
  rep(i,10000000)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,10000001)finv[i]=mod_pow(fac[i],mod-2);

  cin>>N;
  ll res=mod_pow(3,N);
  repl(A,(N/2)+1,N+1){
    ll cnt=comb(N,A)*mod_pow(2,N-A);
    res=(res-cnt+mod)%mod;
    res=(res-cnt+mod)%mod;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 156544
n, k, s = map(int, input().split())

ans = []
for i in range(n):
  if i < k:
    ans.append(str(s))
  else:
    if s < 10**9:
      ans.append(str(s+1))
    else:
      ans.append(str(1))
print(" ".join(ans))

  
 

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

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

    sort(v.begin(), v.end());

    double ans = (double)v[0];

    for (int i = 1; i < n; ++i) {
        ans = (ans + (double)v[i]) / 2.0;
    }

    cout << fixed << setprecision(10) << ans << endl;
}

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

typedef long long int int64;

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  qsort(a,n,sizeof(int),cmp);
  i=0;
  int64 sum=0;
  while(i<n){
    sum+=a[i];
    int j=i+1;
    while(j<n && 2*sum>=a[j]) sum+=a[j++];
    if(j>=n) break;
    i=j;
  }
  printf("%d\n",n-i);
}

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

Measured memory_bytes: 1020
# C
N = int(input())
s = []
for i in range(N):
    s.append(int(input()))
s.sort()
ans = sum(s)
if ans % 10 == 0:
    for i in range(N):
        if s[i] % 10 != 0:
            ans -= s[i]
            break
if ans % 10 == 0:
    print(0)
else:
    print(ans)            

Measured memory_bytes: 3060
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

Ttot = sum(T)
Wf = [0]*(Ttot+1)
Wb = [0]*(Ttot+1)

i = 0
w = 0
for t,v in zip(T,V):
    for j in range(t):
        i += 1
        w = min(w+1, v)
        Wf[i] = w

i = 0
w = 0
for t,v in zip(T[::-1],V[::-1]):
    for j in range(t):
        i += 1
        w = min(w+1, v)
        Wb[i] = w

ans = 0
wp = 0
wfp = 0
wbp = Wb[Ttot]
for i in range(1, Ttot+1):
    wf = Wf[i]
    wb = Wb[Ttot-i]
    
    w = min(wf, wb)
    ans += wp + 0.5*(w-wp)
    if wf-wfp==1 and wb-wbp==-1 and w==wp:
        ans += 0.25

    wp = w
    wfp = wf
    wbp = wb

print(ans)

Measured memory_bytes: 3444
#include <iostream>
#define MOD 1000000007
using namespace std;

long long pow(long long x,long long n) {
	if (n == 0)return 1;
	long long res = pow((x*x)%MOD, n / 2);
	if (n % 2 == 1) {
		res = ((res%MOD) * x) %MOD;
	}
	return res%MOD;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long m, n; cin >> m >> n;
	cout << pow(m, n) << endl;
}

Measured memory_bytes: 3132
#include <stdio.h>
int main(void){
	int a,b;
	int buf;
	int n = 0;
	
	int i;
	
	scanf("%d %d",&a,&b);
	
	while(1){
		if(a > b){
			if(b > 0){
				a = a%b;
			}else{
				n = a;
			}
		}else if(a < b){
			if(a > 0){
				b = b%a;
			}else{
				n = b;
			}
		}else{
			n = a;
		}
		if(n != 0)break;
	}
	
	printf("%d\n",n);

	return 0;
}

Measured memory_bytes: 592
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll n; cin >> n;
    vl h(n); REP(i, n) cin >> h[i];
    ll ans = 0, mh = 0;
    REP(i, n){
        if(mh <= h[i]){
            ans++;
        }
        mh = max(mh, h[i]);
    }
    cout << ans << endstr;
    return 0;
}


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

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


Measured memory_bytes: 3680
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

int main() {
	int n, k, s;
	while (cin >> n >> k >> s, n) {
		vvi dp(k + 1, vi(s + 1));
		dp[0][0] = 1;
		FOR(i, 1, n) {
			for (int j = k; j > 0; j--) {
				FOR(l, i, s) {
					dp[j][l] += dp[j - 1][l - i];
				}
			}
		}
		cout << dp[k][s] << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 

using namespace std;

int a[3];

int main()
{
	scanf("%d%d%d", &(a[0]), &(a[1]), &(a[2]));
	
	int sumA = a[0] + a[1] + a[2];
	int minNum = sumA - a[0];
	int curNum = sumA - a[1];
	if (minNum > curNum)
		minNum = curNum;
		
	curNum = sumA - a[2];
	if (minNum > curNum)
		minNum = curNum;
		
	printf("%d\n", minNum);

	return 0;
}


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

using namespace std;

int main(int argc, const char *argv[])
{
  string s, t;
  cin >> s >> t;

  int cnt = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == t[i]) {
      cnt++;
    }
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    cout << ((n + 999) / 1000) * 1000 - n << endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>

#include <queue>
#include <vector>

using namespace std;

struct Edge {
  int other;
  int d;
  int c;

  Edge(int other, int d, int c) {
    this->other = other;
    this->d = d;
    this->c = c;
  }
};

struct Node {
  vector<Edge> edges;
} nodes[10000];

int N, M;

struct Pos {
  int id;
  int dist;
  int cost;

  Pos(int id, int dist, int cost) {
    this->id = id;
    this->dist = dist;
    this->cost = cost;
  }
};

bool visited[10000];
int dist[10000];
int cost[10000];

typedef bool (*compFuncType)(const Pos&, const Pos&);

bool comparePos(const Pos& p1, const Pos& p2) {
  if (p1.dist != p2.dist) {
    return p1.dist > p2.dist;
  }
  return p1.cost > p2.cost;
}

int getMinCost() {
  memset(visited, false, sizeof(visited));
  memset(dist, -1, sizeof(dist));
  dist[0] = 0;
  memset(cost, -1, sizeof(cost));
  cost[0] = 0;
  priority_queue<Pos, vector<Pos>, compFuncType> q(comparePos);
  q.push(Pos(0, 0, 0));
  int total_cost = 0;
  while (!q.empty()) {
    Pos p = q.top(); q.pop();
    if (visited[p.id]) {
      continue;
    }
    visited[p.id] = true;
    total_cost += p.cost;
    //printf("connect %d, add cost %d\n", p.id, p.cost);
    for (size_t i = 0; i < nodes[p.id].edges.size(); ++i) {
      Edge& edge = nodes[p.id].edges[i];
      if (!visited[edge.other]) {
        int d = dist[p.id] + edge.d;
        int c = edge.c;
        if (dist[edge.other] == -1 || dist[edge.other] > d ||
            (dist[edge.other] == d && cost[edge.other] > c)) {
          dist[edge.other] = d;
          cost[edge.other] = c;
          q.push(Pos(edge.other, d, c));
        }
      }
    }
  }
  return total_cost;
}

int main() {
  //freopen("RoadConstruction.in", "r", stdin);
  while (scanf("%d%d", &N, &M) == 2 && !(N == 0 && M == 0)) {
    for (int i = 0; i < N; ++i) {
      nodes[i].edges.clear();
    }
    for (int i = 0; i < M; ++i) {
      int u, v, d, c;
      scanf("%d%d%d%d", &u, &v, &d, &c);
      u--;
      v--;
      nodes[u].edges.push_back(Edge(v, d, c));
      nodes[v].edges.push_back(Edge(u, d, c));
    }
    int result = getMinCost();
    printf("%d\n", result);
  }
  return 0;
}

Measured memory_bytes: 3168
#include<cstdio>
 
int main(){
    int m,n,i,j,k,s;
    scanf("%d%d",&n,&m);
    int a[n][m],b[m][1];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }}
            for(i=0;i<m;i++){
                for(j=0;j<1;j++){
                    scanf("%d",&b[i][j]);
                }}
                    for(i=0;i<n;i++){
 
                        for(j=0;j<1;j++){
                            s = 0;
                            for(k=0;k<m;k++){
                                s = s + a[i][k] * b[k][j];
                        }
                        printf("%d",s);
                        }
                        printf("\n");
                        }
                
return 0;    
}


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

int par[100010],r[100010]={};
int root(int a);
void unite(int a,int b);

int main(void){
  int n,m,i,p[100010],x,y,ans=0;
  cin >> n >> m;
  for (i=1;i<=n;i++) cin >> p[i];
  for (i=0;i<m;i++){
    cin >> x >> y;
    if (root(x)!=root(y)) unite(x,y);
  }
  for (i=1;i<=n;i++) if (root(i)==root(p[i])) ans++;
  cout << ans << endl;
  return 0;
}

int root(int a){
  if (par[par[a]]==par[a]) return a;
  return par[a]=root(par[a]);
}

void unite(int a,int b){
  a=root(a);
  b=root(b);
  if (a==b) return;
  if (r[a]<r[b]){
    par[a]=b;
    r[b]++;
  }else{
    par[b]=a;
    r[a]++;
  }
  return;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if((x-r>=0 && x+r<=W)&&(y-r>=0 && y+r<=H))cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

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

int main(){
        int n,m,i,t1,t2,cnt=0,cut_point=-1;
        cin >> n >> m;
        vector<pair<int, int>> r;
        for(i=0;i<m;++i){
                cin >> t1 >> t2;
                --t1; --t2;
                r.push_back(make_pair(t1, t2));
        }
        sort(r.begin(), r.end(), sort_at_second);
        for(i=0;i<m;++i){
                if(r.at(i).first>cut_point){
                        cut_point = r.at(i).second - 1;
                        ++cnt;
                }
        }
        cout << cnt << endl;
        return 0;
}

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

int main(){
   string s;
   cin>>s;
   int l=s.length();
   for(int i=0; i<l/2; i++){
        if(s[i]!=s[l-1-i]) {
            cout<<"No"; return 0;
        }
   }
   int k=(l-1)/2;
   for(int i=0; i<k/2; i++){
        if(s[i]!=s[k-1-i]) {
            cout<<"No"; return 0;
        }
   }
   for(int i=(l+3)/2; i<l/2; i++){
        if(s[i]!=s[l-1-i]) {
            cout<<"No"; return 0;
        }
   }
   cout<<"Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b, 
     right = c + d;
  if (left == right) cout << "Balanced";
  else if (left < right) cout << "Right";
  else cout << "Left";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
int gy, gx;
int getans(const int rest,vector<vector<int>>field, const int y, const int x) {
	if (rest<0) {
		return 99;
	}
	else {
		int aans = 99;
		for (int i = 0; i < 4; ++i) {
			int nx = x+dx[i]; int ny = y+dy[i];
			if (field[ny][nx] != 1) {
				int ans = 99;
				while (1) {
					if (field[ny][nx] == 4) {
						break;
					}
					else if (field[ny][nx] == 3) {
						ans = min(ans, 10 - rest);
						break;
					}
					else if (field[ny][nx] == 1) {
						field[ny][nx] = 0;
						ans = min(ans, getans(rest - 1, field, ny - dy[i], nx - dx[i]));
						field[ny][nx] = 1;
						break;
					}
					nx += dx[i]; ny += dy[i];
				}
				aans = min(aans, ans);
			}
		}
		return aans;
	}
}

int main() {
	while (1) {
		int x, y; cin >> x >> y;
		if (!x)break;
		vector<vector<int>>field(y + 2);
		for (int i = 0; i < x+2; ++i) {
			field[0].push_back(4);
			field[y + 1].push_back(4);
		}
		int sy, sx;
		for (int i = 0; i < y; ++i) {
			field[i + 1].push_back(4);
			for (int j = 0; j < x; ++j) {
				int a; cin >> a;
				if (a == 2) {
					sy = i + 1;
					sx = j + 1;
					field[i + 1].push_back(0);
				}
				else {
					field[i + 1].push_back(a);
				}
			}
			field[i + 1].push_back(4);
		}
		const int ans = getans(9, field, sy, sx);
		if (ans == 99) {
			cout << -1 << endl;
		}
		else {
			cout << ans << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3192
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n,ans=0;
  string s;
  cin>>s;
  n=s.size();
  for(ll i=1;i<=n;i++){
    if((i&1)==1){
      if((s[i-1]=='R'||s[i-1]=='U'||s[i-1]=='D')!=1)ans=1;
    }
    else{
      if((s[i-1]=='L'||s[i-1]=='U'||s[i-1]=='D')!=1)ans=1;
    }
  }
  if(ans==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256