akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////


void solve(){
    matrix dxdy={{1,0},{-1,0},{0,1},{0,-1}};
    ll h,w;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    ll ctr=0;
    rp(i,h){
        rp(j,w){
            cin >> s[i][j];
            if(s[i][j]=='#') ctr++;
        }
    }
    queue<pair<P,ll>> que;
    que.push(mp(mp(0,0),0));
    matrix seen(h,Vi(w,0));
    ll shortest=-1;
    while(!que.empty()){
        P loc=que.front().first;
        ll dist=que.front().second;
        que.pop();
        if(seen[loc.first][loc.second]==1) continue;
        if(loc.first==h-1&&loc.second==w-1) {
            shortest=dist;
            break;
        }
        seen[loc.first][loc.second]=1;
        for(auto vec:dxdy){
            if(loc.first+vec[0]<0||loc.first+vec[0]>=h||loc.second+vec[1]<0||loc.second+vec[1]>=w) continue;
            if(s[loc.first+vec[0]][loc.second+vec[1]]=='.'){
                que.push(mp(mp(loc.first+vec[0],loc.second+vec[1]),dist+1));
            }
        }
    }
    if(shortest==-1){
        print(-1);
    }else{
        print(h*w-ctr-shortest-1);
    }

    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;

int main(){
  int a;cin>>a;
  string s;cin>>s;
  if(a>=3200)cout << s << endl;
  else cout << "red" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
const ll M=2505,N=1e4+5;
struct node{
	ll to,next,dis;
}edge[N];
vector<ll> mp[M];
ll head[M],cnt;
ll minn[M],tot[M];
bool vis[M],can[M];
queue<ll> q;
inline void add(ll x,ll y,ll d)
{
	edge[++cnt]=(node){y,head[x],d},head[x]=cnt;
}
inline ll read()
{
	ll x=0,f=1; char ch=0;
	while(!isdigit(ch)) f=(ch=='-'?-1:1),ch=getchar();
	while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*f;
}
void bfs(ll x)
{
	queue<ll> now; now.push(x); can[x]=true;
	while(!now.empty())
	{
		ll u=now.front(); now.pop();
		for(register ll i=0;i<mp[u].size();i++){
			ll v=mp[u][i];
			if(!can[v]) now.push(v),can[v]=true;
		}	
	}
}
int main()
{
	ll n=read(),m=read(),p=read();
	for(register ll i=1;i<=m;i++){
		ll x=read(),y=read(),d=read()-p;
		add(x,y,d); mp[y].push_back(x);
	}
	bfs(n);
	memset(minn,0x80,sizeof(minn));
	q.push(1); minn[1]=0; vis[1]=true; tot[1]=1;
	while(!q.empty())
	{
		ll u=q.front(); q.pop(); vis[u]=false;
		for(register ll i=head[u];i;i=edge[i].next)
		{
			ll v=edge[i].to;
			if(!can[v]) continue;
			if(minn[v]<minn[u]+edge[i].dis){
				tot[v]=tot[u]+1;
				if(tot[v]>n){
					puts("-1");
					return 0;
				}
				minn[v]=minn[u]+edge[i].dis;
				if(!vis[v]) q.push(v),vis[v]=true;
			}
		}
	}
	if(minn[n]<0) puts("0");
	else printf("%lld\n",minn[n]);
	return 0;
}

Measured memory_bytes: 640
#include <map>
#include <set>
#include <list>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
int a[200005],b[200005];
int main ( ) {
	int n,i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	if (n%2==1) {
		for (i=n;i>=1;i-=2) printf("%d ",a[i]);
		for (i=2;i<=n;i+=2) printf("%d ",a[i]);
	}
	else {
		for (i=n;i>=2;i-=2) printf("%d ",a[i]);
		for (i=1;i<=n;i+=2) printf("%d ",a[i]);
	}
	puts("");
	return 0;
}
/*
Sample Input 1
4
1 2 3 4
Sample Output 1
4 2 1 3
Sample Input 2
3
1 2 3
Sample Output 2
3 1 2
Sample Input 3
1
1000000000
Sample Output 3
1000000000
Sample Input 4
6
0 6 7 6 7 0
Sample Output 4
0 6 6 0 7 7
*/

Measured memory_bytes: 2944
#include<stdio.h>
int main(void){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0 || W == 0){
			break;
		}
		else{
			for(i = 0;i < H;i++){
				for(j = 0;j < W;j++){
					if(((i + j) % 2) == 0){
						printf("#");
					}
					else{
						printf(".");
					}
				}
				puts("");
			}
			puts("");
		}
	}
	return 0;
}

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

#define itos(x) to_string(x)
#define stoi(x) stoi(x)
#define ctoi(x) (x-'0')

