akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}


int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	string s,t; cin>>s>>t;
	if( s.length() != t.length() - 1 ){ cout<<"No"; return 0; }
	s += t[t.length()-1];
	if(s==t){ cout<<"Yes"; return 0; }
	cout<<"No";
	
	return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;


public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        String s = next();
        String t = next();
        boolean flag = false;
        if(s.contains("1")|
        s.contains("2")||
        s.contains("3")||
        s.contains("4")||
        s.contains("5")||
        s.contains("6")||
        s.contains("7")||
        s.contains("8")||
        s.contains("9")||
        s.contains("0")){
            flag =false;
        }
        else flag = true;
        if(t.startsWith(s) && t.length()==s.length()+1){
            flag = true;
        }
        else flag = false;
        yesNo(flag);
    }



    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }
    public static void print(Object a){
        System.out.println(a);
    }
}

Measured memory_bytes: 35700
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int N = 505;
int n;
ll s[N], t[N], u[N], v[N];
ll a[N][N];
int T[N][N];
int c[N];
void transpose(){
    for (int i = 1; i <= n; i++){
        for (int j = i+1; j <= n; j++) swap(T[i][j],T[j][i]);
        swap(u[i],v[i]);
        swap(s[i],t[i]);
    }
}
void fix(ll x){
    for (int i = 1; i <= n; i++){
        if (t[i] == 0){
            c[i] = n-1;
            for (int j = 1; j <= n; j++){
                c[i] -= T[j][i];
            }
        }
        else c[i] = 0;
    }
    for (int i = 1; i <= n; i++){
        if (s[i] == 1 && ((u[i] & x))){
            bool done = false;
            for (int j = 1; j <= n; j++) done |= T[i][j];
            if (done) continue;
            //printf("need to fix row %d OR 1\n",i);
            for (int j = 1; j <= n; j++){
                if (c[j] > 0){
                    //printf("can use column %d\n",j);
                    c[j]--;
                    T[i][j] = 1;
                    break;
                }
            }
        }
    }
}
void gen(ll x){
    //printf("genning %llu\n",x);
    memset(T,0,sizeof(T));
    for (int i = 1; i <= n; i++){
        if (s[i] == 0 && (u[i] & x)) for (int j = 1; j <= n; j++) T[i][j] = 1;
        if (t[i] == 0 && (v[i] & x)) for (int j = 1; j <= n; j++) T[j][i] = 1;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            if (s[i] == t[j]){
                if (s[i] == 0) T[i][j] = (u[i] & x)||(v[j] & x);
                else T[i][j] = (u[i] & x)&&(v[j] & x);
            }
        }
    }
    fix(x);
    transpose();
    fix(x);
    transpose();
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            if (T[i][j]) a[i][j] |= x;
        }
    }
}
bool check(){
    for (int i = 1 ; i <= n; i++){
        ll RAND = a[i][1], ROR = 0, CAND = a[1][i], COR = 0;
        for (int j = 1; j <= n; j++){
            RAND &= a[i][j];
            ROR |= a[i][j];
            CAND &= a[j][i];
            COR |= a[j][i];
        }
        if (s[i] == 0 && u[i] != RAND) return 0;
        if (s[i] == 1 && u[i] != ROR) return 0;
        if (t[i] == 0 && v[i] != CAND) return 0;
        if (t[i] == 1 && v[i] != COR) return 0;
    }
    return 1;
}
int main(){
    scanf("%d",&n);
    for (int i = 1; i <= n; i++) scanf("%llu",&s[i]);
    for (int i = 1; i <= n; i++) scanf("%llu",&t[i]);
    for (int i = 1; i <= n; i++) scanf("%llu",&u[i]);
    for (int i = 1; i <= n; i++) scanf("%llu",&v[i]);
    for (int i = 0; i < 64; i++) gen(1llu<<i);
    if (!check()){
        printf("-1\n");
        return 0;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            printf("%llu ",a[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 8504
def main():
 from heapq import heappush, heappop
 import sys
 r=sys.stdin.readline
 def g(n,E,S,G):
  F=[1e7]*-~n;F[S],H=0,[(0,S)]
  while H:
   c,u=heappop(H)
   if u==G:return c
   for f,v in E[u]:
    t=c+f
    if t<F[v]:F[v]=t;heappush(H,(t,v))
  return-1
 def s(n,k):
  E=[[]for _ in[0]*-~n]
  for _ in[0]*k:
   f=r();p=map(int,f[2:].split())
   if'0'==f[0]:print(g(n,E,*p))
   else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
 for e in iter(r,'0 0\n'):s(*map(int,e.split()))
if __name__ == '__main__': main()


Measured memory_bytes: 6308
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++)cin >> a.at(i);

  int p[100100] = {0};
  for(int i = 0; i < N; i++){
    p[a.at(i)]++;
    p[a.at(i)+1]++;
    p[a.at(i)-1]++;
  }
  int ans = 0;
  for(int i = 0; i < 100100 ; i++){
    ans = max(ans,p[i]);
  }
  cout << ans << endl;
  }



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

int main(){
	int n;
	map<string,int> m;
	cin>>n;
	long int cnt=0;

	for (int i = 0; i < n; ++i)
	{
		string st;
		cin>>st;
		if(m.find(st)==m.end()){
			m.insert(make_pair(st,1));
			cnt++;
		}
		
		/* code */
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 19148
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int s,w;
  cin >> s >> w;
  
  if(s > w) cout << "safe" << endl;
  else cout << "unsafe" << endl;
  
}

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

int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  rep(i,K){
    if(B >= C){
      C = C * 2;
      continue;
    }
    if(A >= B){
      B = B * 2;
      continue;
    }
    C = C * 2;
  }
  if(A < B && B < C ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


  

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    vector<int> A;
    cin >> N;
    rep(i, N){int a; cin >> a; A.push_back(a);}
    bool flag = true;
    rep(i, N){
        if (A.at(i) % 2 == 0){
            if ((A.at(i) % 3 != 0) && (A.at(i) % 5 != 0)){flag = false;}
        }
    }
    if (flag){
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		long startTime = System.currentTimeMillis();
		Scanner sc = new Scanner(System.in) ;
		long thing = sc.nextLong();
		//System.out.println(thing*thing+thing+thing);
		//System.out.println(Integer.MAX_VALUE);
		long i = thing;
		long j = thing;
		for (long ii = 1 ; ii <= Math.pow(thing, 0.5) ; ii ++ ) {
			if (thing % ii != 0) { continue;}
			if ((ii+(thing/ii)) < i+j) {
				i=ii;j=(thing/ii);
			}
			//System.out.println(thing/ii+" "+ii);
		}
		//System.out.println(System.currentTimeMillis()-startTime);
		System.out.println(i+ j-2);
		
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  double k, g;
  g = 0;
  cin >> n;
  rep(i, n){
    cin >> k;
    g = g + 1.0000000 / k;
  }
  g = 1.0000000 / g;
  kono(7);
  cout << g;
  memi;
}

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

int main(void)
{
	int N[5],i,n;
  double ans=0,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
	scanf("%lf %s", &a,N);
    if(strcmp("JPY",N)==0) ans+=a;
    else ans+=a*380000;
  }

	printf("%f",ans);
	return 0;
}

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    isPrime[0] = False
    isPrime[1] = False
    for i in range(2, int(n ** 0.5) + 1):
        if isPrime[i]:
            for j in range(i * i, n + 1, i):
                isPrime[j] = False
    return isPrime


q = int(readline())
primelist = makePrimeChecker(10 ** 5 + 2)
check = [0] * (10 ** 5 + 1)
for i in range(1, 10 ** 5 + 1):
    if i % 2 == 1:
        if primelist[i] and primelist[(i + 1) // 2]:
            check[i] += 1
    check[i] += check[i - 1]
lr = [list(map(int, readline().split())) for _ in range(q)]
for l, r in lr:
    print(check[r] - check[l - 1])


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	long long Asum = 0, Bsum = 0, Alldif = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] >= B[i]) Bsum += (long long)A[i] - B[i];
		else Asum += (B[i] - A[i] + 1) / 2;
		Alldif += (long long)B[i] - A[i];
	}
	cout << (Alldif >= Asum && Alldif >= Bsum ? "Yes" : "No") << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char s[100001],s1[100001];
int main(){
    cin>>s>>s1;
    reverse(s1,s1+strlen(s1));  
    if(!strncmp(s,s1,strlen(s))) puts("YES");   
    else puts("NO");   
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,k,zero=0;
    cin>>n>>k;
    vector<int>x,y;
    rep(i,n){
        int a;
        cin>>a;
        if(a>0)x.pb(a);
        if(a<0)y.pb(a);
        if(a==0)zero++;
    }
    sort(all(x));
    sort(all(y));
    int cx=0,cy=0;
    while(cy+1<y.size()&&cy+2<=k){
        cy+=2;
    }
    cx=k-cy;
    if(cx<=x.size()){
        int pos=x.size()-cx-1;
        for(int i=cy-1;i>=0&&pos-1>=0;i-=2,pos-=2){
            if(x[pos]*x[pos-1]>y[i]*y[i-1]){
                cy-=2;
            }
            else break;
        }
        int ans=1;
        for(int i=pos+1;i<x.size();i++){
            ans*=x[i];
            ans%=mod;
        }
        rep(i,cy){
            ans*=y[i];
            ans%=mod;
        }
        cout<<ans<<endl;
        return 0;
    }
    if(zero){
        cout<<0<<endl;
    }
    else{
        for(int &i:y){
            i=-i;
            x.pb(i);
        }
        sort(all(x));
        int ans=1;
        rep(i,k){
            ans*=x[i];
            ans%=mod;
        }
        cout<<mod-ans<<endl;
    }
    return 0;
}


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

int main(){
    int a[5];
    int lasti;
    int lastmini=2<<28;
    for(int i=0; i<5; i++){
        cin>>a[i];
        if(lastmini>a[i]%10 && a[i]%10!=0){
            //cout<<a[i]%10<<endl;
            lastmini=min(lastmini, a[i]%10);
            //cout<<lastmini<<endl;
            lasti=i;
        }
    }
    int sum=0;
    for(int i=0; i<5; i++){
        if(i==lasti){
            continue;
        }
        sum+=a[i]/10*10;
        if(a[i]%10>0){
            sum+=10;
        }
    }
    sum+=a[lasti];
    cout<<sum<<endl;

    return 0;
}


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

n = int(input())
a = list(map(int, input().split()))

g = [[-1] * w for _ in range(h)]

ch = 0
cw = 0
o = 1

for i in range(n):
    while a[i] > 0:
        g[ch][cw] = i + 1

        a[i] -= 1

        if not (0 <= cw + o < w):
            ch += 1

            if o == 1:
                o = -1
            else:
                o = 1
        else:
            cw += o

for i in g:
    print(*i)


Measured memory_bytes: 41840
#include <stdio.h>
#include <string.h>
int top = 0, S[1000];
void push(int x) {
  S[++top] = x;
}
int pop(void) {
  top--;
  return S[top+1];
}
int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}


