akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define fi first
#define se second
template <typename A, typename B> inline bool chmax(A &a, B b) {if (a < b) {a = b; return 1;} return 0;}
template <typename A, typename B> inline bool chmin(A &a, B b) {if (a > b) {a = b; return 1;} return 0;}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const double EPS = 1e-9;
const bool debug = 0;
/****************************/

int main() {
	string s;
	while (cin >> s, s != "#") {
		
		REP(i, s.size()) s[i] -= 'a';
		
		vector<string> ans;
		REP(i, 1<<s.size()) {
			int used = 0;
			string cur = "";
			bool ng = false;
			REP(j, s.size()) {
				if (ng) break;
				
				if (i >> j & 1) {
					if (s[j] == 25) ng = true;
					else {
						if (used >> (s[j] + 1) & 1) ng = true;
						else cur += s[j] + 1 + 'a';
						used |= 1 << (s[j] + 1);
					}
				}
				else {
					if (s[j] != 0 && !(used >> s[j] & 1)) ng = true;
					else cur += s[j] + 'a';
				}
			}
			if (!ng) ans.push_back(cur);
		}
		sort(ALL(ans));
		ans.erase(unique(ALL(ans)), ans.end());
		
		if (debug) printf("@ ");
		cout << ans.size() << endl;
		if (ans.size() <= 10) {
			REP(i, ans.size()) cout << ans[i] << endl;
		}
		else {
			REP(i, 5) cout << ans[i] << endl;
			for (int i = ans.size() - 5; i < ans.size(); i++) cout << ans[i] << endl;
		}
		
	}
}



Measured memory_bytes: 4448
fun f(x : Long) : Long{
    return when(x % 4){
        0L -> x
        1L -> 1L
        2L -> x + 1L
        else -> 0L
    }
}

fun main(args: Array<String>){
    var (a, b) = readLine()!!.split(" ").map(String::toLong)
    println(f(a - 1).xor(f(b)))
}


Measured memory_bytes: 37876
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
from itertools import accumulate #list(accumulate(A))

N, M , Q = mi()
LR = li2(M)

dp = dp2(0, N, N)

for l, r in LR:
    dp[l-1][r-1] += 1

for i in range(N):
    dp[i] = list(accumulate(dp[i]))

for i in reversed(range(N-1)):
    for j in range(N):
        dp[i][j] += dp[i+1][j]

for _ in range(Q):
    f, t = mi()
    print(dp[f-1][t-1])

Measured memory_bytes: 52228
import sys
a = list(input())
k = list("keyence")
n = 7
for i in range(7):
  if k[i]==a[i]:
  	check=True
  else:
    check = False
    n -= i
    break

if check:
  print("YES")
  sys.exit()

check2=False
for i in range(n):
  if k[-i-1]==a[-i-1]:
    check2=True
  else:
    check2=False
    break
if check2:
  print("YES")
