akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;
    int d;
    int num;
    vector<int> data(n, 0);
    for(int i = 0; i < k; ++i){
        cin >> d;
        for(int j = 0; j < d; ++j){
            cin >> num;
            data[num-1]++;
        }
    }
    
    int count = 0;
    for(int i = 0; i < n; i++){
        if(data[i] == 0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


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

int main()
{
  ll n, k;

  cin >> n >> k;

  ll mod = n % k;

  cout << min(abs(mod), abs(mod - k));


}


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

int main() {
  int count=0;
  string s;
  cin >> s;
    r(i,s.size()/2){
      if(s[i]!=s[s.size()-1-i])count++;
    }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    std::deque<long long int> deq;
    int n;
    cin>>n;
    long long int a;
    int count=0;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    sort(deq.begin(),deq.end());
    std::map<long long int, int> map;
    long long int tmp;
    for (int j=0;j<n;j++) {
        if (j==0) {
            map.emplace(deq[j],1);
            tmp=deq[j];
        } else {
            if (tmp==deq[j]) {
                map.at(deq[j])++;
            } else {
                count+=map.at(tmp)%2;
                tmp=deq[j];
                map.emplace(deq[j],1);
            }
        }
    }
    count+=map.at(tmp)%2;
    cout<<count<<endl;
}

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


int main(void){

	int n;
	char s[100001];
	int r[100000];
	int c;
	int i;
	char f;
	int b;

	scanf("%s",s);

	n = strlen(s);

	f = 'r';
	c = 1;
	r[0] = 0;
	r[n-1] = 0;
	for(i=1;i<n-1;i++){

		//要素初期化
		r[i] = 0;

		switch(f){
			case 'r':
				if(s[i] == 'R'){
					c++;
				}else{
					//移動してくる奴の計算
					if(c%2 == 1){
						//奇数だったら一人多め
						r[i-1] += c/2 + 1;
						r[i] += c/2;
					}else{
						//偶数だったら半々
						r[i-1] += c/2;
						r[i] += c/2;
					}
					b = i;
					c = 1;
					f = 'l';
				}
				break;

			case 'l':
				if(s[i] == 'L'){
					c++;
				}else{
					//移動してくる奴の計算
					if(c%2 == 1){
						//奇数だったら一人多め
						r[b] += c/2 + 1;
						r[b-1] += c/2;
					}else{
						//偶数だったら半々
						r[b] += c/2;
						r[b-1] += c/2;
					}
					c = 1;
					f = 'r';
				}
				break;
		}
	}
	i = n -1;
	switch(f){
		case 'r':
			c++;

			//移動してくる奴の計算
			if(c%2 == 1){
				//奇数だったら一人多め
				r[i] += c/2 + 1;
				r[i-1] += c/2;
			}else{
				//偶数だったら半々
				r[i-1] += c/2;
				r[i] += c/2;
			}
			break;

		case 'l':
			c++;

			//移動してくる奴の計算
			if(c%2 == 1){
				//奇数だったら一人多め
				r[b-1] += c/2;
				r[b] += c/2 + 1;
			}else{
				//偶数だったら半々
				r[b] += c/2;
				r[b-1] += c/2;
			}
			break;
	}

	for(i=0;i<n;i++){
		printf("%d ",r[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 896
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<queue>
#define LL long long
using namespace std;
 
const LL N=200010;
 
struct node
{
	LL c0,c1,id;
	bool operator < (const node &x) const { return 1LL*c0*x.c1<1LL*c1*x.c0; }
};
 
priority_queue <node> q;
 
LL father[N],n,c[2][N],fa[N];
 
inline LL read()
{
	LL z=0,base=1;char c=getchar();
	while (!isdigit(c) && c!='-') c=getchar();
	if (c=='-') c=getchar();
	while (isdigit(c)) z=z*10+c-'0',c=getchar();
	return z*base;
}
 
inline LL find(LL x) { return father[x]==x?x:father[x]=find(father[x]); }
 
inline void uni(LL x,LL y)
{
	LL f1=find(x),f2=find(y);
	if (f1!=f2) father[f1]=f2;
}

int main()
{
	int x;
	n=read();
	for (register int i=1;i<=n;++i) father[i]=i;
	for (register int i=2;i<=n;++i) fa[i]=read();
	for (register int i=1;i<=n;++i) x=read(),c[x][i]=1;
	for (register int i=2;i<=n;++i) q.push((node){c[0][i],c[1][i],i});
	LL ans=0,id;
	node cur;
	while (!q.empty())
	{
		cur=q.top();
		id=find(cur.id);
		q.pop();
		if (c[0][id]==cur.c0 && c[1][id]==cur.c1)
		{
			LL f=find(fa[id]);
			ans+=1LL*c[1][f]*c[0][id];
			c[1][f]+=c[1][id];
			c[0][f]+=c[0][id];
			uni(id,f);
			if (f!=1) q.push((node){c[0][f],c[1][f],f});
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 14704
#include<bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define LL long long 
#define mod 998244353 
#define FOR(i, j, k) for (int i=j ; i<k ; i++)
#define ROF(i, j, k) for (int i=j ; i>=k ; i--) 
 
const long long INF = 1e18;
const long long MAX = 1e5+10;

int main(){
    fastio;
    int k,n; cin>>k>>n;
    int a[n]; FOR(i,0,n)cin>>a[i];
    int ans = INT_MAX;
    FOR(i,0,n-1) {
        ans = min(ans ,k-abs(a[i%n]-a[(i+1)%n]) );
    }
    ans = min(ans ,abs(a[0]-a[n-1]) );

    cout<<ans;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    int a[n+2];
    memset(a, 0, sizeof(a));
    rep(i, m){
        int c, d;
        scanf("%d%d", &c, &d);
        ++a[c]; --a[d];
    }
    partial_sum(a, a+n+2, a);
    int ans = n+1;
    int l = 0;
    while(l < n+1){
        if(a[l] == 0){
            ++l;
            continue;
        }
        int r = l;
        while(r < n+1 && a[r] > 0) ++r;
        ans += (r-l) * 2;
        l = r;
    }
    printf("%d\n", ans);
}


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

int main() {
    int x;
    cin >> x;
    int y[x];
    for (int i = 0; i < x; i++) {
        cin >> y[i];
    }
    int min = INT_MAX;
    int max = INT_MIN;
    for(int i = 0; i < x; i++) {
        if( y[i] > max )
            max = y[i];
        if( y[i] < min )
            min = y[i];
    }
    printf("%d\n", max-min);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0 || i == n - 1) continue;
    
    if (min({a[i], a[i - 1], a[i + 1]}) != a[i] && max({a[i], a[i - 1], a[i + 1]}) != a[i]) {
      count++;
    }
  }
  cout << count;
  
}

Measured memory_bytes: 256
def main():
    a, b = map(int, input().split())
    if a == 0 or b == 0 or (a < 0 and 0 < b):
        print("Zero")
    elif 0 < a:
        print("Positive")
    else:
        if (b-a+1)%2 == 1:
            print("Negative")
        else:
            print("Positive")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    ll b[n] = {};
    ll c[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }
    ll dp[n][3];
    rep(i,n){
        if(i==0){
            dp[i][0]=a[i];
            dp[i][1]=b[i];
            dp[i][2]=c[i];
        }else{
            dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
            dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
            dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
        }
    }
    
    int ans = 0;
    ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 4992
function Main(input){
	input=input.split(/\n|\s/);
	input.forEach(function(e,i,a){a[i]=Number(a[i]);});
	
	var arr=[1000, 961, 900, 841, 784, 729, 729, 729, 676, 625, 625, 576, 529, 512, 512, 484, 441, 400, 361, 343, 324, 289, 256, 256, 256, 243, 225, 216, 196, 169, 144, 128, 125, 121, 100, 81, 81, 64, 64, 64, 49, 36, 32, 27, 25, 16, 16, 9, 8, 4, 1];
	var a=1;
	for(var i=0;i<arr.length;i=(i+1)|0){
		if(input[0]>=arr[i]){a=arr[i];break;}
	}
	console.log(a);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int n; cin >> n;
    vint c(n-1), s(n-1), f(n-1);
    rep(i, n-1) {
        cin >> c[i] >> s[i] >> f[i];
    }
    auto solve = [&](int t, int i) {
        int l = 0, r = 1e7;
        while(l + 1 < r) {
            int mid = (l + r) / 2;
            if(t <= mid * f[i]) r = mid;
            else l = mid;
        }
        return r;
    };
    rep(i, n-1) {
        ll ans = 0;
        FOR(j, i, n-1) {
            ans = max(solve(ans, j) * f[j], s[j]) + c[j];
        }
        cout << ans << endl;
    }
    cout << 0 << endl;
    return 0;
}

// 時間tで駅iにいるとき駅i+1に到達できる最短時刻 = max(t以上の最小の(a*f[i]), s[i]) + c[i]


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

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


int main() {
  int x;
  cin >> x;

  int pos = 0;
  int i = 1;
  while(pos < x) {
    pos += i;
    i++;
  }

  cout << i-1 << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
main(){string s,u="[<++++++++++>-]>",c=">+++++[<++++++>-]>+++++[<++++++++>-]>+++++"+u+"++++++"+u+"+++++++"+u+"++++++++"+u+"+++++++++"+u+"++++++++++"+u+"+++++++++++"+u+"++++++++++++"+u+"<<<<<<<<<<<";
int p=0,i,j,a,b,d;for(cin>>s,i=0;i<s.length();++i){a=s[i]/10-3,b=a-p,p=a,d=s[i]-a*10-30;for(j=b>0?b:-b;j--;)c+=(b>=0?62:60);for(j=d;j--;)c+=43;c+=46;for(j=d;j--;)c+=45;}cout<<c<<endl;}

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

ll solveMaze(vector<string> S, ll H, ll W, ll h, ll w)
{
    if(S[h][w] == '#') return -1;

    vector<vector<ll>> D(H+2, vector<ll>(W+2, -1));
    queue<pair<ll,ll>> Q;
    Q.push(make_pair(h, w));
    D[h][w] = 0;

    while(!Q.empty()) {
        auto p = Q.front(); Q.pop();
        ll i = p.first, j = p.second;
        if(S[i-1][j] == '.' && D[i-1][j] == -1) {
            Q.push(make_pair(i-1, j));
            D[i-1][j] = D[i][j] + 1;
        }
        if(S[i][j-1] == '.' && D[i][j-1] == -1) {
            Q.push(make_pair(i, j-1));
            D[i][j-1] = D[i][j] + 1;
        }
        if(S[i+1][j] == '.' && D[i+1][j] == -1) {
            Q.push(make_pair(i+1, j));
            D[i+1][j] = D[i][j] + 1;
        }
        if(S[i][j+1] == '.' && D[i][j+1] == -1) {
            Q.push(make_pair(i, j+1));
            D[i][j+1] = D[i][j] + 1;
        }
    }

    ll m = 0;
    REP(i,1,H+1) {
        REP(j,1,W+1) m = MAX(m,D[i][j]);
    }

    return m;
}

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> S(H+2);
    S[0] = string(W+2, '#');
    S[H+1] = string(W+2, '#');
    REP(i,1,H+1) {
        cin >> S[i];
        S[i] = '#' + S[i] + '#';
    }  

    ll m = 0;
    REP(i,1,H+1) {
        REP(j,1,W+1)
            m = MAX(m,solveMaze(S, H, W, i, j));                   
    }
    _PR(m);

    return 0;
}

/*



*/

Measured memory_bytes: 256
n = int(input())
s = list(input())
l = int(n / 2)
count = 0
if n % 2 != 0:
    print("No")
else:
    for i in range(l):
        if s[i] == s[l + i]:
            count += 1
    if count == l:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include<stdio.h>
int search(int *A,int n,int key);

  int main(){
  int n,q,A[10000],i,j,key,goukei=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(search(A,n,key))goukei++;
  }
  printf("%d\n",goukei);

  return 0;
}

int search(int A[],int n,int key){
  int k=0;
  A[n]=key;
  while(A[k]!=key)k++;
  return k!=n;
}




Measured memory_bytes: 2712
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;




//#[proconio::fastout]
fn main() {
    input! {
        s: String,
    }

    println!("{}", if s == "ABC" {"ARC"} else {"ABC"});
}



Measured memory_bytes: 2116
#include <iostream>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main() {
    //入力
    int n;
    cin >> n;
    int b[n], f[n], r[n], v[n];
    for ( int i = 0; i < n; i++ ) {
        cin >> b[i] >> f[i] >> r[i] >> v[i];
    }
    
    //初期化
    int T[4][3][10];
    for ( int i = 0; i < 4; i++ ) {
        for ( int j = 0; j < 3; j++ ) {
            for ( int k = 0; k < 10; k++) {
                T[i][j][k] = 0;
            }
        }
    }
    
    //家情報入力
    for ( int i = 0; i < n; i++ ) {
        T[b[i]-1][f[i]-1][r[i]-1] += v[i];
    }
  
    //出力
    for ( int i = 0; i < 4; i++ ) {
        for ( int j = 0; j < 3; j++ ) {
            for ( int k = 0; k < 10; k++ ) {
                if ( k != 9 ) {
                  cout << " " << T[i][j][k];
                } else {
                  cout << " " << T[i][j][k] << endl;
                } 
            }
        }
        if ( i != 3 ) cout << "####################" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	k = int(input())
	#b , c = tin()
	#s = input()
	l=['_']*50
	l[0]=0
	for _ in range(k):
		for i, v in enumerate(l):
			l[i]+=1
			if l[i] == 10 and l[i+1]=='_':
				l[i+1]=1
				l[:i+1]=[0]*(i+1)
				break
			elif l[i] == 10:
				l[i]=l[i+1]
			elif l[i+1]=='_':
				#l[:i]=[l[i]-1]*(i)
				for j in range(1,i+1):
					l[i-j]=max(0, l[i-j+1]-1)
				break				
			elif l[i] <= l[i+1]+1:
				#l[:i]=[l[i]-1]*i
				for j in range(1,i+1):
					l[i-j]=max(0, l[i-j+1]-1)
				break	
		#print(*l)
		
	print(''.join([str(c) for c in l[::-1] if c != '_']))
				
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 68316
import itertools

n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

check_list = list(itertools.permutations(list(range(1,n+1)), n))

ans = 0
for i, check_i in enumerate(check_list, 1):
  
  if list(check_i) == P:
    ans += i
  
  if list(check_i) == Q:
    ans -= i
    
print(abs(ans))

Measured memory_bytes: 13844
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    int arr[n];int sum = 0;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    for(int i=0;i<k;i++)
        sum+=arr[i];
    cout<<sum;
    return 0;
}


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

using namespace std;

int N;
unsigned long long a, b, c;

int main()
{
        cin >> N;

        a = 2;
        b = 1;

        if (N == 1)
        {
                cout << b;
                return 0;
        }

        for (int i = 1; i <= N - 1; ++i)
        {
                c = a + b;
                a = b;
                b = c;
        }

        cout << c;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define i64 long long
#define ui64 unsigned long long
#define eps 1e-6
using namespace std;
 
int main() {
	// your code goes here
	ui64 x,y;
	cin>>x>>y;
	ui64 cnt = 0;
	for(;x<=y;x<<=(ui64)1) cnt++;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 384
H,W = map(int,input().split())
s = []
for i in range(H):
    a = list(input())
    s.append(a)
for i in range(H):
    for j in range(W):
        count = 0
        if s[i][j] == ".":
            for k in range(i-1,i+2):
                for l in range(j-1,j+2):
                    if (0 <= k <= H-1) and (0 <= l <= W-1) and s[k][l] == "#":
                        count += 1
            s[i][j] = str(count)
for i in range(H):
    print("".join(s[i]))

Measured memory_bytes: 9144
import java.io.BufferedReader; 
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import static java.lang.Math.abs;
import static java.lang.Math.min;

public class Main
{
	
	
	public static void main(String[] args) {
	
		FastScanner fs = new FastScanner();
		long x = abs(fs.nextLong());
		long k = fs.nextLong();
		long d = fs.nextLong();
		
		if(x/d>=k) {
			System.out.println(Math.abs(x)-(k*d)); 
		}else {
			long k1 = x/d;
			if(k1%2 == k%2) {
				System.out.println(Math.abs(x)-(k1*d));
			}else {
				System.out.println((min(abs((x)-((k1+1)*d)), abs((x)-((k1-1)*d)))));
			}
		}
	
	}

	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}
 
}





Measured memory_bytes: 32824
use proconio::{fastout, input};
use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        k: i64,
        q: usize,
        a: [i64; q]
    };

    let a: Vec<i64> = a.iter().map(|x| x - 1).collect();
    let mut map = BTreeMap::new();

    for i in a.iter() {
        let count = map.entry(i.to_string()).or_insert(0);
        *count += 1;
    }

    for i in 0..n {
        let x = map.get(&i.to_string());
        match x {
            Some(value) => {
                if k - (q as i64 - value) > 0 {
                    println!("Yes")
                } else {
                    println!("No")
                }
            }
            None => {
                if k - q as i64 > 0 {
                    println!("Yes")
                } else {
                    println!("No")
                }
            }
        }
    }
}


Measured memory_bytes: 9340
import java.util.Scanner;

/**
 * B - One Clue
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        int k = sc.nextInt();   // 黒石の数
        int x = sc.nextInt();   // 必ず黒石である座標

        int before = x - ( k - 1 );
        int after = x + ( k - 1 );

        for( int i = before; i <= after; i++ ) {
            if( i > before ) System.out.print( " " );
            System.out.print( i );
        }
        System.out.println();

        sc.close();
    }
}

Measured memory_bytes: 22996
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <iostream>
#define maxn 3009
using namespace std;
const int MOD = 1e9 + 7;
#define N 200005
#define fr(i,x,y) for(int i=x;i<=y;i++)
int n,a[N],tt,pos;
void doit(){
    scanf("%d%d",&n,&tt);
    fr(i,1,n) scanf("%d",&a[i]);
    //a[n+1]=2000000001;
    int tmp=0,ans=a[n]+tt;
    fr(i,2,n)
    if (a[i]-a[i-1]>tt) ans-=(a[i]-a[i-1]-tt);
    printf("%d\n",ans);
}

int main(){
    //while (1) 
     doit();
    return 0;
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author JustLive
 */

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

typedef long long ll;
typedef unsigned long long ull;

const int mod = 1000000007;
const int inf = 1000000000;
const ll infll = (ll)inf * (ll)inf;

class TaskC {
public:
    int n;
    vector<int> a;
    int s;
    bitset<4000100> b;

    void solve(istream& in, ostream& out) {
        in >> n;
        a.resize(n);
        b.set(0);
        s = 0;
        for (int i = 0; i < n; i++) {
            in >> a[i];
            s += a[i];
            b |= b << a[i];
        }
        s = (s + 1) / 2;
        while (not b[s]) {
            s++;
        }
        out << s;
    }
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    TaskC solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1792
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B, K = map(int, readline().split())
ans=''
if B-A+1 <= 2 * K:
    ans += '\n'.join(str(x) for x in range(A, B + 1))
else:
    ans += '\n'.join(str(x) for x in range(A, A + K))
    ans+='\n'
    ans += '\n'.join(str(x) for x in range(B + 1 - K, B + 1))
print(ans)

Measured memory_bytes: 3064
//empty sockets
#include<iostream>
using namespace std;
int main()
{
	string s, t;
	cin >> s;
	cin >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (u == s)
	{
		cout << a - 1 << " " << b << " " << endl;
	}
	else
	{
		cout << a << " " << b - 1 << " " << endl;
	}
	return 0;
}



Measured memory_bytes: 3572
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;



    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt() - 1;
        long A = cin.nextInt();
        long B = cin.nextInt();
        long C = cin.nextInt();
        long D = cin.nextInt();

        for (int i = 0; i <= N; i++)
        {
            int j = N - i;

            long maxAdd = i * D;
            long minAdd = i * C;

            long maxDec = j * D;
            long minDec = j * C;

            if(maxAdd - minDec >= B - A && minAdd - maxDec <= B - A)
            {
                Console.WriteLine("YES");
                return;
            }
        }
        Console.WriteLine("NO");

    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
a = str(input())

if a == "SUN":
  tmp = 0
elif a == "MON":
  tmp = 1
elif a == "TUE":
  tmp = 2
elif a == "WED":
  tmp = 3
elif a == "THU":
  tmp = 4
elif a == "FRI":
  tmp = 5
elif a == "SAT":
  tmp = 6
else:
  print("Error")

ans = 7- tmp
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
int a[100003],ch[100003];
int main()
{
int n,m;
cin>>n>>m;
 
for(int i=0;i<n;i++)
{
    cin>>a[i];
    ch[i]=0;
}
for(int i=0;i<m;i++)
{
    int x,y;
    cin>>x>>y;
    x--;y--;
    ch[x]=max(ch[x],a[y]);
    ch[y]=max(ch[y],a[x]);
}
for(int i=0;i<n;i++)
{
    if(ch[i]==0)
    {
        ch[i]=0;
    }
}
int cnt=0;
for(int i=0;i<n;i++)
{
    if(ch[i]<a[i])
    {
        cnt++;
    }
}
cout<<cnt;
 
 return 0; 
}

Measured memory_bytes: 4244
import           Data.Char (ord)
import           Data.List (unfoldr)

solve :: [Int] -> Int
solve [] = 0
solve xs = head $ last $ unfoldr f xs
  where f [] = Nothing
        f xs = Just (xs, g [] xs)
        g ans [_]        = reverse ans
        g ans (x1:x2:xs) = g (((x1 + x2) `mod` 10):ans) (x2:xs)

main :: IO ()
main = getContents >>= mapM_ (print . solve . map (\c -> ord c - 0x30)) . lines

Measured memory_bytes: 3692
#include <stdio.h>

int main(void)
{
	long n, k;
	scanf("%ld%ld", &n,&k);
	long x = n % k;
	long y;
	if (k > x)
		y = k - x;
	else
		y = x - k;
	if (x < y)
		printf("%ld", x);
	else
		printf("%ld", y);
	return 0;
}


Measured memory_bytes: 128
N,K = map(int,input().split())
A = list(map(int,input().split()))
B = [a%K for a in A]
cs = [0]
for b in B:
    c = (cs[-1] + b-1) % K
    cs.append(c)

from collections import deque
from collections import defaultdict
qs = defaultdict(lambda: deque())

ans = 0
for i,c in enumerate(cs):
    while qs[c] and qs[c][0] + K <= i:
        qs[c].popleft()
    ans += len(qs[c])
    qs[c].append(i)
print(ans)

Measured memory_bytes: 172228
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

char s[102]={},t[102]={};
bool big_to_small(char a,char b){return a>b;}

int main()
{
    scanf("%s%s",s,t);
    sort(s,s+strlen(s)),sort(t,t+strlen(t),big_to_small);
    if(strcmp(s,t)<0)puts("Yes");else puts("No");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}


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

using namespace std;

int solve(int N) {
  for (int i = 1; i <= 50000; i++) {
    if (((int) floor(i * 1.08)) == N) {
      return i;
    }
  }
  return -1;
}

int main() {
  int N;
  cin >> N;

  int ans = solve(N);
  if (ans > 0) {
    cout << ans << endl;
  } else {
    cout << ":(" << endl;
  }

  return 0;
}


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

N, M = MAP()

g = nx.Graph()
g.add_edges_from([LIST() for _ in range(M)])
q = deque()
q.append(1)
ans = [None]*N
ans[0] = 0
while q:
	n = q.popleft()
	for node in g[n]:
		if ans[node-1] == None:
			q.append(node)
			ans[node-1] = n
print("Yes")
for i in range(1, N):
	print(ans[i])


Measured memory_bytes: 199700
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    ll n,i,j,m,cc=0;
    cin>>n;
    ll ara[n];
    map<ll,ll>check;
    for(i=0;i<n;i++)cin>>ara[i],check[ara[i]]=i+1;
    for(i=1;i<=n;i++){
        cout<<check[i]<<spc;
    }
}


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

int main(){
    int c=0;
   string s,x;
   cin>>s>>x;
   for(int i=0,j=s.size()-1;i<s.size();i++,j--){
    if(s[i]==x[j])
        c++;
   }
   if(c==3)
    cout<<"YES";
   else cout<<"NO";

 return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();

            if (N[0] == N[N.Length - 1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();

        long[] cnt = new long[100100];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            cnt[a]++;
            sum += a;
        }

        PrintWriter pw = new PrintWriter(System.out);
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int b = sc.nextInt();
            int c = sc.nextInt();

            sum -= b * cnt[b];
            sum += c * cnt[b];
            pw.println(sum);

            cnt[c] += cnt[b];
            cnt[b] = 0;
        }

        pw.flush();
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 55868
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int, int> tp;
///-------------------------

int main()
{
    Phuong_; /// <3333
        string s;
        cin >> s;
        string t;
        cin >> t;
        s+=t.back();
        if (s==t) cout << "Yes"; else cout << "No";
    return 0;
}


Measured memory_bytes: 3588
#include<stdio.h>
#include <stdbool.h>
int main(){
   int k, a, b;
   bool judge = false;
   scanf("%d", &k);
   scanf("%d %d", &a, &b);
   
   for(int i=a; i<=b; i++){
      if(i % k == 0){
         judge = true;
      }
   }

   if(judge){
      printf("OK\n");
   } else {
      printf("NG\n");
   }

   return 0;
}


Measured memory_bytes: 1620
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MOD = 1000000007;

const int MAX_N = 2000010;
long long fac[MAX_N + 1], finv[MAX_N + 1];

struct init_fac {
    long long mod_inv(long long a, long long m) {   // gcd(a, m) = 1
        long long b = m, x = 1, y = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(x -= t * y, y);
        }
        x = (x % m + m) % m;
        return x;
    }

    init_fac() {
        fac[0] = 1;
        for (int i = 1; i <= MAX_N; ++i) fac[i] = i * fac[i - 1] % MOD;
        finv[MAX_N] = mod_inv(fac[MAX_N], MOD);
        for (int i = MAX_N - 1; i >= 0; --i) finv[i] = (i + 1) * finv[i + 1] % MOD;
    }
} init_fac;

long long nPk(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
}

long long nCk(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return nPk(n, k) * finv[k] % MOD;
}

long long nHk(int n, int k) {
    if (n < 0 || k < 0) return 0;
    return nCk(n + k - 1, k);
}

void _main() {
    int N, M;
    cin >> N >> M;
    if (abs(N - M) > 1) {
        cout << 0 << endl;
        return;
    }
    if (N == M) {
        cout << fac[N] * fac[M] % MOD * 2 % MOD << endl;
        return;
    }
    if (N < M) swap(N, M);
    cout << fac[N] * fac[M] % MOD << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> duo;

#define TT template<typename T>
TT T    sq(T x){ return x*x; }
TT int  ubnd(vector<T>& v,T x){ return upper_bound(v.begin(), v.end(), x) - v.begin(); }
TT int  lbnd(vector<T>& v,T x){ return lower_bound(v.begin(), v.end(), x) - v.begin(); }
TT void sort(T& v){ sort(v.begin(), v.end()); }
TT void revs(T& v){ reverse(v.begin(), v.end()); }
TT void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end()), v.end()); }
TT void show(T& v,char d=' ',char e='\n'){for(int i=0;i<v.size();++i)cout<<v[i]<<((i==v.size()-1)?e:d);}
TT void inpt(vector<T>& v,int n){ v.reserve(n);for(int i=0;i<n;++i){T x; cin>>x; v.push_back(x);} }
TT T In(){ T x; cin >> x; return x; }

static inline void fast_io(){ ios::sync_with_stdio(0); cin.tie(0); }
static inline int in(){ int x; scanf("%d", &x); return x; }
static inline string instr(){ string x; cin >> x; return x; }
static const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
static const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
static const int _mod = 1000000000;

int main()
{
  ll dp[16][1024] = {};
  dp[0][0] = 1;
  for (int k = 0; k <= 100; k++){
    for (int i = 14; i >= 0; i--){
      for (int j = 0; j < 1024 - k; j++){
        if (dp[i][j]) dp[i + 1][j + k] += dp[i][j];
      }
    }
  }
  int n, s;
  while (n = in(), s = in(), n || s){
    printf("%lld\n", dp[n][s]);
  }
  return (0);
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
#define MAX_SIZE 10000

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

const ll MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1.0);
const db ERR = 1e-8;
const int MAXN = 1e7;

int main(int argc, char const *argv[]){
    int n;
    scanf("%d",&n);
    ll a,b,pr;
    ll ans;
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&a,&b);
        pr=a*b;
        ll t=sqrt(pr);
        if(t*(t+1)<pr){
            ans=2*t-1;
        }
        else if(t*t==pr){
            if(a==b){
                ans=(t-1)*2;
            }
            else {
                ans=(t-1)*2-1;
            }
        }
        else{
            ans=(t-1)*2;
        }
        printf("%lld\n",ans);
    }    
    return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

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

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
#define M_PI   3.1415926535 
#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC 132 -A 
static int b[26];
int main(void) {
	char a[5];
	int  i;

	scanf("%s", a);

	if((a[0]==a[1]&&a[2]==a[3]&&a[1]!=a[2]) ||
		(a[0] == a[2] && a[1] == a[3] && a[1] != a[2]) ||
		(a[0] == a[3] && a[1] == a[2] && a[1] != a[3])) {
		printf("Yes\n");
	}else printf("No\n");

	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  
  int result = a * b;
  
  if((result % 2) == 0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int a, b;
  cin >> a >> b;

  int ans = a + b;
  if (a-b > ans) ans = a-b;
  if (a*b > ans) ans = a*b;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = input()

if C < D:
    if '##' in S[A-1:C] or '##' in S[B-1:D]:
        print('No')
    else:
        print('Yes')
else:
    if '...' in S[B-2:D+1] and '##' not in S[A-1:C]:
        print('Yes')
    else:
        print('No')



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

#define int long long

map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, p;
  cin >> n >> p;

  if ( n == 1 ) {
    cout << p << endl;
    return 0;
  }

  for ( int i = sqrt(p); i >= 2; i-- ) {
    if ( p%i ) continue;
    bool f = true;      
    int q = 1;    
    for ( int j = 0; j < n; j++ ) {
      q *= i;
      if ( q > p ) {
	f = false;
	break;
      }
    }
    if ( f && p%q == 0 ) {
      cout << i << endl;
      return 0;
    }    
  }  

  cout << 1 << endl;  
  
  return 0;
}


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

using namespace std;
#define ll long long
const int maxn=1e5+5;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int d=a-b;
    if(c-d<0) cout<<"0"<<endl;
    else cout<<(c-d)<<endl;

    return 0;
}

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

using namespace std;

int main() {
	int base = 0;
	int out = 0;
	int score = 0;
	int inning;
	string evt;
	cin >> inning;
	while (inning) {
		cin >> evt;
		if (evt == "HIT") {
			base <<= 1;
			base |= 1;
			if (base > 7) {
				score++;
				base &= 7;
			}
		} else if (evt == "HOMERUN") {
			score++;
			for (int i = 0; i < 4; i++) {
				if ((base >> i) & 1) {
					score++;
				}
			}
			base = 0;
		} else {
			if (++out >= 3) {
				cout << score << endl;
				base = score = out = 0;
				inning--;
			}
		}
	}
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int32 N;
double R = 0, L = 0;
vector<double> r, x;

pair<double, double> cp(int32 a, int32 b){
	double t = ((x[a]-x[b])*(x[a]-x[b])+r[a]*r[a]-r[b]*r[b])/2/abs(x[a]-x[b]);
	return make_pair(r[a]*r[a]-t*t, t+x[a]);
}

double cx(int32 a, double y){
	return sqrt(max((double)0, r[a]*r[a]-y*y));
}

bool check(double w, double h){
	REP(i, N){
		if(r[i]*r[i]-(w-x[i])*(w-x[i]) < h)
			return 0;
	}
	return 1;
}

bool ok(double y){
	vector<pair<double, int>> a(2*N);
	REP(i, N){
		double w = cx(i, y);
		if(w == 0) return 0;
		a[2*i] = make_pair(x[i]-w, 0);
		a[2*i+1] = make_pair(x[i]+w, 1);
	}
	sort(all(a));
	int32 cnt = 0;
	REP(i, 2*N){
		if(a[i].sc == 0) cnt++;
		else cnt--;
		if(cnt == N) return 1;
	}
	return 0;
}

int main(void){
	cin >> N;
	r = vector<double>(N);
	x = vector<double>(N);
	REP(i, N){
		cin >> x[i] >> r[i];
		if(x[R]+r[R] > x[i]+r[i]) R = i;
		if(x[L]-r[L] < x[i]-r[i]) L = i;
	}
	double l = 0, r = INF, m;
	REP(i, 100){
		m = (l+r)/2;
		if(ok(m)){
			l = m;
		}else{
			r = m;
		}
	}
	cout << fixed << setprecision(10) << l << endl;
}



Measured memory_bytes: 7700