akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 924844033;// 1000000000 + 7;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<string, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, ans, cnt, sum[210000],fact[3000],dp[4000][4000][2],a[210000], b[210000];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n >> k;
	LL cur = 0;
	dp[0][0][0] = 1;
	rep(j, 2 * k) {
		rep(cnt, (n - j - 1) / (2 * k) + 1) {
			LL i = j + cnt * 2 * k + 1;
			rep(l, n + 1) {
				if(i+k<=n)
				dp[cur + 1][l + 1][1] += dp[cur][l][0] + dp[cur][l][1];

				if(i-k>=1)
				dp[cur + 1][l + 1][0] += dp[cur][l][0];

				dp[cur + 1][l][0] += dp[cur][l][0] + dp[cur][l][1];

				dp[cur + 1][l + 1][1] %= MOD;
				dp[cur + 1][l + 1][0] %= MOD;
				dp[cur + 1][l][0] %= MOD;
			}
			//cout << i << endl;
			cur++;
			if (cur == n)break;
		}
		if (cur == n)break;
		rep(l, n + 1) {
			dp[cur][l][0] = (dp[cur][l][0] + dp[cur][l][1]) % MOD;
			dp[cur][l][1] = 0;
		}
	}
	fact[0] = 1;
	rep(i, 2500)fact[i + 1] = (fact[i] * (i+1))%MOD;
	rep(i, n+1) {
		LL num = dp[n][i][0] + dp[n][i][1];
		num %= MOD;
		ans += ((i%2?-1:1)*((num * fact[n - i])%MOD)+MOD)%MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 129280
def main():
    N, x = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()

    ans = 0
    for i in range(len(A)):
        if i == (len(A) - 1):
            if A[i] == x:
                ans += 1

        else:
            if A[i] <= x:
                ans += 1
                x -= A[i]
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 8792
#include<cstdio>
#include<iostream>

using namespace std;

int main(){
  int i,j,k;
  string str="yuiophjklnm";
  bool r[1000];
  fill(r,r+1000,0);
  for(i=0;i<str.size();i++)
    r[str[i]]=1;
  

  while(1){
    cin>>str;
    if(str=="#")break;
    int cur=r[str[0]],re=0;
    for(i=1;i<str.size();i++){
      re+=(cur!=r[str[i]]);
      cur=r[str[i]];
    }
    cout<<re<<endl;
  }
  return 0;
}

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

typedef long long ll;

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

int main() {
    ll N,M;
    cin >> N >> M;
    vector<ll> x(N),y(N),z(N),xm(N),ym(N),zm(N);
    for ( ll i = 0; i < N; ++i){
        cin >> x[i] >> y[i] >> z[i];
        xm[i] = -x[i]; ym[i] = -y[i]; zm[i] = -z[i];
    }
    
    vector<ll> a(N),b(N),c(N);
    ll ans = -1e+15;
    for ( int bit = 0; bit < (1<<3); ++bit){
        a = x; b = y; c = z;
        if ( bit & (1<<0) ) a = xm;
        if ( bit & (1<<1) ) b = ym;
        if ( bit & (1<<2) ) c = zm;
        
        vector<ll> xyz(N);
        for ( ll i = 0; i < N; ++i){
            xyz[i] = a[i] + b[i] + c[i];
        }
        sort(xyz.begin(),xyz.end());
        reverse(xyz.begin(),xyz.end());
        ll sum = 0;
        for ( int i = 0; i < M; ++i){
            sum += xyz[i];
        }
        chmax(ans,sum);
    }
    
    cout << ans << endl;
    
    return 0;
}


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

struct Edge{
	int to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1){
	int k = 1;
	rep(i, g[v].size()){
		int u = g[v][i].to, ei = g[v][i].id;
		if(u == p) continue;
		if(k == c) k++;
		ans[ei] = k;
		k++;
		dfs(u, ans[ei], v);
	}
}

int main() {
	
	int n;
	cin >> n;
	g.resize(n);
	ans.resize(n);
	rep(i, n-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back((Edge){b, i});
		g[b].push_back((Edge){a, i});
	}
	dfs(0);
	int mx = 0;
	rep(i, n) mx = max(mx, int(g[i].size()));
	cout << mx << endl;
	rep(i, n-1) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> dp(n+1), num(n);
    dp[0] = 1;num[0] = 3;
    rep(i,n){
        dp[i+1] = dp[i] * num[a[i]] % MOD;
        num[a[i]]--;
        num[a[i]+1]++;
    }
    cout << dp[n] << endl;

}

Measured memory_bytes: 2560
use std::collections::BinaryHeap;
use std::cmp::{Reverse, min};

fn main() {
    let (h, w): (usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let (ch, cw): (usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse::<usize>().unwrap() - 1,
            iter.next().unwrap().parse::<usize>().unwrap() - 1,
        )
    };

    let (dh, dw): (usize, usize) = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        (
            iter.next().unwrap().parse::<usize>().unwrap() - 1,
            iter.next().unwrap().parse::<usize>().unwrap() - 1,
        )
    };

    let mut s: Vec<Vec<char>> = Vec::with_capacity(h);
    for _ in 0..h {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        s.push(buf.trim_end().chars().collect());
    }

    let mut dist = vec![vec![-1; w]; h];
    let mut heap = BinaryHeap::new();
    dist[ch][cw] = 0;
    heap.push((Reverse(0), (ch, cw)));
    while let Some((Reverse(d), (i, j))) = heap.pop() {
        for p in -2..=2 {
            if i as i32 + p < 0 || i as i32 + p >= h as i32 {
                continue;
            }
            let x = (i as i32 + p) as usize;
            for q in -2..=2 {
                if j as i32 + q < 0 || j as i32 + q >= w as i32 {
                    continue;
                }
                let y = (j as i32 + q) as usize;
                if p == 0 && q == 0 {
                    continue;
                }
                if s[x][y] == '#' {
                    continue;
                }
                let e = min(2, p.abs() + q.abs()) - 1;
                if dist[x][y] < 0 || d + e < dist[x][y] {
                    dist[x][y] = d + e;
                    heap.push((Reverse(d + e), (x, y)));
                }
            }
        }
    }
    println!("{}", dist[dh][dw]);
}

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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    int n,m;
    cin >> n >> m;
    string ans;
    ans.resize(n);
    ffor(i,n){
    	ans[i] = '.';
    }
    ffor(i,m){
    	int s,c;
    	cin >> s >> c;
    	--s;
    	if(ans[s] != '.' && (ans[s] != ('0' + c))) {
    		cout << -1;
    		return 0;
    	}
    	ans[s] = ('0' + c);
    }
    if(ans[0] == '0' && (n > 1)){
    	cout << -1;
    	return 0;
    }
    if(n == 1 && (ans[0] == '.'))ans[0] = '0';
    else if(ans[0] == '.') ans[0] = '1';
    for(int i = 1;i < n; ++i){
    	if(ans[i] == '.') ans[i] = '0';
    }
    cout << ans;
}		

