akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);
	printf("%d\n",a/500*1000+a%500/5*5);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  long long ac,ad,bc,bd;
  ac = a*c, ad = a*d, bc = b*c, bd = b*d;
  cout << max(max(ac,ad),max(bc,bd)) << endl;
}
              

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

int main() {
  string s;
  cin >> s;
  ll q;
  cin >> q;
  bool r=false;
  deque<char> dec;
  for(auto i:s) {
    dec.push_back(i);
  }
  for(ll i=0;i<q;i++) {
    ll temp;
    cin >> temp;
    if(temp==1) {
      r=!r;
    }
    else if(temp==2) {
      ll f;
      char c;
      cin >> f >> c;
      if(!r) {
        if(f==1) {
          dec.push_front(c);
        }
        else if(f==2) {
          dec.push_back(c);
        }
      }
      else {
        if(f==2) {
          dec.push_front(c);
        }
        else if(f==1) {
          dec.push_back(c);
        }
      }
    }
  }
  if(r) {
    reverse(dec.begin(),dec.end());
  }
  for(auto i:dec) {
    cout << i;
  }
  cout << endl;
}

Measured memory_bytes: 896
use std::io::*;

fn main() {
	let mut input = String::new();
	stdin().read_line(&mut input);
	input.pop();

	let n = input.parse().unwrap();

	let out = stdout();
	let mut out = BufWriter::new(out.lock());
	writeln!(out, "0:");

	for p in 0..n {
		for d in (1 << p)..(2 << p) {
			write!(out, "{}:", d);

			for e in 0..p + 1 {
				if d & 1 << e != 0 {
					write!(out, " {}", e);
				}
			}
			writeln!(out);
		}
	}
}



Measured memory_bytes: 5032
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <cmath>
#define EPS 1e-8
using namespace std;
typedef complex<double> P;

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

    vector<P> G(n);
    for(int i=0; i<n; i++){
        int x,y;
        cin >> x >> y;
        G[i] = P(x,y);
    }

    if(n%2!=0){
        cout << "NA" << endl;
        return 0;
    }

    int half = G.size()/2;
    P mid = (G[0] + G[half])/P(2,0);
    for(int i=1; i<half; i++){
        P tmpmid = (G[i] + G[i+half])/P(2,0);
        if(fabs(real(tmpmid)-real(mid))>EPS ||
           fabs(imag(tmpmid)-imag(mid))>EPS){
            cout << "NA" << endl;
            return 0;
        }
    }
    cout << fixed;
    cout << setprecision(5);
    cout << real(mid) << " " << imag(mid) << endl;
            
    return 0;
}

Measured memory_bytes: 3280
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

class MergeFind:
    def __init__(self, n):
        self.parent = list(range(n))
        self.size = [1] * n
        self.num_sets = n
        # self.lista = [[_] for _ in range(n)]

    def find(self, a):
        to_update = []
        while a != self.parent[a]:
            to_update.append(a)
            a = self.parent[a]
        for b in to_update:
            self.parent[b] = a
        return self.parent[a]

    def merge(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b:
            return
        if self.size[a] < self.size[b]:
            a, b = b, a
        self.num_sets -= 1
        self.parent[b] = a
        self.size[a] += self.size[b]
        # self.lista[a] += self.lista[b]
        # self.lista[b] = []

    def set_size(self, a):
        return self.size[self.find(a)]

    def __len__(self):
        return self.num_sets

n,m,k=sep()
d=MergeFind(n)
temp=[]
for _ in range(m):
    a,b=sep()
    a -= 1
    b -= 1
    temp.append((a,b))
    d.merge(a,b)
ans=[0]*n
for i in range(n):
    ans[i]=d.set_size(i)-1
for _ in range(k):
    a, b = sep()
    a -= 1
    b -= 1
    temp.append((a, b))
for i in temp:
    a,b=i
    if d.find(a)==d.find(b):
        ans[a]-=1
        ans[b]-=1
print(*ans)





Measured memory_bytes: 100936
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int d[5*100000+1];
int main(){
    string s;cin>>s;
    int n = s.size();
    int cnt = 0;
    rep(i,n){
        if(s[i]=='<')cnt++;
        else cnt = 0;
        d[i+1] = cnt;
    }
    cnt = 0;
    rep(i,n){
        if(s[n-1-i]=='>')cnt++;
        else cnt = 0;
        d[n-1-i] = max(cnt,d[n-1-i]);
    }
    ll res = 0;
    rep(i,n+1)res += d[i];
    cout<<res;
}



Measured memory_bytes: 2820
#include<bits/stdc++.h>
#define mod 1000000007
#define f first
#define s second

using namespace std;

/*int gcd(int a,int b){
	if(b == 0)
		return a;
	return gcd(b,a%b);
}*/

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

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


    ll a,b,c,d;

    cin>>a>>b>>c>>d;

    //number of intergers neither divided by c and d between a and b;
    //this is (b- a + 1) - number of integers divided by c or d

    //number of integers divided by c
    ll by_c = b/c - a/c + (a%c == 0);

    //number of integers divided by d
    ll by_d = b/d - a/d + (a%d == 0);

    //number of integers divided by c and d
    ll lcm = (c * d)/__gcd(c,d);
    ll by_cd = b/lcm - a/lcm+ (a % lcm == 0);

    cout<<(b - a +1) - (by_c + by_d - by_cd);
    


	return 0;
}

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