Measured memory_bytes: 2148
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	ll n,a,b;
	cin>>n>>a>>b;
	if(n<a){
		cout<<n<<endl;
	}
	else if(n>=a&&n<=(a+b)){
		cout<<a<<endl;
	}
	else{
		ll ans = a*(n/(a+b));
		ll rem = n%(a+b);
		if(rem<a){
			ans += rem;
		}
		else if(rem>=a&&rem<(a+b)){
			ans += a;
		}
		cout<<ans<<endl;
	}
	
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{	int N, M;
	cin >> N >> M;
	vector<vector<pair<int,int> > > G(N+1);
	fx(N) {
		G[x + 1].push_back(make_pair(x,0));
	}
	fx(M) {
		int a, b, c;
		cin >> a >> b >> c;
		G[a].push_back(make_pair(b, c));
		G[b].push_back(make_pair(a, c));
	}

	priority_queue<pair<int, int> > Q;
	Q.push(make_pair(0,1));
	bool flags[110000] = { false, };
	ll cost[110000];
	fx(N) {
		cost[x + 1] = LLONG_MAX / 2;
	}
	cost[1] = 0;
	while(Q.size()) {
		auto q = Q.top(); Q.pop();
		if (flags[q.second]) {
			continue;
		}
		flags[q.second] = true;

		fx(G[q.second].size()) {
			if (cost[G[q.second][x].first]>cost[q.second]+ G[q.second][x].second) {
				cost[G[q.second][x].first] = cost[q.second] + G[q.second][x].second;
				Q.push(make_pair(-cost[G[q.second][x].first], G[q.second][x].first));
			}
		}

	}

	if (cost[N]==LLONG_MAX/2) {
		ce(-1)
	}
	else {
		ce(cost[N])
	}

    return 0;
}