Measured memory_bytes: 256
#include <iostream>
#include <queue>
//配列
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int>>d(n);
	for(size_t i = 0; i<m; i++)
	{
		int a,b;
		cin>>a>>b;
		a--; b--;
		d[a].push_back(b);
		d[b].push_back(a);
	}
	vector<int>ans(n,0);
	ans[0] = 1;
	queue<int>que;
	que.push(1);
	while(!que.empty())
	{
		int qs = que.size();
		for(size_t i = 0; i<qs; i++)
		{
			int q = que.front();
			for(size_t i = 0; i<d[q-1].size(); i++)
			{
				if(ans[d[q-1][i]]==0)
				{
					que.push(d[q-1][i]+1);
					ans[d[q-1][i]] = q;
				}
			}
			que.pop();
		}
	}
	cout<<"Yes"<<endl;
	for(size_t i = 1; i<n; i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 10268
#include<cstdio>

long h;

int main() {
    scanf("%ld", &h);
    long cnt = 0;
    for (long i = 1; i < (1L << 60); i *= 2) {
        if (i > h) break;
        cnt += i;
    }

    printf("%ld\n", cnt);
    return 0;
}


Measured memory_bytes: 128
h, w = map(int, input().split())

a = []
b = []

for i in range(h):
    t = list(map(int, input().split()))
    a.append(t)

q = 0
for i in range(h):
    f = i%2
    if f == 0:
        for j in range(w):
            if a[i][j] %2 == 1:
                if q == 0:
                    q = 1
                    if j != w-1:
                        b.append([i+1, j+1, i+1, j+2])
                    elif i != h-1:
                        b.append([i+1, j+1, i+2, j+1])
                else:
                    q = 0
            else:
                if q == 1:
                    if j != w-1:
                        b.append([i+1, j+1, i+1, j+2])
                    elif i != h-1:
                        b.append([i+1, j+1, i+2, j+1])
    else:
        for j in range(w):
            k = w-j-1
            if a[i][k] %2 == 1:
                if q == 0:
                    q = 1
                    if k != 0:
                        b.append([i+1, k+1, i+1, k])
                    elif i != h-1:
                        b.append([i+1, k+1, i+2, k+1])
                else:
                    q = 0
            else:
                if q == 1:
                    if k != 0:
                        b.append([i+1, k+1, i+1, k])
                    elif i != h-1:
                        b.append([i+1, k+1, i+2, k+1])
                    
print(len(b))
for i in range(len(b)):
    print(b[i][0], b[i][1], b[i][2], b[i][3])

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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (998244353)
#define umap unordered_map

int main()
{
    long t = 1;

    while (t--) {
        long x, y;
        cin >> x >> y;

        if (y % 2 == 0 and y >= 2*x and y <= 4*x) puts("Yes");
        else puts("No");
    }
}


Measured memory_bytes: 3596
N = int(input())
A = list(map(int, input().split()))

S = [0] * 3
for a in A:
  S[a-1] += 1
I, J, K = S

dp = [[[0.0] * (N+1) for j in range(N+1)] for i in range(N+1)]

for k in range(S[2] + 1):
  for j in range(S[1] + S[2] - k + 1):
    for i in range(S[0] + S[1] + S[2] - j - k + 1):
      if i == j == k == 0: continue
      dp[i][j][k] = (i * (dp[i-1][j][k] if i > 0 else 0) + j * (dp[i+1][j-1][k] if j > 0 else 0) + k * (dp[i][j+1][k-1] if k > 0 else 0) + N) / (i + j + k)

print(dp[I][J][K])


Measured memory_bytes: 254216
n,a,b=map(int,input().split())
M=10**9+7
v=pow(2,n,M)-1
s,t=1,1
for i in range(1,a+1):
  s =s * (n-i+1) % M
  t =t * i %M
v-=(s*pow(t,M-2,M)) % M
s,t=1,1
for i in range(1,b+1):
  s =s * (n-i+1) % M
  t =t * i % M
v-=(s*pow(t,M-2,M)) % M
print(v%M)


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

vector<int> ns;

int main()
{
  int n; cin >> n; // number of iterations
  ns = vector<int> {istream_iterator<int>{cin}, istream_iterator<int>{}};
  int k = *max_element(ns.begin(), ns.end());
  int cts[k+1] {0};
  for(int i : ns) {
    ++(cts[i]);
  }
  bool printed=false;
  for(int i=0; i<(k+1); ++i) {
    for(int c=0; c<cts[i]; ++c) {
      if(!printed) {
        cout << i;
        printed = true;
      } else {
        cout << " " << i;
      }
    }
  }
  cout << endl;
}


Measured memory_bytes: 11168
#pypyなら通るとか、そんなことないですよね？大人げなく泣き叫びますけど。
x = int(input())
#素数の列を、つくるわよ
prime_list = [2]
for num in range(3, x + 1, 2):
  if all(num % prime != 0 for prime in prime_list):
    prime_list.append(num)

#２は特殊な例よね
if x == prime_list[-1]:
  print(x)
  exit()

#素数は奇数だけ
if x % 2 == 0:
  p = 1
else:
  p = 0
  
#xから、x未満の最大の素数ｘ２の範囲について調べるわ
#素数ｎ<素数ｍ<素数２ｎは常識？
for i in range(x + p, prime_list[-1] * 2 + 1, 2):
  if all(i % j != 0 for j in prime_list):
    print(i)
    exit()

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

using namespace std;

typedef pair <int, int> pii;

string s[60];

int main(){
        int H, W;
        bool flag[60][60];
        for(int i=0;i<60;i++){
                for(int j=0;j<60;j++){
                        flag[i][j]=false;
                }
        }
        flag[0][0]=true;
        cin>>H>>W;
        for(int i=0;i<H;i++){
                cin>>s[i];
        }
        int res=0;
        for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                        if(s[i][j]=='.'){
                                res++;
                        }
                }
        }
        //cout<<res<<endl;
        queue <pii> q;
        queue <int> len;
        int dx[4]={0, 0, -1, 1};
        int dy[4]={-1, 1, 0, 0};
        q.push(pii(0, 0));
        len.push(1);
        while(!q.empty()){
                int x=q.front().first;
                int y=q.front().second;
                int lnow=len.front();
                if(x==W-1&&y==H-1){
                        res-=lnow;
                        break;
                }
                q.pop();
                len.pop();
                for(int i=0;i<4;i++){
                        if(x+dx[i]>=W||x+dx[i]<0||y+dy[i]>=H||y+dy[i]<0){
                                continue;
                        }
                        if(s[y+dy[i]][x+dx[i]]=='.'&&!flag[y+dy[i]][x+dx[i]]){
                                q.push(pii(x+dx[i], y+dy[i]));
                                len.push(lnow+1);
                                flag[y+dy[i]][x+dx[i]]=true;
                        }
                }
                if(q.empty()){
                        res=-1;
                        break;
                }
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
typedef unsigned long long ULL;

int main() {
	int a, b, c;

	std::cin >> a >> b >> c;

	if (a == 0 && b == 0 && c == 0) {
		std::cout << 0 << std::endl;
	}
	else if (a + b + 1 >= c) {
		std::cout << b + c << std::endl;
		return 0;
	}
	else {
		std::cout << b + a + b + 1 << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
//Δ
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 15;
const int M = 1<<N;
const int inf = 1e9;
inline void cmax(int& x,int y){
	if(x<y)
		x=y;
}
int n,m,a[N][N],b[M],f[M][N],t[M];
int main()
{
	int i,j,k,x,y,z,s=0;
	cin>>n>>m;
	while(m--){
		cin>>x>>y>>z;
		x--,y--;
		a[x][y]=z,a[y][x]=z;
		for(i=0;i<(1<<n);i=i+1)
			if(i&(1<<x))
				if(i&(1<<y))
					b[i]+=z;
		s+=z;
	}
	m=(1<<n)-1;
	for(i=0;i<=m;i=i+1){
		for(x=0;x<n;x=x+1)
			f[i][x]=-inf;
		if(i&1)
			f[i][0]=b[i];
	}
	for(x=0;x<n;x=x+1)
		t[1<<x]=x;
	for(i=0;i<=m;i=i+1){
		for(x=0;x<n;x=x+1){
			if(f[i][x]>=0){
				z=m^i;
				for(j=z;j;j=(j-1)&z){
					for(k=j;k;k=k^(k&-k)){
						y=t[k&-k];
						if(a[x][y])
							cmax(f[i|j][y],f[i][x]+a[x][y]+b[j]);
					}
				}
			}
		}
	}
	cout<<s-f[m][n-1];
	return 0;
}

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

int main(){
    using ll = long long ;
    using vll = vector<ll> ;
    ll n ; cin >> n ;
    ll a ; cin >> a ;
    vll x(n+1) ;
    for(int i=0;i<n;i++) cin >> x.at(i+1) ;
    vector<vector<vll>> dp(n+1,vector<vll>(n+1,vll(2600,0))) ;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            if(j==1){
                dp.at(i).at(1).at(x.at(i)) = 1 ;
            }
            for(int k=1;k<2600;k++){
                if(k<x.at(i)){
                    dp.at(i).at(j).at(k) += dp.at(i-1).at(j).at(k) ;
                }else{
                    dp.at(i).at(j).at(k) += dp.at(i-1).at(j-1).at(k-x.at(i))+dp.at(i-1).at(j).at(k) ;
                }
            }
        }
    }
    ll ans = 0 ;
    for(int i=1;i<=n;i++){
        ans += dp.at(n).at(i).at(a*i) ;
    }
    cout << ans << endl ;
}

Measured memory_bytes: 54272
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, s[100];
int main() {
  cin >> n;
  read_n(s, n);

  i64 x = 0;
  for (i64 i = 0; i < n; ++i) x += s[i];
  
  if (x % 10 == 0) {
    i64 y = 1 << 30;
    for (i64 i = 0; i < n; ++i) {
      if (s[i] < y && s[i] % 10 != 0) y = s[i];
    }
    if (y < (1 << 30)) x -= y;
    else x = 0;
  }
  cout << x << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;

public class Main{
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		//while(sc.hasNext()){
			int n = sc.nextInt() * 2;
			int m = sc.nextInt();
			int [][] table = new int[2][n];
			for(int i = 0; i < n; i++){
				table[0][i] = i + 1;
			}
			for(int i = 0; i < m; i++){
				int k = sc.nextInt();
				if(k == 0){
					for(int j = 0; j < n / 2; j++){
						table[(i+1) % 2][j * 2] = table[i % 2][j];
						table[(i+1) % 2][j * 2 + 1] = table[i % 2][j + n / 2];
					}
				}
				else{
					for(int j = 0; j < n; j++){
						int ind = (k + j) % n;
						table[(i+1) % 2][j] = table[i%2][ind];
					}
				}
			}
			for(int i = 0; i < n; i++){
				System.out.println(table[m % 2][i]);
			}
		//}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {

		static int n;
		static int[] an;
		static boolean[][] memo;

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			n = in.nextInt();
			an = in.nextIntArray(n);
			int q = in.nextInt();
			int[] qn = in.nextIntArray(q);

//			for (int i = 0; i < q; i++) {
//				if (f(0, qn[i])) {
//					out.println("yes");
//				} else {
//					out.println("no");
//				}
//			}

			memo = new boolean[n+1][40001];

			for (int i = 0; i < q; i++) {
			if (f(0, qn[i])) {
				out.println("yes");
			} else {
				out.println("no");
			}
		}


		}
//		boolean f(int i, int target) {
//			if (i >= n) {
//				return false;
//			}
//			if (target == 0) {
//				return true;
//			}
//			return f(i+1, target-an[i]) || f(i+1, target);
//		}
		boolean f(int i, int target) {
			if (target < 0) {
				return false;
			}
			if (memo[i][target]) {
				return memo[i][target];
			}

			if (target == 0) {
				memo[i][target] = true;
			} else if (i >= n) {
				memo[i][target] = false;
			} else if (f(i+1, target-an[i])) {
				memo[i][target] = true;
			} else if (f(i+1, target)) {
				memo[i][target] = true;
			} else {
				memo[i][target] = false;
			}
			return memo[i][target];
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}



Measured memory_bytes: 26960
#include <stdio.h>

#define INIT_LOOP 0
#define SECOND_ELEMENT 1
#define EXIT_SUCCESS 0
#define ELEMENT_MAX_INIT -1000000001

int main( void )
{
	int usW_Delement_cnt;
	int usW_Dloop_cnt;
	int ulW_Delement;
	int ulW_Delement_first;
	int ulW_Delement_min;
	int slW_Delement_max;

	scanf("%d", &usW_Delement_cnt );									/*????´??????°?????°??????*/
	for( usW_Dloop_cnt = INIT_LOOP; usW_Dloop_cnt < usW_Delement_cnt; usW_Dloop_cnt++){
		scanf("%d", &ulW_Delement);
		if( usW_Dloop_cnt == INIT_LOOP ){
			ulW_Delement_first = ulW_Delement;
		}
		else{
			/*else???????????????????????§?????\*/
		}

		if( usW_Dloop_cnt == SECOND_ELEMENT ){
			slW_Delement_max = ulW_Delement - ulW_Delement_first;
		}
		else if( slW_Delement_max < ulW_Delement - ulW_Delement_min ){
			slW_Delement_max = ulW_Delement - ulW_Delement_min;
		}
		else{
			/*else?????????????????????????????\*/
		}

		if( usW_Dloop_cnt == INIT_LOOP ){
			ulW_Delement_min = ulW_Delement;
		}
		else if( ulW_Delement_min > ulW_Delement ){
			ulW_Delement_min = ulW_Delement;
		}
		else{
			/*else?????????????????????????????\*/
		}

	}
	printf("%d\n", slW_Delement_max);
	return EXIT_SUCCESS;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int r,n;
int x[22][44]={};
double y[22];

int main(){
	while(1){
		cin>>r>>n;
		for(int i=0;i<22;i++){
			y[i]=0.0;
		}
		for(int i=0;i<22;i++){
			for(int j=0;j<44;j++){
				x[i][j]=0;
			}
		}
		if(r==0&&n==0)break;
		for(int i=0;i<n;i++){
			int xl,xr,h;
			cin>>xl>>xr>>h;
			for(int i=1;i<=h;i++){
				for(int j=xl+21;j<xr+21;j++){
					x[i][j]=1;
				}
			}
		}
		for(int i=1;i<22;i++){
			int t1=0;
			for(t1=21;t1<42&&x[i][t1]==1;t1++){
			}
			t1-=21;
			int t2;
			for(t2=20;t2>=0&&x[i][t2]==1;t2--){
			}
			t2=20-t2;
			y[i]=min(t1,t2);
		}
		double ans=100.0;
		for(int i=1;i<22;i++){
			if(r>y[i]){
				double t=(double)r-(sqrt(double(r*r)-double(y[i]*y[i]))+1.0-(double)i);
				ans=min(ans,t);
			}
		}
		printf("%f\n",ans);
	}
	return 0;
}
			
		
		


Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<climits>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
#define MOD 2019
#define INF 100000000

int main()
{
  ll L,R;cin>>L>>R;
  
  if (R-L>=2019)
  {
    cout<<0<<endl;
    return (0);
  }
  
  ll minimum = INF;
  for (int i=L;i<=R-1;i++)
  {
    ll im = i % MOD;
    for (int j=i+1;j<=R;j++)
    {
      ll time = (im*(j%MOD))%MOD;
      minimum = min(time, minimum);
    }
  }
  cout<<minimum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for(int i = be; i <= en; i++) 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a, b, c;
	set<int> s;
	cin >> a >> b >> c;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(s.size() == 2) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

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 <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  if(N==1 || N==2 || N==3 || N==5 || N==6 || N==9 || N== 10 || N==13 || N==17)cout << "No";
  else cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int y=0;
  for(int i=0;i<n;i++){
    string st;
    cin>>st;
    if(st=="Y"){
      y+=1;
    }
  }
  if(y!=0){
    cout<<"Four"<<endl;
  }
  else if(y==0){
    cout<<"Three"<<endl;
  }
}

Measured memory_bytes: 256
program sample
implicit none
integer(8) N,M,A(10000),count,S,i
read(*,*) N,M
read(*,*) (A(i),i=1,M)
S=0
do i=1,M
S=A(i)+S
end do
count=N-S
if(count>=0) then
   write(*,*) count
else
   write(*,*) -1
end if

stop
end program sample

Measured memory_bytes: 2916
#include <bits/stdc++.h>
using namespace std;
#define mem(x,v) memset(x,v,sizeof(x))
#define low(x) (x & (-x))
#define ll long long
const int N = 300000;
int c[N],d[N],n,k;
ll b[N];
struct node{
    int b;
    ll a;
}p[N];

bool cmp(const node &a, const node &b){
    if (a.a == b.a) return a.b < b.b;
    return a.a < b.a;
}
void add(int x){
    if (x == 0) {
        c[x]++;
        return;
    }
    while(x <= n){
        c[x]++;
        x += low(x);
    }
    return;
}
ll sum(int x){
    ll m = c[0];
    while(x > 0){
        m += c[x];
        x -= low(x);
    }
    return m;
}
int main() {
    ll ans = 0;
    int x;
    scanf("%d%d",&n,&k);
    for (int i = 1; i <= n; i++){
        scanf("%d",&x);
        p[i].a = p[i-1].a + x - k;
        p[i].b = i;
    }
    sort(p,p + n + 1,cmp);
    for (int i = 0; i <= n; i++){
        if (p[i].b>0) ans += sum(p[i].b);
        add(p[i].b);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7296
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

H,W,K=map(int, sys.stdin.readline().split())
S=[ sys.stdin.readline().strip() for _ in range(H) ]
#print H,W,K
#print S

ans=float("inf")
for bit in range(2**H):
    cnt=0
    group_num=0
    GROUP={}
    for i,s in enumerate(S):
        if i==0:
            GROUP[i]=group_num
        else:
            if bit>>i-1&1==1:
                cnt+=1      #境目のカウントに+1
                group_num+=1
            GROUP[i]=group_num
    #print "GROUP :: ",GROUP

    ok=None
    VALUE=defaultdict(lambda: 0)
    w=0
    for w in range(W):
        for h in range(H):
            VALUE[GROUP[h]]+=int(S[h][w])
        #現在の値がKを超えていないか
        for v in VALUE.values():
            if v<=K:
                pass
            else:
                #print "NG!",w
                if ok is None:      #okに値がない場合は、このパターンは成り立たない
                    #print "IMPOSSIBLE!"
                    cnt=float("inf")    #不可能なパターンなのでカウントに無限大を代入
                else:      #以前の列で成り立たっていた場合
                    cnt+=1      #境目のカウントに+1
                    VALUE=defaultdict(lambda: 0)    #NGの場合は値を初期化して入れなおし
                    for h in range(H):
                        VALUE[GROUP[h]]+=int(S[h][w])
                    break
        else:
            ok=w
    #print "w,ok,cnt,VALUE :: ",w,ok,cnt,VALUE
    ans=min(ans,cnt)
       
print ans

Measured memory_bytes: 34588
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s;
    cin >> s;
    for(auto i = 0; i < s.size(); i += 2) cout << s[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 592
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int i = 1;

        while(true){
            int x = i;
            if(x%3 == 0){
                System.out.print(" "+i);
            }else{
            while(true){
                if(x%10 == 3){
                    System.out.print(" "+i);
                    break;
                }else{
                    x /= 10;
                    if(x == 0) break;
                }
            }
        }
            i++;
            if(i>n) break;
        }
        System.out.println();

    }
}


Measured memory_bytes: 28772
#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using GraphI = vector<vector<int>>;
using GraphC = vector<vector<char>>;
using pint = pair<int, int>;

int main() {
  string S;
  cin >> S;
  int n = S.size();
  set<char> s;
  rep(i, 0, n) s.insert(S[i]);

  if (n == s.size())
    cout << "yes" << endl;
  else
    cout << "no" << endl;

  return 0;
}


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

using namespace std;
 
int main() {

    int N, A;
    cin >> N >> A;

    int t = N / 500;

        if (N - 500 * t > A)
        {
            cout << "No" << endl;;
        }
        
        else
        {
            cout << "Yes" << endl;
        }
        
}

Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:14:03:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("in.txt","r",stdin);
    //freopen(2 "out.txt","w",stdout);

    ll t,k;
    t=1;
    //cin>>t;
    W(t--)
    {
        ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        cin>>k;
        cout<<a[k-1];
    }
    return 0;
}




















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

int main() {
  int x;
  cin >> x;
  int bottom = x - ((x / 1000) * 1000);
  int head = (x - (x % 10)) / 10;
  if(bottom % 111 == 0 || head % 111 == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

ll base_ten[10004];

int main() {

    int d;
    char n[10023] = {};
    ll dp[100][2][2] = {{{}}};
    // [dでの変位][n%2桁目][最大？ 1で最大]
    ll mod = 1000000007;

    Scs(n);
    Scd(d);
    int l = strlen(n);
    base_ten[0] = 1;
    Rep(i,l) n[i]-='0';
    Rep(i,l) base_ten[i+1] = base_ten[i] * 1 % d;

    dp[0][0][1] = 1;
    Rep(li,l){
        Rep(di,d){
            Rep(fi,2){
                dp[di][(li+1)%2][fi] = 0;
            }
        }
        Rep(di,d){
            Rep(fi,2){
                int nn = fi ? n[li]+1 : 10;
                Rep(xi,nn){
                    int flag = fi && xi == n[li];
                    dp[(di+xi*base_ten[l-li-1])%d][(li+1)%2][flag] += dp[di][li%2][fi];
                    dp[(di+xi*base_ten[l-li-1])%d][(li+1)%2][flag] %= mod;
                }
            }
        }
    }

    printf ("%llu\n", (dp[0][l%2][0]+dp[0][l%2][1]+mod-1)%mod );



    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, K;
    cin >> N >> K;
    int x[100];
    for(int i=0;i<N;i++)
        cin >> x[i];
    
    int ans = 0;
    for(int i=0;i<N;i++)
        ans += min(2*x[i], 2*(K - x[i]));

    cout << ans << endl;

}

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

int main() {
  int n;
  cin >> n;
  deque<int> a;
  rep(i,n) {
    int k;
    cin >> k;
    if(i%2==0) a.push_back(k);
    else a.push_front(k);
  }
  if(n%2!=0) reverse(a.begin(),a.end());
  rep(i,n) cout << a[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 2944
using System;

namespace ITP1_3_B
{
    class Program
    {
        static void Main()
        {
            int[] x = new int[10000];
            int i;

            for (i = 0; i < 10000; i++)
            {
                x[i] = int.Parse(Console.ReadLine());

                if (x[i] == 0) break;
            }

            for (int j = 0; j < i; j++) Console.WriteLine("Case {0}: {1}", j + 1, x[j]);
        }
    }
}

Measured memory_bytes: 9296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try {
			Scanner sc = new Scanner(System.in);
			while (sc.hasNext()) {
				int x = Integer.parseInt(sc.next());
				int y = Integer.parseInt(sc.next());
				if (x == 0 && y == 0) {
					break;
				} else if (x < y) {
					System.out.println(x + " " + y);
				} else {
					System.out.println(y + " " + x);
				}
			}
			sc.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

using namespace std;

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

Measured memory_bytes: 3604
#include<stdio.h>
int main(void){
    long long a,b,c,d,e,n;
    c=-10000000;
    d=10000000;
    e=0;
    scanf("%lld",&n);
    for(a=0;a<n;a++){
        scanf("%lld",&b);
        if(b>c){
            c=b;
        }
        if(b<d){
            d=b;
        }
        e=e+b;
    }
    printf("%d %d %lld\n",(int)d,(int)c,e);
    return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int D = NextInt() * 2 + 1;
        int ans = (int)Math.Ceiling(N / (D+.0));

        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
    public long Abs(long a, long b) => Math.Abs(a - b);
}


Measured memory_bytes: 13268
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int INF = 1000000000;
int N, M, a[1000], c[1000], dptable[1000][1 << 12];
int dp(int k, int mask) {
	if (mask == (1 << N) - 1) return 0;
	if (k == M) return INF;
	if (dptable[k][mask] != -1) return dptable[k][mask];
	return dptable[k][mask] = min(dp(k + 1, mask), dp(k + 1, mask | c[k]) + a[k]);
}
int main() {
	memset(dptable, -1, sizeof dptable);
	fill_n(c, 1000, 0);
	int b, x;
	scanf("%d %d", &N, &M);
	for (int i = 0; i < M; ++i) {
		scanf("%d %d", &a[i], &b);
		for (int j = 0; j < b; ++j) {
			scanf("%d", &x);
			c[i] = (c[i] | (1 << (x - 1)));
		}
	}
	int ans = dp(0, 0);
	if (ans >= INF) printf("-1");
	else printf("%d", ans);
	return 0;
}

Measured memory_bytes: 16256
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;


	static long pow=1000000007;




	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N =sc.nextInt();
		int[] h = new int[N];
		for(int i = 0;i < N;i++){
			h[i] = sc.nextInt();
		}
		int[] dp = new int[N];
		dp[0] = 0;
		dp[1] = Math.abs(h[1]-h[0]);
		for(int i = 2;i < N;i++){
			dp[i] = Math.min(dp[i-2]+Math.abs(h[i]-h[i-2]), dp[i-1]+ Math.abs(h[i]-h[i-1]));
		}
		System.out.println(dp[N-1]);

	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 51008
#include <bits/stdc++.h>
#define inf 10000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;



int main(){
    int A,T,N,i,ans;
    double a,b=inf;
    cin >> N >> T >> A;

    int H[N];
    for(i=0 ; i<N ; i++){
        cin >> H[i];
    }

    for(i=0 ; i<N ; i++){
        a = abs(A-(T-H[i]*0.006));
        b = min(a,b);
        if(a == b){
            ans = i+1;
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 1000


int main() {
	int n, k, p[1000];
	int min;
	int minlabel = 0;
	int sum = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> p[i];

	for (int i = 0; i < k; i++) {
		min = MAX;
		for (int j = 0; j < n; j++) {
			if (p[j] < min) {
				min = p[j];
				minlabel = j;
			}
		}
		sum += min;
		p[minlabel] = MAX + 1;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <numeric>

using namespace std;

class B {
	int N;
	int L[100]{ 0 };
public:
	void solve()
	{
		int maximum{ 0 };

		for (int i{ 0 }; i < N; i++)
		{
			cin >> L[i];
			if (maximum < L[i]) maximum = L[i];
		}

		int sumExcludeMax{ accumulate(L, L + 100, 0) - maximum };

		if (maximum < sumExcludeMax) cout << "Yes" << endl;
		else cout << "No" << endl;

	}

	B() { cin >> N; }
};

int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))
ll = []

for i in range(len(l)):
		ll.append((l[i], i+1))

ll = sorted(ll, key=lambda x: (x[0]))
lll = []
for i in ll:
		lll.append(i[1])

print(' '.join(map(str, lll)))

Measured memory_bytes: 25532
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

ll calc(vector<ll> &v) {
    ll sum = 0;

    sum += (v[3] > v[0]? v[0] : v[3]);

    if(v[3] > v[0])
        v[3] -= v[0];

    else {
        return sum;
    }

    v[3] -= v[1];

    if(v[3] <= 0)
        return sum;
    
    sum -= (v[3] > v[2] ? v[2] : v[3]);

    return sum;
}


int main() {
    vector<ll> v(4);

    for(int i = 0; i < 4; i++)
        cin >> v[i];

    auto r = calc(v);

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n,m; cin>>n>>m;
	string s; cin>>s;
	// int dp[n+1]; rep(i,n+1) dp[i]=INF;
	priority_queue<PII,vector<PII>,greater<PII>> q;
	int dp[n+1];
	rep(i,n+1) dp[i]=-1;
	q.push(MP(0,n));
	REP(i,n){
		if(s[i]=='1') continue;
		while(!q.empty()&&q.top().second>i+m) q.pop();
		if(q.empty()) return cout<<-1<<endl,0;
		// if(i==0) cerr<<q.top().first+1<<endl;
		dp[i]=q.top().second;
		q.push(MP(q.top().first+1,i));
	}
	int idx=0;
	// VI ans;
	while(idx!=n){
		// ans.PB(dp[idx]-idx);
		cout<<dp[idx]-idx<<' ';
		idx=dp[idx];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 1912
#include <bits/stdc++.h>
#define int long long 
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //#ifndef ONLINE_JUDGE
    //freopen("bruh.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif
    int n, m , ans=0;;
    cin >> n >> m;
    int a[n + 4]; a[0]=0;
    for (int i = 1; i <= n + 1; i++) {
        a[i] = i - 1;
        if (i > 1) {
            a[i] += a[i - 1];
        }
    }
    // for(int i=19999;i<=200001;i++)cout<<a[i]<<" ";
    for (int k = m; k <= n + 1; k++) {
        int front = a[n + 1] - a[n + 1 - k];
        int end = a[k];
        ans += (front - end +1)%1000000007;
        //cout<<ans<<endl;
    }
    cout << ans%(1000000000+7) << endl;




}



Measured memory_bytes: 5212
L, R = map(int,input().split())

if R-L >= 2018:
  print(0)
else:
  ans = 2018
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      if ans >= (i*j)%2019:
        ans = (i*j)%2019
  print(ans)


Measured memory_bytes: 2940
// from https://atcoder.jp/contests/code-festival-2017-qualb/submissions/8517446

#include<bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

ll color[110000];
vector<ll> v[110000];

bool dfs(ll x, ll c){
  color[x]=c;
  rep(i, v[x].size()){
    if(color[v[x][i]]==c)return false;
    if(color[v[x][i]]==0 && !dfs(v[x][i], -c) )return false;
  }
  return true;  
}

int main(){
  ll n,m;
  cin>>n>>m;

  rep(i, m){
    ll a,b;
    cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  if(dfs(1,1)){
    ll count=0;
    rep(i, n){ 
      if(color[i+1]==1)count++;
    }
    cout<<count*(n-count)-m;
  }else{
    cout<<n*(n-1)/2-m;
  }

  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


int main(){
  int X,t;
  cin >> X >> t;
  cout << max(0,X-t) << endl;
}


Measured memory_bytes: 256