#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)(x).size()

#define ll long long
#define ld long double
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ld pi = acos((ld)-1);
const ld e = exp(1);

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s; cin >> s;
  if (s == "SSS") {
    cout << 0 << "\n";
    return 0;
  }
  if (s == "RSR" || s == "SRS" || s == "SSR" || s == "RSS") {
    cout << 1 << "\n";
    return 0;
  }
  if (s == "RRS" || s == "SRR") {
    cout << 2 << "\n";
    return 0;
  }
  cout << 3 << "\n";
  return 0;
}


Measured memory_bytes: 3624
/**
	*    author:  accesss_denied
	**/
	#include <bits/stdc++.h>
	using namespace std;
	#define ll long long int
	#define ff first
	#define ss second
	#define pb push_back
	#define endl "\n"
	#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll mod=1e9+7;			
	ll inf=1e18;

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

				ll t;
				t=1;
				while(t--)
				{
					string s1,s2;
					cin>>s1>>s2;

					ll ans=inf;
					ll n1=s1.size();
					ll n2=s2.size();

					for(ll i=0;i<=(n1-n2);i++)
					{
						ll count=0;
						ll x=i;
						for(ll j=0;j<n2;j++)
						{
							if(s1[x++]!=s2[j])
							count+=1;
						}
						ans=min(count,ans);
					}
					cout<<ans<<endl;
				}
				return 0;
			}	




Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int N;
int main() {
  string S;
  cin >> S;
  N = S.length();

  string prev="";
  string cur="";
  int cnt=0;
  REP(i,0,N){
      cur+=S[i];
      if(cur!=prev){
          cnt++;
          prev=cur;
          cur="";
      }
  }
  cout<<cnt<<endl;

  return 0;
}


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

int main() {
 	vector <int> p(4, 0);



 	for (int i = 0; i < 3; i++) {
 		int a,b;
 		cin >> a >> b;
 		a--;
 		b--;
 		p[a]++;
 		p[b]++;
 	}


 	for (int i = 0; i < 4; i++) {
 		if (p[i] > 2) {
 			cout << "NO" << endl;
 			return 0;
 		}
 	}
 	cout << "YES" << endl;

	return 0;
}

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

vector<int> flags;
// 0: まだ
// 1: 行ってる
// 2: ループ
vector<vector<int>> g;

// 見つかった:1, 見つかってない:0
bool dfs(int v,int pre){
    flags[v] = 1;
    if(g[v].size() == 1 && g[v][0] == pre){
        return 0;
    }
    for(int to : g[v])if(to != pre){
        if(flags[to] == 1){
            flags[to] = 2;
            flags[v] = 2;
            return 1;
        }
        if(flags[to] == 0){
            if(dfs(to,v)){
                if(flags[v] == 2) return false;
                flags[v] = 2;
                return true;
            }
        }
    }
}

