akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

struct Edge
{
	int to, dist, cost;

	Edge( int t, int d, int c ) : to( t ), dist( d ), cost( c )
	{
		return;
	}

	bool operator > ( const Edge &a ) const
	{
		if ( dist == a.dist )
		{
			return cost > a.cost;
		}

		return dist > a.dist;
	}
};

typedef Edge Node;

int solve( vector< vector< Edge > > G )
{
	const int V = G.size();

	VI dist( V, INT_MAX );

	priority_queue< Node, vector< Node >, greater< Node > > que;
	que.push( Node( 0, 0, 0 ) );

	int res = 0;

	while ( !que.empty() )
	{
		auto cur = que.top();
		que.pop();

		if ( dist[ cur.to ] <= cur.dist )
		{
			continue;
		}

		dist[ cur.to ] = cur.dist;
		res += cur.cost;

		EACH( e, G[ cur.to ] )
		{
			que.push( Node( e.to, dist[ cur.to ] + e.dist, e.cost ) );
		}
	}

	return res;
}

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

	while ( true )
	{
		int n, m;
		cin >> n >> m;

		if ( !( n | m ) )
		{
			break;
		}

		vector< vector< Edge > > G( n );

		REP( i, 0, m )
		{
			int u, v, d, c;
			cin >> u >> v >> d >> c;

			u--;
			v--;

			G[u].PB( Edge( v, d, c ) );
			G[v].PB( Edge( u, d, c ) );
		}

		cout << solve( G ) << endl;
	}

	return 0;
}

Measured memory_bytes: 3512
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	string s,t;
	int i,x;
	cin >> s;
	t = s;
	x = s.size();
	for (i = 0; i < x; i++) {
		if (s[i] == 'b') t[x - i - 1] = 'd';
		else if (s[i] == 'd') t[x - i - 1] = 'b';
		else if (s[i] == 'p') t[x - i - 1] = 'q';
		else if (s[i] == 'q') t[x - i - 1] = 'p';
	}
	printf((s == t) ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>){
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val a = Array(h){ readLine()!!.toCharArray().map { it.toString() }.toTypedArray()}

    for(i in 0 until h){
        var f = false
        for(j in 0 until w){
            f = f || a[i][j] == "#"
        }
        if(!f){
            for(j in 0 until w){
                a[i][j] = ""
            }
        }
    }

    for(j in 0 until w){
        var f = false
        for(i in 0 until h){
            f = f || a[i][j] == "#"
        }
        if(!f){
            for(i in 0 until h){
                a[i][j] = ""
            }
        }
    }

    for(i in 0 until h){
        a[i].joinToString(separator = "").let {
            if(it.isNotEmpty()){
                println(it)
            }
        }
    }
}

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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int sr, sc;
    cin >> sr >> sc;
    string s, t;
    cin >> s >> t;
    // 各方向に何個動かせば落ちるか
    int l = sc, r = w - sc + 1, u = sr, d = h - sr + 1;
    // 各方向に落とせるかどうか
    bool drop = false;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L') {
            l--;
            r++;
        }
        if (l == 0) {
            drop = true;
            goto END;
        }
        if (t[i] == 'R' and r != 1) {
            l++;
            r--;
        }
    }
    l = sc;
    r = w - sc + 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r--;
            l++;
        }
        if (r == 0) {
            drop = true;
            goto END;
        }
        if (t[i] == 'L' and l != 1) {
            r++;
            l--;
        }
    }
    
    for (int i = 0; i < n; i++) {
        if (s[i] == 'U') {
            u--;
            d++;
        }
        if (u == 0) {
            drop = true;
            goto END;
        }
        if (t[i] == 'D' and d != 1) {
            u++;
            d--;
        }
    }
    u = sr;
    d = h - sr + 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'D') {
            d--;
            u++;
        }
        if (d == 0) {
            drop = true;
            goto END;
        }
        if (t[i] == 'U' and u != 1) {
            d++;
            u--;
        }
    }

    END:
    if (drop) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v.size() << "\n";
    return 0;
}


Measured memory_bytes: 3460
import itertools
N = int(input())
dmat = input().split()
dmatint = []
for i in range(len(dmat)):
    dmatint.append(int(dmat[i]))

#print(N)
#print(dmatint)

#全パターン選ぶ
allpatern = list(itertools.combinations(range(N), 2))
#print(allpatern)
sum = 0
for patern in allpatern:
    first = patern[0]
    second = patern[1]
    #print(first)
    #print(second)
    product = dmatint[first]*dmatint[second]
    sum += product