Measured memory_bytes: 9340
n = gets.to_i
vs = gets.chomp.split.map(&:to_i)
cnt = 0
even = Hash.new(0)
odd = Hash.new(0)
vs.each_with_index do |v,i|
	i += 1
	if i.even?
		even[v] += 1
	else
		odd[v] += 1
	end
end

even = even.sort_by(&:last)
odd = odd.sort_by(&:last)
if even[-1][0] == odd[-1][0]
	if odd.size == 1 && even.size == 1
		cnt += n/2
	elsif odd.size == 1
		cnt += n/2 - even[-2][1]
	elsif even.size == 1
		cnt += n/2 + n%2 - odd[-2][1]
	else
		cnt += n - [even[-1][1] + odd[-2][1], even[-2][1] + odd[-1][1]].max
	end
else
	cnt += n - even[-1][1] - odd[-1][1]
end

puts cnt

Measured memory_bytes: 20980
I = [int(_) for _ in open(0).read().split()]
N = I[0]
W, S, V = I[1::3], I[2::3], I[3::3]
dp = [-float('inf')] * (2 * 10**4 + 5)
dp[0] = 0
#dp[重さの総和]=その重さの総和になる最大価値
for s, w, v in sorted(zip(S, W, V), key=lambda swv: swv[0] + swv[1]):
    for wbefore in range(s, -1, -1):
        dp[wbefore + w] = max(dp[wbefore + w], dp[wbefore] + v)
