akhauriyash/Code-Regression huggingface dataset:
import sys
while True:
    h, w = [int(i) for i in input().split()]
    if h == 0 and w == 0:
        sys.exit()
    else:
        for i in range(1, h+1):
            buf = []
            if i % 2 == 0:
                for j in range(1, w+1):
                    if j % 2 == 0:
                        buf.append('#')
                    else:
                        buf.append('.')
                print(''.join(map(str, buf)))
            else:
                for j in range(1, w+1):
                    if j % 2 == 0:
                        buf.append('.')
                    else:
                        buf.append('#')
                print(''.join(map(str, buf)))
        print('')


Measured memory_bytes: 5624
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

double x1,x2,x3,x4,y2,y3,y4,y5;//y1 crash with include cmath...
double g1,g2;
int tc;

int main()
{
	scanf("%d",&tc);
	while(tc--)
	{
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y5,&x2,&y2,&x3,&y3,&x4,&y4);
		/*g1=(y2-y5)/(x2-x1); //seeems broken with infinity loll
		g2=(y4-y3)/(x4-x3);
		printf("%.2lf,%.2lf\n",g1,g2);*/
		if(abs((x2-x1)*(y4-y3)-(x4-x3)*(y2-y5))<1e-10)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
		
	}
	return 0;
}

Measured memory_bytes: 1204
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int size = 100000 + 5;
typedef long long ll;
ll sum[size], d[size];
int main()
{
	int n, k;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%lld", &d[i]);
	sort(d + 1, d + n + 1);
	sum[0] = (ll)0;
	for (int i = 1; i <= n; i++)
		sum[i] = sum[i-1] + d[i];
	for (k = n-1; k >= 1; k--) {
		if (2 * sum[k] < d[k+1])
			break;
	}
	printf("%d", n - k);
	return 0;
}

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

int main() {
  int N;
  double ans_inv = 0.0;
  cin >> N;
  vector<double> A = vector<double>(N);
  for (int i = 0; i < N; i++) {
    int val;
    cin >> val;
    ans_inv += 1.0 / (double)val;
  }
  cout << (1.0 / ans_inv) << endl;
}


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

int main(void)
{
    int H, W;
    char moji;
    cin >> H;
    cin >> W;
    for (int i = 1; i < H+1; i++)
    {
        char moji = 'A';
        for (int j = 0; j < W; j++)
        {
            string sample;
            cin >> sample;
            if (sample == "snuke")
            {
                cout << moji << i << endl;
            }
            ++moji;
        }
    }
    return 0;
}

Measured memory_bytes: 256
void main() {
	auto N = ri;
	auto a = readAs!(int[]);
	ulong cnt;
	ulong rate;
	while(rate <= 3200) {
		if(a.filter!(k => k >= rate-400 && k < rate).count != 0) cnt++;
		rate+=400;
	}
	ulong cnt2 = a.filter!(k => k >= 3200).count;
	writefln("%d %d", cnt == 0 ? 1 : cnt, cnt + cnt2);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <iostream>
typedef long long int ll;
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  ll n1 = 2, n2 = 1, nsum;
  for(ll i=0; i<n-1; i++){
      nsum = n2;
      n2 += n1;
      n1 = nsum;
  }
  cout << n2;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  double a[10];
  double s;
  int i;
  
  while(scanf("%lf",&a[0])!=EOF) {
 
    for(i=0;i<4;i++) {

      a[2*i+1]=2.0*a[2*i];
      a[2*i+2]=a[2*i+1]/3.0;
    
    }

    a[9]=2.0*a[8];
    
    s=0.0;
    
    for(i=0;i<10;i++) {
      
      s+=a[i];
      
    }
    
    printf("%.8lf\n",s);
    
  }

  return 0;

}

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

int main(){
	int a, b;
	char op;
	
	while(true){
		cin >> a >> op >> b;
		switch(op){
			case '?':
				return 0;
			case '+':
				cout << a + b << "\n";
				break;
			case '-':
				cout << a - b << "\n";
				break;
			case '*':
				cout << a * b << "\n";
				break;
			case '/':
				cout << a / b << "\n";
				break;
		}
	}
}


Measured memory_bytes: 3096
# 配るDP
N,K=map(int,input().split())
H=list(map(int,input().split()))
INF=10**9
add_list=[INF]*K

H.extend(add_list)

dp=[INF]*(N+100) #Kの分追加
dp[0]=0
for n in range(N):
    for k in range(n+1,n+K+1):
        dp[k]=min(dp[k], dp[n]+abs(H[n]-H[k]))