int main(){
    int n;
    cin>>n;
    g.resize(n);
    flags.resize(n);
    rep(i,n){
        int u,v;
        cin>>u>>v;
        u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(0, -1);
    int Q;
    cin>>Q;
    rep(q,Q){
        int u,v;
        cin>>u>>v;
        u--,v--;
        if(flags[u] == 2 && flags[v] == 2){
            cout<<2<<endl;
        }else{
            cout<<1<<endl;
        }
    }
}


Measured memory_bytes: 15028
#include<stdio.h>
#include<math.h>
int main(){
  int i,j,k;
  int sum,n,r,s[10000];
  s[0]=2;
  for(i=3,j=1;j<10000;i+=2){
    r=(int)sqrt(i)+1;
    for(k=3;k<r;k+=2){
      if(i%k==0)
	r=0;
    }
    if(r){
      s[j]=i;
      j++;
    }
  }
  for(;;){
    scanf("%d",&n);
    if(n==0)
      break;
    sum=0;
    for(i=0;i<n;i++)
      sum+=s[i];
    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long

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

void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}



int main(int argc, char const *argv[])
{
    //file();
    fast();

    int a, b, k;cin>>k>>a>>b;

    for (int i = a; i <= b; ++i)
    {
        if(i % k == 0)
            return cout<<"OK", 0;
    }
    cout<<"NG";
  
}

Measured memory_bytes: 3612
#include <iostream>
#include <math.h>

#define N 1000000

using namespace std;

int main(void){
	bool prm[N];
	for(int i=0;i<N;i++)prm[i]=true;
	int upto = (int)sqrt(N);
	for(int i=2;i<=upto;i++){
		if(prm[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<=N;j++) prm[i*j] = false;
		}
	}
	int n;
	while(cin >> n){
		int count = 0;
		for(int i=2;i<=n;i++){
			if(prm[i]) count++;
		}
		cout << count << "\n";
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

int main(){
  ll N;
  cin>>N;
  vector<ll> a(5);rep(i,5)cin>>a[i];
  
  sort(all(a));
  
  ll ans;
  ans = N / a[0];
  ans += N % a[0] != 0;
  ans += 4;
  print(ans)
  return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    if(n <= 999){
        cout << "ABC" << endl;
    }
    else{
        cout << "ABD" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "stdio.h"

int main()
{
	int n, m, l;

	while(scanf("%d", &n) != EOF){
		m = n;
		l = 0;

		for (int a = 0; a < 10; a++){
			if (m < a) break;
			else m -= a;
			for (int b = 0; b < 10; b++){
				if (m < b) break;
				else m -= b;
				for (int c = 0; c < 10; c++){
					if (m < c) break;
					else m -= c;
					for (int d = 0; d < 10; d++){
						if (m < d) break;
						else if(m == d) l++;
					}
					m += c;
				}
				m += b;
			}
			m += a;
		}

		printf("%d\n", l);
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;

const long long TIME_LIMIT=10000;


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

    ll d;
    cin >> d;
    vector<ll> c(26);
    rep(i, 26)
    {
        cin >> c[i];
    }
    vector<vector<ll>> s(d, vector<ll>(26));
    rep(i, d)
    {
        rep(j, 26)
            cin >> s[i][j];
    }

    vector<ll> ans(d);

    for (ll i = 0; i < d; i++)
    {
        ll man = 0;
        ll manu = 0;
        for (int j = 0; j < 26; j++)
        {
            if (man < s[i][j])
            {
                man = s[i][j];
                manu = j + 1LL;
            }
        }
        ans[i] = manu;
    }

    rep(i, d)
    {
        cout << ans[i] << endl;
    }

	return 0;

}

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

int main() {
  ll n,k;
  cin >> n >> k;
  ll sum =0;
  while(n){
    n/=k;
    sum++;
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let mut g = gcd(read(), read());
    let mut ret = 1;

    for i in 2..g {
        let mut n = 0;
        if g < i * i {
            break;
        }
        while g % i == 0 {
            g /= i;
            n += 1;
        }
        if n > 0 {
            ret += 1;
        }
    }

    if g > 1 {
        ret += 1;

    }
    println!("{}", ret);
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a, b, c;
  cin>>a>>b>>c;
  
  if(a+b==c||a+c==b||b+c==a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
using namespace std;
 
 
 
int main(){
	int N;
	int  Flag[9]={};
	int  a;
	int score;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a;
		a/=400;
		if(a>8)	a=8;
		Flag[a]++;
	}
	a=0;
	for(int i=0;i<8;i++){
		if(Flag[i])
			a++;
	}
 
	if(a==0)
		cout << "1" << " ";
	else
		cout << a << " ";
	cout << a+Flag[8];
	cin >> score;
	return 0;
 
 
 
}

Measured memory_bytes: 256
/**
*    created: 15.06.2020 11:38:44
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> now(n);
    int cnt = 0;

    auto check = [&](vector<int> vec) {
        bool ok = true;
        rep(i, vec.size()) {
            if (vec[i] != h[i]) {
                ok = false;
                break;
            }
        }
        return ok;
    };
    
    while (true) {
        if (check(now)) break;
        int t = 0;
        vector<int> c(n+1);
        rep(i,n) {
            if (now[i] < h[i]) {
                now[i]++;
                c[i]++;
            }
        }
        rep(i,n) {
            if (c[i] == 1 && c[i+1] == 0) cnt++;
        }
    }
    
    cout << cnt << endl;
    return 0;
}

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

int main(){
  int x, h;
  while(cin >> x >> h){
    if(x == 0 && h == 0) break;
    printf("%.6f\n", x* sqrt(4*h*h + x*x) + x*x);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define modp 1000000007
#define Maxn 200007
int n,a[Maxn],f[Maxn],s[Maxn];
int main()
{
    scanf("%d",&n);
    int m=1;
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for (int i=2;i<=n;i++)
        if (a[i]!=a[m]) a[++m]=a[i];
    n=m;
    f[0]=1;
    for (int i=1;i<=n;i++)
    {
        f[i]=(f[i-1]+s[a[i]])%modp;
        s[a[i]]=f[i];
    }
    printf("%d\n",f[n]);
    return 0;
}

Measured memory_bytes: 6136
#include <iostream>

using namespace std;

int main()
{
 long long n,i,p=0;
 cin >> n;
 for(i=1;i<n+1;i++){
  if(i%3!=0 && i%5!=0) p=p+i; 
 }
 cout << p << endl;
 return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    if(N == 1){
        cout<<"Hello World"<<endl;
    }else{
        cin>>A>>B;
        cout<<A+B<<endl;
    }
}


Measured memory_bytes: 256
class NormalInput{
  input: string[];
  pointer: number;
  constructor(raw:string){
    this.input=raw.split(/ |\n/);
    this.pointer=0;
  }
  int():number{
    const ret= parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  }  
  ints(length:number):number[]{
    let ret:number[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.int());
    }
    return ret;
  }
  str():string{
    const ret= this.input[this.pointer];
    this.pointer++;
    return ret;
  }
  strs(length:number):string[]{
    let ret:string[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.str());
    }
    return ret;
  }
}
function Main(_:NormalInput) {
  const N=_.int();
  const A=_.ints(N+1);
  const B=_.ints(N);
  let count=0;
  for(let i=0;i<N;i++){
    const v=Math.min(A[i],B[i]);
    B[i]-=v;
    count+=v;

    const v2=Math.min(A[i+1],B[i]);
    A[i+1]-=v2;
    count+=v2;
  }
  console.log(count);
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 38220
num = int(input())
dictionary = {}
for i in range(num):
    com, key = tuple(input().split(' '))
    if com == 'insert':
        dictionary[key] = dictionary.get(key, 0) + 1
    if com == 'find':
        if dictionary.get(key):
            print('yes')
        else:
            print('no')
            


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

int main(){
    string str;
    int n;
    cin>>str>>n;
    int k = 1;
    cout<<str[0];
    for(int i=1;i<str.length();i++){
        if(i == n*k){
            cout<<str[i];
            k++;
        }
    }
    cout<<"\n";
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $w, $h, $n);
$S = array();
for($x=0; $x<$w; $x++){
    for($y=0; $y<$h; $y++){
        $S[$x][$y] = 1;
    }
}

while(fscanf(STDIN, "%d %d %d", $xi, $yi, $ai)){
    if($ai == 1){
        for($x=($xi-1); 0<=$x; $x--){
            for($y=0; $y<$h; $y++){
                $S[$x][$y] = 0;
            }
        }
    }elseif($ai == 2){
        for($x=$xi; $x<$w; $x++){
            for($y=0; $y<$h; $y++){
                $S[$x][$y] = 0;
            }
        }
    }elseif($ai == 3){
        for($y=($yi-1); 0<=$y; $y--){
            for($x=0; $x<$w; $x++){
                $S[$x][$y] = 0;
            }
        }
    }else{
        for($y=$yi; $y<$h; $y++){
            for($x=0; $x<$w; $x++){
                $S[$x][$y] = 0;
            }
        }
    }
}

$total = 0;
for($x=0; $x<$w; $x++){
    $total += array_sum($S[$x]);
}
print $total;


Measured memory_bytes: 4728
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        int answer = 0;
        for (char x : s.toCharArray()) {
            if (x == '1') {
                answer += 1;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 20820
import collections
import math

N, A, B = map(int, input().split())
v = list(map(int, input().split()))
d = list(reversed(sorted(v)))
c = collections.Counter(v)

start = A
end = A
if c[d[0]] >= A:
  end = min(c[d[0]], B)
  
ans = 0
ans_com = 0
for i in range(start, end+1):
  sel = i
  com = 1
  total = 0
  for j in range(len(d)):
    p = c[d[j]]
    com *= math.factorial(p)
    total += d[j] * p
    if sel <= p:
      com /= (math.factorial(sel) * math.factorial(p-sel))
      total -= d[j] * (p - sel)
      break
    sel -= p
  ave = total / i
  ans = ave
  ans_com += int(com)
print(ans)
print(ans_com)


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

int main(){
  int c=0;
  int k, s, x=0, y, z;

  cin >> k >> s;

  while(x <= k){
    y=x;
    while(y <= k){
      z=s-x-y;
      if ((z >= y) && (z <= k)){
	if ((x == y) && (y == z)){
	  c++;
	} else if ((x == y) || (y == z)){
	  c+=3;
	} else {
	  c+=6;
      }
      }
      
      y++;
    }
        
    x++;
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 384
import sys
n,m = map(lambda x: int(x),input().split())
ans = list('z'*(n))
kotae = 0
flag = 0
for i in range(m) :
    s,c = map(lambda x: int(x),input().split())
    if (s == 1 and c == 0 and n != 1) or(ans[s-1] != str(c) and ans[s-1] != 'z'):
        flag = 1
    ans[s - 1] = str(c)

if flag == 1 :
    print(-1)
    sys.exit()
for j in range(n) :
    if j == 0 and ans[j] == 'z' and n > 1:
        kotae += 10**(n-j -1)

    else :
        if ans[j] != 'z':
            kotae += int(ans[j])*10**(n-j -1)




print(kotae)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int M=20005;
int A[M],B[M],p[M];
int n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",p+i);
		A[i]=i*n;
		B[i]=(n-i+1)*n;
	}
	for(int i=2;i<=n;++i)
		A[p[i]]+=i-1;
	for(int i=1;i<=n;++i)
		printf("%d%c",A[i]," \n"[i==n]);
	for(int i=1;i<=n;++i)
		printf("%d%c",B[i]," \n"[i==n]);

	return 0;
}


Measured memory_bytes: 4056
n=int(input())
p=[complex(*map(int,input().split())) for _ in range(n)]
e=[b-a for a,b in zip(p,p[1:]+[p[0]])]
p=e[0]
for i in range(1,n,):
    now=e[-i]
    if now.real*p.imag-p.real*now.imag<-1e-6:print(0);break
    p=now
else: print(1)

Measured memory_bytes: 7768
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, k, a[MAXN];
bool work() {
	static int s[MAXN];
	memset(s, 0, sizeof(s));
	for (int i = 1; i <= n; i++) {
		int l = max(1, i - a[i]), r = min(n, i + a[i]);
		s[l]++, s[r + 1]--;
	}
	bool res = false;
	for (int i = 1; i <= n; i++) {
		s[i] += s[i - 1];
		if (s[i] != a[i]) {
			res = true;
			a[i] = s[i];
		}
	}
	return res;
}
int main() {
	read(n), read(k);
	for (int i = 1; i <= n; i++)
		read(a[i]);
	for (int i = 1; i <= k; i++)
		if (!work()) break;
	for (int i = 1; i <= n; i++)
		printf("%d ", a[i]);
	printf("\n");
	return 0;
}


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

int main(void) {
	string S, T;
	cin >> S >> T;

	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) {
			ans++;
		}
	}
	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main(){
  	int N,X,Y,DEF;
  	cin >> N >> X >> Y;
  	DEF = Y-X;
  	X--;
  	Y--;
  	vector<int>dist;
 	for(int i = 0;i < N - 1;i++){
    	for(int j = i + 1;j < N;j++){
        	int tmpDist = j - i;
          int state = 0;
          	if(i <=X && j > X ){
				if(j >=Y){
              		tmpDist -= (DEF - 1);
            	}else if(j - X > Y - j+ 1){
            		tmpDist = X - i + 1 + Y - j;
            	}
            }else if(i > X  &&i < X+  DEF / 2 ){
              	if(j >= Y){
            		tmpDist = (i-X + 1) +  (j- Y);
     
                }else if(i - X + 1 + Y - j < j - i){
                	tmpDist = i - X + 1 + Y - j;
                }
            }

          	dist.push_back(tmpDist);
        }
    } 
  
  	vector<int>count(N - 1,0);
  	for(int i = 0;i < dist.size();i++){
   		count[dist[i] - 1]++;
      	
    }
  
  	for(int e : count){
    	cout << e <<endl;
    }
}

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

int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int sum=0;
    for(int i=0;i<k;i++)
    {
        sum+=arr[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <string>
#include <tuple>
using namespace std;

int main(void){
  int N,W;
  cin >> N >> W;
  
  vector<vector<int>> dp(W+1);
  vector<int> Vs;
  vector<int> Ws;
  
  for(int i=0;i<=W;i++){
    dp[i].reserve(N+1);
  }
  
  Vs.push_back(0);
  Ws.push_back(0);

  for(int i=0;i<N;i++){
    int v,w;
    cin >> v >> w;
    Vs.push_back(v);
    Ws.push_back(w);
  }
  
  for(int w=1;w<=W;w++){
    for(int n=1;n<=N;n++){
      if(w-Ws[n]>=0){
        dp[w][n] = max(dp[w][n-1],dp[w-Ws[n]][n-1]+Vs[n]);
      } else {
        dp[w][n] = dp[w][n-1];
      }
    }
  }
  
  cout << dp[W][N] << endl;
}



Measured memory_bytes: 7028
#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <string>

using namespace std;

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

	int count = 0;
	for (int i = 0; i <= a; i++) {
		if (500 * i > x) {
			break;
		}
		for (int j = 0; j <= b; j++) {
			if (500 * i + 100 * j > x) {
				break;
			}
			for (int k = 0; k <= c; k++) {
				auto sum = 500 * i + 100 * j + 50 * k;
				if (sum == x) {
					count++;
				}
				else if (sum > x) {
					break;
				}
			}
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
K=int(input())
A=list(map(int,input().split()))

def func(num):
    for item in A:
        num=num//item*item
    return num

ans=[]
ok=10**20
ng=0

while ok-ng>1:
    mid=(ok+ng)//2
    if func(mid)>=2:
        ok=mid
    else:
        ng=mid

ans=ok

ok=10**20
ng=0

while ok-ng>1:
    mid=(ok+ng)//2
    if func(mid)>=4:
        ok=mid
    else:
        ng=mid

if func(ans)==2 and func(ng)==2:
    print(ans,ng)
else:
    print(-1)

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

int main() {
  string s;
  cin >> s;
  while (true) {
    s.erase(s.end() - 1);
    s.erase(s.end() - 1);
    if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2, s.size() / 2)) {
      cout << s.size() << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=1e2+10;
int a[N],n;
int main()
{
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	ll ans=-1;
	for(int x=1;x<=100;++x){
        ll sum=0;
        for(int i=1;i<=n;++i){
            sum+=(a[i]-x)*(a[i]-x);
        }
        if(ans==-1) ans=sum;
        else ans=min(ans,sum);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6)

n,m,q = map(int,input().split())
score = []
for _ in range(q):
    score.append(list(map(int,input().split())))

def search(lis):
    global n,m,score
    if len(lis)==n:
        total = 0
        for s in score:
            if lis[s[1]-1]-lis[s[0]-1]==s[2]: total += s[3]
        return total
        
    first = 1 if len(lis) == 0 else lis[-1]
    res = []
    for i in range(first, m+1):
        nlis = lis + [i]
        res.append(search(nlis))
    return max(res)

print(search([]))


Measured memory_bytes: 9212
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll nCrModpDP(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C));   
    C[0] = 1;
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
} 
ll nCrModp(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
   ll ni = n%p, ri = r%p; 
  
   return (nCrModp(n/p, r/p, p) * 
           nCrModpDP(ni, ri, p)) % p; 
} 
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,c,a,b,h,k,y,maxi,d,x;
	cin>>x>>n;
	map<ll,ll> m;
	for(j=0;j<n;j++)
	{
		cin>>c;
		m[c]=1;
	}
	a=x;
	b=x;
	ll ans=0;
	while(true)
	{
		
		
		if(m.find(b)==m.end())
		{
			ans=b;
			break;
		}
		if(m.find(a)==m.end())
		{
			ans=a;
			break;
		}
		a++;
		b--;

	}
	cout<<ans;
}



	

		

Measured memory_bytes: 3648
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private int dfs(List<Integer> l, int a, int b, int c) {
		if(l.size() == 0) {
			if(a==0 || b==0 || c==0) {
				return 1_000_000_000;
			}else {
				return Math.abs(A-a) + Math.abs(B-b) + Math.abs(C-c) -30;
			}
		}

		int x = l.get(0);
		List<Integer> newL = l.subList(1, l.size());

		int ret0 = dfs(newL, a, b, c);
		int ret1 = dfs(newL, a + x, b, c) + 10;
		int ret2 = dfs(newL, a, b + x, c) + 10;
		int ret3 = dfs(newL, a, b, c + x) + 10;

		return Math.min(Math.min(ret0, ret1), Math.min(ret2, ret3));

	}

	int A, B, C, n;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		n = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();

		List<Integer> l = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			l.add(sc.nextInt());
		}

		out.println(dfs(l, 0, 0, 0));

		sc.close();
	}

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

}


Measured memory_bytes: 26964
def lcm(x,y):
    return (x * y)// gcd(x,y)
def gcd(x,y):
    if x < y:
        x, y = y, x
    while y!=0:
        x,y=y,x%y
    return x
def main():
    A, B = map(int, input().split())
    print(lcm(A,B))
main()


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

#include <iostream>

using namespace std;

typedef long long ll;
const int _max = 110;

int g[_max][_max];
int H, W, n;
int a[_max * _max];

int main()
{
    scanf("%d%d%d", &H, &W, &n);
    for(int i = 1; i <= n; i++) scanf("%d", a + i);
    int len = H * W;
    int cur = 0;
    int ix = 0, jx = 0;
    for(int k = 1; k <= n; k++)
    {
        while(a[k]--)
        {
            if(ix & 1)
            {
                g[ix][jx--] = k;
                if(jx == -1) jx = 0, ix++;
            }
            else
            {
                g[ix][jx++] = k;
                if(jx == W) jx = W - 1, ix++;
            }
        }
    }
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
            printf("%d ", g[i][j]);
        printf("\n");
    }
    return 0;
}

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

class SegmentTree{
public:
    int n;
    vector<int> tree;
    SegmentTree(int size){
        n=1;
        while(n<size) n*=2;
        tree.resize(n,0);
    }

    SegmentTree(vector<int> v){
        n=1;
        while(n<v.size()) n*=2;
        tree.resize(2*n-1,0);
        for(int i=0;i<v.size();i++) tree[i+n-1]=v[i];
        for(int i=n-2;i>=0;i--) tree[i]=tree[2*i+1]+tree[2*i+2];
    }

    void update(int index,int val){
        index+=n-1;

        tree[index]=val;
        while(index>0){
            index=(index-1)/2;
            tree[index]=tree[2*index+1]+tree[2*index+2];
        }
    }

    int getSum(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0) r=n;

        if(r<=a||b<=l) return 0;
        else if(a<=l&&r<=b) return tree[k];
        else{
            int lval=getSum(a,b,2*k+1,l,(l+r)/2);
            int rval=getSum(a,b,2*k+2,(l+r)/2,r);
            return lval+rval;
        }
    }
};


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

  vector<pair<int,int>> v;
  for(int i=0;i<N;i++) v.push_back(make_pair(A[i],i));
  sort(v.begin(),v.end());

  ll ans=0;
  SegmentTree seg(vector<int> (N,1));
  int tar=0;
  for(int i=0;i<N;i++){
      int now=v[i].second;
      while(tar<N&&v[tar].first==v[i].first){
          int idx=v[tar].second;
          seg.update(idx,0);
          tar++;
      }
      int lval=seg.getSum(0,now);
      int rval=seg.getSum(now+1,N);
      ans+=min(lval,rval);
  }

  cout<<ans<<endl;


  return 0;
}



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

// ABC123A - Five Antennas
// https://atcoder.jp/contests/abc123/tasks/abc123_a
void ABC123A() {
	int a[5],k;
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	cin >> k;

	for (int i = 0; i < 5; i++) //基準のアンテナ
	{
		for (int j = i+1; j < 5; j++) //比較対象のアンテナ
		{
			if (abs(a[i] - a[j]) > k) {
				cout << ":(" << endl;
				return;
			}
		}
	}

	cout << "Yay!" << endl;

}

int main() {
	ABC123A();

	return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
if d <= a or b <= c:
  print(0)
elif a <= c and d <= b:
  print(d-c)
elif c <= a and b <= d:
  print(b-a)
elif a <= c <= b <= d:
  print(b-c)
elif c <= a <= d <= b:
  print(d-a)
  

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

using namespace std;
typedef long long ll;

// #define DEBUG

const int maxint = 1e9;
struct timestamp;
vector<int> shortest;
vector<vector<pair<int, int>>> connective;

void djkstra(int x)
{
    vector<int> search = {x};
    vector<int> new_search;
    shortest[x] = 0;
    int v, d;
    while (!search.empty())
    {
        for (auto itr = search.begin(); itr != search.end(); itr++)
        {
            for (auto itr2 = connective[*itr].begin(); itr2 != connective[*itr].end(); itr2++)
            {
                v = itr2->first, d = itr2->second;
                if (shortest[v] > d + shortest[*itr])
                {
                    shortest[v] = d + shortest[*itr];
                    new_search.push_back(v);
                }
            }
        }
        search.clear();
        search = new_search;
        new_search.clear();
    }
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, v, k, x, c;
    cin >> n;
    connective.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v >> k;
        shortest.push_back(maxint);
        for (int j = 0; j < k; j++)
        {
            cin >> x >> c;
            connective[i].push_back(make_pair(x, c));
        }
    }
    djkstra(0);
    for (int i = 0; i < n; i++)
    {
        cout << i << " " << shortest[i] << endl;
    }

    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)
// for (int j = 0; j < m; j++)


Measured memory_bytes: 7752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main(){
    int n; cin>>n;
    int b[n-1];
    for(int i=0; i<n-1; i++){
        cin>>b[i];
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(i == 0){
            ans += b[0];
        }
        else if(i == n-1){
            ans += b[n-2];
        }
        else{
            ans += min(b[i-1], b[i]);
        }
    }
    OUT(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, W;
  cin >> n >> W;
  vector<int> v(n), w(n);
  for(int i = 0; i < n; i++){
    cin >> w[i] >> v[i];
  }
  vector<vector<int>> dp(105, vector<int>(100100, 1001001001));
  dp[0][0] = 0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= 100001; j++){
      if(j >= v[i]){
        dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      }
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    }
  }
  ll ans = 0;
  for(int i = 0; i <= 100000; i++) {
    if(dp[n][i] <= W){
      ans = i;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 41856
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using i64 = int64_t;
using u64 = uint64_t;
using u32 = uint32_t;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

constexpr int64_t MOD = 1000000007LL;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)    

template<class T>
std::tuple<T> input() {
    T x; std::cin >> x;
    return std::make_tuple(x);
}

template<class T, class U, class... Args>
std::tuple<T, U, Args...> input() {
    auto first = input<T>();
    auto rest = input<U, Args...>();
    return std::tuple_cat(first, rest);
}

template<class T>
std::vector<T> input_vec(std::size_t size) {
    std::vector<T> vec(size);
    for (std::size_t i=0; i<size; i++)
        cin >> vec[i];
    return vec;
}

template<class T>
std::vector<T> input_vec(std::size_t size, T fill_value) {
    std::vector<T> vec(size, fill_value);
    for (std::size_t i=0; i<size; i++)
        cin >> vec[i];
    return vec;
}

/******************************************************/

void solve()
{
    auto [N] = input<int>();
    vector<int> f(N + 1);

    for (int x = 1; x <= 100; x++)
        for (int y = 1; y <= 100; y++)
            for (int z = 1; z <= 100; z++)
            {
                int n = x * x + y * y + z * z + x * y + y * z + z * x;
                if (n <= N)
                    f[n]++;
            }
    FOR(i, 1, N + 1)
    {
        cout << f[i] << "\n";
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3532
#
# 5c
#

def main():
    while True:
        H, W = map(int, input().split())
        if H == W == 0:
            break
        for i in range(H):
            s = ""
            if i % 2 == 1:
                for j in range(W):
                    if j % 2 == 0:
                        s += "."
                    else:
                        s += "#"
                print(s)
            else:
                for j in range(W):
                    if j % 2 == 0:
                        s += "#"
                    else:
                        s += "."
                print(s)
        print()


if __name__ == '__main__':
    main()


Measured memory_bytes: 5616
#include <iostream>

using namespace std;

int main(){
    long K;
    long a[50];
    cin >> K;
    
    cout << 50 << endl;
    for(int i = 0; i < 50; i++){
        if(i >= 50 - K%50) a[i] = i+1;
        else a[i] = i;
        a[i] += K/50;
        cout << a[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, K, ans=1;
    in2(N, K);
    rep(_, N){
        ans = min(ans*2, ans+K);
    }
    put(ans);
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
INF = float("inf")
import numpy as np
from collections import Counter
from itertools import permutations


def solve(N: int, C: int, D: "List[List[int]]", c: "List[List[int]]"):
    D = np.array(D)
    onedim = [[], [], []]
    for i in range(N):          # O(N^2)
        for j in range(N):
            onedim[(i+j) % 3].append(c[i][j])
    # print(onedim)
    counters = [Counter(onedim[i]) for i in range(3)]  # O(3*N*N)
    arr = np.empty((C, C))
    for i in range(3):          # O(C*C)
        for j in range(C):
            arr[i][j] = counters[i][j+1]
    # print("arr", arr)
    # print("D", D)
    hint = arr.dot(D)         # O(C*C*3)
    # print("arr@D\n", hint)
    print(int(min([hint[0][a] + hint[1][b]+hint[2][c]
                   for a, b, c in permutations(range(C), 3)])))
    # O(C*(C-1)*(C-2))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = [[int(next(tokens)) for _ in range(C)]
         for _ in range(C)]  # type: "List[List[int]]"
    c = [[int(next(tokens)) for _ in range(N)]
         for _ in range(N)]  # type: "List[List[int]]"
    solve(N, C, D, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21288
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {
	int t;
	String num;
	int ans;
	boolean rejected;
	ArrayList<String> digit,ansDigit;
	public void dfs(String s,int begin){

		if(begin == s.length()){

			int sum = 0;

			for(String d : digit){
				sum += Integer.parseInt(d);
			}

			if(Math.abs(t - sum) <= Math.abs(t - ans) && sum <= t){

				if(Math.abs(t - sum) == Math.abs(t - ans)){
					rejected = true;
				}else{
					rejected = false;
					ans = sum;
				}
				ansDigit.clear();
				ansDigit.addAll(digit);
			}

		}

		for(int i = begin + 1;i <= s.length();i++){
			digit.add(s.substring(begin,i));
			dfs(s,i);
			digit.remove(digit.size() - 1);
		}
	}



	public void solve() {

		while(true){
			t = nextInt();
			num = next();

			if(t == 0 && num.equals("0"))break;
			digit = new ArrayList<String>();
			ansDigit = new ArrayList<String>();
			ans = (int)1e9 + 7;

			dfs(num,0);

			if(ans > t){
				out.println("error");
			}else if(rejected){
				out.println("rejected");
			}else{
				out.print(ans);
				for(String d : ansDigit){
					out.print(" ");
					out.print(d);
				}
				out.println();
			}
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 25232