akhauriyash/Code-Regression huggingface dataset:
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int a[N], n, m, cnt[N << 2], ch[N << 2], mn[N << 2];
void pull(int v) {
	int l = v << 1, r = l | 1;
	int val = min(mn[l], mn[r]);
	mn[v] = val + ch[v];
	cnt[v] = (val == mn[l] ? cnt[l] : 0) + (val == mn[r] ? cnt[r] : 0);
}

void build(int v = 1, int b = 0, int e = n) {
	if (b + 1 == e) {
		cnt[v] = 1;
		mn[v] = 0;
		return;
	}
	int m = b + e >> 1, l = v << 1, r = l | 1;
	build(l, b, m);
	build(r, m, e);
	pull(v);
}

void update(int i, int j, int x, int v = 1, int b = 0, int e = n) {
	if (i >= e || b >= j) return;
	if (i <= b && e <= j) {
		mn[v] += x;
		ch[v] += x;
		return;
	}
	int m = b + e >> 1, l = v << 1, r = l | 1;
	update(i, j, x, l, b, m);
	update(i, j, x, r, m, e);
	pull(v);
}
int xl[N], xr[N];
void add(int val, int x) {
	update(xl[val], xr[val], -1);
	xl[val] -= x;
	update(xl[val], xr[val], +1);
}
int main() {
	cin >> n >> m;
	build();
	for (int val = 0; val <= n; ++val) xl[val] = val, xr[val] = val;
	for (int j = 0; j < n; ++j) {
		cin >> a[j];
		xl[a[j]]--;
	}
	for (int val = 0; val <= n; ++val) update(xl[val], xr[val], +1);
	while (m--) {
		int pos, val;
		cin >> pos >> val;
		--pos;
		add(a[pos], -1);
		a[pos] = val;
		add(a[pos], 1);
		cout << (mn[1] == 0 ? cnt[1] : 0) << '\n';
	}
	
	
}





Measured memory_bytes: 22784
n=int(input())
#a,b=map(int,input().split())
xl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
l2d=[]
for i in range(n):
    l2d.append([i,xl[i]])