using namespace std;

int Solve(string s)
{
    if (s[0] == '[' && s.size() > 2 && isdigit(s[1]))
        return (stoi(s.substr(1, s.size() - 2)) + 2) / 2;

    vector<int> res;
    int N = s.size();
    int idx = 1;


    while (idx < N) {
        if (s[idx] == '[') {
            int end = idx + 1, cnt = 1;
            while (cnt != 0) {
                if (s[end] == '[')
                    ++cnt;
                else if (s[end] == ']')
                    --cnt;
                ++end;
            }
            res.push_back(Solve(s.substr(idx, end - idx)));
            idx = end;
        }
        else
            ++idx;
    }

    sort(res.begin(), res.end());
    int res_num = 0;
    N = (res.size() + 2) / 2;
    for (int i = 0; i < N; ++i)
        res_num += res[i];

    return res_num;
}

int main()
{
    int n;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;

        cin >> s;
        cout << Solve(s) << '\n';
    }

    return 0;
}

Measured memory_bytes: 1296
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    A, B = parseMap(split(readline()))
    for ii in 1:10009
        x = floor(ii * 0.08)
        y = floor(ii * 0.1)
        if x == A && y == B
            println(ii)
            return
        end
    end
    println(-1)
end

main()

Measured memory_bytes: 173172
#include <iostream>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std; typedef long long ll; const int INF=1e9; typedef pair<ll,ll> P;

int main() {
  int n; cin>>n;
  ll a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) a[i]-=n-1;
  ll s[n]; fill(s,s+n,0);
  ll an=0;
  
  bool update=true;
  while(update) {
    update=false;
    for(int i=0;i<n;i++) {
      a[i] += an-s[i]; s[i]=an;
    }
    //cout<<"upp:"<<endl;
    //for(ll x:a) cout<<x<<" "; cout<<endl;
    //for(ll x:s) cout<<an-x<<" "; cout<<endl;
    for(int i=0;i<n;i++) {
      if (a[i] > 0) {
        update=true;
        ll gt = a[i] / n;
        a[i] -= gt * n;
        if (a[i] > 0) gt++, a[i]-=n;
        an += gt;
        s[i] += gt;
      }
    }
    //cout<<an<<": ";
    //for(ll x:a) cout<<x<<" "; cout<<endl;
    //for(ll x:s) cout<<x<<" "; cout<<endl;
  }
  cout<<an<<endl;
}

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

using namespace std;

const int oo = 1000000005;

int f[100005], w[105], v[105];