print(max(dp))


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

int main(){
	int n;
	int d=100000;
	cin >> n;
	for(int i = 0; i < n; i++){
		d=d*1.05;
		if(d%1000!=0)d+=1000-d%1000;
	}
	cout << d << endl;

	return 0;
}

Measured memory_bytes: 1160
from collections import deque
 
def dfs(n, start, graph):
  visited = [False] * n
  stack = deque()
  stack.append(start)
  visited[start] = True
  while stack:
    q = stack.popleft()
    nxts = graph[q]
    for nxt in nxts:
      if not visited[nxt]:
        visited[nxt] = True
        stack.append(nxt)
  return visited
 
n, m = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(m)]
 
ans = 0
for i in range(m):
  graph = [[] for _ in range(n)]
  for itr, (a, b) in enumerate(edge):
    if itr != i:
      graph[a - 1].append(b - 1)
      graph[b - 1].append(a - 1)
 
  if not all(dfs(n, 0, graph)):
    ans += 1
print(ans)

Measured memory_bytes: 3436
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(rall(l));
    int ans = 0;
    rep(i,k) ans += l[i];
    print(ans);
}


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

#define MAX 244140625

int Hash[MAX];
char s[13];

int getChar(char);
int getKey();
int find();
void insert();

int main(){
  int n;
  char com[7];

  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,com ,s);

    if(com[0] == 'i'){
      insert();
    }else{
      if(find()){
	puts("yes");
      }else{
	puts("no");
      }
    }
  }

  return 0;
}

int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }
  return 4;
}

int getKey(){
  int sum = 0, p = 1, i;

  for(i = 0 ; i < strlen(s) ; i++){
    sum += p*(getChar(s[i]));
    p *= 5;
  }
  return sum;
}

int find(){
  int key = getKey();

  if(Hash[key]){
    return 1;
  }

  return 0;
}

void insert(){
  Hash[getKey()] = 1;
}


Measured memory_bytes: 18680
#include <iostream>
#include <vector>