print(sum)


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

int main(){
  int a,b,W;
  cin >> W >> a >> b;

  if(b==a){
    cout << 0 << endl;
  }else if(b>a){
    if(b>a+W){
      cout << b-(a+W) << endl;
    }else{
      cout << 0 << endl;
    }
  }else{
    if(a>b+W){
      cout << a-(b+W) << endl;
    }else{
      cout << 0 << endl;
    }
  }
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=3030;
int i,j,k,n,En,x,y;
int A[N],h[N];
struct edge { int s,n;} E[N<<1];
void E_add(int x,int y) {
	E[++En].s=y;E[En].n=h[x];h[x]=En;
	E[++En].s=x;E[En].n=h[y];h[y]=En;
}
bool dfs(int x,int F) {
	for (int k=h[x];k;k=E[k].n) if (E[k].s!=F && A[E[k].s]<A[x] && !dfs(E[k].s,x)) return 1;
	return 0;
}
int main() {
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&A[i]);
	for (i=1;i<n;i++) {
		scanf("%d%d",&x,&y);
		E_add(x,y);
	}
	for (i=1;i<=n;i++) if (dfs(i,0)) printf("%d ",i);
	puts("");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
int main(){
  int n;
  scanf("%d", &n);
  long long sum = 0;
  int max;
  scanf("%d", &max);
  for(int i=1; i<n; ++i){
    int h;
    scanf("%d", &h);
    if( h < max){
      sum += max - h;
    } else{
      max = h;
    }
  }
  printf("%lld\n", sum);
  return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
typedef long long ll;

int main(void){
  int n, m, k, i, j;
  scanf("%d %d %d", &n, &m, &k);
  ll a[n+1], b[m+1], ans = 0, best = 0;
  
  b[0] = a[0] = 0;
  for(i = 1; i <= n; i++){
    a[i] = 0;
    scanf("%lld", &a[i]);
    a[i] += a[i-1];
  }
  for(j = 1; j <= m; j++){
    b[j] = 0;
    scanf("%lld", &b[j]);
    b[j] += b[j-1];
    if(b[j] <= k)best = j;
  }
    
  for(i = 0; a[i] <= k; i++){
    while(a[i] + b[best] > k)best--;
    if(i + best > ans)ans = i + best;
  }
  
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 4820
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll mod = 1000000007;

ll modpow(ll a, ll k) {
	if (k == 0) return 1;
	ll tmp = modpow(a, k / 2);
	if (k % 2 == 0)
		return tmp * tmp % mod;
	return tmp * tmp % mod * a % mod;
}

ll inverse(ll a) {
	return modpow(a, mod - 2);
}

ll combination(ll a, ll b) {
	ll num = 1, den = 1;
	for (ll i = a; i > a - b; --i)
		num = (num * i) % mod;
	for (ll i = b; i > 0; --i)
		den = (den * i) % mod;
	return num * inverse(den) % mod;
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll res = modpow(2, n) - 1;
	res = (res - combination(n, a)) % mod;
	res = (res - combination(n, b)) % mod;
	res = (res + mod) % mod;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vector<int> v[100010];
  rep(i,n){
    int b,c;
    cin>>b>>c;
    v[b].push_back(c);
  }
  int ans=0;
  priority_queue<int> p;
  rep(i,m){
    rep(j,v[i+1].size() ){
      p.push(v[i+1][j]);
    }
    if(!p.empty()){
      ans+=p.top();
      p.pop();
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5632
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by sonetsuyoshi on 2016/07/31.
 */
public class Main {
    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a1 = sc.nextLong();
        long a2 = sc.nextLong();
        long a3 = sc.nextLong();
        long a4 = sc.nextLong();
        long a5 = sc.nextLong();
        long a6 = sc.nextLong();
        long a7 = sc.nextLong();

        long length = a2;

        if(a1 % 2 + a4 % 2 + a5 % 2 >= 2 && a1 > 0 & a4 > 0 & a5 > 0) {
            length += 3;
            a1 -= 1;
            a4 -= 1;
            a5 -= 1;
        }

        length += (a1 / 2) * 2;
        length += (a4 / 2) * 2;
        length += (a5 / 2) * 2;

//        long l = Math.min(a4, a5);
//        a4 -= l;
//        a5 -= l;
//        length += l * 2;
//
//        long a = a4 / 2;
//        l = Math.min(a, a1);
//        length += l * 3;
//        a1 -= l;
//
//        a = a5 / 2;
//        l = Math.min(a, a5);
//        length += l * 3;
//        a1 -= l;
//
//        a = a1 / 2;
//        length += a * 2;


        System.out.println(length);
    }
}

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

using namespace std;

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

    string s;

    cin >> s;

    sort(s.begin(), s.end());

    if(s[0] != s[3] && s[0] == s[1] && s[2] == s[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a = n%10;
  int b = (n/10)%10;
  int c = (n/100)%10;
  int d = n/1000;
  if(a==b&&b==c){
    cout << "Yes" << endl;
  }else if(b==c&&c==d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
h, w, num = map(int, input().split())
lis = []
for i in range(num):
    k, j = map(lambda x: int(x) - 1,input().split())
    for a in range(3):
        for b in range(3):
            cou1 = k - a
            cou2 = j - b 
            if cou1 < 0 or cou1 > h - 3:
                continue
            if cou2 < 0 or cou2 > w - 3:
                continue
            lis.append((cou1, cou2))

lis = Counter(Counter(lis).values())

print((h - 2) * (w - 2) - sum(lis.values()))
for i in range(1, 10):print(lis[i])


Measured memory_bytes: 198516
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

bitset<4000010> b;
int a[2001];
int main(){
    int n;
    cin>>n;
    int sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sum=(sum-1)/2+1;
    rep(i,n){
        b|=(b<<a[i]);
        b[a[i]]=1;
    }
    FOR(i,sum,4000001){
        if(b[i]){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1664
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/15
# Filename: main 
# Author: acto_mini

def main():
    S = input()
    num0 = int(S[0])
    num1 = int(S[1])
    num2 = int(S[2])
    num3 = int(S[3])

    for i in range(2):
        for j in range(2):
            for k in range(2):
                ans = 0
                op1 = i == 1
                op2 = j == 1
                op3 = k == 1

                if op1:
                    ans = num0 - num1
                else:
                    ans = num0 + num1

                if op2:
                    ans -= num2
                else:
                    ans += num2

                if op3:
                    ans -= num3
                else:
                    ans += num3

                if ans == 7:
                    print(str(num0) + conv(op1) + str(num1) + conv(op2) + str(num2) + conv(op3) + str(num3) + "=7")
                    exit()

    return


def conv(s):
    if s:
        return "-"
    else:
        return "+"


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i=(a); i < (int)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int d,g;
vector<int> p, c;

int main(){
	
	cin >> d >> g;
	g /= 100;
	p.resize(d+1);
	c.resize(d+1); // 1 based
	REP(i,d){
		cin >> p[i+1] >> c[i+1];
		c[i+1] /= 100;
	}
	
	int ans = 100000000;
	for(int bit=0; bit<(1<<d); bit++){
		int s = 0;
		int count = 0;
		FOR(i,1,d+1){
			if(bit & (1 << (i-1))){
				s += i*p[i] + c[i];
				count += p[i];
			}
		}
		
		if(s >= g){	
			chmin(ans, count);
			continue;
		}
		
		for(int i = d; i >= 1; i--){
			if( !(bit & (1 << (i-1))) ){
				int a = (g-s)/i;
				if((g-s)%i) a++;
				
				if(a <= p[i]-1){
					s += a*i;
					count += a;
				}else{
					s += (p[i]-1)*i;
					count += p[i]-1;
				}
				
				if(s >= g){
					chmin(ans, count);
					break;
				}
			}
		}
	}
	
	cout << ans << endl;
	
	
	return 0;
}

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

#define rep(i,x) for(int i=0;i<x;i++)
#define pb push_back
#define sr(v) sort(v.begin(),v.end());

int main(){
	while(1){
		int n; cin>>n; if(n==0)break;
		string s; cin>>s;

		int a[16]={0};
		int t=0;

		rep(i,100){
			switch(s[i]){
				case 'M': a[t]++; break;
				case 'S': a[14]+=a[t]+1; a[t]=0; break;
				case 'L': a[t]+=a[14]+1; a[14]=0; break;
			}
			t++; t%=n;
		}

		vector<int> ret; rep(i,n)ret.pb(a[i]); sr(ret);

		rep(i,n)cout<<ret[i]<<" "; cout<<a[14]<<endl;
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
int find_len(int n) {
int len = 1;
int le = 0;
int ri = 1;
while (n < le || n > ri) {
  if (len % 2 == 0) {
    ri += ri - le + 1;
  } else {
    le -= ri - le + 1;
  }
  len++;
}
 
return len;
}
 
signed main() {
int n;
cin >> n;
if (n == 0) { cout << "0\n"; return 0; }
int l = find_len(n);
vector<int> digs(l);
while (n != 0) {
  l = find_len(n);
  l--;
  digs[l] = 1;
  if (l % 2 == 0) n -= 1LL << l;
  else n += 1LL << l;
}
 
reverse(begin(digs), end(digs));
 
for (auto x: digs) {
 cout << x;
}
cout << "\n";
}

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

int main(){
  int a, b, m;
  cin >> a >> b >> m;
  int count = 0;
  for(int x = a;x <= b; x++){
    if(m % x == 0){
      count = count + 1;
    }
  }
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


vector<LL> fact;
vector<LL> inver(300001);
vector<int> v[200001];

LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=300000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[300000]=fpow(fact[300000],mod-2);
    for(int i=299999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}


vector<P> dp1(200001);
vector<P> dp2(200001);
int n;
 
P dfs(int u,int prev){
    dp1[u] = mp(1,0);
    for (int i = 0; i < v[u].size(); i++) {
        if(v[u][i]==prev) continue;
        P p = dfs(v[u][i],u);
        dp1[u].sc += p.sc;
        dp1[u].fs = dp1[u].fs*combi(dp1[u].sc,p.sc)%mod*p.fs%mod;
    }
    dp1[u].sc++;
    return dp1[u];
}


void dfs2(int u,int prev,LL st,LL t){
    dp2[u] = mp(st,t);
    for (int i = 0; i < v[u].size(); i++) {
        if(v[u][i]==prev) continue;
        dp2[u].sc += dp1[v[u][i]].sc;
        dp2[u].fs = dp2[u].fs*combi(dp2[u].sc,dp1[v[u][i]].sc)%mod*dp1[v[u][i]].fs%mod;
    }
    for (int i = 0; i < v[u].size(); i++) {
        if(v[u][i]==prev) continue;
        dfs2(v[u][i],u,dp2[u].fs*fpow(dp1[v[u][i]].fs*combi(dp2[u].sc,dp1[v[u][i]].sc)%mod,mod-2)%mod,n-dp1[v[u][i]].sc);
    }
}


int main(){
    set_combi();
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(0,-1);
    dfs2(0,-1,1,0);
    for (int i = 0; i < n; i++) {
        cout << dp2[i].fs << endl;
    }
    return 0;
}


Measured memory_bytes: 25836
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {

	static int list[];

	public static void main(String args[]) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {

			String str[] = br.readLine().split(" ");
			int n = Integer.parseInt(str[0]);
			int r = Integer.parseInt(str[1]);

			if (n == 0 && r == 0)
				break;

			list = new int[n];

			for (int i = 0; i < n; i++) {
				list[i] = n - i;
			}

			for (int i = 0; i < r; i++) {
				str = br.readLine().split(" ");
				int p = Integer.parseInt(str[0]) - 1;
				int c = Integer.parseInt(str[1]);
				cutting(p, c);
			}
			System.out.println(list[0]);
		}
	}

	static void cutting(int p, int c) {
		int under[] = new int[c];
		for (int i = 0; i < c; i++) {
			under[i] = list[p + i];
		}
		for (int i = 0; i < p; i++) {
			list[p + c - i - 1] = list[p - i - 1];
		}
		for (int i = 0; i < c; i++) {
			list[i] = under[i];
		}
	}
}


Measured memory_bytes: 28376
import math
n = int(input())
nn = int(math.sqrt(n)) + 1
ans = max(1, len(str(n)))

for i in range(1, nn):
    if n % i == 0:
        if max(len(str(i)), len(str(n//i))) < ans:
            ans = max(len(str(i)), len(str(n//i)))

print(ans)

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

#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

const double PI = acos(-1.0);

// long long積のオーバーフロー検出
bool detect_mul_overflow(ll a, ll b)
{
    return a >= LONG_MAX / b;
}

int lcm(int a, int b)
{
    //最小公倍数
    return a / __gcd(a, b) * b;
}

struct edge
{
    int from, to, cost;
};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));



int main()
{
    int n;
    string s;
    vector<int> data(4, 0);
    cin>>n;
    rep(i,n){
        cin>>s;
        if(s=="AC"){
            data[0]++;
        }else if (s=="WA")
        {
            data[1]++;
        }else if (s=="TLE")
        {
            data[2]++;
        }else if (s=="RE")
        {
            data[3]++;
        }

    }

    cout<<"AC x "<<data[0]<<endl;
    cout<<"WA x "<<data[1]<<endl;
    cout<<"TLE x "<<data[2]<<endl;
    cout<<"RE x "<<data[3]<<endl;
    return 0;
}


Measured memory_bytes: 3628
//#pragma comment(linker, "/STACK:102400000,102400000")
//#include <initializer_list>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define slla(n) scanf("%lld", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); repp(i,1,___T)

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 2e5 + 50;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int n;
int vis[maxn];
vector<pair<int,int>>a,b,c;
void solve()
{
    sa(n);
    repp(i,1,n)
    {
        int x,y;
        sa(x),sa(y);
        a.push_back(mp(x,y));
        c.push_back(mp(y,x));
    }
    repp(i,1,n)
    {
        int x,y;
        sa(x),sa(y);
        b.push_back(mp(x,y));
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());


    int ans = 0;
    for(int i=a.size()-1;i>=0;i--)
    {
        for(int j=0;j<b.size();j++)
        {
            if(vis[j])continue;
            if(b[j].first>a[i].first&&b[j].second>a[i].second)
            {
                vis[j]=1;
                ans++;
                break;
            }
        }
    }

    mem(vis,0);
    int ans2 = 0;

    for(int i=c.size()-1;i>=0;i--)
    {
        for(int j=0;j<b.size();j++)
        {
            if(vis[j])continue;
            if(b[j].first>c[i].second&&b[j].second>c[i].first)
            {
                vis[j]=1;
                ans2++;
                break;
            }
        }
    }


    cout<<max(ans,ans2)<<endl;
}

int main(){

    solve();
    return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def dfs(s):
    global used, G
    used.add(s)
    for t in G[s]:
        if t not in used:
            dfs(t)

N, M = map(int, input().split())
es = []
G = [[] for i in range(N)]
for i in range(M):
    a, b = [int(i) - 1 for i in input().split()]
    G[a].append(b)
    G[b].append(a)
    es.append([a, b])

ans = 0
for a, b in es:
    G[a].remove(b)
    G[b].remove(a)
    used = set()
    dfs(0)
    if len(used) != N:
        ans += 1
    G[a].append(b)
    G[b].append(a)

print(ans)




Measured memory_bytes: 3064
x,k,d = map(int,input().split())

if x<0:
  x *= -1

if x>=0 and x-k*d>=0:
  print(x-k*d)
else:
  tmp = x//d
  if tmp%2==k%2:
    print(x%d)
  else:
    print(d-x%d)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
string s;
bool dp[505][505];
/**********************************************/

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

    cin >> s;
    int n = s.size();
    REP(i, n) dp[i][i] = true;
    REP(l, n-2){
        int r = l+2;
        if(s.substr(l, 3) == "mew") dp[l][r] = true;
    }

    for(int len = 6; len <= n; len += 3){
        REP(l, n){
            int r = l + len - 1;
            if(r >= n) break;
            /*
            for(int c = l+3; c < r; c += 3){
                if(dp[l][c-1] && dp[c][r]) dp[l][r] = true;
            }
            */
            for(int c = l+1; c < r; c++){
                if(s[l] == 'm' && s[c] == 'e' && s[r] == 'w'){
                    if(l+1 != c && !dp[l+1][c-1]) continue;
                    if(c+1 != r && !dp[c+1][r-1]) continue;
                    dp[l][r] = true;
                }
            }
        }
    }
    cout << (dp[0][n-1] ? "Cat" : "Rabbit") << endl;
}



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

using namespace std;

int main(void) {
	long n;
	int cnt;

	while (cin >> n, n) {
		cnt = 0;
		while(n != 1) {
			if (n % 2 == 0) {
				n /= 2;
			}
			else {
				n = n * 3 + 1;
			}
			cnt++;
		}
		cout << cnt << endl;
	}

	return 0;
}


Measured memory_bytes: 2996
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;



int main()
{
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2] ;
    sort(v.begin(),v.end());

    int gap1=v[2]-v[0];
    int gap2=v[2]-v[1];

    if(gap1%2==0 && gap2%2==0){
        p(gap1/2+gap2/2)
    } else if(gap1%2==1 && gap2%2==1){
        p(gap1/2+gap2/2+1)
    } else{
        p(gap1/2+gap2/2+2)
    }
} 

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

            Dept. of CSE
        Comilla  University

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

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

int main()
{
    ll x,a;
    cin>>x>>a;
    cout<<(x<a ? 0 : 10)<<endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main(){
    int N;
    cin>>N;
    bool can=false;
 
    if(N/100==7){
        can=true;
    }
    N=N-(N/100)*100;
    if(N/10==7){
        can=true;
    }
    N=N-(N/10)*10;
    if(N==7){
        can=true;
    }
    if(can){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
typedef vector<int> Vi;
typedef pair<int,int> Pii;
typedef pair<int,Pii> Pip; 
const int INF = (1<<30);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){

  int n;
  cin >> n;

  map<int, int> data[3];
  int one[200], two[200], three[200];

  for(int i=0; i<n; i++) {
    cin >> one[i] >> two[i] >> three[i];
    data[0][one[i]]++;
    data[1][two[i]]++;
    data[2][three[i]]++;
  }
  
  int ans = 0;
  for(int i=0; i<n; i++) {
    ans = 0;
    if( data[0][one[i]] -1 == 0 ) ans += one[i];
    if( data[1][two[i]] -1 == 0 ) ans += two[i];
    if( data[2][three[i]] -1 == 0 ) ans += three[i];
    cout << ans << endl;
  } 
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using lli = long long int;

int main(){
  lli n;
  while(std::cin >> n){
    if(n == 0) break;
    vector<lli> p(n), j(n - 1);
    for (int i = 0; i < n; i++) std::cin >> p[i];
    for (int i = 0; i < n - 1; i++) std::cin >> j[i];
    sort(j.begin(), j.end());
    reverse(j.begin(), j.end());
    lli maxi = 0, sum = 0;
    for (int i = 0; i < n; i++) sum += p[i];
    maxi = sum*n;
    for (int i = 0; i < n - 1; i++) {
      sum += j[i];
      maxi = max(maxi, sum*(n - i - 1));
    }
    std::cout << max(maxi, sum) << std::endl;
  }
  return 0;
}



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

int n,a[100005];  
string s;

int main() {
  cin >> n;
  int cnt=0;
  rep(i,n){
  cin >> a[i];
  if(a[i]&1) cnt++;
  }
  cout << (cnt&1?"NO":"YES") << endl;
}

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

ll res(ll a, ll b, ll c, ll d) {
  ll M = max(a, max(b, max(c,d)));
  ll m = min(a, min(b, min(c,d)));
  return M-m;
} 

int main() {
  ll N; cin >> N;
  ll a[N];
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll suml[N+1], sumr[N+1];
  suml[0] = 0;
  for (ll i = 1; i <= N; i++) {
    suml[i] = suml[i-1]+a[i-1];
  }
  for (ll i = 0; i <= N; i++) {
    sumr[N-i] = suml[N] - suml[i];
  }
  ll ans = 1e18;
  for (ll i = 2; i <= N-2; i++) {
    ll ub = i+1; ll lb = -1;
    while (ub - lb > 1) {
      ll mid = (ub+lb)/2;
      (suml[mid] > suml[i]/2? ub:lb) = mid;
    }
    vector<ll> w0 = {suml[ub], suml[i]-suml[ub]};
    ll w1[2];
    if (ub > 0) {
      w1[0] = suml[ub-1]; w1[1] = suml[i]-suml[ub-1];
    } else {
      w1[0] = 0; w1[1] = 1e18;
    }
    
    ub = N-i+1; lb = -1;
    while (ub - lb > 1) {
      ll mid = (ub+lb)/2;
      (sumr[mid] > sumr[N-i]/2? ub:lb) = mid;
    }
    vector<ll> x0 = {sumr[ub], sumr[N-i]-sumr[ub]};
    ll x1[2];
    if (ub > 0) {
      x1[0] = sumr[ub-1]; x1[1] = sumr[N-i]-sumr[ub-1];
    } else {
      x1[0] = 0; x1[1] = 1e18;
    }
    ll r0 = res(w0[0],w0[1],x0[0],x0[1]);
    ll r1 = res(w1[0],w1[1],x0[0],x0[1]);
    ll r2 = res(w0[0],w0[1],x1[0],x1[1]);
    ll r3 = res(w1[0],w1[1],x1[0],x1[1]);
    ll r = min(r0, min(r1, min(r2,r3)));
    ans = min(r,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <algorithm>
using namespace std;

#define REPi(N) for(int i = 0; i < (N); i++)

int d[20], memo[50001];

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    fill_n(memo, 50001, 1<<20);
    memo[0] = 0;

    REPi(m) scanf("%d", &d[i]);
    sort(d, d+m);

    REPi(n){
        for(int j = 0; j < m; j++){
            int cost = i + d[j];
            if(cost > n) break;
            memo[cost] = min(memo[cost], memo[i] + 1);
        }
    }
    printf("%d\n", memo[n]);
    return 0;
}


Measured memory_bytes: 2956
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int a, b;
  cin >> a >> b;
  if(9<a || 9<b){
    cout << -1 << endl;
  } else {
    cout << a*b << endl;
  }

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String input = bf.readLine();
    System.out.println(check(input));
    bf.close();
  }
  static String check(String s){
    //文字列sの最初の文字について、偶数個あったら、trueを返す。
    if (s.length() == 0) {
      return "Yes";
    }
    char[] cList = s.toCharArray();
    char checkChar = cList[0];
    int count = 0;
    StringBuilder sb = new StringBuilder();
    for (char c : cList) {
      if (c == checkChar) {
        count++;
      } else {
        sb.append(c);
      }
    }
    if (count % 2 == 0) {
      return check(sb.toString());
    } else {
      return "No";
    }
  }
}

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

int main(){
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for (int i = 0; i < n; i++) {
    cin>>a[i];
  }
  for (int i = 0; i < n; i++) {
    b[i]=a[i];
  }
  sort(a, a+n, greater<int>());
  for (int i = 0; i < n; i++) {
    if (b[i]==a[0]) cout<<a[1]<<endl;
    else cout<<a[0]<<endl;
  }
}


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

#define REP(i,n) for(i=0;i<n;i++)

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int dfs(int v, int n, int *visited, int table[n][n]);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);

//main function
int main() {
    int a = iin(), b = iin(), c = iin();
    stout((a == b && b == c) ? "Yes" : "No");
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int dfs(int v, int n, int *visited, int table[n][n]) {
    int all_visited = 1, i;

    REP(i,n) {
        if (!visited[i]) {
            all_visited = 0;
            break;
        }
    }

    if (all_visited) {
        return 1;
    }

    int count = 0;

    REP(i,n) {
        if (!table[v][i]) continue;
        if (visited[i]) continue;

        visited[i] = 1;
        count += dfs(i, n, visited, table);
        visited[i] = 0;
    }

    return count;
}

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int i;
    cin >> i;
    int j=i%10;
    if(j==2 || j==4 || j==5 || j==7 || j==9){
        cout << "hon" << endl;
    }else if(j==0 || j==1 || j==6 || j==8){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, k, i, j, ct, x;
	cin >> n >> k;
	ct = 0;
	for (i = 0; i < n; i++) {
		cin >> x;
		if (x >= k) ct++;
	}
	cout << ct << "\n";
	
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn dfs(pos: usize, d: usize, parent: usize, dists: &mut Vec<usize>, map: &Vec<Vec<usize>>) {
    dists[pos] = d;

    for &next in map[pos].iter() {
        if next != parent {
            dfs(next, d+1, pos, dists, map);
        }
    }
}

fn solve(n: usize, abs: Vec<(usize, usize)>) -> bool {
    let mut map = vec![vec![]; 100001];

    for (a,b) in abs {
        map[a].push(b);
        map[b].push(a);
    }

    let mut fdists = vec![0; 100001];
    let mut sdists = vec![0; 100001];

    dfs(1, 0, 0, &mut fdists, &map);
    dfs(n, 0, 0, &mut sdists, &map);

    let mut fwin = 0;
    let mut swin = 0;
    for i in 1..n+1 {
        if fdists[i] <= sdists[i] {
            fwin += 1;
        } else {
            swin += 1;
        }
    }

    swin < fwin
}

fn main() {
    let n = parse_line!(usize);

    let abs = (0..n-1).map(|_| parse_line!(usize, usize)).collect();

    println!("{}", if solve(n, abs) { "Fennec" } else { "Snuke"});
}

fn solve_test() {
    assert_eq!(solve(7, vec![(3,6),
                             (1,2),
                             (3,1),
                             (7,4),
                             (5,7),
                             (1,4)]), true);

    assert_eq!(solve(4, vec![(1,4),
                             (4,2),
                             (2,3)]), false);
}


Measured memory_bytes: 20732
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=0;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        if(i%2==1 && arr[i]%2==1)
            ans++;
    }
    cout<<ans<<endl;
}


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

int main()
{
    int n;
    scanf("%d",&n);
    
    int a[n+1][4];
    
    for(int i=1; i<=n; i++){
        for(int j=1; j<=3; j++){
            scanf("%d",&a[i][j]);
        }
    }
    
    int dp[n+1][4];
    
    dp[1][1] = a[1][1], dp[1][2] = a[1][2], dp[1][3] = a[1][3];
    
    for(int i=2; i<=n; i++){
        dp[i][1] = max(dp[i-1][2], dp[i-1][3]) + a[i][1];
        dp[i][2] = max(dp[i-1][1], dp[i-1][3]) + a[i][2];
        dp[i][3] = max(dp[i-1][1], dp[i-1][2]) + a[i][3];
    }
    
    cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
}

Measured memory_bytes: 3328
N = gets.to_i

ans = Array.new(N, 0)
1.step(100) do |x|
  1.step(100) do |y|
    1.step(100) do |z|
      n = x**2 + y**2 + z**2 + x*y + y*z + z*x
      break if N < n
      ans[n - 1] += 1
    end
    break if N < x**2 + y**2
  end
  break if N < x**2
end

puts ans

Measured memory_bytes: 14344
def main():
    A, B = list(map(int, input().split(' ')))
    A -= 1
    B -= 1
    K = 50
    H, W = 2 * K, 2 * K
    ans = list()
    for h in range(K):
        if h % 2 == 0:
            ans.append('#' * W)
        else:
            white_cells = K if A >= K else max([A, 0])
            ans.append('#.' * white_cells + '##' * (K - white_cells))
            A -= white_cells
    for h in range(K):
        if h % 2 == 0:
            ans.append('.' * W)
        else:
            black_cells = K if B >= K else max([B, 0])
            ans.append('.#' * black_cells + '..' * (K - black_cells))
            B -= black_cells
    print('{} {}'.format(H, W))
    for s in ans:
        print(s)


if __name__ == '__main__':
    main()


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

typedef uint32_t u32;
typedef uint64_t u64;

int main() {

  int a[5];
  for(u32 i = 0; i < 5; ++i) {
    std::cin >> a[i];
  }

  std::sort(a, a + 5);
  std::reverse(a, a + 5);

  std::cout << a[0];
  for(int i = 1; i < 5; ++i) {
    std::cout << " " << a[i];
  }
  std::cout << std::endl;
  
  return 0;
}

Measured memory_bytes: 1172
#include <cstdio>

int main(){
    char s[27];
    scanf("%s",s);
    bool check[26];
    for(int i = 0; i < 26; i++){
        check[i] = true;
    }
    for(int i = 0; s[i] != '\0'; i++){
        if(check[s[i] - 97]){
            check[s[i] - 97] = false;
        }else{
            printf("no\n");

            return 0;
        }
    }
    printf("yes\n");

    return 0;
}

Measured memory_bytes: 256
int a[200000];
int ans[200000];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=2;i<=n;i++)scanf("%d",&a[i]);
	for(int i=2;i<=n;i++)ans[a[i]]++;
	for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}


Measured memory_bytes: 3232
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  //fact 階乗　iface 階乗の逆数
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  int s;
  cin >> s;
  combination c(100005);
  mint ans = 0;
  rep(i,s/3+1){
    if(i==0)continue;
    ans += c((s-i*3)+(i-1),i-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4836
#include <iostream>
#include <cstdio>
#define N 10005
#define NN 1000000
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, ans, lcm = 1, a[N], mx[NN + 5];

ll pow(ll p, ll q) {
	ll re;
	if (q == 0) return 1;
	re = pow(p, q / 2);
	re = re * re % M;
	if (q % 2) re = re * p % M;
	return re;
}

int main()
{
	ll i, j, t, c;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		t = a[i];
        for (j = 2; j * j <= t; j++) {
			for (c = 0; t % j == 0; c++, t /= j);
			mx[j] = max(mx[j], c);
        }
        mx[t] = max(mx[t], 1LL);
	}
	for (i = 2; i <= NN; i++) {
		lcm = lcm * pow(i, mx[i]) % M;
	}
	for (i = 0; i < n; i++) {
		ans = (ans + lcm * pow(a[i], M - 2)) % M;
	}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6656
def main():
    N = int(input())
    A = list(map(int,input().split()))

    A.sort()
    dict = {}
    for i in range(1,A[N-1]+1):
        dict[i] = 0

    if N == 1:
        return 1

    if A[0] == 1 and A[1] != 1:
        return 1
    elif A[0] == 1 and A[1] == 1:
        return 0

    temp = 1

    for num in A:
        while True:
            if num*temp <= A[N-1]:
                dict[num*temp] += 1
                temp += 1
            else:
                temp = 1
                break

    ans = 0
    for num2 in A:
        if dict[num2] <= 1:
            ans += 1

    return ans


print(main())


Measured memory_bytes: 103152