else: print("NO")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a=gi();
	    int b=gi();
	    int c=gi();
	    

	    //System.out.print(a-b+1);
	    if (a==b && b==c) {
	    	System.out.print("Yes");
	    }else {
	    	System.out.print("No");
	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35708
#include<stdio.h>
int w[50000][3];
int main(){
  int n,m,i,j,l,p[10000],c[10000],r=0;
  scanf("%d %d",&n,&m);
  while(scanf("%d %d %d",&w[r][0],&w[r][1],&w[r][2]),
	w[r][0]||w[r][1]||w[r][2])r++;
  scanf("%d",&l);//printf("%d\n",r);
  while(l--){
    for(i=0;i<m;i++)scanf("%d",&c[i]);
    for(i=0;i<n;i++)p[i]=0;
    for(i=0;i<r;i++)p[w[i][0]-1]+=c[w[i][1]-1]*w[i][2];
    for(i=0;i<n;i++){
      if(i)printf(" ");
      printf("%d",p[i]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1264
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define Yes()           printf("Yes\n")
#define No()            printf("No\n")
#define YES()           printf("YES\n")
#define NO()            printf("NO\n")
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

void solve() {
  int n, k; cin >> n >> k;
  int ans = __INT_MAX__;
  for (int i = 0; i < (1 << n); i++) {
    int l = 1;
    for (int j = 0; j < n; j++) {
      if ((i >> j) & 1) l *= 2;
      else l += k;
    }
    ans = min(l, ans);
  }
  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a = 0;
    for (int i = 0; i < 4; ++i) {
        int s;
        cin >> s;
        a += s;
    }
    int b = 0;
    for (int i = 0; i < 4; ++i) {
        int s;
        cin >> s;
        b += s;
    }
    cout << max(a, b) << '\n';
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int dh[8] = {0, 1, 1, 1, 0, -1, -1, -1},
    dw[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
    cout << fixed << setprecision(10);
    
    int w=1, h=1;

    while(w != 0 && h != 0) {
        int ans = 0;
        cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }
        vector<vector<int>> m(h, vector<int>(w));
        rep(i, h) {
            rep(j, w) {
                cin >> m[i][j];
            }
        }
        stack<P> q;
        rep(i, h) {
            rep(j, w) {
                // 到達していない陸じゃなければcontinue
                if (m[i][j] != 1) continue;
                q.emplace(make_pair(i, j));
                m[i][j] = 0;
                while(!q.empty()) {
                    P pp = q.top();
                    q.pop();
                    rep(d, 8) {
                        int nh = pp.first + dh[d], nw = pp.second + dw[d];
                        if (nh >= 0 && nw >= 0 && nh < h && nw < w && m[nh][nw] == 1) {
                            q.emplace(make_pair(nh, nw));
                            m[nh][nw] = 0;
                        }
                    }
                }
                ans += 1;
            }
        }

        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  ll ans = 1000;
  ll m = 1000;
  ll k = 0;
  bool f = true;
  for(int i = 0; i < n-1; ++i){
    if(f){
      if(v[i] < v[i+1]){
	k += m / v[i];
	m %= v[i];
	f = false;
      }
    } else {
      if(v[i] > v[i+1]){
	m += k * v[i];
	k = 0;
	f = true;
      }
    }
    ChangeMax(ans, m);
  }
  m += k * v[n-1];
  ChangeMax(ans, m);
  cout << ans << endl;
  return 0;
}


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

using namespace std;

string keyd[] = {"",".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
int main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		string input; cin >> input;
		int pos = -1, key = 0;
		string::iterator itr = input.begin();
		while(itr != input.end()){
			if( *itr == '0'){
				if(key == 0){
					itr++;
					continue;
				}
				pos = pos % keyd[key].size();
				cout << keyd[key][pos];
				pos = -1;
				key = 0;
			}
			else{
				if(pos == -1)key = *itr - '0';
				pos++;
			}
			itr++;
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3008
#include <cstdio>
#include <array>

std::array<int, 100005> p;
std::array<int, 100005> fa;

int find(int x)
{
    if (fa[x] != x)
    {
        fa[x] = find(fa[x]);
        return fa[x];
    }
    else
    {
        return x;
    }
}

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &p[i]);
        fa[i] = i;
    }
    int u, v;
    for (int i = 0; i < m; ++i)
    {
        scanf("%d %d", &u, &v);
        fa[find(u)] = find(v);
    }

    int count = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (find(p[i - 1]) == find(i))
        {
            count++;
        }
    }
    printf("%d\n", count);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
	FASTIO
	/*
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
//*/
	int T;
	//scanf("%d", &T);
	T = 1;
	for (int cs = 1; cs <= T; cs++) {
		int n, k;
		cin >> n >> k;
		for (int i = k - n + 1; i < n + k; i++)
			cout << i << " ";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S, T, U;
    int A, B;
    cin>>S>>T>>A>>B>>U;
    if(S==U){
        cout << A - 1 << ' ' << B << endl;
    }
    else{
        cout << A << ' ' << B - 1 << endl;
    }
    
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0

n=int(input())
v=list(map(int,input().split()))
v.sort(reverse=1)
tmp=1
for i in range(n-1):
    tmp*=2
    ans+=v[i]/tmp
ans+=v[n-1]/tmp
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
using ll = long long;
int main(){
	int N,M;
	cin>>N>>M;
	vector<ll>x(N),y(N),z(N);
	rep(i,N) cin>>x[i]>>y[i]>>z[i];
	ll ans = 0;
	rep(a,2) rep(b,2) rep(c,2){
		rep(i,N-1){
			rep(j,N-1){
				ll vl = (a ? x[j] : -x[j]) + (b ? y[j] : -y[j]) + (c ? z[j] : -z[j]);
				ll vr = (a ? x[j+1] : -x[j+1]) + (b ? y[j+1] : -y[j+1]) + (c ? z[j+1] : -z[j+1]);
				if(vl<vr){
					swap(x[j],x[j+1]);
					swap(y[j],y[j+1]);
					swap(z[j],z[j+1]);
				}
			}
		}
		ll xs=0,ys=0,zs=0;
		rep(i,M){
			xs += x[i],ys+=y[i],zs+=z[i];
		}
		chmax(ans,(ll)0 + abs(xs)+abs(ys)+abs(zs));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
A = LIST()

A = [x-i for i, x in enumerate(A, 1)]
A.sort()

print(sum([abs(x - A[len(A)//2]) for x in A]))

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char buf[425252];

const int LIM = 4;

vector<bool> chk[LIM];

int enc(char *s, int len){
  int ret = 0;
  REP(i,len){
    ret *= 26;
    ret += s[i]-'a';
  }
  return ret;
}
string dec(int x,int len){
  string ret = "";
  REP(i,len){
    ret = string(1,(char)(x%26)+'a') + ret;
    x/=26;
  }
  return ret;
}

int main(){
  {
    int k = 26;
    REP(i,LIM){
      chk[i].assign(k,false);
      k *= 26;
    }
  }
  int n;
  scanf("%d",&n);
  REP(i,n){
    scanf("%s",buf);
    int len = strlen(buf);
    REP(j,len){
      REP(k,LIM){
        if(j+k<len){
          int v = enc(buf+j,k+1);
          chk[k][v] = true;
        }
      }
    }
  }
  string ans = "";
  REP(k,LIM){
    bool ok = false;
    REP(i,chk[k].size())if(!chk[k][i]){
      ans = dec(i,k+1);
      ok = true;
      break;
    }
    if(ok)break;
  }
  assert(ans != "");
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    long X = sc.nextInt();
    String ans = "";

    long t[] = new long[200];
    for (int i = 0; i < 200; i++) {
      t[i] = (long) Math.pow(i, 5);
    }
    for (int i = 0; i < 200; i++) {
      for (int j = 0; j < 200; j++) {
        if (t[i] - t[j] == X) {
          ans = i + " " + j;
          break;
        }
        if (t[i] + t[j] == X) {
          ans = i + " " + j * -1;
          break;
        }
        if (!ans.equals("")) {
          break;
        }
      }
    }

    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 25748
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    ll a,b,v,w,t;

    cin>>a>>v>>b>>w>>t;

    ll d=abs(a-b);

    ll dc=v-w;

    if(dc<0)
        dc=0;



    if(dc*t>=d)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;



    return 0;
}



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

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<vector<int>> vec(n, vector<int>(m + 1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m + 1; j++) {
			cin >> vec.at(i).at(j);
		}
	}
	int ans = 10000000;
	for (int bit = 0; bit < (1 << n); bit++) {
		vector<int> buy(n,0);
		for (int i = 0; i < n; i++) {
			if (1 & (bit >> i))buy.at(i) = 1;
		}
		vector<int> result(m + 1, 0);
		for (int i = 0; i < n; i++) {
			if (buy.at(i) == 1) {
				for (int j = 0; j < m + 1; j++) {
					result.at(j) += vec.at(i).at(j);
				}
			}	
		}
		if (result.at(0) < ans) {
			bool study = true;
			for (int i = 1; i < m+1; i++) {
				if (result.at(i) < x)study = false;
			}
			if (study)ans = result.at(0);
		}

	}
	if (ans == 10000000)ans = -1;
	cout << ans << endl;
}

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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,aa,ans=0;

    cin>>n;
    forn(i,0,n){
    	cin>>aa;
    	ans+=(aa%2)&&((i+1)%2);
    }
    cout<<ans<<'\n';
    
    return 0;
}

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

using namespace std;
int n, k;
const int maxn = 2005;
const int maxk = 10005;
const int maxc = 1e6 + 20;
int len[maxn];
int start[maxn];

bitset<maxk> can[maxn];
int ss[maxc];
int critical[maxc];

int loc[2][maxc];

int main(){
  memset(critical, -1, sizeof(critical));
  scanf("%d%d\n", &n, &k);
  int tt = 0;
  vector<bool> appr(26);
  for(int i=0;i<n;i++){
    string s; getline(cin, s);
    len[i] = s.length();
    start[i] = tt;
    critical[tt] = i;
    for(int e=0;e<s.length();e++){
      int c = s[e] - 'a';
      appr[c] = true;
      ss[tt] = c;
      tt++;
    }
  }
  int numappr = 0;
  for(int i=0;i<26;i++)if(appr[i]) numappr++;
  if(numappr == 1){
    for(int i=0;i<26;i++){
      if(appr[i]){
	cout << string(k, (i + 'a')) << "\n";
	return 0;
      }
    }
  }
  
  can[n][0] = true;
  for(int i=n-1;i>=0;i--){
    can[i] = can[i+1] | (can[i+1]<<len[i]);
  }

  int q = 0;
  int cnt = 0;
  
  for(int i=0;i<n;i++){
    if(can[i+1][k-len[i]]) loc[q][cnt++] = start[i];
  }
  string ans = "";

  
  for(int eee = 0; eee < k; eee++){
    int mn = 1e9;
    for(int i=0;i<cnt;i++){
      int x = loc[q][i];
      mn = min(mn, ss[x]);
    }
    ans.push_back(mn + 'a');
    int mnn = 1e9;
    int ncnt = 0;
    for(int i=0;i<cnt;i++){
      int x = loc[q][i];
      if(ss[x] != mn) continue;
      if(critical[x+1] != -1){
	mnn = min(mnn, critical[x+1]);
      }
      else{
	loc[q ^ 1][ncnt++] = x + 1;
      }
    }
    if(mnn != 1e9){
      for(int i = mnn; i < n; i++){
	if(k-eee-1-len[i]>=0 && can[i+1][k-eee-1-len[i]]) loc[q ^ 1][ncnt++] = start[i];
      }
    }

    q ^= 1;
    cnt = ncnt;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 10624
N = int(input())
T, A = map(int, input().split())
lst = list(map(int, input().split()))
diff = 10 ** 5
ans = 0
for i, k in enumerate(lst):
    tmp = T - k* 0.006
    if (abs(tmp - A) < diff):
        diff = abs(tmp - A)
        ans = i + 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

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

	double d = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	printf("%lf\n", d);

	return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <cstring>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cassert>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;

auto dist(ll a, ll b, ll c, ll d) {
  return abs(a-c) + abs(b-d);
}

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int N,M;
  cin >> N >> M;
  vector <int> A(N), B(N), C(M), D(M);
  rep(i,N){
    cin >> A[i] >> B[i];
  }
  rep(i,M){
    cin >> C[i] >> D[i];
  }
  rep(i,N){
    int ansi = 0;
    auto curd = dist(A[i], B[i], C[0], D[0]);
    rep2(j,1,M){
      auto d = dist(A[i], B[i], C[j], D[j]);
      if (curd > d) {
        ansi = j;
        curd = d;
      }
    }
    cout << ansi+1 << endl;
  }
  
  
  return 0;
}



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

temp=0

s=[0]*n

for i in range(n):
    s[a[i]-1]=s[a[i]-1]+1

for i in range(n):
    c=s[i]
    temp=temp+int(c*(c-1)/2)

for k in range(n):
    ch=a[k]
    c2=s[ch-1]
    if c2==0 or c2==1:
        print(temp)
    else:
        ans=temp-int(c2*(c2-1)/2)+int((c2-1)*(c2-2)/2)
        print(ans)


Measured memory_bytes: 83916
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()

if N % 2 == 0:  # Nが偶数ならそのままやる
    small = A[:N//2]
    big = A[N//2:]
    ans = sum(big)*2 - sum(small)*2 - big[0] + small[-1]
    print(ans)
else:  # Nが奇数なら中央値くんをsmallに加えるかbig加えるかで議論が起きる
    small = A[:N//2]
    big = A[N//2+1:]
    midian = A[N//2]

    # midianをbigに加えた時, midianを右端に置く
    ans_big = sum(big)*2 - sum(small)*2 - big[0] + midian  # midianを加える代わりにbig[0]とsmall[-1]を救うことができない
    # midianをsmallに加えた時, midianを左端に置く
    ans_small = sum(big)*2 - sum(small)*2 - midian + small[-1]  # midianが引かれる代わりにbig[0]とsmall[-1]を救うことができる
    print(max(ans_big, ans_small))


Measured memory_bytes: 7752
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    ll H;
    cin >> H >> N;
    vll A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
 
    ll maxB = *max_element(B.begin(), B.end());
    v2ll dp(N + 1, vll(H  + maxB + 1, LINF));
    dp[0][0] = 0;
    REP(i, 0, N) {
        REP(j, 0, H + maxB + 1){
            if (j < A[i])
                dp[i + 1][j] = dp[i][j];
            else {
                //if (j - A[i] == LINF) continue;
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - A[i]] + B[i]);
            }
        }
    }

    ll ans = LINF;
    REP(i, H, H + maxB + 1) {
        ans = min(ans, dp[N][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 160640
#include <cstdio>
#include <algorithm>
int main(){
	int n, t, ans = 998585;
	scanf("%d %d", &n, &t);
	for(int i = 1, a, b; i <= n; i++){
		scanf("%d %d", &a, &b);
		if(b <= t && a < ans) ans = a;
	}
	if(ans > 998000) return !puts("TLE");
	return !printf("%d\n", ans);
}

Measured memory_bytes: 128
import sys

def main():
    n = int(sys.stdin.readline())

    max_a = -1
    min_a = 1001

    line = sys.stdin.readline()
    for ch in line.split():
        a = int(ch)
        if a > max_a:
            max_a = a
        if a < min_a:
            min_a = a

    print(max_a - min_a)
    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define mod 1e9+7
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)

//int a[1001][1001] //aise global me hi

ll lcm(ll a, ll b){
    return a / __gcd(a, b) * b;
}
//memset can initialize to 0 or -1 ONLY
// memset(a,0,sizeof(a[0][0])*n*n); //2D array
//memset(a, 0, sizeof(a));  //1D array
//memset(str, 't', sizeof(str)); // string
void solve()
{
    int a,b,c;cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
    
}


int main()
{

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

    ll t=1;
   // cin>>t;
    while(t--)
    {
    
    solve();
    
    }

}


Measured memory_bytes: 256
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# main
Sx,Sy,Tx,Ty = map(int,input().split())

dx = Tx - Sx
dy = Ty - Sy

ans1 = "U"*dy + "R"*dx
ans2 = "D"*dy + "L"*dx
ans3 = "L" + "U"*(dy+1) + "R"*(dx+1) + "D"
ans4 = "R" + "D"*(dy+1) + "L"*(dx+1) + "U"

print(ans1 + ans2 + ans3 + ans4)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	int odd=0,even=0;
	rep(i,n){
		int a;
		cin >> a;
		if(a%2==0) even++;
		else odd++;
	}
	if(odd%2==0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

class Main {
    public static void main(String[] args) {
        // input
        Scanner scanner = new Scanner(System.in);
        int[] a=new int[5];
        for (int i = 0; i < 5; i++) {
            a[i] = Integer.parseInt(scanner.next());
        }
        int k = Integer.parseInt(scanner.next());
        scanner.close();
        //solve
        String message;
        if (Math.abs(a[0] - a[4]) <= k) {
            message="Yay!";
        } else {
            message=":(";
        }
        // output
        System.out.println(message);
        System.out.flush();
    }
}

Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
vector<vector<int> > al(100005);
int dist[100005];
bool vis[100005];
int dp[100005];

void dfs(int root){
	vis[root] = true;

	int& ans = dp[root];  
	for(int x: al[root]){
		if(!vis[x]){
			dfs(x);
		}
		ans = max(ans,1 + dp[x]);
	}
}

int main(){
	IOS;
	//memset(dp,-1,sizeof(dp));
	int n,m;
	cin >> n >> m;
	int x,y;
	for(int i=0;i< m; ++i){
		cin >> x >> y;
		al[x].push_back(y);
	}
	for(int i=1;i<=n ; ++i){
		if(vis[i]) continue;
		dfs(i);

	}
	int ans = 0;
	for(int i=1;i<=n;++i){
		ans = max(ans,dp[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8320
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long int;
 
#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 1000000007 //10^9+7
//#define MOD 1
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
const int MAX = 2000;

long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void sosuu(ll n, vector<ll> &v){

  vector<ll> num(n, 0);

  FOR(i, 1, sqrt(n)){
    if(num[i]==0){
      FOR(j, 0, n/i){
        num[i+(j*i)] = 1;
      }
    }
  }
  REP(i, n){
    if(num[i]==0) v.push_back(i+1);
  }
}

ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

ll power(ll a, ll b){
  ll ans = 1;
  if(b%2==0){
    REP(i, b/2){
      ans *= a;
      if(ans>1000000000){
        return -1;
      }
    }
    return ans * ans;
  }else{
    b = b/2;
    REP(i, b){
      ans *= a;
      if(ans>1000000000){
        return -1;
      }
    }
    return ans * ans* a;
  }
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main(void){

  ll n;
  cin>>n;
  vector<ll> v(n+1);

  REP(i, n+1) v[i] = 0;
  REP(i, n+1){
    ll piv = i;
    if(i!=0){
      while(piv<=n){
        v[piv]++;
        piv += i;
      }
    }  
  }

  ll ans = 0;
  FOR(i, 1, n){
    ans += i*v[i];
  }
  cout<<ans<<endl;
  
  return 0;
  
}

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

#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define lg long long
#define db double
#define lb(x) ((x)&-(x))
#define ft first
#define sd second

#define HII cerr<<"HI"<<endl
#define LLLINE cerr<<"@@@@@@@@@@@@@@@@@@@@"<<endl

template <class _T_>
void read(_T_& d){
	d=0;int f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f*=-1;
	for(;c>='0'&&c<='9';c=getchar())d=d*10+c-'0';
	d*=f;
}

/************************************************/
#define MN 3005
#define Md 998244353
int Fix(int x){return x<0?x+Md:(x>=Md?x-Md:x);}
int dp[MN][MN*2];
int C[MN][MN];
int n,x;
int main(){
	read(n);read(x);
	C[0][0]=1;
	lg res=0;
	for(int i=1;i<MN;++i){
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;++j){
			C[i][j]=Fix(C[i-1][j-1]+C[i-1][j]);
		}
	}
	dp[0][0]=1;
	for(int i=0;i<x;++i){
		for(int j=0;j<=n;++j){
			res=Fix(res+1ll*C[n][j]*dp[j][i]%Md);
			dp[j+1][i+2]=Fix(dp[j+1][i+2]+dp[j][i]);
			dp[j+1][i+1]=Fix(dp[j+1][i+1]+dp[j][i]);
		}
		res%=Md;
	}
	if(x&1){
		for(int j=1;j<=n;++j){
			if(j*2>x){
				res=Fix(res+C[n][j]);
			}
		}
	}
	memset(dp,0,sizeof dp);
	dp[1][1]=1;
	for(int i=1;i<=n;++i)C[n][i]=Fix(C[n][i]+C[n][i-1]);
	for(int i=1;i<x;++i){
		for(int j=1;j<=n;++j){
			if(((x-i)&1)&&(x-i>2)){
				int h=(x-i)/2+j;
				res=Fix(res+1ll*Fix(C[n][min(n,h+(x-i)/2)]-C[n][min(n,h)])*dp[j][i]%Md);
			}
			dp[j+1][i+2]=Fix(dp[j+1][i+2]+dp[j][i]);
			dp[j+1][i+1]=Fix(dp[j+1][i+1]+dp[j][i]);
		}
		res%=Md;
	}
	cout<<res;
	return 0;
}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int LOG_N = 20, MAX_N = 2e5 + 100;

int N; char S[MAX_N];
int Block[LOG_N][MAX_N];
vector<int> Ix[26];
int getL(vector<int> &vec, int val) {return vec[lower_bound(ALL(vec), val) - vec.begin()];}
int main() {
	scanf("%s", S); N = strlen(S);
	for(int i=0; i<N; i++) Ix[S[i]-'a'].push_back(i);
	for(int k=0; k<26; k++) Ix[k].push_back(N);
	for(int i=0; i<=N; i++) for(int k=0; k<26; k++) Block[0][i] = max(Block[0][i], getL(Ix[k], i));
	for(int p=0; p<LOG_N; p++) Block[p][N+1] = N;
	for(int p=1; p<LOG_N; p++) for(int i=0; i<=N; i++) Block[p][i] = Block[p-1][Block[p-1][i]+1];

	int ansL = 0, nowIx = 0;
	for(int p=LOG_N-1; p>=0; p--) if(Block[p][nowIx] < N) ansL += (1<<p), nowIx = Block[p][nowIx] + 1;
	bitset<26> chkLast; for(int i=nowIx; i<N; i++) chkLast[S[i]-'a'] = true;
	vector<int> candiLast;
	for(int i=0; i<26; i++) if(chkLast[i] == false) candiLast.push_back(i);
	
	if(ansL == 0) return printf("%c\n", candiLast.front() + 'a') < 0;

	vector<string> candiAns;
	for(int last : candiLast) {
		candiAns.push_back("");
		int now = 0;
		int less = Ix[last][SZ(Ix[last])-2];
		for(int l=1; l<=ansL; l++) {
			for(int k=0; k<26; k++) {
				int start = getL(Ix[k], now)+1; 
				int end = start; for(int p=0; p<LOG_N; p++) if((ansL-l) & (1<<p)) end = Block[p][end] + 1;
				if(end <= less) continue;
				candiAns.back().push_back(k + 'a');
				now = start;
				break;
			}
		}
		candiAns.back().push_back(last + 'a');
	}

	string ans = "";
	for(string &str : candiAns) if(ans == "" or ans > str) ans = str;
	printf("%s\n", ans.c_str());
	return 0;
}


Measured memory_bytes: 17152
#include<cstdio>
using namespace std;
int main(){
  int n,a,flag[100010]={},cnt=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    if(flag[a])
      cnt++;
    flag[a]=1;
  }
  /*for(int i=0;i<=n;i++)
    cnt+=flag[i];
  if(cnt==n)
    printf("%d\n",cnt);
  else if(cnt%2==0)
    printf("%d\n",cnt-1);
  else
    printf("%d\n",cnt);*/
  if((n-cnt)%2==0)
    printf("%d\n",n-cnt-1);
  else
    printf("%d\n",n-cnt);
  
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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 in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int A, B;
    cin >> A >> B;

    int x_A_min = ceil(double(100*A)/8);
    int x_A_sup = 100*(A+1)/8;
    int x_B_min = 10*B;
    int x_B_sup = 10*(B+1);

    for(int x=x_A_min; x < x_A_sup; x++) {
        for(int y=x_B_min; y<x_B_sup; y++) {
            if(x==y){cout << x << endl; return 0;}
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
input_line = input()
b = int(input_line)
a = (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)
a_list = list(a)
print(a_list[b-1])

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

const int MAXN = 1e5 + 10;
const int INF = 2*1e9;

int dp[MAXN],N,K,h[MAXN];

int main(){

	scanf("%d",&N);
	K = 2;
	for(int i = 1;i<=N;i++){
		scanf("%d",&h[i]);
	}

	for(int i = 2;i<=N;i++){
		dp[i] = INF;
		for(int j = i-1;j>=max(i - K,1);j--){
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]) );
		}
	}

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

	return 0;

}

Measured memory_bytes: 4496
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, x;
	cin >> N >> x;
	vector<int> a(N);
	for (auto &a_i : a) {
		cin >> a_i;
	}
	sort(a.begin(), a.end());

	int ans = 0;

	for (auto a_i : a) {
		if (x < a_i) {
			cout << ans << endl;
			return 0;
		}
		x -= a_i;
		++ans;
	}
	if (x > 0) {
		--ans;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<vi> vii;
const int mxN=2e5+5,M=1e9+7;
const int LINF = 0x3f3f3f3f3f3f3f3f;
//did u check when n=1?
//is mxN correct?
set<int>s;
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    for(int i=0;i<3;i++){
        int x;cin>>x;
        s.insert(x);
    }
    if(sz(s)!=2)cout<<"No";
    else cout<<"Yes";
}

Measured memory_bytes: 3616
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
typedef long long ll;
using namespace std;

int n,a[100000],cnt;;
set<int>ev;

int main() {
	cin>>n;
	rep(n){
		cin>>a[i];
		if(i%2==0)
			ev.insert(a[i]);
	}
	sort(a,a+n);
	cnt=0;
	for(int i=0;i<n;i+=2){
		if(ev.find(a[i])==ev.end())++cnt;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 2944
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e12;


int main(){
	double a,b;char c;
	double x=0,y=0,sita=0;
	while(cin>>a>>c>>b){
		
		if(a==0&&b==0)break;
		x+=cos((sita/180.0)*M_PI)*a;
		y+=sin((sita/180.0)*M_PI)*a;
		sita+=b;
		
		
	}
	cout<<(int)y<<endl;
	cout<<(int)x<<endl;
	return 0;
}

Measured memory_bytes: 1228
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compu(const void *a, const void *b){
	if(*((int*)a+1)==*((int*)b+1)){
		return *((int*)a+2)-*((int*)b+2);
	}else{
		return *((int*)a+1)-*((int*)b+1);
	}
}

uint32_t nextpint(void){
	uint_fast32_t x=0;
	while(1){
		uint_fast8_t c=getchar();
		if('0'<=c && c<='9'){
			x=x*10+c-'0';
		}else{
			break;
		}
	}
	return x;
}

int data[100000][4];
int main(void){
	int n = nextpint();
	int m = nextpint();
	for(int i=0; i<m; i++){
		data[i][0] = i;
		data[i][1] = nextpint();
		data[i][2] = nextpint();
		data[i][3] = 0;
	}
	qsort(data, m, sizeof(int)*4, compu);
	int a = 0;
	int b = 0;
	for(int i=0; i<m; i++){
		if(data[i][1] != a){
			a = data[i][1];
			b = 0;
		}
		data[i][3] = ++b;
	}
	qsort(data, m, sizeof(int)*4, comp);
	for(int i=0; i<m; i++){
		printf("%06d%06d\n", data[i][1], data[i][3]);
	}
}


Measured memory_bytes: 4580
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b){
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
long long L[100005];
long long R[100005];
int main(void){
	int N;
	cin >> N;
	long long A[N];
	for(int i=0;i<N;i++)cin >>A[i];
	//L[i]はi番目までの累積最大公約数gcd
	L[0]=A[0];
	for(int i=1;i<N;i++){
		L[i]=gcd(L[i-1],A[i]);
	}
	//R[i]はN-1番目から0番目までの累積最大公約数
	R[N-1] = A[N-1];
	for(int i=N-2;i>=0;i--){
		R[i]=gcd(R[i+1],A[i]);
	}
	long long ans = 0;
	for(int i=1;i<N-1;i++){
		ans = max(ans,gcd(L[i-1],R[i+1]));
	}
	ans = max(ans,R[1]);
	ans = max(ans,L[N-2]);
	cout << ans << endl;
}

Measured memory_bytes: 2560