xlsort=sorted(xl)
v1=xlsort[n//2-1]
v2=xlsort[n//2]

l2d.sort(key=lambda x: x[1])
dic={}
for i in range(n):
    dic[l2d[i][0]]=i
thre=n//2
for i in range(n):
    if dic[i]<thre:
        print(v2)
    else:
        print(v1)



Measured memory_bytes: 148328
n,m = map(int,input().split())
def div(x,y):
    if x%y!=0:
        return 0
    else:
        return 1+div(int(x/y),y)

p=[]
q=[]

def fact(s):
    if len(p)!=0:
        k=p[-1]
    else:
        k=2
    for i in range(2,max(int(s**0.5) +2,2)):
        a=div(s,i)
        if a==0:
            0
        else:
            p.append(a)
            q.append(i)
            s=int(s/i**a)
    if s!=1:
        p.append(1)
            
fact(m)
def comb(nn,rr):
    rr=min(rr,nn-rr)
    rt=1
    for i in range(rr):
        #rt=rt*(nn-i)/(rr-i)
        rt*=(nn-i)
    for i in range(rr):
        rt//=(rr-i)
    return int(rt)
#print(p,q,m)
mo=10**9 +7
ans=1
if len(p)==0:
    ans=1
else:
    for i in p:
        ans*=comb(i+n-1, i) % mo
print(ans % mo)


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;
signed main(){
	int a,b,ans=INT_MAX,sum=0;
	cin>>a;
	f(i,a){
		cin>>b;
		sum+=b;
		ans=min(ans,sum/(i+1));
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3124
N, M = gets.chomp.split.map(&:to_i)
votes = gets.chomp.split.map(&:to_i)
sum = votes.inject(:+)
overs = votes.select { |v| v >= sum * 1.0 / (4*M) }
if overs.count >= M
  puts "Yes"
else
  puts "No"
end



Measured memory_bytes: 1788
#include<stdio.h>

#include<algorithm>


using namespace std ;



int use[ 50000 + 1 ] ;


int coin[ 20 ] ;



int main()
{
	int n ,m ;
	scanf( "%d %d" ,&n ,&m ) ;


	int i ,j ;
	for( i = 0 ; i < m ; ++i )
	{
		scanf( "%d" ,&coin[ i ] ) ;


		++use[ coin[ i ] ] ;
	}


	i = 1 ;
	while( i < n )
	{
		if( use[ i ] > 0 )
		{
			for( j = 0 ; j < m ; ++j )
			{
				if( i + coin[ j ] <= n )
				{
					if( use[ i + coin[ j ] ] != 0 )
					{
						use[ i + coin[ j ] ] = min( use[ i ] + 1 ,use[ i + coin[ j ] ] ) ;
					}

					else
					{
						use[ i + coin[ j ] ] = use[ i ] + 1 ;
					}
				}
			}
		}


		++i ;
	}


	printf( "%d\n" ,use[ n ] ) ;


	return 0 ;
}

Measured memory_bytes: 2952
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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;
}

int main()
{
  ll D,T,S;
  cin >> D >> T >> S;
  if(S*T>=D){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define int ll
#define Endl endl

signed main(){
    int N;
    int u[114514],v[114514],w[114514];
    vector<pair<int,int>> G[114514];
    cin >> N;
    REP(i,N){
        cin >> u[i] >> v[i] >> w[i];
        w[i]%=2;
        u[i]--;v[i]--;
        G[u[i]].push_back({v[i],w[i]});
        G[v[i]].push_back({u[i],w[i]});
    }
    int Ans[114514]={};
    int mode=0;
    
    bool al[214514]={};
    
    pair<int,int> mx={0,0};
    vector<pair<int,int>> Q;
    
    Q.push_back(mx);
    Ans[0]=0;
    while(!Q.empty()){
        pair<int,int> top=Q[(Q.size())-1];
        Q.pop_back();
        int f=top.first;
        int s=top.second;
        //cout << f << " " << s << endl;
        al[f]=1;
        mode = (Ans[f]+s)%2;
        REP(i,G[f].size()){
            if(al[G[f][i].first]==0){
                Q.push_back(G[f][i]);
                Ans[G[f][i].first]=(Ans[f]+G[f][i].second)%2;
                
            }
        }
    }
    
    REP(i,N){
        cout << Ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> ii;
typedef tuple<int,int,int> i3;
typedef std::pair<int, ii> iii;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<ii> vii;
typedef std::vector<iii> viii;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const ll MOD = 1e9 + 7;
const ld pi=acos(-1);
const double PI = acos(-1);
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);  // greater than or equal
#define ub(v,n) upper_bound(v.begin(), v.end(), n);  // greater than
#define all(x) (x).begin(), (x).end();
#define fi first;
#define se second;
#define endl '\n';
#define loop(i,n) for(int i=0;i<(n);i++);
#define FOR(i, m, n) for(int i = m; i < n; i++);

ll gcd(ll a, ll b) {return b==0 ? a : gcd(b,a%b);}
ll add(ll x, ll y) { return ((x + y) % MOD + MOD) % MOD;}
ll sub(ll x, ll y) { return ((x - y) % MOD + MOD) % MOD;}
ll mult(ll x, ll y) { return (x * y) % MOD;}
ll po(ll base, ll exp, ll mod){
	if(exp==0) return 1;
	if(exp&1) return (base*po(base,exp-1,mod))%mod;
	else return po((base*base)%mod, exp/2,mod);
}


int c[13];
int a[13][13];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n,m,x;
  cin >> n >> m >> x;
  for (int i=0; i<n; i++){
  	cin >> c[i];
  	for (int j=0; j<m; j++){
  		cin >> a[i][j];
  	}
  }
 ll cost=INF;
 for (int i=0; i<(1<<n); i++){
 	ll temp=0;
 	vector<int> counter(m+1,0);
 	for (int j=0; j<n; j++){
 		if (i&(1<<j)) {
 			temp+=c[j];
 			for (int k=0; k<m; k++) counter[k]+=a[j][k];
 		}
 	}
 	bool check=true;
 	for (int j=0; j<m; j++){
 		if (counter[j]<x) check=false;
 	}
 	if (check) cost=min(cost,temp);
 }

 if (cost!=INF) {cout<<cost<<endl;}
 else {cout<<-1<<endl;}

  
}




Measured memory_bytes: 3644
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int N = sc.nextInt();
		if(N % 100 == 0) {
			N += 1;
		}

		System.out.println(N * (int)Math.pow(100, D));
	}
}

Measured memory_bytes: 21840
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int Q = 2e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

vector<int> primes;
int x,np[N];

int main() {

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

    for(int i=2;i<N;i++) {

        if(np[i]) continue;

        primes.pb(i);

        for(int j=2*i;j<N;j+=i) {

            np[j] = 1;

        }

    }

    cin >> x;

    cout << primes[lower_bound(primes.begin(),primes.end(),x)-primes.begin()] << '\n';

    return 0;
}

Measured memory_bytes: 768
while True:
    n = int(input())
    if n == 0:
        break
    z = sorted([tuple(map(int, input().split())) for _ in range(n)],  key=lambda x: x[1])
    total = 0
    for a, b in z:
        total += a
        if total > b:
            print("No")
            break
    else:
        print("Yes")

Measured memory_bytes: 7752
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        int cnt = 0;
        for(int i=0; i<n; i++){
            int s = sc.nextInt();
            for(int j=1; j<=d; j+=s){
                cnt++;
            }
        }

        System.out.println(cnt+x);
    }
}


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

using namespace std;
typedef long long ll;
const int N = 105;
int h,w;
char s[N][N];
int dir[5][2]={0,1,0,-1,1,0,-1,0};
int judge(int a,int b)
{
    if(a<0||a>h||b<0||b>w)
        return 0;
    return 1;
}
int main()
{
    cin>>h>>w;
    for(int i=0;i<h;i++)
        scanf("%s",s[i]);
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(s[i][j]=='#'){
            int flag=1;
            for(int k=0;k<4;k++){
                int x=i+dir[k][0];
                int y=j+dir[k][1];
                if(judge(x+1,y+1))
                    if(s[x][y]=='#')
                    {
                        flag=0;
                        break;
                    }
              }
              if(flag==0)
                continue;
              else{
                printf("No\n");
                return 0;
              }
          }
       }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
struct Interval {int start, end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}
int main()
{
    string s;
    cin>>s;
    ll ans=0;
    if(s.size()<3)
    {
        cout<<0;
        return 0;
    }
    ll fir=-1;
    rep(i,s.size())
    if(s[i]=='A')
    {
        fir=i;
        break;
    }
    if(fir==-1)
    {
        cout<<0;
        return 0;
    }
    ll counA=0;
        repA(i,fir,s.size()-2)
        {
            if(s[i]=='A')
                counA++;
            else if(s[i]=='B'&&s[i+1]=='C')
            {
                ans+=counA;
                i++;
            }
            else
            {
                counA=0;
            }
        }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
unsigned long long f[55][5005];
int a[105],n;
unsigned long long dfs(int cn,int s)
{
	if(s<0) return 0;
	if(f[cn][s]!=-1) 
	{return f[cn][s];}
	if(cn==0)
	{
		f[cn][s]=0;
		return 0;
	}
	return f[cn][s]=dfs(cn-1,s-a[cn])+dfs(cn-1,s);
}
int main()
{
	int k;
	cin>>n>>k;
	memset(f,-1,sizeof(f));
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	f[0][0]=1;
	f[0][a[0]]=1;
	unsigned long long res=0;
	for(int i=0;i<5001;i++)
	{
		unsigned long long r=dfs(n-1,i);
		if(i%2==k&&r!=-1) res+=r;
//		cout<<r<<"A"<<endl; 
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 2432
function Main(s) {
  s = s.split(" ").map(a => +a);
  var ans = "Yes";
  if(Math.abs(s[0] - s[2]) > s[3])
  if(Math.abs(s[0] - s[1]) > s[3] || Math.abs(s[2] - s[1]) > s[3]){
    ans = "No";
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int V = 200000;
struct UF {
	int id[V];
	vector<int> vec[V];
	void init() {
		inc(i, V) { id[i] = i; vec[i].PB(i); }
	}
	void unite(int x, int y) {
		if(id[x] == id[y]) { return; }
		if(size(x) < size(y)) { swap(x, y); }
		
		int iy = id[y];
		inc(i, vec[iy].size()) {
			id[ vec[iy][i] ] = id[x];
			vec[ id[x] ].PB(vec[iy][i]);
		}
		vec[iy].clear();
	}
	int find(int x) {
		return id[x];
	}
	int size(int x) {
		return vec[ id[x] ].size();
	}
};

int n, k, l;
UF K, L;
multiset<pair<int, int>> ms;
map<pair<int, int>, int> mp;

int main() {
	cin >> n >> k >> l;
	
	K.init();
	L.init();
	
	inc(i, k) {
		int p, q;
		cin >> p >> q;
		p--; q--;
		K.unite(p, q);
	}
	inc(i, l) {
		int r, s;
		cin >> r >> s;
		r--; s--;
		L.unite(r, s);
	}
	inc(i, n) {
		ms.emplace(K.find(i), L.find(i));
	}
	FOR(it, ms) {
		mp[*it]++;
	}
	
	inc(i, n) {
		cout << (i == 0 ? "" : " ") << mp[ MP(K.find(i), L.find(i)) ];
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 44672
#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);

	//freopen("input.txt", "r", stdin); // redirects standard input
	//freopen("output.txt", "w", stdout); // redirects standard output

	long long n, i, j, k, ans;
	cin >> n;
	vector<long long> h(n);
	map<long long, long long> ca, cb;
	for (i = 0; i < n; i++) {
		cin >> h[i];
		ca[h[i] + i]++;
		cb[-(h[i] - i)]++;
	}

	ans = 0;
	for (i = 0; i < n; i++) {
		ans += cb[h[i] + i];
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 38608
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 998244353;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main() {
	ll N, M = 0, t;
	cin >> N;
	vector<int> K(N);
	cin >> t;
	if (t == 0) {
		rep(i, 1, N)cin >> t, K[t]++, M = max(M, t);
		if (K[0] == 0) {
			t = K[0] = 1;
			rep(i, 1, M + 1) {
				t *= (ll)mpower(K[i - 1], K[i]);
				t %= mod;
			}
			printf("%lld\n", t);
			return 0;
		}
	}
	puts("0");
	return 0;
}


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

int main(){
	char trash;
	int hisi = 0, tyou = 0;
	int a, b, c;
	while(cin >> a >> trash >> b >> trash >> c){
		if(a == b){
			hisi++;
		}
		if(a*a+b*b == c*c){
			tyou++;
		}
	}
	cout << tyou << endl << hisi << endl;
}

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

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

    int p = (n-1)*(n-2)/2;
    vector<pair<int,int>> uv;
    rep(i,n-1) uv.push_back({0,i+1});

    rep2(i,1,n-1)
        rep2(j,i+1,n)
        {
            if(p==k) break;            
            p--;
            uv.push_back({i,j});
        }

    if(p==k)
    {
        int m = uv.size();
        cout << m << endl;
        rep(i,m) 
            cout << uv[i].first+1 << " " << uv[i].second+1 << endl;
    }
    else
        cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a + b >= c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;
using ll = long long;

int main() {
    int X;
    cin >> X;
    bool check = 1;

    int temp = X%100;
    temp = (temp + 4)/5;
    if(X/100 >= temp) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }


    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll N, M, K;
    sll(N);
    sll(M);
    sll(K);
    vector<ll> ns(N,0);
    vector<ll> cumsum_n(N+1,0);
    vector<ll> ms(M,0);
    vector<ll> cumsum_m(M+1,0);

    rep(i, N){
        sll(ns[i]);
        cumsum_n[i+1] = ns[i] + cumsum_n[i];
        cumsum_n[i+1] = min(cumsum_n[i+1], K+1);
    }

    rep(i, M){
        sll(ms[i]);
        cumsum_m[i+1] = ms[i] + cumsum_m[i];
        cumsum_m[i+1] = min(cumsum_m[i+1], K+1);
    }

    // cout << "cumsum m =" << cumsum_m <<endl;
    // cout << "cumsum n =" << cumsum_n <<endl;
    ll ans = 0;
    rep(i, N+1){
        ll left_k = K - cumsum_n[i];
        if(left_k<0){
            break;
        }
        auto max_mit = lower_bound(cumsum_m.begin(), cumsum_m.end(), left_k);
        ll max_m = *max_mit;
        ll this_m = max_mit - cumsum_m.begin() - 1;
        if(max_m==left_k){
            this_m ++;
        }
        // cout << "i=" <<i<<", this_m=" << this_m<<", left_k=" << left_k <<" maxm=" << max_m  << endl;;
        if(this_m+i > ans){
            ans = this_m + i;
        }
    }

    cout << ans <<endl;
}

int main(){
    Main();
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int bingo[3][3];
bool judge[3][3];
int main()
{
  rep(i,3)
  {
    rep(j,3)
    {
      cin >> bingo[i][j];
    }
  }
  int n;cin >> n;
  rep(i,n)
  {
    int temp;cin >> temp;
    rep(i, 3)
    {
      rep(j, 3)
      {
        if(temp==bingo[i][j])
        {
          judge[i][j] = true;
        }
      }
    }
  }
  
  rep(i,3)
  {
    bool flag = true;
    rep(j,3)
    {
      if(!judge[i][j])
      {
        flag = false;
        break;
      }
    }
    if(flag)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  rep(i, 3)
  {
    bool flag = true;
    rep(j, 3)
    {
      if (!judge[j][i])
      {
        flag = false;
        break;
      }
    }
    if (flag)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  bool flag = true;
  rep(i,3)
  {
    if(!judge[i][i])
    {
      flag = false;
      break;
    }
  }
  if(flag)
  {
    cout << "Yes" << endl;
    return 0;
  }
  flag = true;
  rep(i,3)
  {
    if(!judge[i][2-i])
    {
      flag = false;
      break;
    }
  }
  if (flag)
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> 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};



int main(){
    int a,b;cin >> a >> b;
    if(a<b) swap(a,b);
    if(a==b) cout << 0 << endl;
    else if((a+b)%2==0) cout << (a+b)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}


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


int main() {
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy";
    }
    else if(s == "Cloudy"){
        cout << "Rainy";
    }
    else
    {
        cout << "Sunny";
    }
    cout << endl;
}


Measured memory_bytes: 256
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 1e5+10;
ll n, k;
vll a;
ll dp[N];
ll go(ll i)
{
	if(i == 0)
		return 0;
	if(i < k)
		return abs(a[i] - a[0]);
	ll &ans = dp[i];
	if(ans != 9999999999999999)
		return ans;
	rep(j,1,k+1)
	{
		ans = min(ans , go(i-j) + abs(a[i] - a[i-j]));
	}
	return ans;
}
signed main()
{

	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	
	cin >> n >> k;
	cres(a , n);
	rep(i,0,n)
	{
		dp[i] = 9999999999999999;
		cin >> a[i];
	}

	cout<<go(n-1)<<endl;






////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}


Measured memory_bytes: 6528
class String
  def to_ia
    self.split(/\s+/).map {|s| s.to_i}
  end
end
 
class Array
  def rsort
    self.sort {|a, b| b <=> a}
  end

  def swap(i, j)
    t = self[i]
    self[i] = self[j]
    self[j] = t
  end
end

def bubble_sort(ary)
  switch = 0
  flag = true
  while flag
    flag = false
    (1...ary.size).to_a.rsort.each do |i|
      if ary[i] < ary[i-1]
        ary.swap(i, i-1)
        flag = true
        switch += 1
      end
    end
  end
  puts ary.join(" ")
  puts switch
end
 
STDIN.readline
ary = STDIN.readline.to_ia
bubble_sort(ary)

Measured memory_bytes: 8760
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k, i, j;
    cin>>n>>k;
    int a[n+1];
    for(i=1; i<=n; ++i){
        cin>>a[i];
    }
    int dp[n+2];
    dp[1] = 0;
    dp[2] = abs(a[2]-a[1]);
    int flag = 1;
    for(i=3; i<=n; ++i){
        int temp = INT_MAX;
        for(j=i-1; j>=max(i-k, flag); --j){
            temp = min(dp[j] + abs(a[i]-a[j]), temp);
        }
        dp[i] = temp;
    }
    cout<<dp[n]<<'\n';
}    

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    ll N, K; cin >> N >> K;
    vector<pair<ll, ll> > C(N);
    vector<ll> A(N);
    // 初期化
    rep(i,N){
        C[i] = make_pair(0, 0);
        cin >> A[i]; A[i]--;
    }
    ll count = -1, next = 0;
    ll roop, start, cnt0;
    rep(_,2*N){
        C[next].first++;
        count++;
        if(C[next].first == 2){
            roop = count - C[next].second;
            start = next;
            cnt0 = C[next].second;
            break;
        }
        C[next].second = count;
        next = A[next];
    }
    if(K < cnt0){
        next = 0;
        rep(_,K){
            next = A[next];
        }
        next++;
        cout << next << endl;
    }
    else{
        K = K - cnt0;
        K = K % roop;
        next = start;
        rep(_,K){
            next = A[next];
        }
        next++;
        cout << next << endl;
    }
}

Measured memory_bytes: 8012
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    size_t n, d, x;

    cin >> n >> d >> x;
    for (auto i = 0u; i < n; ++i) {
        size_t a;
        cin >> a;
        x += (d - 1) / a + 1;
    }
    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cassert>

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

using namespace std;

const int INF=1<<29;

class edge{
public:
	int v,cost;
	edge(int v,int cost):v(v),cost(cost){}
};

int main(){
	for(int n,m,k;scanf("%d%d%d",&n,&m,&k),n;){
		vector<edge> G[100];
		int d[100][100];
		rep(u,n) rep(v,n) d[u][v]=(u==v?0:INF);
		rep(_,m){
			int u,v,cost; scanf("%d%d%d",&u,&v,&cost);
			d[u][v]=d[v][u]=cost;
			G[u].push_back(edge(v,cost));
			G[v].push_back(edge(u,cost));
		}

		rep(w,n) rep(u,n) rep(v,n) d[u][v]=min(d[u][v],d[u][w]+d[w][v]);

		vector<int> D[100]; // 最短経路 DAG
		rep(u,n) rep(i,G[u].size()) {
			int v=G[u][i].v,cost=G[u][i].cost;
			if(d[0][u]+cost+d[v][n-1]==d[0][n-1]) D[u].push_back(v);
		}

		double dp[100][100]={}; // dp[u][v] := ( u->v 間の最短経路の個数 )
		// rep(u,n){
			// bool vis[100]={}; vis[u]=true;
			// dp[u][u]=1;
			// queue<int> Q; Q.push(u);
			// while(!Q.empty()){
				// int v=Q.front(); Q.pop();
				// rep(i,D[v].size()){
					// int w=D[v][i];
					// if(!vis[w]){
						// vis[w]=true;
						// Q.push(w);
					// }
					// dp[u][w]+=dp[u][v];
				// }
			// }
		// }
		rep(u,n) rep(i,G[u].size()) {
			int v=G[u][i].v,cost=G[u][i].cost;
			if(d[0][u]+cost+d[v][n-1]==d[0][n-1]) dp[u][v]=1;
		}
		rep(w,n) rep(u,n) rep(v,n) dp[u][v]+=dp[u][w]*dp[w][v];

		rep(_,k){
			int c; scanf("%d",&c);
			assert(c!=0 && c!=n-1);
			printf("%.9f\n",dp[0][c]*dp[c][n-1]/dp[0][n-1]);
		}
		puts("");
	}

	return 0;
}

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

int main() {
  long n,k,a=0,ans;
  bool ss=false;
  cin >> n >> k;
  ans=n-k+1;
  vector<long> p(n);
  vector<bool> s(n-k+1,true);
  set<long> aaa;
  for(long i=0;i<n;i++) cin >> p[i];
  for(long i=0;i<n-1;i++) {
    if(p[i]<p[i+1]) a++;
    else a=0;
    if(a>=k-1) {
      s[i-k+2]=false;
      if(ss) ans--;
      else ss=true;
    }
  }
  for(long i=1;i<n-1;i++) {
    aaa.insert(p[i]);
    if(aaa.size()==k-1) {
      if(s[i-k+1]||s[i-k+2]){
        auto itr=aaa.begin();
        auto itr2=aaa.end();
        itr2--;
        if(p[i-k+1]<*itr&&p[i+1]>*itr2) ans--;
      }
      aaa.erase(aaa.lower_bound(p[i-k+2]));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136
W, H, *L = map(int, open(0).read().split())
p = L[:W]
q = L[W:]
H += 1
W += 1
h = 0
w = 0
ls = [(c,0) for c in p]+[(c,1) for c in q]
ls.sort()
ans = 0
for c,s in ls:
  if s==1:
    ans += c*(W-w)
    h += 1
  if s==0:
    ans += c*(H-h)
    w += 1
print(ans)

Measured memory_bytes: 30300
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int H, W = 0;
        while(true) {
            H = sc.nextInt();
            W = sc.nextInt();
            if(H==0&&W==0) break;
            for(int i=0; i<H; i++) {
                for(int j=0; j<W; j++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
        
        
    }
}



Measured memory_bytes: 37712
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cstddef>
#include <vector>

enum {BUF_SIZE=(1<<17)};
char buf[BUF_SIZE|1], *pos, *endbuf;

inline int buffer() {
    size_t len=fread(buf, 1, BUF_SIZE, stdin);
    buf[len] = 0;
    endbuf = buf + len;
    pos = buf;
    return len;
}

inline int rebuffer() {
    ptrdiff_t left=endbuf-pos;
    if (buf+left >= pos)
        return *pos;

    memcpy(buf, pos, left);
    size_t len=fread(buf+left, 1, BUF_SIZE-left, stdin);
    endbuf = buf + (left+=len);
    *endbuf = 0;
    pos = buf;
    return len;
}

inline unsigned scan() {
    unsigned u=0;
    if (pos + 10 >= endbuf)
        rebuffer();

    do {
        u = u*10 + *pos-'0';
    } while (*++pos >= '0');

    ++pos;
    return u;
}

int B[100010], R[100010];

int main() {
    buffer();
    size_t N=scan();
    int M=scan();

    R[1] = 1;

    for (int i=0; i<M; ++i) {
        size_t x=scan(), y=scan();

        ++B[y];
        if (R[x])
            R[y] = 1;

        if (--B[x] == -1)
            R[x] = 0;
    }

    int res=0;
    for (size_t i=1; i<=N; ++i)
        if (R[i])
            ++res;

    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
	int N,M;
	int i,j,temp;
	scanf("%d %d",&N,&M);
	int K[30];
	int A[31]={};
	for(i=0;i<N;i++){
		scanf("%d",&K[i]);
		for(j=0;j<K[i];j++){
			scanf("%d",&temp);
			A[temp]++;
		}
	}
	int ans = 0;
	for(i=1;i<M+1;i++){
		if(A[i]==N){
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict, deque


def bfs(graph, n, start):
    q = deque([start])

    dists = [-1] * (n+1)
    dists[start] = 0

    while q:
        cur = q.pop()

        for neigh, d in graph[cur].items():
            if dists[neigh] == -1:
                q.appendleft(neigh)
                dists[neigh] = dists[cur] + d

    return dists


def main():
    n = int(input())

    graph = defaultdict(dict)

    for _ in range(n-1):
        a, b, c = (int(x) for x in input().split())
        graph[a][b] = c
        graph[b][a] = c

    q, k = (int(x) for x in input().split())

    dists = bfs(graph, n, k)

    for _ in range(q):
        start, end = (int(x) for x in input().split())
        print(dists[start] + dists[end])


if __name__ == "__main__":
    main()


Measured memory_bytes: 57676
#include<cstdio>
#include<cstdlib>	//abs(int)はcmathでなくcstdlib

using namespace std;

int max,index = 0;	//これでinitializeできてる？

void find_max(int A[], int n) {
	for (int i=0;i<n;i++) {
	if (abs(A[i]) > max) {
		max = abs(A[i]);
		index = i;
		}
	}
}

int main () {

	int n;
	scanf("%d", &n);
	int A[51] = {};
	for (int i=0;i<n;i++) {
	scanf("%d", &A[i]);
	}
//	最初から条件を満たしていれば、0を出力して終わらそう
	int tf = 1;
	for (int i=0;i<n;i++) {
	if (A[i] > A[i+1]) tf = 0;
	}
	if (tf == 1) {
	printf("0\n");
	 return 0;
	}

	find_max(A, n);
	max = A[index];	//負の場合は負になるように。



	//回数
	printf("%d\n", 2*n-2);	

	for (int i=0;i<n;i++) {
	if (i != index) {A[i] += max; printf("%d %d\n", index+1, i+1);} 
//	printf("%d %d\n", i , A[i]);
	}

//	答える時は、index 0;index 1; ... index (n-1); ただしindex=iは除く
//	規則性があるので、わざわざメモリに入れる必要がない。
//	けど回数はもうわかってるし、もう書いちゃうか！

//	累積和
	if (A[index] >= 0) {	
	for (int i=0;i<n-1;i++) {
	A[i+1] += A[i];
	printf("%d %d\n", i+1, i+2);
	}	
	}
	else
	{
        for (int i=n-2;i>=0;i--) {
        A[i] += A[i+1];
        printf("%d %d\n", i+2, i+1);
        }
        }

	return 0;
}
	


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;
// for文短縮類
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
// iteratorのbeginとendをまとめて渡す
#define ALL(x) (x).begin(), (x).end()
//略
#define PB push_back  // vectorヘの挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素
//出力
#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "
#define ENDL cout << endl
int main(int argc, char *argv[]) {
  // input高速化。cinとcoutの結合解除。scanfとprintfは使えない。
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ll n;
  cin >> n;
  map<ll, ll> counts;
  vector<ll> a;
  REP(i, n) {
    ll ai;
    cin >> ai;
    a.PB(ai);
    auto it = counts.find(ai);
    if (it == counts.end()) {
      counts.insert(make_pair(ai, 1));
    } else {
      it->second += 1;
    }
  }
  ll q;
  cin >> q;
  vector<ll> b;
  vector<ll> c;
  REP(i, q) {
    ll bi, ci;
    cin >> bi >> ci;
    b.PB(bi);
    c.PB(ci);
  }
  ll sum = accumulate(ALL(a), 0LL);
  REP(i, q) {
    auto it = counts.find(b[i]);
    if (it != counts.end()) {
      ll count = it->second;
      sum += (c[i] - b[i]) * count;
      counts.erase(b[i]);
      it = counts.find(c[i]);
      if (it == counts.end()) {
        counts.insert(make_pair(c[i], count));
      } else {
        counts[c[i]] += count;
      }
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 10272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

int saitan[100000] = {};

int keisan(int okane, int kaisuu) {

	if (okane < 6) return kaisuu + okane;

	int saishou6 = 100000;
	rep(i, 7) {
		int kari = okane - pow(6, i);
		if (kari >= 0) saishou6 = kari;
		else break;
	}
	int saishou9 = 100000;
	rep(i, 6) {
		int kari = okane - pow(9, i);
		if (kari >= 0) saishou9 = kari;
		else break;
	}
	int test6, test9;
	if (saitan[saishou6] != 0 && saitan[saishou6] <= kaisuu) test6 = 123456;
	else {
		saitan[saishou6] = kaisuu;
		test6 = keisan(saishou6, kaisuu + 1);
	}
	if (saitan[saishou9] != 0 && saitan[saishou9] <= kaisuu) test9 = 123456;
	else {
		saitan[saishou9] = kaisuu;
		test9 = keisan(saishou9, kaisuu + 1);
	}
	return min(test6, test9);
}

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N;
	cin >> N;

	cout << keisan(N, 0) << "\n";
	Would you please return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
 
int main(void) {
    int n, i, j;
    int t = 0, h = 0;
    char at[100], ah[100];
     
     
    scanf("%d", &n);
     
    for(i = 0; i < n; i++) {
        scanf("%s %s", at, ah);
         
        for(j = 0; at[j] != '\0'; j++) {
             
            if(at[j] > ah[j]) {
                t+=3;
                break;
            } else if(at[j] < ah[j]) {
                h+=3;
                break;
            } else if(at[j+1] == '\0') {
                if(ah[j+1] == '\0') {
                    t++;
                    h++;
                } else {
                    h+=3;
                }
                break;
            } else if(ah[j+1] == '\0') {
                t+=3;
                break;
            }
        }
    }
     
    printf("%d %d\n", t, h);
     
    return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
const int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint LCM(lint a,lint b){
  if(a==0 || b==0) return 0;
  lint tmp,r,x;
  x=a*b;
  if(a<b) tmp=a,a=b,b=tmp;
  r=a%b;
  while(r!=0) a=b,b=r,r=a%b;
  x=x/b;
  return x;
}

lint GCD(lint a,lint b){
  if(a==0 || b==0) return max(a,b);
  else return (a*b)/LCM(a,b);
}

int main(void){
    lint K;
    cin >> K;
    lint ans=0;
    for(int i=1;i<=K;i++) for(int j=1;j<=K;j++) for(int k=1;k<=K;k++){
        lint add=GCD(i,j);
        add=GCD(add,k);
        ans+=add;
    }
    cout << ans << endl;
}


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

int main() {
  string s;cin>>s;
  while(1){
    s.pop_back();
    int n=s.size();
    if(s.substr(0,n/2)==s.substr(n/2)){
      cout<<n<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3604
rle = gets.split[0..-2]
word = gets.split[0..-2]
alter = gets.split[0..-2]

idx = nil
(0..(rle.size-word.size)/2).each do |k|
    catch(:break) do
        i = 2 * k
        throw(:break) unless rle[i] == word[0]
        throw(:break) unless rle[i+1].to_i >= word[1].to_i
        (2..word.size-2).each do |j|
            throw(:break) unless rle[i+j] == word[j]
        end
        if rle[i+word.size-1].to_i >= word[-1].to_i
            idx = k
        end
    end
    break if idx
end

if !idx
    puts rle * ' ' + " $"
    exit
end

a = (idx == 0 ? [] : rle[0..2*idx-1])
b = alter
b = [word[0], rle[2*idx+1].to_i - word[1].to_i] + b if rle[2*idx+1].to_i > word[1].to_i && word.size > 2
b += [word[-2], rle[2*idx+word.size-1].to_i - word[-1].to_i] if rle[2*idx+word.size-1].to_i > word[-1].to_i
c = rle[2*idx+word.size..-1]

x = a + b + c
y = []

x.each_slice(2) do |c, k|
    k = k.to_i
    if c == y[-2]
        y[-1] += k
    else
        y += [c, k]
    end
end

puts y * ' ' + " $"

Measured memory_bytes: 28900
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main(){
  string s;
  cin >> s;
  vector<vector<int> > count(s.length()+1, vector<int>(26, 0));
  for (int i = 0; i < s.length(); i++){
    for (int j = 0; j < 26; j++){
      if ((char)('a'+j) == s[i]){
        count[i+1][j] = count[i][j]+1;
      }else{
        count[i+1][j] = count[i][j];
      }
    }
  }

  for (int i = 0; i < s.length(); i++){
    for (int t = i+2; t <= s.length() && t <= (i+3); t++){
      for (int j = 0; j < 26; j++){
        if ((count[t][j]-count[i][j])*2 > (t-i) || (count[t][j]-count[i][j]) == (t-i)){
          cout << (i+1) << ' ' << t << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << ' ' << -1 << endl;
  return 0;
}


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

int main(){
  vector<int> outp;
  int icn;
  int icd;
  int g;
  vector<int> ice;
  for(g = 0;;g++){
    vector<int> ice(10,0);
    cin >> icn;
    if(icn == 0){
      break;
    }else{
    for(int a = 0;a< icn;a++){
      cin >> icd;
      ice[icd] += 1;
    }
    outp.insert(outp.end(),ice.begin(),ice.end());
  }
  }
  for(int n = 0;n<g * 10;n++){
    if(outp[n] == 0){
      cout << "-";
    }else{
      for(int c = 0;c<outp[n];c++){
        cout << "*" ;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	ll := make([]int, n)

	for i := 0; i < n; i++ {
		ll[i] = getNextInt(scanner)
	}

	sort.Ints(ll)

	ans := 0
	for i := 0; i < n-2; i++ {
		for j := i + 1; j < n-1; j++ {
			l := j + 1
			r := n
			for l < r {
				m := (l + r) >> 1
				if ll[m] < ll[i]+ll[j] {
					l = m + 1
					continue
				}
				r = m
			}

			ans += l - (j + 1)
		}
	}
	fmt.Fprintln(writer, ans)

	writer.Flush()
}


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

using namespace std;

int main(){
	int n,m,T;
	cin>>n>>m>>T;
	int pre=0,ans=0;
	for(int i=0;i<n;++i){
		int a;
		cin>>a;
		if(i==0){
			ans+=a-m;
		}else if(int buf=a-pre-2*m){
			if(buf>0)ans+=buf;
		}
		if(i==n-1){
			if(int buf=T-a-m){
				if(buf>0)ans+=buf;
			}
		}
		pre=a;
	}
	cout<<ans<<endl;
}

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

int main()
{
	int ans, n;
	string s,c;
	cin >> s >> c;
	reverse(s.begin(), s.end());

	if (s == c) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 6e5 + 30 , Mod = 998244353 ;
const ll SQ = 330 ;


ll F[N] , I[N] ;
inline ll sum(ll a , ll b) {
	return (a + b) % Mod ;
}
inline ll mul(ll a , ll b) {
	return (a * b) % Mod ;
}
inline ll pw(ll x , ll y) {
	ll res = 1 ;
	while (y) {
		if (y & 1) res = mul(res , x) ;
		x = mul(x , x) ;
		y >>= 1 ;
	}
	return res ;
}
inline ll C(ll r , ll n) {
	if (r < 0 || r > n) return 0 ;
	return mul(F[n] , mul(I[r] , I[n - r])) ;
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    F[0] = 1 ;
    for (int i = 1 ; i < N ; i ++) F[i] = mul(i , F[i - 1]) ;
    I[N - 1] = pw(F[N - 1] , Mod - 2) ;
    for (int i = N - 2 ; i >= 0 ; i --) I[i] = mul(i + 1 , I[i + 1]) ;
    ll n , k ,a , b ;
    cin >> n  >> a >> b >> k ;
	ll ans = 0 ;
	for (int i= 0 ; i < N ; i ++) {
		ll tmp  = i * a ;
		tmp = k - tmp ;
		if (tmp % b) continue ;
		tmp /= b ;
		ans = sum(ans , mul(C(i , n) , C(tmp , n))) ;
	}
	cout << ans ;
    
    return (0) ;
}

Measured memory_bytes: 9600
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h>
using namespace std;
int main(void){
  int N,L;
  cin >> N >> L;
  vector<string> vec(N);
  for(int i = 0; i < N;i++) cin >> vec.at(i);
  
  sort(vec.begin(),vec.end());
  
   for(int i = 0;i < N; i++){
      cout << vec.at(i); 
   }
   cout << endl;
}

Measured memory_bytes: 256