const uint64_t LIMIT = 1'000'000'000'000'000'000;

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::vector<uint64_t> A(N, 0);
  bool zero = 0;
  for (auto &&a : A) {
    std::cin >> a;
    zero |= (a == 0);
  }
  if (zero) {
    std::cout << 0 << std::endl;
  } else {
    uint64_t prod = 1;
    for (uint32_t i = 0; i < N; i++) {
      if ((LIMIT + prod - 1) / prod < A[i] || prod * A[i] > LIMIT) {
        std::cout << -1 << std::endl;
        prod = 0;
        break;
      } else {
        prod *= A[i];
      }
    }
    if (prod) {
      std::cout << prod << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3976
#include<iostream>
using namespace std;
int main(){
    int K,A,B;
    cin>>K>>A>>B;
    for(int i=A;i<B+1;i++){
        if(i%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}

Measured memory_bytes: 3592
n,m=map(int,input().split())
A=[]
for i in range(m):
    a,b=map(int,input().split())
    a-=1 ;b-=1
    A.append([a,b])

A=sorted(A, key=lambda x:x[1])
ans=0
last=-5000
for l in A:
    #print(a,b)
    if last<l[0]:
        ans+=1
        last=l[1]-1
print(ans)

Measured memory_bytes: 26304
N,K=map(int,input().split())

if N==1 or K==1:
  print(1)
else:
  if N%2==0:
    print((N//2)*K)
  else:
    if K%2==0:
      print((K//2)*N)
    else:
      print(N*(K//2)+(N//2)+1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define MAX 10001
#define INF 2000000001
#define LGMAX 18
#define MOD 1000003
#define F first
#define S second
#define ll long long
#define pb push_back
using namespace std;

int main() {
    ll n;
    cin >> n;
    ll res = 0;
    for (ll d = 1; d * d <= n; ++d) {
        if (n % d) continue;
        ll m = n / d - 1;
        if (d < m) res += m;
    }
    cout << res;
}


Measured memory_bytes: 256
from itertools import combinations
_=list(map(int,input().split()))
print(min([i[0]*i[1]%2019 for i in list(combinations([i for i in range(_[0],_[1]+1)],2)if _[1]-_[0]<2019else combinations([i for i in range(_[0],_[0]+2020)],2))]))

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

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  
  unordered_set<int> have;
  for(int i=0; i<K; i++){
    int d;
    cin >> d;
    for(int j=0; j<d; j++){
      int a;
      cin >> a;
      have.emplace(a);
    }
  }
  
  cout << N - (int)have.size() << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;

long long fre[26];
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    string s;
    cin>>s;
    long long ans = (s.size()*1LL *(1+s.size()))/2 + 1;
    ans -= s.size();
    for(auto i:s){
        fre[i-'a']++;
    }

    REP(i,0,26){
        ans -= (fre[i]*(fre[i]-1))/2;

    }
    cout<<ans<<'\n';
    return 0;
}



Measured memory_bytes: 720
n = int(input())
a = list(map(int, input().split()))  

l = {}
r = {}

for i in range(n):
    if i+a[i] in l.keys():
        l[i+a[i]] += 1
    else:
        l[i+a[i]] = 1
    if i-a[i] in r.keys():
        r[i-a[i]] += 1
    else:
        r[i-a[i]] = 1         

ans = 0
for i in l.keys():
    if i in r.keys():
        ans += l[i]*r[i]

print(ans)

Measured memory_bytes: 56588
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    char op;
    while(true){
        cin >> a >> op >> b;
        if ( op == '?') break;
        if ( op == '+'){
            c = a + b;
        }  
        if ( op == '-' ){
            c = a - b; 
        } 
        if ( op == '*' ){
            c = a * b;        
        }
        if ( op == '/' ){
            c = a / b;
        }
        cout << c << endl;
        
    }
}



Measured memory_bytes: 3084
#include <iostream>
#include <string.h>
#include <algorithm>
#define ll long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t;
    cin >> t;
    while(t--)
    {
        int ans[3];
        for(int i=0;i<3;i++) cin >> ans[i];
        sort(ans, ans+3);
        if(ans[2]*ans[2] - (ans[1]*ans[1] + ans[0]*ans[0]) == 0) cout << "YES" << "\n";
        else cout << "NO" << "\n";
    }
    return 0 ;
}



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

left=0;right=0
SUM = 0
ans = 0
for i in range(N):
  left = i
  while right < N and  SUM+A[right] == SUM^A[right]:
    SUM += A[right]
    right += 1
    #print(left,right,SUM)
  ans += right-left
  #print(ans)
  if right == left:
    right += 1
    #print(left,right,SUM)
  else:
    SUM -= A[left]
print(ans)

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

int main() {
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  for (ll b=k+1; b<=n; b++) {
    ans+=(n+1)/b*(b-k);
    ans+=max(0ll,(n+1)%b-k);
  }
  if (k==0) ans-=n;
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
h=get_i
flag=true
(N-1).times do|i|
  if h[i]<h[i+1]
        h[i+1]-=1
  end
end
(N-1).times do|i|
    if h[i]>h[i+1]
        flag=false
        break
    end
end
puts yn_judge(flag)

Measured memory_bytes: 21760
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

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

    int N;
    cin >> N;
    int A[N][3];
    REP(i, N) REP(j, 3) cin >> A[i][j];
    ll dp[N + 1][3] = {};

    FOR(i, 1, N + 1) {
        REP(j, 3) {
            REP(k, 3) {
                if (j == k)
                    continue;
                chmax(dp[i][k], dp[i - 1][j] + A[i - 1][k]);
            }
        }
    }
    ll ans = 0;
    REP(i, 3) chmax(ans, dp[N][i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3840
a= list(map(int,input().split()))
a2= list(map(int,input().split()))
a3= list(map(int,input().split()))
b=[0,0,0,0,0,0,0,0,0]
a+=a2
a+=a3
n=int(input())
for i in range(n):
    j = int(input())
    for aa in range(9):
        if a[aa] == j:
            b[aa]=1

if sum(b[0:3])==3 or  sum(b[3:6])==3 or  sum(b[6:9])==3 :
    print('Yes')
elif b[0]+b[3]+b[6]==3 or b[1]+b[4]+b[7]==3 or b[2]+b[5]+b[8]==3:
    print('Yes')
elif b[4]==1 and (b[0]+b[8]==2 or b[2]+b[6]==2):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  n--;
  char c = 'a';
  string ans = "";
  while(n >= 0){
    int x = n % 26;
    ans += (c + x);
    n /= 26;
    n--;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int x, y;
  cin >> x >> y;
  int xg, yg;
  if(x == 2){
    xg = 1;
  }
  else if (x == 4 ||x == 6 || x == 9 || x == 11){
    xg = 2;
  }
  else xg = 3;

  if(y == 2){
    yg = 1;
  }
  else if (y == 4 || y == 6 || y == 9 || y == 11){
    yg = 2;
  }
  else yg = 3;

  if(xg == yg) cout << "Yes" << endl;
  else cout <<"No" << endl;

  return 0;
}


Measured memory_bytes: 3600
import itertools


def calc_dist(p1, p2):
    return sum([(i - j) ** 2 for i, j in zip(p1, p2)])


def is_integer(p1, p2):
    dist = calc_dist(p1, p2)
    if pow(dist, 0.5).is_integer():
        return True
    else:
        return False


def main():
    points = []
    N, D = map(int, input().split())

    for _ in range(N):
        points.append(list(map(int, input().split())))

    cnt = 0
    for pair in list(itertools.combinations(points, 2)):
        if is_integer(pair[0], pair[1]):
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


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

#define ll long long
#define endl "\n"

int main ()
{
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //#define int ll
	
	int n, k;
	cin >> n >> k;

	vector <int> piles(n);
	vector <bool> dp(k+1, false);

	for (int i=0; i<n; i++){
		cin >> piles[i];
		dp[piles[i]] = true;
	}
	
	sort(piles.begin(), piles.end());

	for (int i=0; i<=k; i++){
		for (int j=0; j<n; j++){
			if (i >= piles[j] and dp[i - piles[j]] == false){
				dp[i] = true;
			}
		}
	}

	if (dp[k]) cout << "First" << endl;
	else cout << "Second" << endl;

	return 0;
	
}


Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] lines = Console.ReadLine().Split(' ');
            int H = int.Parse(lines[0]);
            int W = int.Parse(lines[1]);
            char[,] a = new char[H + 2, W + 2];

            for (int i = 0; i < H + 2; i++)
            {
                for (int j = 0; j < W + 2; j++)
                {
                    a[i, j] = '#';
                }
            }

            for (int i = 0; i < H; i++)
            {
                char[] line = Console.ReadLine().ToCharArray();

                for (int j = 0; j < W; j++)
                {
                    a[i + 1, j + 1] = line[j];
                }
            }

            for (int i = 0; i < H + 2; i++)
            {
                for (int j = 0; j < W + 2; j++)
                {
                    Console.Write(a[i, j]);
                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);
	
	int X, A; scanf("%d%d", &X, &A);

	if (X < A){
		printf("0");

	}
	else{
		printf("10");
	}



	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<int, int> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<pii> vpii;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))

namespace IO {

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a);

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a);

    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int M = 1e9 + 7;
int bp(int a, int b) {
    if (b == 0) return 1;
    int x = bp(a, b/2);
    x = (x*x) %M;
    if (b % 2) x = x * a % M;
    return x;
}
void solve() {
    int n, k;
    cin >> n >> k;
    vector<vi> dp(n + 1, vi(4e3, 0));
    rep(i, 1, n + 1) rep(j, 0, dp[i].size()) {
        rep(m, 0, k + 1) {
            int incr = (m > i?0:(m + j)/i);
            if (j + incr < dp[i].size()) {
                dp[i][j] += dp[i - 1][j + incr] + (m > i?m + j:(m + j) % i) * bp(k + 1, i - 1);
                dp[i][j] %= M;
            }
        }
    }
    put(dp[n][0]);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
    int q = 1;
//    cin >> q;
//    freopen("input.txt", "r", stdin);
    while (q--) solve();
}


Measured memory_bytes: 6180
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=190;
int n,m,f[N][N][N],g[N][N][N],ff[N][N][N],gg[N][N][N];
char str[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",str[i]+1);
	for(int i=n;i;--i)
		for(int j=1;j<=m;++j){
			f[i][j][j]=(str[i][j]==str[i+1][j]?f[i+1][j][j]:i+1);
			if(str[i][j]==str[i][j-1])
				for(int k=1;k<j;++k)
					f[i][k][j]=min(f[i][k][j-1],f[i][j][j]);
			else
				for(int k=1;k<j;++k)
					f[i][k][j]=i;
		}
	for(int i=m;i;--i)
		for(int j=1;j<=n;++j){
			g[i][j][j]=(str[j][i]==str[j][i+1]?g[i+1][j][j]:i+1);
			if(str[j][i]==str[j-1][i])
				for(int k=1;k<j;++k)
					g[i][k][j]=min(g[i][k][j-1],g[i][j][j]);
			else
				for(int k=1;k<j;++k)
					g[i][k][j]=i;
		}
	for(int ans=0;;++ans){
		if(f[1][1][m]==n+1)
			return printf("%d\n",ans),0;
		swap(f,ff);swap(g,gg);
		for(int i=1;i<=n;++i)
			for(int j=1;j<=m;++j)
				for(int k=j;k<=m;++k)
					if(ff[i][j][k]==n+1)
						f[i][j][k]=n+1;
					else{
						f[i][j][k]=ff[ff[i][j][k]][j][k];
						while(f[i][j][k]<=n&&gg[gg[j][i][f[i][j][k]]][i][f[i][j][k]]>k)++f[i][j][k];
					}
		for(int i=1;i<=m;++i)
			for(int j=1;j<=n;++j)
				for(int k=j;k<=n;++k)
					if(gg[i][j][k]==m+1)
						g[i][j][k]=m+1;
					else{
						g[i][j][k]=gg[gg[i][j][k]][j][k];
						while(g[i][j][k]<=m&&ff[ff[j][i][g[i][j][k]]][i][g[i][j][k]]>k)++g[i][j][k];
					}
	}
}


Measured memory_bytes: 107392
import heapq
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


class Graph:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes
        self.edges = [[] for _ in range(n_nodes)]

    def add_edge(self, s, t, d=None, undirected=False):
        if d is not None:
            self.edges[s].append((t, d))
        else:
            self.edges[s].append(t)
        if undirected:
            self.add_edge(t, s, d)

    def add_edges(self, edges, undirected=False):
        for edge in edges:
            self.add_edge(*edge, undirected=undirected)


class Dijkstra:
    def __init__(self, graph):
        self.graph = graph

    def compute(self, s, t):
        distances = [float('inf') for _ in range(self.graph.n_nodes)]
        visited = [False for _ in range(self.graph.n_nodes)]
        prev_nodes = [None for _ in range(self.graph.n_nodes)]
        distances[s] = 0
        q = []
        heapq.heappush(q, (0, s))
        while q:
            dist_x, x = heapq.heappop(q)
            if x == t:
                return distances, prev_nodes

            if visited[x]:
                continue
            visited[x] = True

            for y, d_xy in self.graph.edges[x]:
                if visited[y]:
                    continue
                dist_y = dist_x + d_xy
                if dist_y < distances[y]:
                    distances[y] = dist_y
                    prev_nodes[y] = x
                    heapq.heappush(q, (dist_y, y))
        return distances, prev_nodes

    def compute_all(self, s):
        distances = [float('inf') for _ in range(self.graph.n_nodes)]
        visited = [False for _ in range(self.graph.n_nodes)]
        prev_nodes = [None for _ in range(self.graph.n_nodes)]
        distances[s] = 0
        q = []
        for t in range(self.graph.n_nodes):
            heapq.heappush(q, (distances[t], t))
        while q:
            dist_x, x = heapq.heappop(q)
            if visited[x]:
                continue
            visited[x] = True

            for y, d_xy in self.graph.edges[x]:
                if visited[y]:
                    continue
                dist_y = dist_x + d_xy
                if dist_y < distances[y]:
                    distances[y] = dist_y
                    prev_nodes[y] = x
                    heapq.heappush(q, (dist_y, y))
        return distances, prev_nodes


n, m = ril()
graph = Graph(n)
for i in range(1, n):
    graph.add_edge(i, i - 1, 0)
for _ in range(m):
    a, b, c = ril()
    graph.add_edge(a - 1, b - 1, c)
dijkstra = Dijkstra(graph)
distances, _ = dijkstra.compute(0, n - 1)
d = distances[-1]
if d == float('inf'):
    print(-1)
else:
    print(d)

Measured memory_bytes: 85536
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())
if c3-c2==c6-c5 and c6-c5==c9-c8 and c2-c1==c5-c4 and c5-c4==c8-c7 and c4-c1==c5-c2 and c5-c2==c6-c3 and c7-c4==c8-c5 and c8-c5==c9-c6:
    print("Yes")
else:
    print("No")


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

fn main(){
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();
    let mut ans = 2 * n;
    for i in 0..n {
        let mut check = true;
        for j in 0..n-i {
            if s[i+j] != t[j] {
                check = false;
                break;
            }
        }
        if check {
            ans = n + i;
            break;
        }
    }
    println!("{}", ans);
}

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

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int w = vs[1];

			long[] dp = new long[w + 1];
			for (int i = 0; i < n; i++) {
				int[] obj = Console.ReadLine().Split().Select(int.Parse).ToArray();
				for (int j = w; j >= obj[0]; j--) {
					dp[j] = Math.Max(dp[j], dp[j - obj[0]] + obj[1]);
				}
			}

			Console.WriteLine(dp[w]);

		}
	}
}


Measured memory_bytes: 13920
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#define V 13100
#define E 1000100 
#define inf 0x3f3f3f3f
using namespace std;
int vis[V];
int dist[V];
int pre[V];
int ans1,ans2;
int n,m;
struct Edge{
    int u,v,cap,flow,cost,next,id;
}edge[E];
int head[V],cnt;

void init(){
    cnt=0;ans1=ans2=0;
    memset(head,-1,sizeof(head));
}
void addedge(int u,int v,int c,int cost,int id)
{
    edge[cnt].u=u;edge[cnt].v=v;edge[cnt].cost=cost;edge[cnt].id=id;
    edge[cnt].cap=c;edge[cnt].flow=0;edge[cnt].next=head[u];head[u]=cnt++;
    

    edge[cnt].u=v;edge[cnt].v=u;edge[cnt].cost=-cost;edge[cnt].id=id;
    edge[cnt].cap=0;edge[cnt].flow=0;edge[cnt].next=head[v];head[v]=cnt++;
}

bool spfa(int begin,int end){
    int u,v;
    queue<int> q;
    for(int i=0;i<=n;i++){
        pre[i]=-1;
        vis[i]=0;
        dist[i]=inf;
    }
    vis[begin]=1;
    dist[begin]=0;
    q.push(begin);
    while(!q.empty()){
        u=q.front();
        q.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edge[i].next){
            //if(edge[i].c>0){
                v=edge[i].v;
                if(edge[i].cap>edge[i].flow && dist[v]>dist[u]+edge[i].cost){
                    dist[v]=dist[u]+edge[i].cost;
                    pre[v]=i;
                    if(!vis[v]){
                        vis[v]=true;
                        q.push(v);
                    }
                }
            }
    }
    if(pre[end] == -1) return false;
    else return true;
}

void MCMF(int begin,int end){
    int ans=0,flow;
    int flow_sum=0;
    while(spfa(begin,end)){
        flow=inf;
        for(int i=pre[end];i!=-1;i=pre[edge[i^1].v])
            if(flow>edge[i].cap-edge[i].flow)
                flow=edge[i].cap-edge[i].flow;
        for(int i=pre[end];i!=-1;i=pre[edge[i^1].v]){
            edge[i].flow+=flow;
            edge[i^1].flow-=flow;
            ans2 += edge[i].cost*flow;
        }
        ans1 += flow;
    }
}

int main()
{
   // freopen("in.txt","r",stdin);
    int a,b,c;
    int s,t;
    while(scanf("%d %d",&n,&m)!=EOF){
        init();
		for(int i=1;i<=m;i++){
            scanf("%d %d",&a,&b);
            addedge(a,b,1,0,i);
            addedge(b,a,1,1,i);
        }
        scanf("%d %d",&s,&t);
        MCMF(s,t);
        printf("%d\n%d\n",ans1,ans2);
        vector<int>v;
		for (int i=1;i<=n;i++)
		    for (int j=head[i];j!=-1;j=edge[j].next)
		    	if (edge[j].flow==1 && edge[j].cost){
		    		v.push_back(edge[j].id);
				} 

		for (int i=0;i<v.size();i++)
			printf("%d\n",v[i]);
    }
    return 0;
}

Measured memory_bytes: 1396
n = int(input())
d, x = list(map(int, input().split()))
a = [int(input()) for i in range(n)]

result = x

for i in range(n):
  result +=  d // a[i]                                                                                                     
  result += 1 if d % a[i] != 0 else 0

print(result)

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

int main()
{
    int n, i, j, l=0, r=0;
    cin>>n;
    int arr[n], a[n];

    for(i=0; i<n; i++)
        cin>>arr[i];

    for(i=0; i<n; i++)
    {
        l=0;
        r=0;
        for(j=0; j<n; j++)
        {
            if(i>=j)
                l = l + arr[j];
            else
                r = r + arr[j];
        }
        a[i] = abs(r-l);
    }

    sort(a, a+n);

    cout<<a[0];
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

typedef complex<double> P;
typedef vector<P> G;


#define X(a)		( (a).real() )
#define Y(a)		( (a).imag() )
#define EQ(a,b)		( -EPS<(a)-(b) && (a)-(b)<EPS )
#define EQV(a,b)	( EQ(X(a),X(b)) && EQ(Y(a),Y(b)) )

#define unit(a)		( (a)/abs(a) )
#define normal(a)	( (a)*P(0,1) )
#define dot(a,b)	( X((a)*conj(b)) )
#define cross(a,b)	( Y(conj(a)*(b)) )

namespace std
{
	bool operator < (const P& a, const P& b)
	{
		return X(a)!=X(b) ? X(a)<X(b) : Y(a)<Y(b);
	}
}

// 3ツ点ツづ個暗環置ツ甘鳴係
int ccw(P a, P b, P c)
{
	b -= a; c -= a;
	if(cross(b, c) > 0)   return +1;	// counter clockwise
	if(cross(b, c) < 0)   return -1;	// clockwise
	if(dot(b, c) < 0)     return +2;	// c--a--b on line
	if(norm(b) < norm(c)) return -2;	// a--b--c on line
	return 0;
}


G convexhull(G g)
{
	G h(2*g.size());
	sort(g.begin(), g.end());

	int i,k,t,sz=g.size();
	for(i=0,k=0; i<sz; h[k++]=g[i++])
	{
		while( k>=2 && ccw(h[k-2],h[k-1],g[i])<=0 ) k--;
	}
	for(i=sz-2,t=k+1; i>=0; h[k++]=g[i--])
	{
		while( k>=t && ccw(h[k-2],h[k-1],g[i])<=0 ) k--;
	}

	h.resize(k-1);
	return h;
}


int main()
{
	int n; double x,y; char c;
	while(cin >> n, n)
	{
		G g,h;
		while(n--)
		{
			cin >> x >> c >> y;
			g.push_back(P(x,y));
		}
		h=convexhull(g);
		cout << g.size()-h.size() << endl;
	}
}

Measured memory_bytes: 0