akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  if(x1==x2){
    cout<<0<<endl;
    return 0;
  }
  cout<<1<<endl;
  return 0;
}

Measured memory_bytes: 256
def matcher(s1,s2):
    match=0
    for i in range(len(s1)):
        if(s1[i]!=s2[i]):
            match+=1
            
    return match

#print(matcher("eforces","atcoder"))

s = input()
st = input()
mx=10**5

rangeforloop= len(s)+1 - len(st)
 
for i in range(rangeforloop):
    mx=min(mx,matcher(s[i:len(st)+i], st))
    
     
print(mx)

Measured memory_bytes: 9052
# -*- coding: utf-8 -*-
# C

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

N, K, Q = map(int, input().split())
d = [0] * N
for _ in range(Q):
    a = int(input())
    d[a-1] += 1

for i in range(N):
    # print(K - Q + d[i])
    if K - Q + d[i] >0:
        print('Yes')
    else:
        print('No')


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

#define Pair make_pair
#define Push push_back
typedef long long lli;
typedef pair<lli,lli> pll;
typedef vector<lli> vcL;
typedef vector<pll> vPL;

bool cmp(pll x, pll y) {
	return x.second > y.second;
}

void solve() {
	lli n, m;
	cin >> n >> m;

	vcL A( n, 0 );
	vPL BC( m, Pair( 0, 0 ) );

	for (int i = 0; i < n; ++i) {
		cin >> A[i];
	}
	
	for (int i = 0; i < m; ++i) {
		cin >> BC[i].first >> BC[i].second;
	}
	
	sort( A.begin(), A.end() );
	sort( BC.begin(), BC.end(), cmp );
	
	bool flag = true;
	int tok = 0;
	
	for (int i = 0; i < m and flag; ++i) {
		for (int j = 0; j < BC[i].first; ++j) {
			if ( BC[i].second >= A[tok] ) A[ tok++ ] = BC[i].second;
			else flag = false;
		}
	}
	
	lli ans = 0;
	
	for (auto x : A) ans += x;
	
	cout << ans << '\n';
	
	return;
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 2560
import java.util.*;

public class Main{
  public static void main (String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();

     for (int i = 0; i < K; i++) {
       if (i % 2 == 0) {
         B += A / 2;
         A /= 2;
       } else {
         A += B / 2;
         B /= 2;
       }
     }
    System.out.println(A);
    System.out.println(B);
  }
}
      
    

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

int main(){
    string s;
    cin>>s;
    int one=0;
    int zero=0;
    rep(i,s.size()){
        if(s[i]=='0')zero+=1;
        else one+=1;

    }
    int aho=min(one,zero);
    int ans=aho*2;
    cout<<ans<<endl;
}

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

#define pb push_back

struct Vector {
  int x, y;
  Vector() {}
  Vector(int x, int y) : x(x), y(y) {}
  
  double norm() {
    return x*x + y*y;
  }
};

typedef vector<Vector> vv;

Vector rotate90R(Vector v) {
  return Vector(-v.y, v.x);
}

int lcm(int a, int b) {
  return (a*b)/__gcd(a, b);
}

bool isEqVecs(vv vv1, vv vv2) {
  int a, b, l;
  l = lcm(vv1[0].norm(), vv2[0].norm());
  a = l / vv1[0].norm(); // テ・ツ?催ァツ篠?
  b = l / vv2[0].norm();
  
  if(vv1.size() != vv2.size()) return false; // テ」ツδ凖」ツつッテ」ツδ暗」ツδォテ」ツ?ョテヲツ閉ーテ」ツ?古ァツ閉ーテ」ツ?ェテ」ツつ?
  
  bool isok = true;
  // テヲツッツ氾ァツ篠?」ツ?古ッツシツ敕」ツ?凝ィツェツソテ」ツ?ケテ」ツつ?
  for(int i=0; i<vv1.size(); i++) {
    if(!(vv1[i].x * a == vv2[i].x * b
	 && vv1[i].y * a == vv2[i].y * b)) isok = false;
  }
  
  return isok;
}

int main() {
  int n;
  
  // input data
  while(cin >> n && n) {
    vv vvec[51][8];
    int id2m[51];
    Vector data[51];

    for(int id=0; id<=n; id++) {
      cin >> id2m[id];
      for(int j=0; j<id2m[id]; j++) {
	cin >> data[j].x >> data[j].y;
      }
      
      for(int j=1; j<id2m[id]; j++) {
	Vector V1(data[j].x-data[j-1].x, data[j].y-data[j-1].y);
	Vector V2(-(data[id2m[id]-1-j].x-data[id2m[id]-j].x), -(data[id2m[id]-1-j].y-data[id2m[id]-j].y));
	vvec[id][0].pb(V1);
	vvec[id][1].pb(rotate90R(vvec[id][0][j-1]));
	vvec[id][2].pb(rotate90R(vvec[id][1][j-1]));
	vvec[id][3].pb(rotate90R(vvec[id][2][j-1]));
	
	vvec[id][4].pb(V2);
	vvec[id][5].pb(rotate90R(vvec[id][4][j-1]));
	vvec[id][6].pb(rotate90R(vvec[id][5][j-1]));
	vvec[id][7].pb(rotate90R(vvec[id][6][j-1]));
      }
      
      /*
	for(int k=0; k<4; k++) {
	for(int v_i=0; v_i<id2m[id]-1; v_i++) {
	cout << vvec[id][k][v_i].x << ' ' << vvec[id][k][v_i].y << endl;
	}
	}
      */
    }
    
    for(int i=1; i<=n; i++) {
      // Obj(id = 0) テ」ツ?ィ Obj(for all except id = 0) * 8 テ」ツ?ィテ」ツ?ョテ、ツクツ?ィツ?エテ」ツつ津ィツェツソテ」ツ?ケテ」ツつ?
      for(int k=0; k<8; k++) {
	if(isEqVecs(vvec[i][k], vvec[0][0])) {
	  cout << i << endl;
	}
      }
    }
    cout << "+++++" << endl;
  }
    
  return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
   ll arr[]={0,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},n,m;
   scanf("%lld",&n);
   printf("%lld\n",arr[n]);
}


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

int main()
{
    int a, b, c, five = 0, seven = 0;
    cin >> a >> b >> c;

    if(a == 5)
        five++;
    if(b == 5)
        five++;
    if(c == 5)
        five++;

    if(a == 7)
        seven++;
    if(b == 7)
        seven++;
    if(c == 7)
        seven++;

    if(five == 2 && seven == 1)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    ll period;
    ll count = 0;
    rep(i, n) {
        cin >> a[i];
        if (i == 0) {
            period = a[i];
            ll num = a[i];
            while (!(num & 1)) {
                num >>= 1;
                count++;
            }
            continue;
        }
        period = lcm(period, a[i]);
        ll num = a[i];
        ll cnt = 0;
        while (!(num & 1)) {
            num >>= 1;
            cnt++;
        }
        if (cnt != count || period > (m << 1)) {
            cout << 0 << endl;
            return 0;
        }
    }
    // if (seeds == 1) {
    //     cout << 0 << endl;
    //     return 0;
    // }
    // cout << seeds << endl;
    // cout << period << endl;
    ll ans;
    if (m >= (period >> 1)) {
        ans = 1;
        m -= period >> 1;
        ans += m / period;
    } else
        ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
int main(){
    Fast;
    char ch;
    cin>>ch;
    if(ch>='a' && ch<='z'){
        cout<<"a"<<endl;
    }
    else{
        cout<<"A"<<endl;
    }

}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,x,a[2],cur;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>m>>x;
    for(ll i=1;i<=m;i++)cin>>cur,a[cur<x]++;
    cout<<min(a[0],a[1]);
}

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

int main(void) {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    
    ll ans = 0;
    for (int i=1; i<a.size(); i++) {
        if (a[i] < a[i-1]) {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4788
n, m = map(int,input().split())

A = []
for _ in range(n):
	A.append(list(map(int, input().split())))

b = []
for _ in range(m):
	b.append(int(input()))

for i in range(n):
	sum = 0
	for j in range(m):
		sum += A[i][j]*b[j]
	print(sum)


Measured memory_bytes: 6008
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int ans =0;
  for(int i=0 ;i<n; ++i)
  {
    int k;
    cin >> k;
    while (k%2==0)
    {
      ans++;
      k>>=1;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	string s;
	int x,y;
	vector<int> Z,X,Y;
	
	cin >> s >> x >> y;
	int count = 0;
	int len = s.length();
	
	REP(i,len){
		if (s[i] == 'T'){
			Z.PB(count);
			count = 0;
		}else{
			count++;
		}
	}
	Z.PB(count);
	
	REP(i,Z.size()){
		if (i % 2 == 0) X.PB(Z[i]);
		else Y.PB(Z[i]);
	}
	
	bool flg = true;
	X.PB(0); Y.PB(0);
	
	
	static bool dp[8002][33000];
	REP(j,8002){REP(i,33000){dp[j][i] = 0;}}
	
	const int K = 16002;
	
	dp[0][K+X[0]] = true;
	FORq(i,1,X.size()-1){
		FORq(j,-8002,8002){
			
			if ((dp[i-1][j-X[i] + K]) or (dp[i-1][j+X[i] + K]) ){
				dp[i][j+K] = true;
			}
			
		}
	}
	
	if (!(dp[X.size()-1][x+K])) flg = false;
	
	REP(j,8002){REP(i,33000){dp[j][i] = 0;}}
	
	
	dp[0][K+Y[0]] = true;
	dp[0][K-Y[0]] = true;
	FORq(i,1,Y.size()-1){
		FORq(j,-8002,8002){
			
			if ((dp[i-1][j-Y[i] + K]) or (dp[i-1][j+Y[i] + K]) ){
				dp[i][j+K] = true;
			}
			
		}
	}
	
	if (!(dp[Y.size()-1][y+K])) flg = false;
	
	
	
	if (flg) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 258176
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 200005

ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

ll n,k;
ll a[maxn];

int check(ll len){
	ll res=0;
	for(int i=0;i<n;i++)
		res+=(a[i]-1)/len;
	return res<=k;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--){
		cin>>n>>k;
		ll l=0,r=1;
		for(int i=0;i<n;i++){
			cin>>a[i];
			r=max(r,a[i]);
		}
		ll ans=1e18;
		while(r-l>1){
			ll mid=(l+r)/2;
			if(check(mid)){
				r=mid;
				ans=min(ans,r);
			}
			else l=mid;
		}
		cout<<r;
	}
}

Measured memory_bytes: 5132
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AthleteProgramming
{
    class Program
    {
        static void Main()
        {

            while (true)
            {
                string str = Console.ReadLine();
                if (str == null)
                {
                    break;
                }
                int[] ab = str.Split(' ').Select(int.Parse).ToArray();
                int sum = ab[0] + ab[1];
                bool b = true;
                int i = 1;
                int count = 1;
                while (b)
                {
                    if (sum / i < 1)
                    {
                        b = false;
                        count -= 1;
                        Console.WriteLine(count);
                    }else
                    {
                        i *= 10;
                        count++;
                    }
                }
            }
        }

    }
}

Measured memory_bytes: 9508
import scala.io.StdIn._
object Main {
	def main(args :Array[String]) = {
		val Buff = readf("{0} {1} {2}").map(_.toString.toInt)
		if (Buff(0) < Buff(1)){
			if (Buff(1) < Buff(2)) println("Yes")
			else println("No")
		}
		else println("No")
	}
}

Measured memory_bytes: 43412
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <bits/stdc++.h>
#include <unistd.h>

using i64 = std::uint_fast32_t;

namespace io {
  constexpr int is = 1 << 17;
  char ib[is], *ip = ib + is, it;
  inline char getc() {
    if (ip == ib + is) { read(STDIN_FILENO, ib, is); ip = ib; }
    return *ip++;
  }
  inline i64 scan() {
    i64 r = 0;
    if (ip + 16 > ib + is) while ((it = getc()) & 16) r = r * 10 + it - '0';
    else while ((it = *ip++) & 16) r = r * 10 + it - '0';
    return r;
  }
}

signed main() {
  i64 h = io::scan();
  i64 n = io::scan();
  i64 s = 0;
  for (int i = 0; i < n; i++) {
    s += io::scan();
  }
  if (s >= h) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}

Measured memory_bytes: 384
n=int(input())
hs=input().rstrip().split(" ")
costs=[0 for i in range(n)]
costs[1]=abs(int(hs[1])-int(hs[0]))
for i in range(n-2):
    jump=costs[i]+abs(int(hs[i+2])-int(hs[i]))
    walk=costs[i+1]+abs(int(hs[i+2])-int(hs[i+1]))
    costs[i+2]=min(jump,walk)
print(costs[-1])

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

long int min(long int a, long int b){
    return a<b ? a:b;
}

int main(){
    long int N,A,B,C,D,E;
    scanf("%ld",&N);
    scanf("%ld",&A);
    scanf("%ld",&B);
    scanf("%ld",&C);
    scanf("%ld",&D);
    scanf("%ld",&E);
    long int kai[5]={0,0,0,0,0};
    long int max=0;
    kai[0] = N/A +4;
    kai[1] = N/B +4;
    kai[2] = N/C +4;
    kai[3] = N/D +4;
    kai[4] = N/E +4;
    int i=0;
    if(N%A!=0) kai[0]+=1;
    if(N%B!=0) kai[1]+=1;
    if(N%C!=0) kai[2]+=1;
    if(N%D!=0) kai[3]+=1;
    if(N%E!=0) kai[4]+=1;
    for(;i<5;i++){
        if(max<kai[i]) max = kai[i];
    }
    printf("%ld",max);
    return 0;
}

Measured memory_bytes: 128
class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1


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

ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if i == j:
            continue
        
        uf.unite(es[j][0], es[j][1])

    # 外した辺の両端が同じUnionでなければそれは橋
    if not uf.is_same(es[i][0], es[i][1]):
        ans += 1
        

print(ans)

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std; 

int main(void)
{   
    int n;
    cin >> n;
    v_int a(n), b(n);

    irep(i, n) {
        cin >> a[i];
        b[i] = a[i];
    }
    int k = 0;

    irep(i, n-1) {
        if(a[i] == i+1) {
            swap(a[i], a[i+1]);
            k++;
        }
    }

    irep(i, n-1) {
        if(a[n-i-1] == n-i) {
            a[n-i-1] = a[n-i-2];
            swap(a[n-i-1], a[n-i-2]);
            k++;
        }
    }
    #if 0
    irep(i, n) {
        printf("%d,", a[i]);
    }cout << endl;
    #endif
    cout << k << endl;
    return 0;
}
/** tcoder **/


Measured memory_bytes: 1024
//
// Created by ss250251 on 2/16/2020.
//

#include<bits/stdc++.h>
using namespace std;
#define INFL 1e18L + 7
#define MOD 1e9+7
template <typename T>
void max_self(T&a,T b){
    a = max(a,b);
}
template <typename T>
void min_self(T&a,T b){
    a = min(a,b);
}
template <typename T>
void add_self(T&a,T b){
    a +=b;
    if(a>=1e9+7){
        //a-=(1e9+7);
    }
}
template <typename T>
void sub_self(T&a,T b){
    a -=b;
    if(a<0){
        //a+=(1e9+7);
    }
}
using ll= long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    auto sm = [&](int l,int r){
        ll s =0;
        for(int i=l;i<=r;i++){
            s+=a[i];
        }
        return s;
    };
    vector<vector<ll>>dp(n,vector<ll>(n));
    for(int L=n-1;L>=0;L--){
        for(int R=L;R<n;R++){
            if(L!=R){
                dp[L][R] = INFL;
                ll s= sm(L,R);
                for(int i=L;i<R;i++){
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R]+s);
                }
            }
        }
    }
    cout<<dp[0][n-1];
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int N = 1e5 + 667;
char a[N];

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

    for(int i = 0;i<3;i++){
        cin >> a[i];
    }
    sort(a, a+3);
    if(a[0] == a[2]){
        cout << "No";
    }
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
//gauravsinghh
#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 ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999
#define lim 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < pair < ll, ll >, ll >&a,const pair < pair <ll, ll>, ll >&b){
    return (a.ff.ff > b.ff.ff ||(a.ff.ff == b.ff.ff && a.ss > b.ss));
}

signed main(){ 
    IOS
    //io_set();
    ll n;
    cin >> n;
    ll c = 0;
    string s;
    fo(i, 1, n){
        s = to_string(i);
        if(sz(s)&1){
            c++;
        }
    }
    cout << c << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

bool isprime(int n)
{
	for(int i = 2; i * i <= n; i++){
		if(n % i == 0) return false;
	}
	return true;
}

int main()
{
	int n;
	cin >> n;
	long long int result[1001][1001] = {};
	// result[i][j] : iをjで割れる回数
	for(int i = 1; i <= n; i++){
		result[i][1] = 1;
		// cout << i << " ";
		for(int j = 2; j <= i; j++){
			result[i][j] = 0;
			int tmp = i;
			while(tmp % j == 0){
				result[i][j]++;
				tmp = tmp / j;
			}
			// cout << result[i][j] << " ";
		}
		// cout << endl;
	}
	vector<long long int> tmpans;
	for(int i = 2; i <= n; i++){
		if(!isprime(i)) continue;
		// もしiが素数なら、個数数える
		long long int tmp = 0;
		for(int j = 1; j <= n; j++){
			tmp += result[j][i];
			tmp = tmp % mod;
		}
		tmpans.push_back(tmp);
	}
	long long int ans = 1;
	for(int i = 0; i < tmpans.size(); i++){
		ans = (ans * (tmpans[i] + 1)) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8064
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long ans;
		if (a == b) {
			ans = a;
        } else if (a == 0) {
			ans = function(b);
		} else {
			ans = function(a - 1) ^ function(b);
		}
		System.out.println(ans);
	}
	
	// 0からxまでの排他的論理和を計算する
	static long function(long x) {
		if (x % 2 == 0) {
			if (x % 4 == 0) {
				return x;
			} else {
				return x ^ 1L;
			}
		} else {
			if ((x + 1) % 4 == 0) {
				return 0;
			} else {
				return 1;
			}
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n,a[105],num=0;
int main()
{
	cin>>n;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	rep(i,n) rep2(j,i+1,n) rep2(k,j+1,n) if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i]) num++;
	re(num)
	return 0;}

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

int main(){
	int N;
	int V[20],C[20];
	int i;
	int temp;
	int total = 0;
	
	//入力
	cin >> N;
	
	for(i=0;i<N;i++)
	{
		cin >> V[i];
	}
	
	for(i=0;i<N;i++)
	{
		cin >> C[i];
	}
	
	for(i=0;i<N;i++)
	{
		temp = V[i]-C[i];
		
		if(temp > 0 )
		{
			total =total + temp; 
		}
	}
	
	//出力
	cout << total << endl;

	return 0;
}

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

int main(){
	int a, b;

	cin >> a;
	cin >> b;

	if(a < b){
		cout << "a < b" << endl;
	}else if(a > b){
		cout << "a > b" << endl;
	}else{
		cout << "a == b" << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    have = [False] * N
    ans = N
    for k in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            if not have[a-1]:
                ans -= 1
            have[a-1] = True
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9204
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		PriorityQueue<Integer> queue = new PriorityQueue<>();
		for (int i = 0; i < w; i++) {
		    queue.add(-sc.nextInt());
		}
		PriorityQueue<Integer> next = new PriorityQueue<>();
		for (int i = 0; i < h; i++) {
		    int count = sc.nextInt();
		    for (int j = 0; j < w; j++) {
		        if (j < count) {
		            if (queue.peek() == 0) {
		                System.out.println(0);
		                return;
		            }
		            next.add(queue.poll() + 1);
		        } else {
		            next.add(queue.poll());
		        }
		    }
		    PriorityQueue<Integer> tmp = next;
		    next = queue;
		    queue = tmp;
		}
		if (queue.peek() != 0) {
		    System.out.println(0);
		} else {
		    System.out.println(1);
		}
	}
}



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

using namespace std;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  for(int i=0;i<s.length();i++){
      s[i]=(s[i]-'A'+n)%26+'A';
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
typedef long long ll;
const ll mod = 1000000007;
using namespace std;

int main()
{
    long long N, ans = 0;
    cin >> N;
    for (int i = 1; i <= N; i++)
    {
        ans += ((N - 1) / i);
    }

    cout << ans;
}

Measured memory_bytes: 3504
#pragma once
#pragma once
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include <iomanip>
#define rep(i,n) for(auto i=0;i<(n);i++)
#define all(vs) (vs).begin(),(vs).end()
#define roundup(A,B) (A)/(B)+((A)%(B)==0?0:1)
#define read(type,name) type name;cin>>name
using namespace std;


/*
	3桁の数字からなる、重複を許す数字列はN^3パターンになる。O(1)
*/
void A() {
	read(int, i);
	cout << i * i * i << endl;
}

/*
 次の数字が連番である場合、追加でスコアが入る。そのため、直前の数字を記憶する必要がある。
 あとは情報を読み込んで配列を走査すればよい。空間量は今回削減できないと思われる。
*/
void B() {
	read(int, n);
	auto dishes = vector<int>(n);
	auto scores = vector<int>(n);
	auto bonus = vector<int>(n - 1);
	rep(i, n) cin >> dishes[i];
	rep(i, n) cin >> scores[i];
	rep(i, n - 1) cin >> bonus[i];
	auto prev = -1;
	int current;
	int result = 0;
	rep(i, n) {
		current = dishes[i];
		result += scores[current - 1];
		if (prev + 1 == current) result += bonus[prev - 1];
		prev = current;
	}
	cout << result << endl;
}

/*
 Bi>=max(Ai,A+1)が必ず満たされる。例えばB0はmax(A0,A1)以上の数字である。逆に言えば、A0とA1は最大でB0ということになる。
 となればA0とA1がともにB0であるとすれば最大である。一方で、B1がB0よりも小さい場合、A1はB1よりも小さくなければならないので
 A1をB0としてはならない。結局、Aiはmin(Bi-1,Bi)というのが最大になる。これを繰り返せばよい。O(n)の解法である。
*/
void C() {
	read(int, n);
	auto B = vector<int>(n - 1);
	rep(i, n - 1) cin >> B[i];
	int prevB = 100000000;
	int currentB;
	auto sum = 0;
	rep(i, n - 1) {
		currentB = B[i];
		sum += min(prevB, currentB);
		prevB = currentB;
	}
	//ラストはB１つで決まる。
	sum += currentB;
	cout << sum << endl;
}
void D() {

}
void E() {

}
void F() {

}



int main() {
	C();
}

Measured memory_bytes: 3592
import java.util.Scanner;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		int a;
		a = input.nextInt();
		System.out.println((int)(a + Math.pow(a,2) + Math.pow(a,3)));
	}
}


Measured memory_bytes: 35348
fn main() {
    let mut t_s: Vec<usize> = Vec::new();

    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    t_s.push(buf.trim().parse().unwrap());
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    t_s.push(buf.trim().parse().unwrap());
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    t_s.push(buf.trim().parse().unwrap());
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    t_s.push(buf.trim().parse().unwrap());
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    t_s.push(buf.trim().parse().unwrap());

    let mut min_food_t: usize = 0;
    let mut min_food_i: usize = 0;
    for (i, t) in t_s.iter().enumerate() {
        let t_mod = t%10;
        if t_mod != 0 && (10-t_mod) > min_food_t {
            min_food_t = 10-t_mod;
            min_food_i = i;
        }
    }

    let mut ans: usize = 0;
    for (i, t) in t_s.iter().enumerate() {
        ans += *t;
        let t_mod = t%10;
        if i != min_food_i && t_mod != 0 {
            ans += 10 - t_mod;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
n = int(input())
S = input()
ans = 0
def ok(i):
    pin = '{:0=3}'.format(i)
    j = 0
    for s in S:
        if s == pin[j]:
            j += 1
            if j == 3:
                return True
    else:
        return False

for i in range(1000):
    ans += ok(i)
print(ans)

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

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

const int N = 100179;

int sx, sy;
int a[26];

int main() {
    ios::sync_with_stdio(false);

    cin >> sx >> sy;
    for (int i = 0; i < sx; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < sy; ++j)
            ++a[s[j]-'a'];
    }

    int c1 = 0, c2 = 0, c4 = 0;
    if (sx % 2 == 1 && sy % 2 == 1)
        ++c1;
    if (sx % 2 == 1)
        c2 += sy / 2;
    if (sy % 2 == 1)
        c2 += sx / 2;
    c4 = (sx/2) * (sy/2);

    if (c1) {
        bool ok = false;
        for (int i = 0; i < 26; ++i)
            if (a[i] % 2 == 1) {
                --a[i];
                ok = true;
                break;
            }
        if (!ok) {
            cout << "No\n";
            return 0;
        }
    }

    while (c2--) {
        bool ok = false;
        for (int i = 0; i < 26; ++i)
            if (a[i] % 4 == 2) {
                a[i] -= 2;
                ok = true;
                break;
            }
        if (!ok) {
            for (int i = 0; i < 26; ++i)
                if (a[i] >= 2) {
                    a[i] -= 2;
                    ok = true;
                    break;
                }
            if (!ok) {
                cout << "No\n";
                return 0;
            }
        }
    }
    while (c4--) {
        bool ok = false;
        for (int i = 0; i < 26; ++i)
            if (a[i] >= 4) {
                a[i] -= 4;
                ok = true;
                break;
            }
        if (!ok) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

    return 0;
}


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

int main(){

    long long N,K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i=0;i<N;i++){
        int temp;
        cin >> temp;
        A[i] = temp - 1;
    }

    int T;
    int loop_pos=0,pos = 0;
    if (N>=K){
    for (int i=0;i<K;i++){
        pos = A[pos];
    }
    }else{
    for(int i=0;i<N+1;i++){
        pos = A[pos];
    }
    for(int i=0;i<N;i++){
        if(loop_pos == pos){
            T = N-i+1;
            loop_pos = i;
            break;
        }
        loop_pos=A[loop_pos];
    }
    pos = 0;
    for(int i=0;i<loop_pos+(K-loop_pos)%T;i++){  
      pos=A[pos];
    }
    }

    cout << pos + 1 << endl;

}

Measured memory_bytes: 4052
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <math.h>

using namespace std;

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

int main() {
  int n, k; cin >> n >> k;
  vector<vector<ll> > dp(n + 1, vector<ll>(k + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      (dp[i][j] += dp[i-1][j] * j % MOD) %= MOD;
      (dp[i][j] += dp[i-1][j-1]) %= MOD;
    }
  }

  ll res = 0;
  for (int i = 0; i <= k; i++) {
    (res += dp[n][i]) %= MOD;
  }
  cout << res << endl;
}




Measured memory_bytes: 10680
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>
#include <ctime>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 1001001001;
const ll INFLL = 1001001001001001001LL;


template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }




int main() {
	srand(time(NULL));
//Prepare
	int N;
	int A,B,C,D;
//

	scanf("%d %d %d %d", &A,&B,&C,&D);
	


	if (abs(A - C) <= D) {
		printf("Yes");
	}
	else if (abs(A - B) <= D && abs(B - C) <= D) {
		printf("Yes");
	}
	else {
		printf("No");
	}


	return 0;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const int MAX = 100000;
static const int NIL = -1;
using namespace std;

ll calC(ll a, ll b){

    if(a == 1) return 0;
    ll ans = 1;
    ll tmpB = b;
    ll tmpA = a;
    for(int i = 1; i <= b; i ++){
        ans *= tmpA;
        tmpA --;
    }
    for(int i = 1; i <= b; i ++){
        ans /= tmpB;
        tmpB --;
    }

    return ans;
}
int main() {
    int n; cin >> n;
    vector<int> p(n);
    bool flag = false;
    rep(i,n) cin >> p[i];
    int ans = 0;

   rep(i, n) {
       if(i == n-2){
           if(p[i] == i+1 && p[i+1] == i+2){
               ans ++;
               break;
           }
       }
       if(i != n-1 && p[i] == i+1 && p[i+1] == i+2){
           ans ++;
           i ++;
       }else{
           if(p[i] == i+1){
               ans ++;
           }
       }
   }


    cout << ans;
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> K;;
  Vec(Q,lli,N,0);
  rep(i,0,N)cin >> Q[i];
  B=5*N;
  Vec(P,lli,N,0);
  P[0]=1;
  int a=1;
  while(B>0){
    a=Q[a-1];
    B--;
    P[a-1]++;
  }
  rep(i,0,N)if(P[i]>1)num++;
  rep(i,0,N)if(P[i]==1)sum++;
  if(K>sum+num)B=sum+(K-sum+num)%num;
  else B=K;
  a=1;
  while(B>0){
    a=Q[a-1];
    B--;
  }
  Out(a);   
}
  

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(9e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ 
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve() {
    int n, m;
    cin >> n >> m;
    vi g[n+1];
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    int vis[n] = {0};
    int ans[n] = {0};
    queue<int> q;
    q.push(0);
    vis[0] = 1;
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(auto u : g[v]){
            if(!vis[u]){
                vis[u] = 1;
                q.push(u);
                ans[u] = v;
            }
        }
    }
    for(int i = 1; i < n; i++){
        if(!vis[i]){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++)
        cout << ans[i]+1 << " ";
}

signed main(){

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

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    //cin >> t;
    
    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


Measured memory_bytes: 13844
import Control.Monad
import Data.List
-- import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as V

main = do
    n <- head . unfoldr BS.readInt <$> BS.getLine
    a <- V.fromList . map (head . unfoldr BS.readInt) <$> replicateM n BS.getLine
    let [m1, m2] = take 2 $ reverse $ sort $ V.toList a
    V.mapM_ (print . sub3 m1 m2) a
    -- a <- unfoldr (BS.readInt . BS.dropWhile . isSpace) <$> BS.getLine

sub3 :: Int -> Int -> Int -> Int
sub3 m1 m2 n = if n == m1 then m2 else m1


Measured memory_bytes: 57724
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


a, b = invr()
res = "Negative"

if 0 < a and a <= b:
    res = "Positive"
if a <= b and b < 0:
    temp = (b-a)+1
    if temp % 2 == 0:
        res = "Positive"
    else:
        res = "Negative"
if a <= 0 and b >= 0:
    res = "Zero"

print(res)


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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

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

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP (i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector <vector<int>>;
using vvll = vector <vector<ll>>;

#define inf(T) (numeric_limits<T>::max() / 2)
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    vector<char> left{'q', 'w', 'e', 'r', 't',
                      'a', 's', 'd', 'f', 'g',
                      'z', 'x', 'c', 'v', 'b'};
    vector<char> right{'y', 'u', 'i', 'o', 'p',
                       'h', 'j', 'k', 'l', 'n', 'm'};

    map<char,int> pos;
    for (char c : left) pos[c] = 0;
    for (char c : right) pos[c] = 1;

    for (;;) {
        string str; cin >> str;
        if (str == "#") break;

        int prev = -1;
        int ans = -1;
        for (char c : str) {
            if (prev != pos[c]) ++ans;
            prev = pos[c];
        }

        cout << ans << endl;
    }

    return 0;
}



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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}
template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

struct UF
{
    vi par, sizes;

    UF() {}
    UF(int size) : par(size, -1), sizes(size, 1) {
	rep(i, size) par[i] = i;
    }

    int root(int x)
    {
	return par[x] == x ? x : par[x] = root(par[x]);
    }

    bool same(int x, int y)
    {
	return root(x) == root(y);
    }

    int size(int x)
    {
	return sizes[root(x)];
    }

    void unite(int x, int y)
    {
	x = root(x);
	y = root(y);

	if(x == y) return ;

	if(sizes[x] < sizes[y]) swap(x, y);
	par[y] = x;
	sizes[x] += sizes[y];
	sizes[y] = 0;
    }
};

llint n, m;
int a[100001];
int b[100001];

int main()
{
    ci >> n >> m;
    rep(i, m) ci >> a[i] >> b[i];

    stack<llint> st;
    
    UF uf(n + 1);
    llint sum = n * (n - 1) / 2;

    for(int i = m - 1; i >= 0; i--) {
	st.push(sum);
	
	if(!uf.same(a[i], b[i])) {
	    sum -= uf.size(a[i]) * uf.size(b[i]);
	    uf.unite(a[i], b[i]);
	}
    }
    
    while(!st.empty()) {
	co << st.top() << en;
	st.pop();
    }

    return 0;
}


Measured memory_bytes: 3484
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 100001;

int n;
int a[MAX];

int main(void) {
	// in = fopen("B.in", "rt");
	
	fscanf(in, "%d", &n);
	for (int i = 0; i < n; i++) {
	    fscanf(in, "%d", &a[i]);
    }

	int odd = 0, even = 0;
	for (int i = 0; i < n; i++)
	    if (a[i] % 2 == 0) even++; else odd++;
	
	fprintf(out, "%s\n", odd == 0 ? "second" : "first");
	
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#define rep(i,l,r) for(i=l;i<r;i++)
#define repb(i,r,l) for(i=r;i>l;i--)
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
const int mod=998244353;
using namespace std;
ll gcdl(ll a ,ll b){ 
    if (a == 0) 
        return b;  
    return gcdl(b % a, a);  
 }
 vector<ll> prime;
ll phi(ll n) 
{ 
    ll result = n; // Initialize result as n 
  
    // Consider all prime factors of n and subtract their 
    // multiples from result 
    for (auto p:prime) { 
        if(p*p>n){
            break;
        }
        // Check if p is a prime factor. 
        if (n % p == 0) { 
              
            // If yes, then update n and result 
            while (n % p == 0) 
                n /= p; 
            result -= result / p; 
        } 
    } 
  
    // If n has a prime factor greater than sqrt(n) 
    // (There can be at-most one such prime factor) 
    if (n > 1) 
        result -= result / n; 
    return result; 
} 
ll power(ll x, ll y) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % mod;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % mod; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll n) 
{ 
    return power(n, mod-2); 
} 
int main(){
    
    int n;
    cin>>n;
    ll a[n];
    int i;
    int flag=0;
    rep(i,0,n){
        cin>>a[i];
    }
    sort(a,a+n);
    rep(i,1,n){
        if(a[i]==a[i-1]){
            flag=1;
        }
    }
    if(flag){
        cout<<"NO";
    }
    else{
        cout<<"YES";
    }
}


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

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


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  REP(i, n) cin >> h[i];

  int cnt = 0;
  REP(i, n) {
    if(h[i] >= k) ++cnt;
  }

  cout << cnt << endl;
  return 0;

}

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

int main()
{
    string a, b;

    cin >> a >> b;

    if( a.size() < b.size() )
        return 0;

    for( int i = 0; i <= a.size() - b.size(); i++ )
    {
        int k = i;
        bool judge = true;
        for( int j = 0; j < b.size(); j++ )
        {
            if( a[k] != b[j] )
                judge = false;
            k++;
        }
        if( judge )
            cout << i << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3228