int main(){
    //freopen("KNAPSACK2.INP", "r", stdin);

    int n, W;
    cin >> n >> W;
    for (int i = 1; i <= n; i++){
        cin >> w[i] >> v[i];
    }

    for (int i = 1; i <= 100000; i++){
        f[i] = oo;
    }
    for (int i = 1; i <= n; i++){
        for (int t = 100000; t >= v[i]; t--){
            f[t] = min(f[t], f[t - v[i]] + w[i]);
        }
    }
    for (int i = 100000; i >= 1; i--){
        if (f[i] <= W){
            cout << i;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         int d=gi();
         int t=gi();
         int s=gi();

         long ans=0;


         if (t*s>=d) {
             System.out.println("Yes");
         } else {
        	 System.out.println("No");
         }
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 35532
#include<stdio.h>

int P,Q,R,min;

int main(void){
  scanf("%d%d%d",&P,&Q,&R);
  min = P+Q;
  if(min>P+R){
    min=P+R;
  }
  if(min>R+Q){
    min=R+Q;
  }
  printf("%d",min);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
bool vis[1000006];
int main()
{
    int s;
    cin>>s;
    vis[s]=1;
    int c=1;
    while(1)
    {
        if(s%2==0)
        {
            s/=2;
        }
        else
        {
            s=3*s+1;
        }
        c++;
     //   vis[s]=1;
        if(vis[s])
        {
            cout<<c<<endl;
            return 0;
        }
        vis[s]=1;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std; 
int main() {
    string s; 
    short k; 
    cin >> k;
    cin.ignore(); 
    cin >> s; 
    short longueur = s.length(); 
    if (longueur <= k) 
        cout << s; 
    else {
        for (short  i= 0; i < k; i ++) {
            cout << s[i]; 
        }
        cout << "..."; 
    }
    return 0; 
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>

using namespace std;

char s[5005];
int len, K, sum;
bool buc[30];

struct Trie{
	int c[30], pre;
	char ch;
}tr[3000005];
int cnt;
void insert(int pos){
	int now = 0;
	for(int i = pos; i <= len; i++){
		if(tr[now].c[s[i]-'a'])
			now = tr[now].c[s[i]-'a'];
		else{
			tr[now].c[s[i]-'a'] = ++cnt;
			tr[cnt].pre = now;
			tr[cnt].ch = s[i];
			now = cnt;
		}
	}
}

char ans[5005];
void print(int x){
	while(x){
		ans[++ans[0]] = tr[x].ch;
		x = tr[x].pre;
	}
	for(int i = ans[0]; i; i--)
		putchar(ans[i]);
}

bool findAns;
void dfs(int x){
	if(findAns)	return;
	if(sum == K){
		findAns = 1;
		print(x);
		return;
	}
	for(int i = 'a'; i <= 'z'; i++)
		if(tr[x].c[i-'a'])
			sum++, dfs(tr[x].c[i-'a']);
}

int main(){
	scanf("%s", s+1);
	scanf("%d", &K);
	len = strlen(s+1);
	for(int i = 1; i <= len; i++)
		buc[s[i]-'a'] = 1;
	for(int c = 0; c < 26; c++)
		if(buc[c]){
			cnt = 0;
			memset(tr, 0, sizeof tr);
			for(int i = 1; i <= len; i++)
				if(s[i] == c + 'a')
					insert(i);
			dfs(0);
			if(findAns)	break;
		}
	return 0;
}


Measured memory_bytes: 375168
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#include<cmath>
using namespace std;
#define int long long
void read(int &x){
	char ch;bool ok;
	for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
	for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
#define rg register
const int maxn=1e5+10;
int mm,m,n,a[60];
long long f[60];
long long ans;
void dfs(int x,int n,long long sum){
	if(x==n/2+1){
		if(sum==m){
			long long now=a[1]>=0?(9-a[1]):(9+a[1]);
			for(rg int i=2;i<x;i++)now=now*(a[i]>=0?(10-a[i]):(10+a[i]));
			ans+=n&1?now*10:now;
		}
		return ;
	}
	if(sum+10ll*(f[n-x]-f[x-1])<m||sum-10ll*(f[n-x]-f[x-1])>m)return ;
	for(rg int i=-9;i<10;i++){
		a[x]=i;
		dfs(x+1,n,sum+1ll*a[x]*(f[n-x]-f[x-1]));
	}
}
signed main(){
	read(m),mm=m;f[0]=1;
	while(mm)n++,mm/=10;
    for(rg int i=1;i<=18;i++)f[i]=f[i-1]*10;
	for(rg int i=n;i<=18;i++)dfs(1,i,0);
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    long a,b,n,m,s,cou,abe;
    scanf("%ld%ld%ld",&n,&a,&b);
    
    s = a + b;
    cou = 0;
    if(s <= n){
        abe = n/s;
        m = n%s;
        if(m >= a)
            cou = abe * a + a;
        else 
            cou = abe * a + m;
    }
    
    else if(a >= n)
        cou = n;
    else
        cou = a;
    
    printf("%ld",cou);
    return 0;
}

Measured memory_bytes: 128
H,W=map(int,input().split())
s=[list(input()) for _ in range(H)]
s2=[["" for _ in range(W)] for _ in range(H)]
flag=1
#print(s,s2)
for i in range(H):
    for j in range(W):
        if s[i][j]=="#":
            if (i==0):
                if (j==0):
                    if not((s[i][j+1]=="#")or(s[i+1][j]=="#")):
                        flag=0
                elif (j==W-1):
                    if not((s[i][j-1]=="#")or(s[i+1][j]=="#")):
                        flag=0
                else:
                    if not((s[i][j-1]=="#")or(s[i][j+1]=="#")or(s[i+1][j]=="#")):
                        flag = 0

            elif (i==H-1):
                if (j==0):
                    if not((s[i-1][j]=="#")or(s[i][j+1]=="#")):
                        flag=0
                elif (j==W-1):
                    if not((s[i-1][j]=="#")or(s[i][j-1]=="#")):
                        flag=0
                else:
                    if not((s[i][j+1]=="#")or(s[i-1][j]=="#")or(s[i][j-1]=="#")):
                        flag=0
            else:
                if (j==0):
                    if not ((s[i + 1][j] == "#") or (s[i - 1][j] == "#") or (s[i][j + 1] == "#")):
                        flag = 0
                elif (j==W-1):
                    if not ((s[i + 1][j] == "#") or (s[i - 1][j] == "#") or (s[i][j - 1] == "#")):
                        flag = 0
                else:
                    if not((s[i+1][j]=="#")or(s[i-1][j]=="#")or(s[i][j+1]=="#")or(s[i][j-1]=="#")):
                        flag=0
if flag==1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 39280
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

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

  vector<int> l(n + 1), r(n + 1);
  l[0] = 0;
  for (int i = 1; i < l.size(); i++) l[i] += w[i - 1] + l[i - 1];
  r[r.size() - 1] = 0;
  for (int i = r.size() - 2; i >= 0; i--) r[i] += w[i] + r[i + 1];

  int ans = INF;
  for (int i = 0; i < n; i++) {
    ans = min(ans, abs(l[i] - r[i]));
  }

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

Measured memory_bytes: 256
def div_cards(cards, xi, yi)
  cds0 = []
  cds1 = []
  cds2 = []
  k = 0
  sum = 0

  while sum + cards[k][2] < xi
    cds0 << cards[k]
    sum += cards[k][2]
    k += 1
  end

  a0, c0, w = cards[k]
  w0 = xi - sum
  b0 = a0 - 1 + w0

  cds0 << [a0, b0, w0]
  sum += w0

  if w0 < w
    cards[k] = [b0 + 1, c0, w - w0]
  else
    k += 1
  end

  while sum + cards[k][2] < yi
    cds1 << cards[k]
    sum += cards[k][2]
    k += 1
  end

  a0, c0, w = cards[k]
  w0 = yi - sum
  b0 = a0 - 1 + w0

  cds1 << [a0, b0, w0]
  sum += w0

  if w0 < w
    cards[k] = [b0 + 1, c0, w - w0]
  else
    k += 1
  end

  cds2 = cards[k...cards.length]

  [cds0, cds1, cds2]
end

### main

loop do
  n = gets.strip.to_i
  break if n == 0

  m = gets.strip.to_i
  pn, qn, rn = gets.strip.split(' ').map{|s| s.to_i}

  cards = [[1, n, n]]
  #p cards

  m.times do
    xi, yi = gets.strip.split(' ').map{|s| s.to_i}

    cds0, cds1, cds2 = div_cards(cards, xi, yi)
    cards = cds2 + cds1 + cds0
    #p ['shffle', xi, yi]
    #p ['cds0', cds0]
    #p ['cds1', cds1]
    #p ['cds2', cds2]
    #p ['cards', cards]
  end
  #p cards

  cds0, cds1, cds2 = div_cards(cards, pn - 1, qn)
  #p cds1

  count = 0
  for cg in cds1
    if cg[0] <= rn
      count += (cg[1] <= rn ? cg[1] : rn) - cg[0] + 1
    end
  end

  puts count
end

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, m;
  cin >> n >> m;
  int ans[100001] = {};
  rep(i, 0, m) {
    int a, b;
    cin >> a >> b;
    ans[a]++;
    ans[b]++;
  }
  rep(i, 0, n + 1) {
    if(ans[i] % 2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, W;
    cin >> N >> W;

    vector<int64_t> w(N), v(N);
    for (size_t i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    auto dp = make_v(0LL, N + 1, W + 1);
    for (int i = 0; i < N; ++i) {
        for (int weight = 0; weight <= W; ++weight) {
            chmax(dp[i + 1][weight], dp[i][weight]);
            if (weight - w[i] >= 0) {
                chmax(dp[i + 1][weight], dp[i][weight - w[i]] + v[i]);
            }
        }
    }

    cout << dp[N][W] << "\n";

    return 0;
}


Measured memory_bytes: 80256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	string n,k,r;
  	cin >> n >> k;
  	int a,b;
  	cin >> a >> b;
  	cin >> r;
  	if(r == n)
  	{
  		cout << a-1 <<" " << b;
  	}
  	else
  	{
  		cout << a << " " << b-1;
  	}	
  	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mc = 4009,md=2009;
int ww[mc][md];
int bb[mc][md];
int dp[mc][mc];
int bp[md];
int wp[md];
int gc(int pos,int i,int j,int n){
    return ww[pos][n]-ww[pos][i]+bb[pos][n]-bb[pos][j];
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=2*n;i++){
        char c[10];int d;
        scanf("%s%d",c,&d);
        if(c[0]=='B'){
            for(int j=i;j<=2*n;j++){
                bb[j][d]++;
            }
            bp[d] = i;
        }else{
            for(int j=i;j<=2*n;j++){
                ww[j][d]++;
            }
            wp[d] = i;
        }
    }
    for(int i=1;i<=2*n;i++){
        for(int j=1;j<=n;j++){
            bb[i][j] += bb[i][j-1];
            ww[i][j] += ww[i][j-1];
        }
    }
    dp[0][0] = 0;
    for(int i=1;i<=n;i++){
        dp[i][0] = gc(wp[i],i,0,n)+dp[i-1][0];
        dp[0][i] = gc(bp[i],0,i,n)+dp[0][i-1];
    }
    //cout<<gc(1,1,1,n)<<endl;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dp[i][j] = min(gc(wp[i],i,j,n)+dp[i-1][j],gc(bp[j],i,j,n)+dp[i][j-1]);
        }
    }
    printf("%d\n",dp[n][n]);
    return 0;
}


Measured memory_bytes: 96768
#include<stdio.h>
void funk(int,int);
char sima[13][13];
int main(void)
{
	int i,m,sk;
	sk=0;
	while(scanf("%s",&sima[0])!=EOF){
		for(i=1;i<12;i++){
				scanf("%s",sima[i]);
			}
		for(i=0;i<12;i++){
			for(m=0;m<12;m++){
				if(sima[i][m]=='1'){
					sk++;
					funk(i,m);
				}
			}
		}
		printf("%d\n",sk);
		sk=0;
	}
	return 0;
}
void funk(int i,int m){
	sima[i][m]='0';
	if(i+1<12){
		if(sima[i+1][m]=='1'){
			funk(i+1,m);
		}
	}
	if(i-1>=0){
		if(sima[i-1][m]=='1'){
			funk(i-1,m);
		}
	}
	if(m+1<12){
	if(sima[i][m+1]=='1'){
		funk(i,m+1);
	}
	}
	if(m-1>=0){
		if(sima[i][m-1]=='1'){
			funk(i,m-1);
		}
	}
}

Measured memory_bytes: 976
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int x,a,b;
    cin >> x >> a >> b;
    string ans = (a>=b)?"delicious":(x+a>=b)?"safe":"dangerous";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=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 main(){
  int n,m;
  cin>>n>>m;

  bool a[1000001];
  rep(i,n+1) a[i]=true;
  rep(i,m){
    int x;
    cin>>x;
    a[x]=false;
  }

  ll dp[100001];
  rep(i,n+1) dp[i]=0;
  dp[0]=1;

  rep(i,n+1){
    if(i==1){
      if(a[i]) dp[i]=1;
    }
    else{
      if(a[i-1]) dp[i]+=(dp[i-1]);
      if(a[i-2]) dp[i]+=(dp[i-2]);
      dp[i]%=inf;
    }
  }

  cout<<dp[n]<<endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define RI register
using namespace std;
const int N=3e5+10,mod=1e9+7;
typedef long long ll;

int n,t[26];
char s[N];

int main(){
	int i,ans=1;
	scanf("%d%s",&n,s+1);
	for(i=1;i<=n;++i){
		t[s[i]-'a']++; 
	}
	for(i=0;i<26;++i) ans=(ll)ans*(t[i]+1)%mod;
	printf("%d",(ans-1+mod)%mod);
	return 0;
}

Measured memory_bytes: 384
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
Point2D p2d=new Point2D.Double(d1,d2);
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int n = sc.nextInt();
        long[] a = new long[n];
        int pos = 0, neg = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            if (a[i] < 0) neg++;
            else if (a[i] > 0) pos++;
        }
        Arrays.sort(a);
        long[] x = new long[n - 1];
        long[] y = new long[n - 1];
        long m = 0;
        if (neg == 0) {
            for (int i = n - 1; i > 1; i--) {
                x[n - 1 - i] = a[0];
                y[n - 1 - i] = a[i];
                a[0] = a[0] - a[i];
            }
            x[n - 2] = a[1];
            y[n - 2] = a[0];
            m = a[1] - a[0];
        } else if(pos==0) {
            for (int i = 0; i < n - 1; i++) {
                x[i] = a[n - 1];
                y[i] = a[i];
                a[n-1]=x[i]-y[i];
            }
            m = a[n-1];
        }else {
            int c = 0;
            for (int i = neg; i < n - 1; i++) {
                x[c] = a[0];
                y[c] = a[i];
                a[0] = x[c] - y[c];
                c++;
            }
            for (int i = 0; i < neg; i++) {
                x[c] = a[n - 1];
                y[c] = a[i];
                a[n - 1] = a[n - 1] - a[i];
                c++;
            }
            m = a[n - 1];
        }
        out.println(m);
        for (int i = 0; i < n - 1; i++) {
            out.println(x[i] + " " + y[i]);
        }
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static String nextLine() {
            return s.nextLine();
        }

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

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

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

        static boolean hasNext() {
            return s.hasNext();
        }

        static boolean hasNextInt() {
            return s.hasNextInt();
        }

    }

}

Measured memory_bytes: 50556
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      xys: [(f64, String); n],
    }

    let mut ans = 0.0;
    for i in 0..n {
        let x = xys[i].0;
        let y = &xys[i].1;
        if y == &"JPY".to_string() {
            ans += x;
        } else {
            ans += x * 380000.0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>

void swap(int *x,int *y)
{
    int temp;
    temp=*x;
    *x=*y;
    *y=temp;
}

int main()
{
    int a[1000],n;
    while(~scanf("%d",&n))
    {
        int len = 0;
        while(n--) scanf("%d",&a[len++]);
        int i,j,count=0;
        for(i=0;i<len-1;i++)
        {
            for(j=0;j<len-i-1;j++)
            {
                if(a[j]>a[j+1]){
                    swap(&a[j],&a[j+1]);
                count++;}
            }
        }
        for(i=0;i<len;i++) printf("%d%c",a[i],(i==len-1)?'\n':' ');
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 1032
n=int(input())
a=list(map(int,input().split()))
num=[0]*8
up2800=0
for i in range(n):
    if a[i]<400:
        num[0]+=1
    elif a[i]<800:
        num[1]+=1
    elif a[i]<1200:
        num[2]+=1
    elif a[i]<1600:
        num[3]+=1
    elif a[i]<2000:
        num[4]+=1
    elif a[i]<2400:
        num[5]+=1
    elif a[i]<2800:
        num[6]+=1
    elif a[i]<3200:
        num[7]+=1
    else:
        up2800+=1
num2=8-num.count(0)
if num2==0:
    print(1,up2800)
else:
    print(num2,num2+up2800)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int X,Y;
	cin >> X >> Y;
	cout << X+Y/2 << endl;
}

Measured memory_bytes: 256
def count_divisor(n):
    count = 1
    divisor = 2
    while divisor * divisor <= n:
        degree = 0 # 次数
        while n % divisor == 0:
            n = n // divisor
            degree += 1
        divisor += 1
        count *= (degree + 1)
    if n > 1:
        count *= 2
    return count

def solve():
    n = int(input())
    MOD = 10 ** 9 + 7
    f = 1
    for i in range(1, n+1):
        f *= i
    return count_divisor(f) % MOD

print(solve())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
int n, a, b, res = 0;
vector<int> g[111111];
vector<pair<int, int>> gg;
map<pair<int, int>, int> col;
void search(int now, int prev, int used) {
    int color = 1;
    each(i, g[now]) {
        if(i == prev) continue;
        if(color == used) color++;
        col[{now, i}] = color;
        search(i, now, color);
        color++;
    }
}
signed main() {
    INCANT;
    cin>>n;
    rep(i, n - 1) {
        cin>>a>>b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
        gg.push_back({a, b});
    }
    search(0, -1, -1);
    each(p, col) {
        chmax(res, p.second);
    }
    cout<<res<<endl;
    each(p, gg) {
        cout<<col[p]<<endl;
    }
}


Measured memory_bytes: 16496
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {

        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };


    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: i32,
        s: i32,
    }
    let mut cnt = 0;
    for x in 0..k + 1 {
        for y in 0..k + 1 {
            let target = s - x - y;
            if 0 <= target && target <= k {
                cnt += 1;
            }
        }
    }
    println!("{}", cnt);
}


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

string s;
map<char, int> check;

main(){
			//freopen("input.inp","r",stdin);
			cin>>s;
			for(int i=0; i<s.size(); i++) 
				check[s[i]]=1;
			for(char i='a'; i<='z'; i++){
				if (check[i]==0){
					cout<<i;
					return 0;
				}
			}
			cout<<"None";
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main() {
  int count_5=0,count_7=0;
  for(int i=0;i<3;i++){
    int c;
    cin >> c;
    if(c==5) count_5++;
    else if(c==7) count_7++;
  }
  if(count_5==2,count_7==1) cout << "YES";
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt(); // N個のたこ焼き
		int []d = nextIntArray(N);

		long sum = 0;
		for(int i=0;i<N-1;i++) {
			for(int j=i+1;j<N;j++) {
				sum += d[i]*d[j];
			}
		}
		out.println(sum);
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 21844
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

class UnionFind():
	def __init__(self, n):
		self.n=n
		self.parents = [-1]*n
	def find(self, x):
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]
	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)
		if x==y:
			return
		if self.parents[x] > self.parents[y]:
			x, y = y, x
		self.parents[x] += self.parents[y]
		self.parents[y] = x
	def size(self, x):
		return -self.parents[self.find(x)]
	def same(self, x, y):
		return self.find(x) == self.find(y)
	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]
	def roots(self):
		return [i for i, x in enumerate(self.parents) if x < 0]
	def group_count(self):
		return len(self.roots())
	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}
	def __str__(self):
		return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
	N,M = MI()
	pp = LI1()
	uf = UnionFind(N)
	for _ in range(M):
		x,y = MI()
		x-=1
		y-=1
		uf.union(x,y)

	ans = 0
	for i,p in enumerate(pp):
		if(uf.same(i,p)):
			ans+=1
	print(ans)




if __name__ == '__main__':
	main()

Measured memory_bytes: 13876
S = input()

c1 = (S==S[-1::-1])
S2 = S[0:(len(S)-1)//2]
c2 = (S2==S2[-1::-1])
S3 = S[(len(S)+3)//2-1:]
c3 = (S3 == S3[-1::-1])
if c1 and c2 and c3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n,x,y,m,ans1=INT_MIN,i,ans2=INT_MAX,a;
    cin>>n>>m>>x>>y;
    for(i=0;i<n;i++)
    {
        cin>>a;
        ans1=max(ans1,a);
    }
    for(i=0;i<m;i++)
    {
        cin>>a;
        ans2=min(ans2,a);
    }
    bool flag=false;
    for(i=x+1;i<=y;i++)
    {
        if((i<=y && i>ans1 && i<=ans2))
        flag=true;
    }
    flag?cout<<"No War":cout<<"War";
    return 0;
}


Measured memory_bytes: 256
n = int(input())

cnt = [float("inf")] * (n + 1)
cnt[0] = 0

sixes = [pow(6, num) for num in range(1, 10)]
nines = [pow(9, num) for num in range(1, 10)]

for six in sixes:
    for i in range(n + 1):
        if six + i <= n and cnt[i] != float("inf"):
            cnt[six + i] = min(cnt[six + i], cnt[i] + 1)

for nine in nines:
    for i in range(n + 1):
        if nine + i <= n and cnt[i] != float("inf"):
            cnt[nine + i] = min(cnt[nine + i], cnt[i] + 1)

for i in range(n):
    cnt[i + 1] = min(cnt[i + 1], cnt[i] + 1)

print(cnt[n])


Measured memory_bytes: 74684
#include<stdio.h>
int x[45];
int fibo(int);
int main(){
  int n,i;
  for(i=0;i<45;i++){
    x[i]=-10;
  }
  scanf("%d",&n);
  printf("%d\n",fibo(n));
  return 0;
}
int fibo(int y){
  if(y==1||y==0)
    return x[y]=1;
  if(x[y]!=-10)
    return x[y];
  return x[y]=fibo(y-1)+fibo(y-2);
}



Measured memory_bytes: 2112
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define lli long long int  
#define ll  long long 
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl   vector<lli>
#define mii unordered_map<ll,ll>
#define pb push_back
double pi = 2*acos(0.0);
const int INF = 1e9 + 7;
//ull power(ull a,ull b){ ull res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}
bool sortinrev(const pair<int,int> &a,   const pair<int,int> &b) {  if(a.second==b.second) return a.first>b.first;  return (a.second > b.second);} 






void WetPitch()
{
  lli n,x,t;
  cin>>n>>x>>t;
  if(n%x==0)
  	cout<<(n/x)*t<<endl;
  else
  	cout<<((n/x)+1)*t<<endl;




}     
signed main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	lli tst;
    tst=1; 
    //cin>>tst;
    while(tst--)
    WetPitch();
    return 0;
 } 

Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf (ll)2e18
#define EPS 1e-12
#define mod 1000000007LL
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	ll x;
	cin >> x;
	ll cur = 100;
	ll otv = 0;
	while (cur < x) {
		otv++;
		cur += cur / 100;
	}
	cout << otv;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	fore(t, 0, q)
	{
		solve();
		cout << '\n';
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll s,w;
  cin>>s>>w;
  if(s<=w)
    cout<<"unsafe"<<endl;
  else
    cout<<"safe"<<endl;
}



Measured memory_bytes: 3652
// 2011/03/04 Tazoe

#include <iostream>
using namespace std;

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

	for(int i=0; i<n; i++){
		int puz[9][9];
		for(int j=0; j<9; j++)
			for(int k=0; k<9; k++)
				cin >> puz[j][k];

		char chk[9][9];
		for(int j=0; j<9; j++)
			for(int k=0; k<9; k++)
				chk[j][k] = ' ';

		for(int j=0; j<9; j++){
			int cnt[10] = {0};
			for(int k=0; k<9; k++)
				cnt[puz[j][k]]++;

			for(int k=0; k<9; k++)
				if(cnt[puz[j][k]]>1)
					chk[j][k] = '*';
		}

		for(int k=0; k<9; k++){
			int cnt[10] = {0};
			for(int j=0; j<9; j++)
				cnt[puz[j][k]]++;

			for(int j=0; j<9; j++)
				if(cnt[puz[j][k]]>1)
					chk[j][k] = '*';
		}

		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				int cnt[10] = {0};
				for(int j2=0; j2<3; j2++)
					for(int k2=0; k2<3; k2++)
						cnt[puz[3*j+j2][3*k+k2]]++;

				for(int j2=0; j2<3; j2++)
					for(int k2=0; k2<3; k2++)
						if(cnt[puz[3*j+j2][3*k+k2]]>1)
							chk[3*j+j2][3*k+k2] = '*';
			}
		}

		if(i!=0)
			cout << endl;

		for(int j=0; j<9; j++){
			for(int k=0; k<9; k++){
				cout << chk[j][k] << puz[j][k];
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	var count int
L:
	for i := 0; i < n; i++ {
		for j := 0; j < i; j++ {
			if h[i] < h[j] {
				continue L
			}
		}
		count++
	}
	fmt.Println(count)
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


string s[50];

int main2() {
  int H, W; cin >> H >> W;
  REP(i, H) cin >> s[i];
  bool ok = true;

  int di[4] = {0,1,0,-1};
  int dj[4] = {1,0,-1,0};
  REP(i, H) REP(j, W) {
    if (s[i][j] == '#') {
      int x = 0;
      REP(k, 4) {
        int ni = i + di[k];
        int nj = j + dj[k];
        if (0 <= ni && ni < H && 0 <= nj && nj < W && s[ni][nj] == '#') {
          x++;
        }
      }
      if (x == 0) ok = false;
    }
  }

  if (ok) cout << "Yes" << endl; else cout << "No" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,A[50];

int solve(int i, int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res = solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}

int main(){
  int q,M,i;
						    
  scanf("%d",&n);
  for(i = 0; i< n; i++) scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&M);
    if(solve(0,M)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2108