print(dp[N-1])

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

int main() {
	
	string S;
	cin >> S;
	int N = S.size();
	string ans = "yes";
	for (int i = 0; i <= N; ++i) {
		for (int j = i + 1; j <= N; ++j) {
			if (S[i] == S[j]) {
				ans = "no";
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
	int m,f,r,k;
	while(true){
	std::cin >> m >> f >> r;
	if(m==-1 && f==-1 && r==-1)break;
	if(m==-1 || f==-1){std::cout << "F" << std::endl;goto END;}
	if(m+f>=80){std::cout << "A" << std::endl;goto END;}//k=1;
	if(m+f>=65 && m+f<80){std::cout << "B" << std::endl;goto END;}//k=2;
	if(m+f>=50 && m+f<65){std::cout << "C" << std::endl;goto END;}//k=3;
	if(m+f<30){std::cout << "F" << std::endl;goto END;}//k==6;
	if(m+f>=30 && m+f<50){
		if(r>=50){
			std::cout << "C" << std::endl;goto END;//k==3;
		}else{
			std::cout << "D" << std::endl;goto END;//k==4;
		}
	}
    END:
    ;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
int main(){
    int a,b,c,d,e;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
    if(a==0){
        printf("1\n");
    }else if(b==0){
        printf("2\n");
    }else if(c==0){
        printf("3\n");
    }else if(d==0){
        printf("4\n");
    }else if(e==0){
        printf("5\n");
    }
    return 0;
}

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

using namespace std;

using ll = long long;

int main(){
    long double a, b, c;
    cin >> a >> b >> c;
    ll garbo = 4 * a * b, trash = (c - a - b) * (c - a - b);
    if(c - a - b < 0)cout << "No";
    else if(garbo < trash)cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    int k;cin>>k;
    string s= "ACL";
    fi(i,0,k-1)cout<<s;
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  
  ll L, R; cin >> L >> R;
  
  if (R - L >= 2019){
    cout << 0 << endl;
  }else{
    int ans = 2019;

    for (ll i = L; i < R; i++){
      for (ll j = i + 1; j <= R; j++){
        if (ans > (i * j) % 2019){
          ans = (i * j) % 2019;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

typedef pair<ll, pll> plll;

int main(){
	ll N, M;
	cin >> N >> M;
	vector<ll> P(M), Y(M);
	REP(i, M) cin >> P[i] >> Y[i];
	REP(i, M) P[i]--;
	vector<pll> ai[N];
	REP(i, M){
		ai[P[i]].push_back(make_pair(Y[i], i));
	}
	REP(i, N){
		sort(ai[i].begin(), ai[i].end());
	}

	/*
	REP(i, N){
		dump(i)
		REP(j, ai[i].size()){
			cout << ai[i][j].first << " " << ai[i][j].second << endl;
		}
	}
	*/

	vector<plll> sa;
	REP(i, N){
		REP(j, ai[i].size()){
			sa.push_back(make_pair(ai[i][j].second, make_pair(j+1, i+1)));
		}
	}
	sort(sa.begin(), sa.end());

	REP(i, sa.size()){
		ll ord = (sa[i].second).first;
		ll pre = (sa[i].second).second;
		string ords = to_string(ord);
		string pres = to_string(pre);
		REP(i, 6-pres.size()) cout << '0';
		cout << pres;
		REP(i, 6-ords.size()) cout << '0';
		cout << ords;
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 11892
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ordered_set_ii tree<pair<int,int>,null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_set_int tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define MP make_pair
#define pb push_back
#define FS first
#define SC second
#define INF (1e9+7)

typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef long long ll;
typedef pair<long long,int> pli;

int maxn = 200000;

int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    int ans = int(ceil(double(n)/double(x))) * t ;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3556
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
    
// ここから
function main(){
  var intInput = new Int32Array(input);
  var primeNumbers = calcPrimeNumbers();
  for(var i = 0, len = input.length - 1; i < len; i++){
    console.log(primeNumbers[intInput[i]]);
  }
   
     
}
   
function calcPrimeNumbers(){
  var max = 999999;
  var primeNumbers = new Int32Array(max + 1);
   
  // 除外
  primeNumbers[0] = primeNumbers[1] = 0;// あえて0,1を素数とみなす
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
       
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
   
   for(var i = 2; i <= max; i++){
     // と、ここがこうなる
     primeNumbers[i] = primeNumbers[i-1] - primeNumbers[i] + 1;
  }
     
  return primeNumbers;
}

Measured memory_bytes: 12588
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

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

  cin >> X; 
         if (400  <= X and X <= 599)  cout << 8; 
    else if (600  <= X and X <= 799)  cout << 7; 
    else if (800  <= X and X <= 999)  cout << 6; 
    else if (1000 <= X and X <= 1199) cout << 5; 
    else if (1200 <= X and X <= 1399) cout << 4; 
    else if (1400 <= X and X <= 1599) cout << 3; 
    else if (1600 <= X and X <= 1799) cout << 2; 
    else if (1800 <= X and X <= 1999) cout << 1; 
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
void fin(int n){
  cout<<n<<endl;
  exit(0);
}
const int inf=1e7;
//main
signed main(){
  string s,t;cin>>s>>t;
  int S=s.size(),T=t.size();
  string K;while(K.size()<T)K+=s;K=t+"#"+K+s+s;
  //cout<<K<<endl;
  std::vector<int> A(inf,-1);
  int j=-1;
  for(int i=0;i<K.size();i++){
    while(j>=0&&K[i]!=K[j])j=A[j];
    j++;
    A[i+1]=j;
  }
  std::vector<int> match(inf,0);
  for(int i=0;i<S;i++)if(A[2*T+S+i]==T)match[i]++;
  std::vector<int> d(inf),edge[inf];
  for(int i=0;i<S;i++)if(match[i])edge[i].push_back((i+T)%S);
  std::vector<int> si(inf,0);
  for(int i=0;i<S;i++)for(int p:edge[i])si[p]++;
  queue<int> que;
  for(int i=0;i<S;i++)if(si[i]==0)que.push(i);
  int ans=0;
  while(que.size()){
    int p=que.front();que.pop();
    for(int q:edge[p]){
      d[q]=max(d[q],d[p]+1);ans=max(ans,d[q]);
      if(--si[q]==0)que.push(q);
    }
  }
  //for(int i=0;i<30;i++)cout<<A[i]<<" ";cout<<endl;
  //for(int i=0;i<S;i++)for(int p:edge[i])cout<<i<<" "<<p<<endl;
  for(int i=0;i<S;i++)if(si[i])fin(-1);
  fin(ans);
}

/*
解説AC
snukeさんの記事でMP法を理解、とりあえずコードはそのままはっつけた
さらにmatchの作り方まで聞いて、最長パスはどうやるのかも軽く聞いてようやくAC
学べることが多くてすごい楽しかった
残りのやり方も理解しなくては
*/


Measured memory_bytes: 566156
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(){
    int n,m; cin >> n >> m;
    vector<ll> x(m);
    rep(i,m) cin >> x[i];

    sort(x.begin(),x.end());
    vector<ll> dx(m-1);
    rep(i,m-1){
        dx[i] = x[i+1] - x[i];
    }

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

    ll ans = 0;
    rep(i,m - n){
        ans += dx[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N =  INT()
a = LIST()

print(sum(a)-N)


Measured memory_bytes: 5460
#include<bits/stdc++.h>
using namespace std;
int f(int x,int y,int z){
    return (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
}
int a[100007];
int main()
{
    int n;
    cin>>n;
    int n1=sqrt(n);
    for(int i=1;i<=n1;i++){
        for(int j=1;j<=n1;j++){
            for(int k=1;k<=n1;k++){
                int x=f(i,j,k);
                 a[x]++;
            }
        }
    }
    for(int i=1;i<=n;i++) cout<<a[i]<<endl;
    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  cout << a + a*a + a*a*a << endl;
  
  return 0;
}



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

struct Point{
  double x,y;

  Point(double x = 0,double y = 0) : x(x), y(y) {}

  Point operator + (const Point &p)const{
    return Point(x + p.x , y + p.y);
  }

  Point operator - (const Point &p)const{
    return Point(x - p.x , y - p.y);
  }

  Point operator * (const double &k)const{
    return Point(x * k , y * k);
  }

  Point operator / (const double &k)const{
    return Point(x / k , y / k);
  }
  double norm(){
    return x*x + y*y;
  }
  double dot(const Point &p)const{
    return x*p.x + y*p.y;
  }
};
typedef Point Vector;

struct Segment{
  Vector s, t;

  Segment(){}
  Segment(Vector s, Vector t) : s(s), t(t) {}

  Point Projection(Point p){
    Vector base = t - s;
    double t = (p-s).dot(base) / base.norm();
    return s + base*t;
  }
  Point Reflection(Point p){
    return p + (Projection(p) - p) * 2.0;
  }
};

int main(){
  Point p1, p2, p3;
  int q;

  std::cin >> p1.x >> p1.y >> p2.x >> p2.y >> q;
  Segment s = Segment(p1, p2);
  for(int i = 0 ; i < q ; i++){
    std::cin >> p3.x >> p3.y;
    Point p = s.Reflection(p3);
    printf("%.10f %.10f\n",p.x ,p.y);
  }

  return 0;
}

Measured memory_bytes: 1248
from bisect import *

def sieve(n):
    a = range(n)
    a[:2] = None, None
    for i in range(2, n):
        if i ** 2 >= n: break
        if not a[i]: continue
        for i in range(i ** 2, n, i):
            a[i] = None
    return [v for v in a if v]

try:
    a = sieve(90000)
    while True:
        n = int(raw_input())
        i = bisect_right(a, n)
        print a[i - (2 if a[i - 1] == n else 1)], a[i]
except EOFError:
    pass

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

ll keta(ll x){
    ll res = 0;
    while(x > 0){
        x/=10;
        res++;
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    ll ans = keta(n);
    for(ll i = 1; i*i <= n; ++i){
        if(n%i!=0) continue;
        ll t = n/i;
        ll k = max(keta(t), keta(i));
        ans = min(ans, k);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int N,M;
  string s;
  
  char c2[10001];
  
  cin >> N;
  cin >> s;
  
  const char *c1 = s.c_str();
  M = s.length();
  rep(i,M) c2[i] = c1[i];
  
  rep(i,M){
    c2[i]+=N;
    if(c2[i]>'Z') c2[i]-=26;
    cout << c2[i];
  }
  
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
ll r1,r2;
ll chck(ll x,ll y)
{
    ll A=5,B=5*x*x,C=x*x*x*x;
    C-=y;
    r1=-1,r2=-1;
    ll root=(B*B-(4*A*C));
    ll sq_rt = sqrtl(root);
    if((sq_rt*sq_rt)==root)
    {
        r1=-B+sq_rt;
        r2=-B+sq_rt;
        if(r1%10==0)
        r1/=10;
        else
        r1=-1;
        if(r2%10==0)
        r2/=10;
        else
        r2=-1;
    }
    if(r1!=-1)
    {
        // cout<<r1<<endl;
        ll org_a,org_b,tot;
        tot=(x*x)+(4*r1);
        ll tot1=sqrtl(tot);
        if((tot1*tot1)==tot && (tot1+x)%2==0 && (tot1-x)%2==0){
        org_a=(tot1+x)/2;
        org_b=(tot1-x)/2;
        cout<<org_a<<' '<<org_b<<endl;
        return 1;
        }
    }
    if(r2!=-1)
    {
        // cout<<r2<<endl;
        ll org_a,org_b,tot;
        tot=(x*x)+(4*r2);
        ll tot1=sqrtl(tot);
        if((tot1*tot1)==tot && (tot1+x)%2==0 && (tot1-x)%2==0){
        org_a=(tot1+x)/2;
        org_b=(tot1-x)/2;
        cout<<org_a<<' '<<org_b<<endl;
        return 1;
        }
    }
    return 0;
}
int main()
{
    IO
    ll X;
    cin>>X;
    for(ll i=1;i*i<=X;i++)
    {
        if(X%i==0)
        {
            ll p=(i),q=(X/i);
            if(chck(p,q)==1)
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3696
#include<cstdio>

int main() {
  int num[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int in;
  scanf("%d", &in);
  printf("%d\n", num[in-1]);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    rep(i,0,S.size()-1){
        if(S[i] == S[i+1]){
            print("no");
            return 0;
        }
    }
    print("yes");
}

Measured memory_bytes: 256
import numpy as np
#int(input())
n=int(input())
ae=[]
for _ in range(5):
    ae.append(int(input()))
ae=np.array(ae)
min_ae=min(ae)
num_ae=-(-n//ae)-1
#num_ae=-(-ae//min_ae)
print(5+max(num_ae))

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

int main()
{
    int n,a;
    cin>>n;
    set<int> st;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        st.insert(a);
    }
    if(st.size()==n)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}


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

int main(){
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	if(a == 0) cout << 1 << endl;
	if(b == 0) cout << 2 << endl;
	if(c == 0) cout << 3 << endl;
	if(d == 0) cout << 4 << endl;
	if(e == 0) cout << 5 << endl;
	return 0;
}


Measured memory_bytes: 3164
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node
{
    int key;
    Node *right, *left, *parent;
};

Node *NIL, *root;

void insert(int key){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->left = NIL;
    z->right = NIL;
    while (x != NIL)
    {
        y = x;
        if (z->key < x->key)
        {
            x = x->left;
        }
        else
        {
            x = x->right;
        }
    }
    z->parent = y;

    if (y == NIL)
    {
        root = z;
    }
    else {
        if (z->key < y->key)
        {
            y->left = z;
        }
        else
        {
            y->right = z;
        }
        
    }
}

void preorder(Node *root){
    if(root == NIL) return;
    cout << " " << root -> key;
    preorder(root->left);
    preorder(root->right);
}

void Inorder(Node *root){
    if(root == NIL) return;
    Inorder(root->left);
    cout << " " << root -> key;
    Inorder(root->right);
}

int main(){
    int n, key;
    string com;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> com;
        if (com[0] == 'i')
        {
            cin >> key;
            insert(key);
        }
        else
        {
            Inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
        
    }
    

}


Measured memory_bytes: 26504
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveA();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		int n = 0;
		while (true) {
			if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
				System.out.println(n);
				return;
			}
			if (a == b && b == c) {
				System.out.println("-1");
				return;
			}
			n++;
			long nextA = (b + c) / 2;
			long nextB = (a + c) / 2;
			long nextC = (a + b) / 2;
			a = nextA;
			b = nextB;
			c = nextC;
		}
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int h,n;
    cin>>h>>n;
    int a[n];
    int s=0;
    for(int x=0;x<n;x++){
        cin>>a[x];
        s+=a[x];
    }
    if(s>=h){
        cout<<"Yes";
    }else{
        cout<<"No";
    }








	
return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))

a.sort()
b.sort()
c=0
for i in b:
    right=n
    left=0
    while left<right:
        mid=(left+right)//2
        if a[mid]==i:
            c=c+1
            break
        elif i<a[mid]:
            right=mid
        else:
            left=mid+1
        
print(c)


Measured memory_bytes: 16708
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int K;
	cin>>K;
	print(K/3);
	return 0;
}




Measured memory_bytes: 764
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
    ll A[3];
    for(int i=0;i<3;i++){
      cin >> A[i];
      if(A[i]%2==0){
        cout << 0 <<endl;
        return 0;
      }
    }
    sort(A, A+3);

    cout << A[0]*A[1] <<endl;


  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))



ll h;
ll w;
ll k;
vector <vector <ll>> m;
vector <vector <ll>> ruiseki;
vector <pair<ll,ll>> tugis = {{0,1}, {1,0}, {-1,0}, {0,-1}};





ll solve(vector<ll> h_kiremes){
    ll start_w = 0;
    ll end_w = 0;
    vector <ll> yoko_kire;
    ll cnt = 0;
    while(end_w <= w){
        bool flg = true;
        REP(i, h_kiremes.size()-1){
            ll h_ue = h_kiremes[i];
            ll h_dame = h_kiremes[i+1];
            ll num = 0;
            for(int hh=h_ue; hh<h_dame; hh++){
                num += ruiseki[hh][end_w] - ruiseki[hh][start_w];
            }
            if (num > k){
                if(end_w - start_w == 1){
                    return 1e9;
                }
                start_w = end_w-1;
                cnt++;
                yoko_kire.push_back(start_w-1);
                flg=false;
            }
        }

        if (flg){
            end_w++;
        }
    }
    return cnt +  h_kiremes.size() - 2;
}



int main(void){
    cin >> h;
    cin >> w;
    cin >> k;
    REP(i, h){
        string s; cin >> s;
        vector <ll> row;
        for(auto c: s){
            row.push_back(c-'0');
        }
        m.push_back(row);
    }
    REP(i, h){
        vector <ll> row = {0};
        for(auto n: m[i]){
            row.push_back(row[row.size()-1] + n);
        }
        ruiseki.push_back(row);
    }
    ll ans = 1e9;
    REP(i, pow(2, h-1)){
        vector <ll> kiremes = {0};
        ll cnt = 1;
        ll num = i;
        while(num > 0){
            if (num%2 == 1){
                kiremes.push_back(cnt);
            }
            num /= 2;
            cnt++;
        }
        kiremes.push_back(h);
        ll cand = solve(kiremes);
        ans = min(cand, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  ll S;
  cin>>S;
  ll X,Y,XX,YY;
  if(S==1000000000000000000){
    X=1000000000;
    XX=0;
    Y=0;
    YY=X;
  }
  else{
    XX=sqrt(S)+1;
    Y=XX;
    if(XX==YY*(XX*Y-S)){
      XX+=1;
      X=XX*Y-S;
      YY=1;
    }
    else{
      YY=XX*Y-S;
      X=1;
    }
  }
  cout<<X<<" "<<Y<<" "<<XX<<" "<<YY<<" "<<0<<" "<<0<<endl;
}


Measured memory_bytes: 256
K, S = map(int, input().split())
c = 0
for x in range(K + 1):
    if x > S:
        continue
    for y in range(S - x + 1):
        if y > K:
            break
        z = S - x - y
        if 0 <= z <= K:
            c += 1
print(c)

Measured memory_bytes: 8976
#include <bits/stdc++.h>
#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++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int Inf = 1e9;
const double EPS = 1e-9;



int main()
{
  int w, h, n ;
  cin >> w >> h >> n ;
  vector<pair<pair<int,int>,int>> vec(n) ;
  REP(i,n){
    int a, b, c ;
    cin >> a >> b >> c ;
    vec.at(i) = make_pair(make_pair(a,b),c) ;
  }
  int wb = w ;
  int ws = 0 ;
  int hb = h ;
  int hs = 0 ;
  
  REP(i,n){
    int a = vec.at(i).F.F ;
    int b = vec.at(i).F.S ;
    int c = vec.at(i).S ;
    if(c == 1){
      ws = max(ws,a) ;
    }
    else if(c==2){
      wb = min(wb,a) ;
    }
    else if(c==3){
      hs = max(hs,b) ;
    }
    else{
      hb = min(hb,b) ;
    }
  }
  
  cout <<max(hb-hs,0)*max(wb-ws,0) <<endl ;

  return 0 ;
}




Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class agc024c {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            in >> A[i];
        }
        for (int i = 0; i < N; ++i) {
            if (A[i] > i) {
                out << -1 << "\n";
                return;
            }
        }
        vector<int> X(N, 0);
        long long res = 0;
        int add = 0;
        for (int i = N - 1; i >= 0; --i, --add) {
            add = max(add, 0);
            X[i] += add;
            if (X[i] > A[i]) {
                out << -1 << "\n";
                return;
            } else if (X[i] < A[i]) {
                add = A[i];
                res += A[i];
                X[i] = A[i];
            }
        }
        if (add > 0) {
            out << -1 << "\n";
        } else {
            out << res << "\n";
        }
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	agc024c solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1792
N, M = [ int(x) for x in input().split() ]
ab_s = [ [ int(x) for x in input().split() ] for _ in range(M) ]

ans = []
for i in range(N):
    n = 0
    for j in range(M):
        a, b = ab_s[j]
        if a == (i + 1) or b == (i + 1):
            n += 1
    ans.append(n)

print("\n".join(map(str, ans)))
    


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
    string str;
    getline(cin, str);

    for(int i=0; i<str.size(); i++){
        if('a'<= str.at(i) && str.at(i) <='z'){
            str.at(i) -= 32;
        }
        else if('A'<= str.at(i) && str.at(i) <='Z'){
            str.at(i) += 32;
        }
    }

    cout << str << endl;
    return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

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


void solve(){
	int n;
	cin >> n;
	int a[n+1];
	int ans = 0;
	for(int i =1;i<=n;i++){
		cin >> a[i];
		if(i%2==1 && a[i]%2==1)
			ans++;
	}
	cout << ans << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3648
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int n , m , q, a[maxn], b[maxn], c[maxn], d[maxn];
ll ans;
int zz[maxn];
void dfs(int num, int pre){
    if(num == n+1){
        // cout << "ks " << endl;
        ll tp = 0;
        for(int i =1 ; i <= q;i++)if(zz[b[i]]-zz[a[i]] == c[i])tp += d[i];
        ans = max(ans, tp);
        return ;
        // cout << "ans == " << ans << endl;
    }
    for(int i = pre; i <= m; i++){
        zz[num] = i;
        dfs(num+1, i);
    }
}
int main()
{
    cin >> n  >> m >> q;
    for(int i = 1; i <= q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(0,1);
    cout << ans << endl;
}

Measured memory_bytes: 3224
#include<stdio.h>
int main(void){
	int H,W,i,j;
	
	while(1){
		scanf("%d %d",&H,&W);
		if(W==0&&H==0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
K = int(input())
g_list = []
k_list = []

for i in range(1, K+1):
    if i%2 == 0:
        g_list += [i]
    elif i%2 == 1:
        k_list += [i]

g_len = len(g_list)
k_len = len(k_list)
print(g_len*k_len)




Measured memory_bytes: 2940
h,w,k=map(int,input().split())
c=[]
for i in range(h):
    cc=input()
    c.append(cc)
ans=0
for i in range(1<<h):
    for j in range(1<<w):
        b=0
        for ii in range(h):
            for jj in range(w):
                if(((i>>ii)&1)==0 and ((j>>jj)&1)==0):
                    if(c[ii][jj]=="#"):b+=1
        if(b==k):ans+=1

print(ans)        

Measured memory_bytes: 73684
#include<iostream>
using namespace std;
#define MAX 10050

#define FAULT 0
#define SAFE 1
#define UNDEFD 2

int main(){
	while(true){
		int a,b,c;
		int rep_i[MAX], rep_j[MAX], rep_k[MAX], rep_res[MAX];
		int st[MAX];
		int n;
		scanf("%d%d%d", &a, &b, &c);
		if( a==0 && b==0 && c==0 )break;
		scanf("%d", &n);

		for(int i = 0; i < MAX; ++i){
			st[i] = UNDEFD;
		}

		for(int t = 1; t <= n; ++t){
			int i,j,k,r;
			scanf("%d%d%d%d", &i,&j,&k,&r);
			rep_i[t] = i; rep_j[t] = j; rep_k[t] = k; rep_res[t] = r;
			if( r == 1 ){
				st[i] = SAFE; st[j] = SAFE; st[k] = SAFE;
			}
		}

	
		for(int t = 1; t <= n; ++t){
			int i = rep_i[t], j = rep_j[t], k = rep_k[t], r = rep_res[t];

			if( st[i] == SAFE && st[j] == SAFE && st[k] == SAFE )
				continue;
			if( st[i] == FAULT || st[j] == FAULT || st[k] == FAULT )
				continue;
			
			if( st[i] == SAFE && st[j] == SAFE ){
				st[k] = FAULT;
			}else if( st[i] == SAFE && st[k] == SAFE ){
				st[j] = FAULT;
			}else if( st[j] == SAFE && st[k] == SAFE ){
				st[i] = FAULT;
			}
		}

		for(int i = 1; i <= a+b+c; ++i){
			printf("%d\n", st[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#knapsack2
n,w=map(int,input().split())
data=[]
for i in range(n):
    u,v=map(int,input().split())
    data.append((u,v))
inf=10**20
pack_min=[[10**20 for i in range(10**5+1)]for _ in range(101)]
#pack_min[i][j]=i番目の荷物までを使って、価値の値をｊにするために必要な重さの最小の値、不可能ならinf
for i in range(101):
    pack_min[i][0]=0
    #価値の値を0にするために必要な重さの最小の値は0である
for i in range(n):
    a,b=data[i][0],data[i][1]
    #a,bはそれぞれ重さ、価値を表すものである
    for j in range(10**5+1):
        if j>=b:
            pack_min[i+1][j]=min(pack_min[i][j],pack_min[i][j-b]+a)
        else:
            pack_min[i+1][j]=pack_min[i][j]

        
ans=0

for i in range(10**5+1):
    if pack_min[n][i]<=w:
        try:
            ans=i
        except:
            break
print(ans)



Measured memory_bytes: 173896
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

// naive
ll solve(int N, map<int,int>& M) {
    int res = 0;
    ll wa = 0;
    for (auto x = M.begin(); x != M.end(); x++) {
        wa += x->first * x->second;
        auto n = next(x);
        if (n == M.end()) { // right next is not there
            res += x->second;
            break;
        }
        ll cur = wa; // You can eat every smaller animals
        while (n != M.end()) {
            if (cur * 2 >= n->first) cur += n->first;
            else goto LOOP;
            n = next(n);
        }
        res += x->second;
LOOP: ;
    }
    return res;
}

// right answer
ll solve2(int N, map<int,int>& M) {
    int res = 0;
    ll wa = 0;
    for (auto x : M) wa += (ll)x.first * x.second;

    for (auto x = M.rbegin(); x != M.rend(); x++) {
        wa -= (ll)x->first * x->second;
        res += x->second;
        if (wa *2 < x->first) break;
    }
    return res;
}

// editorial
ll solve3(int N, map<int,int>& M) {
    ll wa = 0;
    ll cnt = 0;
    ll ma = 0;
    for (auto x = M.begin(); x != M.end(); x++) {
        ll k = x->first, v = x->second;
        cnt += v;
        wa += (ll) k * v;
        auto n = next(x);
        if (n == M.end()) break;
        if (2 * wa < n->first) {
            if (ma < cnt) ma = cnt;
            continue;
        }
    }
    return N - ma;
}

int main() {
    int N; cin >> N;
    map<int, int> M;
    rep(i,N) {
        int a; cin >> a;
        M[a]++;
    }

    cout << solve3(N, M) << endl;
}


Measured memory_bytes: 8288
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;

int n, m, a, b;
int c[N][N];
char s[N];

int main() {
    cin >> n >> m >> a >> b;
    for (int i = 1; i <= (n - b); ++i)
        for (int j = 1; j <= a; ++j) c[i][j] = 1;
    for (int i = (n - b + 1); i <= n; ++i)
        for (int j = a + 1; j <= m; ++j) c[i][j] = 1;
    for (int i = 1; i <= n; ++i, puts(""))
        for (int j = 1; j <= m; ++j) cout << c[i][j];
    return 0;
}

Measured memory_bytes: 5120
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int L = sc.nextInt();
  String[] s = new String[N];
  for(int i = 0;i < N;i++){s[i] = sc.next();}
  Arrays.sort(s);
  for(int i = 0;i < N;i++){System.out.print(s[i]);}
}}

Measured memory_bytes: 22100
#!/usr/bin/env python3

from collections import Counter

N, M = map(int, input().split())
PY = [ (i, P, Y) for i, (P, Y) in enumerate([map(int, input().split()) for _ in range(M)])]

answers = [0 for x in range(M)]
counter = Counter()

for index, P, Y in sorted(PY, key = lambda x : x[2]):
    counter[P] += 1
    answers[index] = "{:06}{:06}".format(P, counter[P])

print("\n".join(answers))

Measured memory_bytes: 60640
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
/*
struct cmp{
bool operator()(const pii &a,const pii &b)
{
    if(a.first==b.first) return a.second<b.second;///second value small to big
    else return a.first>b.first;///first value big to small
}
};
///in pq true means swap required  ,false means swap  not required...
set<pii,cmp>st;
priority_queue<pii,deque<pii>,cmp>pq;
*/
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll a,b,c,d;
     cin>>a>>b>>c>>d;
     ll ans=max({a*c,a*d,b*c,b*d});
     cout<<ans<<endl;
}




Measured memory_bytes: 3652
#include <stdio.h>
 
int main()
{
  int n1,n2,n3;
  
  scanf("%d%d%d", &n1, &n2, &n3);
  
  if(n1==n2 && n1==n3){
    puts("No");
  }else if(n1!=n2 && n1!=n3 && n2!=n3){
    puts("No");
  }
  else
    puts("Yes");
  
  return 0;
}

Measured memory_bytes: 1576
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
using namespace std;

int main() {
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;

    double xdis=pow((x1-x2),2);
    double ydis;
    ydis = pow((y1 - y2), 2);

    double dis=sqrt(xdis+ydis);


    printf("%.10f",dis);







    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>

int main()
{
    long N;
    std::cin >> N;
    long ki=std::ceil((double)N/2.0);
    double per=(double)ki/(double)N;
    std::cout << per << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a,b,i,f=0;
	scanf("%d%d",&a,&b);
	if(b/100>0)a=a*1000+b;
	else if(b/10>0)a=a*100+b;
	else a=a*10+b;
	for(i=1;i<1000;i++){
		if(i*i==a){
			f=1;
			break;
		}
	}
	if(f==0)puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 128
def mulmod(x, y, mod=10**9 + 7):
    return x * y % mod


def comb(n, k, mod=10**9 + 7):
    from functools import reduce
    k = min(k, n - k)
    x = reduce(mulmod, range(n - k + 1, n + 1), 1)
    y = reduce(mulmod, range(1, k + 1), 1)
    return x * pow(y, mod - 2, mod) % mod


def solve(string):
    n, m, k = map(int, string.split())
    mod = 10**9 + 7
    base = n * m * (n + m) * (n * m - 1) // 6 % mod
    return str(base * comb(n * m - 2, k - 2) % mod)


if __name__ == '__main__':
    print(solve(input()))


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

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

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

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) {
  for (auto &e : vec) cout << e << " \n"[&e==&vec.back()];
}

template <class T>
void OUTS(vector<vector<T>> &df) {
  for (auto &vec : df) OUTS(vec);
}

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) {
  for (auto &e : vec) cout << e << "\n";
}

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  VAR(int, n);
  double res = 0.0;
  rep(i, n) {
    VAR(double, a);
    res += (1.0 / a);
  }
  Float(12);
  OUTL(1.0 / res);
  return 0;
}


Measured memory_bytes: 256