akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a+=b;
    c+=d;
    if(a>c){
        cout<<"Left"<<endl;
    }else if(a==c){
        cout<<"Balanced"<<endl;
    }else{
        cout<<"Right"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd3(int a, int b, int c);
int gcd2(int a, int b);
void swap(int *a, int *b);

int main(){
	int k;
	if(scanf("%d",&k)==EOF){return 0;}
	int sum = 0;
	for(int a = 1; a<=k; a++){
		for(int b = 1; b<=k; b++){
			for(int c = 1; c<=k; c++){
				sum += gcd3(a,b,c);
			}
		}
	}
	printf("%d\n", sum);
	return 0;

}


int gcd3(int a, int b, int c){
	int ab = gcd2(a,b);
	int bc =  gcd2(b,c);
	return gcd2(ab, bc);
}

int gcd2(int a,int b){
	if(a<b){swap(&a,&b);		}
	int c;
	c = a%b;
	if(c == 0){return b;}
	while(c!=0){
		swap(&a,&b);
		swap(&b,&c);
		//a=b;
		//b=c;
		c=a%b;
		if(c==1){break;}
	}
	if(c==1){return 1;}
	if(c==0){return b;}
	return 0;
}


void swap(int *a, int *b){
	int temp;
	temp =*a;
	*a = *b;
	*b = temp;
}

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

const long long int MODN = (long long int)(1e9+7);
long long int sumXOR(long long int arr[], int n) 
{ 
    long long int sum = 0; 
    for (int i = 0; i < 64; i++)  
    { 
        long long int zc = 0, oc = 0;  
          
        long long int idsum = 0;  
        for (int j = 0; j < n; j++) 
        { 
            if (arr[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2; 
        } 
          
        idsum = ((((oc%MODN) * (zc%MODN))%MODN) * ((1L << i)%MODN))%MODN;  
  
        sum += idsum;  
        sum %= MODN;
    } 
    return sum; 
} 

int main() {
  long long int N;
  scanf("%lld",&N);
  long long int arr[N];
  for (int i=0;i<N;i++) {
    scanf("%lld",&arr[i]);
  }
  printf("%lld\n",sumXOR(arr,N));
}

Measured memory_bytes: 2560
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) A[i] = scanner.nextInt();
    int count = 1;
    boolean inc = false;
    boolean dec = false;
    for (int i = 1; i < N; i++) {
      if (A[i] > A[i - 1]) inc = true;
      if (A[i] < A[i - 1]) dec = true;
      if (inc && dec) {
        count++;
        inc = false;
        dec = false;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 50852
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n,x,ans,a[110000];
signed main(){
  cin>>n>>x;rep(i,n)cin>>a[i];
  ans += max(0LL, a[0] - x);a[0] = min(a[0], x);
  repd(i,1,n){
    int d = max(0LL, (a[i-1]+a[i]) - x);
    ans += d;a[i] -= d;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
def main
  d = gets.chomp.to_i

  s = case d
      when 22 then 'Christmas Eve Eve Eve'
      when 23 then 'Christmas Eve Eve'
      when 24 then 'Christmas Eve'
      when 25 then 'Christmas'
      end

  puts s
end

if __FILE__ == $0
  main
end


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

#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)
#define rep(i,x,N) for(int i=x;i<=N;i++)
#define revrep(i,x,N) for(int i=x;i>=N;i--)
#define ar array

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
using vvi=vector<vi>;
int ctoi(char c) {return c-'0';}
int slen(string s) {return s.length();}
int vsize(vi a) {return (int)a.size();}
int in() {int x;cin>>x;return x;}
void tf(bool ok) {cout<<(ok ? "YES" : "NO")<<endl;}

//https://dmoj.ca/problem/dpv

const int MAXN = 1e5 + 10;

vector<int> g[MAXN];
ll dp[MAXN],c[MAXN],ans[MAXN];
int N,M;

void dfs1(int e,int p){
	dp[e]=1;
	vi cdrn;
	for(int& u : g[e]){
    if(u!=p) {
      dfs1(u,e);
      dp[e]=(dp[e]*(dp[u]+1))%M;
      cdrn.pb(u);
    }
	}

	vll ps,ss;
	ll pref=1,suf=1;
	forn(i,vsize(cdrn)) {
    ps.pb(pref);
		pref=(pref*(dp[cdrn[i]]+1))%M;
	}
	revrep(i,vsize(cdrn)-1,0) {
    ss.pb(suf);
		suf=(suf*(dp[cdrn[i]]+1))%M;
	}
	reverse(all(ss));
	forn(i,vsize(cdrn)) {
		c[cdrn[i]]=(ps[i]*ss[i])%M;
	}
}

void dfs2(int e,int p){
	ans[e]=(dp[e]*c[e])%M;
	for(int& u: g[e]){
      if(u!=p) {
      c[u]=(c[u]*c[e]+1)%M;
      dfs2(u,e);
    }
	}
}

int main(){

cin>>N>>M;
forn(i,N-1) {
  int u,v;
  cin>>u>>v;
  g[u].pb(v);
  g[v].pb(u);
}

dfs1(1,-1);
c[1]=1;
dfs2(1,-1);

rep(i,1,N)
  cout<<ans[i]<<endl;
return 0;
}


Measured memory_bytes: 24856
def main():
    N = int(input())
    a = list(map(int,input().split()))
        
    j = 1
    for i in range(N):
        if(j == a[i]):
            j += 1
    print(N - j + 1 if j > 1 else -1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 26268
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n, cnt=0, i;
    string s="No";
    cin >> n;
    for(i=0;i<n;i++){
        long long a, b;
        cin >> a >> b;
        if(a==b) cnt++;
        else cnt=0;
        if(cnt==3){
            s="Yes";
        }
    }
    cout << s <<endl;
    return 0;
}

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

int32_t main(){
	int n; cin>>n;
	vector<int> a(n);
	for(int i =0 ; i < n; i++){
		cin>>a[i];
	}
	int ans = INT_MAX;
	for(int state = 1; state <= 100; state++){
		int res = 0;
		for(int x: a){
			res += (state - x) * (state - x);
		}
		ans = min(ans, res);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
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();
        if (a<b) System.out.println("a < b");
        else if (a>b) System.out.println("a > b");
        else System.out.println("a == b");
    }
}


Measured memory_bytes: 26292
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int res = 0, a, b;
    cin >> a >> b;
    for (int i = 1; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                int pro = i * 10001 + j * 1010 + k * 100;
                if (pro >= a && pro <= b) res++;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int [] S = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int q = Integer.parseInt(br.readLine());
        int [] T = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int count = 0;
        for(int i = 0; i < q; i++) {
            for(int j = 0; j < n; j++) {
                if(T[i] == S[j]) {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 32328
import std.stdio : writeln;

void main() {
    int a,b,c,d;
    scan(a,b,c,d);

    if (a+b > c+d) {
        writeln("Left");
    }
    else if (a+b < c+d) {
        writeln("Right");
    }
    else {
        writeln("Balanced");
    }
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.array : split;
    import std.conv  : to;
    import std.range.primitives;

    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <set>
#include <cmath>

using namespace std;

typedef pair<int, int> pii;
set<int> bullets[100001];

inline int pow2(int x){ return x * x; }

int main(){
	while(true){
		int an, bn, r;
		scanf("%d%d%d", &an, &bn, &r);
		if(an == 0 && bn == 0 && r == 0){ break; }
		for(int i = 100000; i >= 0; --i){ bullets[i].clear(); }
		vector<pii> ships;
		while(an--){
			int x, y;
			scanf("%d%d", &x, &y);
			ships.push_back(pii(x, y));
		}
		while(bn--){
			int x, y;
			scanf("%d%d", &x, &y);
			bullets[y].insert(x);
		}
		int answer = 0;
		for(vector<pii>::iterator it = ships.begin(); it != ships.end(); ++it){
			int y = max(0, (*it).second - 4 * r), yto = min(100000, (*it).second + 4 * r);
			for(; y <= yto; ++y){
				int diff = static_cast<int>(sqrt(pow2(4 * r) - pow2(y - (*it).second)));
				int xfrom = max(0, (*it).first - diff), xto = (*it).first + diff;
				for(
					set<int>::iterator jt = bullets[y].lower_bound(xfrom);
					jt != bullets[y].end() && (*jt) <= xto; ++jt
				){ 	++answer; }
			}
		}
		printf("%d\n", answer);
	}
	return 0;
}

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

int main(){
  string S;
  cin>>S;
  for(int i=S.size()/2-1;i>=0;i--){
    bool flag=true;
    for(int j=0;j<i;j++){
      if(S.at(j)!=S.at(j+i)){
        flag=false;
        break;
      }
    }
    if(flag){
      cout<<2*i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
vector<int> h (100001);
vector<int> dp(100001, 100001 * 10001);
int main () {
  int n, k;
  
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  
  dp[0] = 0;
  for (int stone = 0; stone < n; stone++) {
	for (int jump = 1; jump <= k; jump++) {
		if (jump + stone >= n) break;
      	dp[stone + jump] = min(dp[stone + jump], dp[stone] + abs(h[stone + jump] - h[stone])); 
    }
  }
  
  cout << dp[n - 1];
  
  return 0; 
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H,W;
    cin >> H >> W;
    if(H == 1 | W == 1) cout << 1 << endl;
    else cout << (ll)(H * W + 1) /2;
    
    return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable
import scala.io.StdIn._



object Main extends App {
  val n = readInt()
  val queue = mutable.PriorityQueue[Bacteria]()(Ordering.by[Bacteria, Long](_.in).reverse)
  val bacterias = Array.tabulate(n){_ ⇒
    val Array(a, b) = readLine.trim.split(' ').map(_.toLong)
    Bacteria(a, b)
  }.sortWith((a, b) ⇒ if (a.out == b.out) a.in < b.in else a.out < b.out)
  var max = 0
  var sum = 0L
  for (b ← bacterias) {
    sum += b.out
    queue.enqueue(b)
    while (queue.nonEmpty && queue.head.in * queue.size < sum) {
      val remove = queue.dequeue()
      sum -= remove.out
    }
    if (max < queue.size){
      max = queue.size
    }
  }
  println(max)

  case class Bacteria(out: Long, in: Long)
}


Measured memory_bytes: 467828
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int N, i;
  ci(N, i);
  co(N - i + 1);
}

Measured memory_bytes: 384
import java.util.*;

public class Main{ 

	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		SortContext context = new SortContext(scan.nextInt(), new Bubble());
		context.readSequence(scan);
		scan.close();
		System.out.println(context);
		System.out.println(context.swapTimes());
	}

}

abstract class SortStrategy{
	int swapTimes = 0;
	int seqLength;
	int getSwapTimes(){
		return swapTimes;
	}
	abstract Iterator<Integer> sort(ArrayList<Integer> seq);
}
class Bubble extends SortStrategy{
	@Override
	public Iterator<Integer> sort(ArrayList<Integer> seq){
		for(int i=0; i<seq.size();i++)
			for(int j=seq.size()-1; i<j ;j--)
				if(seq.get(j)<seq.get(j-1)){
					Collections.swap(seq, j, j-1);
					swapTimes++;
				}
		return seq.iterator();
	}

}
/*
class Selection extends SortStrategy{
	public Selection(int n){
		super(n);
	}
	@Override
	public ArrayList<Integer> sort(){

}*/
class SortContext{
	SortStrategy strategy;
	ArrayList<Integer> seq = new ArrayList<Integer>();
	int seqLength;
	public SortContext(int length, SortStrategy s){
		seqLength = length;
		this.strategy = s;
	}
	public void readSequence(Scanner scan){
		for(int i=0; i<seqLength; i++)
			seq.add(scan.nextInt());
	}
	public String toString(){
		String tmp = "";
		for(Iterator<Integer> iter = strategy.sort(seq); iter.hasNext();)
			tmp += iter.next() + " ";
		return tmp.trim();
	}
	public int swapTimes(){
		return strategy.getSwapTimes();
	}
}

Measured memory_bytes: 20092
<?php
list($n, $a, $b) = ints();
if (($b - $a) % 2 === 0)
    echo intdiv($b - $a, 2);
else
    echo min($a - 1, $n - $b) + 1 + intdiv($b - $a - 1, 2);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16208
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S = input()
    N = len(S)
    dp = [[0] * 13 for _ in range(N)]

    if S[-1] == "?":
        for i in range(10):
            dp[0][i] = 1
    else:
        dp[0][int(S[-1])] = 1

    tenfactor = 1
    for i in range(1, N):
        tenfactor *= 10
        tenfactor %= 13

        if S[N - i - 1] != "?":
            for k in range(13):
                j = int(S[N - i - 1])
                idx = (k + j * tenfactor) % 13
                dp[i][idx] += dp[i - 1][k]
                dp[i][idx] %= MOD
        else:
            for j in range(10):
                for k in range(13):
                    idx = (k + j * tenfactor) % 13
                    dp[i][idx] += dp[i - 1][k]
                    dp[i][idx] %= MOD

    print(dp[-1][5])


if __name__ == "__main__":
    main()


Measured memory_bytes: 61788
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int K,A,B;
cin >> K >> A >> B;
for (int i = A;i <= B;i++) {
    if (i%K == 0) {
        cout << "OK" << endl;
        return 0;
    }
}
cout << "NG" << endl;


return 0;
}

Measured memory_bytes: 3636
# Author: cr4zjh0bp
# Created: Sat Mar 14 20:41:10 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from collections import Counter

s = ns()
n = len(s)
s = s + "$"
k = ni()

c = []
cnt = 1
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        cnt += 1
    elif cnt > 1:
        c.append(cnt)
        cnt = 1

if (len(c) == 1 and c[0] == n) or n == 1:
    print(n * k // 2)
elif s[0] != s[-2]:
    print(sum([x // 2 for x in c[:]]) * k)
else:
    a, b = 1, 1
    if s[0] == s[1]:
        a = c[0]
    if s[-2] == s[-3]:
        b = c[-1]
    print(sum([x // 2 for x in c[:]]) * k - (a // 2 + b // 2 - (a + b) // 2) * (k - 1))

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

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


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

int main(){
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> aa(A), bb(B);
  for(int i = 0; i < A; i++){
    cin >> aa.at(i);
  }
  for(int i = 0; i < B; i++){
    cin >> bb.at(i);
  }
  vector<int> x(M), y(M), c(M);
  for(int i = 0; i < M; i++){
    cin >> x.at(i) >> y.at(i) >> c.at(i);
    x.at(i)--; y.at(i)--;
  }

  int result = aa.at(0) + bb.at(0);
  for(int i = 0; i < M; i++){
    int sum = aa.at(x.at(i)) + bb.at(y.at(i)) - c.at(i);
    if(result > sum) result = sum;
  }
  
  sort(ALL(aa));
  sort(ALL(bb));
  if(result > aa.at(0) + bb.at(0)) result = aa.at(0) + bb.at(0);

  cout << result << endl;
}


Measured memory_bytes: 2176
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
c.sort()

ans = 0
for B in b:
    i = bisect.bisect_left(a, B)
    j = bisect.bisect_right(c, B)
    ans += i * (n - j)

print(ans)

Measured memory_bytes: 29388
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int x,y;
    cin>>x>>y;
    cout<<x+(y/2)<<nl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;


int main() {
    int x;
    scanf("%d", &x);
    if(x % 10 == 3) {
        printf("bon\n");
    } else if(x % 10 == 0 || x % 10 == 1 ||x % 10 == 6 ||x % 10 == 8){
        printf("pon\n");
    } else {
        printf("hon\n");
    }

    return 0;
}


Measured memory_bytes: 1660
#include <stdio.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    char s[10];
    int len, count, i;
    scanf("%s", s);
    len = strlen(s);
    if (s[0] != 'A')
    {
        printf("WA\n");
        return 0;
    }

    count = 0;
    for (i = 1; i < len; i++)
    {
        if (('A' <= s[i]) && (s[i] <= 'Z'))
        {
            count++;
        }
    }
    if (count != 1)
    {
        printf("WA\n");
        return 0;
    }

    count = 0;
    for (i = 2; i < len - 1; i++)
    {
        if (s[i] == 'C')
        {
            count++;
        }
    }
    if (count != 1)
    {
        printf("WA\n");
        return 0;
    }

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


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

char s[2000005];
int main()
{
	int n,a,b,c,d;
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
	scanf("%s",s+1);
	if(c==d)
	return printf("No"),0;
	if(c<d)
	{
		for(int i=b;i<d;i++)
		if(s[i]=='#'&&s[i+1]=='#')
		return printf("No"),0;
		for(int i=a;i<c;i++)
		if(s[i]=='#'&&s[i+1]=='#')
		return printf("No"),0;
	}
	if(c>d)
	{
		int f=0,ff=0;
		for(int i=b;i<d;i++)
		if(s[i]=='#'&&s[i+1]=='#')
		return printf("No"),0;
		s[d]='#';
		for(int i=a;i<c;i++)
		if(s[i]=='#'&&s[i+1]=='#')
		{
			ff=1;
			break;
		}
		if(!ff)
		return printf("Yes"),0;
		s[d]='.';
		for(int i=b;i<d;i++)
		if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
		{
			f=1;
			break;
		}
		if(!f)
		return printf("No"),0;
		for(int i=a;i<c;i++)
		if(s[i]=='#'&&s[i+1]=='#')
		return printf("No"),0;
	}
	printf("Yes");
} 


Measured memory_bytes: 384
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
 
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 
class Segtree_op():
     def __init__(self, n):
         self.size = 1
         while(n >= 1):
             self.size = self.size << 1
             n = n//2
 
         self.arr = [self.unit() for i in range(self.size*2)]
 
     def op(self, lch, rch):
         # update min with holding index
         return lch + rch
 
     def unit(self):
         return 0
 
     def update(self, k, val):
         k += self.size - 1
         self.arr[k] = val
         while(k):
             k = (k - 1) // 2
             self.arr[k] = self.op(self.arr[k*2 + 1], self.arr[k*2 + 2])
 
     def query(self, l, r):
         L = l + self.size
         R = r + self.size
         s = self.unit()
         while L < R:
             if R & 1:
                 R -= 1
                 s = self.op(s, self.arr[R - 1])
 
             if L & 1:
                 s = self.op(s, self.arr[L - 1])
                 L += 1
             L >>= 1
             R >>= 1
         return s
 
 
     def show(self):
         idx = 1
         while(idx <= self.size):
             print(self.arr[idx - 1:idx * 2 - 1])
             idx *= 2
def tento(nums):
    st = Segtree_op(max(nums))
    ret = 0
    for i, num in enumerate(nums):
        st.update(num, st.query(num, num+1)+1)
        # st.show()
        ret += i - st.query(0, num+1) + 1

    return ret



def main():
    n, kk = getList()
    nums = getList()
    ten = tento(nums)
    oneset = 0
    for k, v in Counter(nums).items():
        oneset += (n - v) * v
    # print(ten, oneset)
    print((kk * ten + kk * (kk-1) * oneset // 4)% MOD)

if __name__ == "__main__":
    main()
   

Measured memory_bytes: 75464
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a + b == 15) {
			System.out.println("+");
		}
		else if(a * b == 15){
			System.out.println("*");
		}
		else {
			System.out.println("x");
		}

	}
}


Measured memory_bytes: 22868
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;



int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    if((y-x+1)<=z)
    {
        for(int i=x;i<=y;i++)
        cout<<i<<endl;
    }
    else
    {
        vector<int>v;
        for(int i=0;i<z;i++)
        v.push_back(x+i);
        for(int i=0;i<z;i++)
        v.push_back(y-i);
        sort(v.begin(),v.end());
        for(int i=0;i<v.size();i++)
        {
            if(v[i+1]!=v[i])
            cout<<v[i]<<endl;
        }
    }
    
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int N;
  cin >>N;
  vector<int> d(N);
  for(int i=0; i<N; i++) cin >> d[i];
  sort(d.begin(),d.end());
  cout << d[N/2]-d[N/2-1] << endl;
  
}

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

int main(){
    int N;
    int d[110];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>d[i];
    }
    set<int>values;
    for (int i=0;i<N;i++){
        values.insert(d[i]);
    }
    cout<<values.size()<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void) {

	string w;
	int a[26] = { 0 };

	bool jud = true;

	cin >> w;

	for (int i = 0; i < w.size(); i++)
	{
		a[w[i] - 'a']++;
	}

	for (int k = 0; k < 26; k++)
	{
		//cout << a[k] << "\n";
		if (a[k] % 2 != 0)jud = false;
	}

	if (jud == true)cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
S=input()
n=len(str(S))
if n%2==1:
  count=0
  m=int((n-1)/2)
  for i in range(0,m):
    if S[i]!=S[n-i-1]:
      count+=1
else:
  count=0
  m=int(n/2)
  for i in range(0,m):
    if S[i]!=S[n-i-1]:
      count+=1
      
print(count)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    A, B, X = [int(i) for i in input().strip().split()]
    for i in range(B+1):
        if A + i == X:
            return "YES"
    return "NO"


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9164
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define l long long
#define pb push_back
#define mem(a,n) memset(a,n,sizeof(a))
//#define find(v,n) find(v.begin(),v.end(),n)
#define sort1(v) sort(v.begin(),v.end())
#define lb(v,n) lower_bound(v.begin(),v.end(),n)-v.begin()
//#define ub(v,n) upper_bound(v.begin(),v.end(),n)-v.begin()
#define mod 1000000007
#define reverse(s) reverse(s.begin(),s.end())
//#define pi pair<l,l> 
const double pi=3.141592653589793;
bool isprime(l n)
{
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
/*bool fact(l n)
{
	vector<l> v;
	for(l i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			if(i%2==1||(n/i)%2==1)
			{
				return true;
			}
		}
	}
	return false;
}*/
l power(l a,l b)
{
	l ans=1;
	while(b>0)
	{
		if(b&1)
		{
			ans=(ans*a)%mod;
		}
		b>>=1;
		a=(a*a)%mod;
	}
	return ans%mod;
}//prefixsums
l ncr(l n,l r,vector<l> fact)
{
	l ans=(fact[n]/((fact[n-r]*fact[r])%mod))%mod;
	return ans;
}
void frooty(l t)
{
	l n;
	cin>>n;
	vector<l> v;
	l ans=0;
	//l maxx=0;
	for(l i=0;i<n;i++)
	{
		l a;
		cin>>a;
		v.pb(a);
	}
	l maxx=v[0];
	for(l i=1;i<n;i++)
	{
		if(v[i]<maxx)
		{
			ans+=maxx-v[i];
		}
		else
			maxx=v[i];
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q=1;
	//cin>>q;
	//q++;
	for(int i=0;i<q;i++)
	{
		char c[]="anudeep";
		frooty(i+1);
	}
}

Measured memory_bytes: 5332
import re
class c(int):
    def __add__(self,n):
        return c(int(self)+int(n))
    def __sub__(self,n):
        return c(int(self)-int(n))
    def __mul__(self,n):
        return c(int(self)*int(n))
    def __truediv__(self,n):
        return c(int(int(self)/int(n)))
n = int(input())
for i in range(n):
    print(eval(re.sub(r'(\d+)',r'c(\1)',input()[:-1])))


Measured memory_bytes: 6612
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

ll maxlist(vector<ll> &maxindices, vector<ll> &counts) {
    ll maxval = -1;
    for (ll i = 0; i < (ll)counts.size(); i++) {
        if (maxval == counts[i]) {
            maxindices.push_back(i);
        } else if (maxval < counts[i]) {
            maxval = counts[i];
            maxindices.clear();
            maxindices.push_back(i);
        }
    }
    return maxval;
}

int main() {
    ll H, W, M;
    cin >> H >> W >> M;
    vector<ll> hcount(H, 0);
    vector<ll> wcount(W, 0);

    unordered_set<ll> exist;
    for (ll i = 0; i < M; i++) {
        ll h, w;
        cin >> h >> w;
        h--;
        w--;
        hcount[h]++;
        wcount[w]++;
        exist.insert(h * 1000000LL + w);
    }
    vector<ll> max_hi;
    ll max_h = maxlist(max_hi, hcount);
    vector<ll> max_wi;
    ll max_w = maxlist(max_wi, wcount);

    for (auto hi : max_hi) {
        for (auto wi : max_wi) {
            if (!exist.count(hi * 1000000LL + wi)) {
                cout << max_h + max_w << endl;
                return 0;
            }
        }
    }
    cout << max_h + max_w - 1 << endl;
}


Measured memory_bytes: 29780
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	string S;
	cin >> S;
	for (int i = 0; i < S.size() - 1; i++) {
		for (int j = i + 1; j < S.size(); j++) {
			if (S.at(i) != S.at(j) && i < S.size() - 2) {
				continue;
			}
			else if (S.at(i) != S.at(j) && i == S.size() - 2) {
				cout << "yes" << endl;
			}
			else if (S.at(i) == S.at(j)) {
				cout << "no" << endl;
				exit(0);
			}
		}
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n, m;
    cin >> n >> m;
    cout << (m == n ? "Yes" : "No") << endl;
    return 0;
}

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

#define Sort(ob,n) sort(ob,ob+n)
#define SorT(ob) sort(ob.begin(),ob.end())
#define rev(ob) reverse(ob.begin(),ob.end())
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define fi(start,End,I) for(int i=start; i<=End; i+=I)
#define PII pair<ll,ll>
//#define fr first
//#define se second

ll func(ll n1, ll n2)
{
    if(n2 == 0){
        return n1;
    }

    func(n2,n1%n2);


}

int main()
{
    fast;

    ll a,b,c,d,LCM,pum;

    cin >> a >> b >> c >> d;

    LCM = (c*d)/func(c,d);

    ll C,D,newC,newD,com,newCom;
    ll sum=0;

    C = b/c;
    D = b/d;
    com = b/LCM;
    sum = C+D-com;
    //cout << func(c,d) << "\n";

    newC = (a-1)/c;
    newD = (a-1)/d;
    newCom = (a-1)/LCM;

    pum = newC+newD-newCom;

    sum-=pum;
    //sum = (C+D)-(newC+newD+com);
    //if(a%2 == 0 && b%2 == 0) b++;
    cout << ((b-a+1)-sum) << "\n";

















    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
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 LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def need(m):
        s=1
        for i in range(n):
            if i==m:continue
            s|=s<<aa[i]
            s&=mask
        #print(m,bin(s),bin(s>>k-aa[m]))
        if s>>k-aa[m]:return True
        return False

    n,k=MI()
    mask=(1<<k)-1
    #print(bin(mask))
    aa=LI()
    aa.sort()
    for i in range(n):
        if aa[i]>k:
            aa=aa[:i]
            break
    n=len(aa)
    #print(aa)
    l=-1
    r=n
    while l+1<r:
        m=(l+r)//2
        #while aa[m-1]==aa[m]:m-=1
        #print(m,aa[m],need(m))
        if need(m):r=m
        else:l=m
    print(l+1)

main()

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef long long ll;
#define loop(n)      for(int i=0;i<(n);i++)
#define lp(x,s,e)    for(int x=(s);x<(e);x++)
#define lpe(x,s,e)    for(int x=(s);x<=(e);x++)
#define MP make_pair
#define PB push_back
#define all(a)  a.begin(),a.end()
#define clr(x,val) memset((x),(val),sizeof(x))
#define endl '\n'

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;
    long long n;
    cin>>s>>n;
    long long si=s.size();
    long long j= min(si,n);
    for(int i=0;i<j;i++){
      int x=s[i]-'0';
     if(x>=2){
      cout<<s[i];
      return 0;}
    }
    cout<<1;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;
    vector<string> S;
    string tmp = "";
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == 'A') {
            tmp.push_back('A');
        } else if (s[i] == 'B') {
            if (i + 1 < (int)s.size() && s[i + 1] == 'C') {
                tmp.push_back('B');
                i++;
            } else {
                S.push_back(tmp);
                tmp = "";
            }
        } else {
            S.push_back(tmp);
            tmp = "";
        }
    }
    S.push_back(tmp);

    ll ans = 0;
    for (auto str : S) {
        ll N = str.size();
        ll na = 0;
        for (int i = N - 1; i >= 0; i--) {
            if (str[i] == 'A') {
                ans += (N - 1 - i) - na;
                na++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    string s, p;
    cin >> s >> p;
    string a= s+s;
    bool b=0;
    for(int i=0; i<s.size(); i++){
        if(a.substr(i, p.size()) == p) b=1;
    }
    if(b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 3184
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            //var allPatterns = new List<List<Tuple<int, int>>>();
            var allPatterns = Enumerable.Range(0, N).Select(_ => new List<Tuple<int, int>>()).ToList();

            for (int i = 0; i < N; i++)
            {
                var evidences = new List<Tuple<int, int>>();
                var a = int.Parse(Console.ReadLine());
                for (int j = 0; j < a; j++)
                {
                    var oneLine = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                    evidences.Add(new Tuple<int, int>(oneLine[0], oneLine[1]));
                }
                //allPatterns.Add(evidences);
                allPatterns[i] = evidences;
            }

            var max = 0;
            for (int i = 0; i < Math.Pow(2, N); i++)
            {
                var ok = true;
                // 全パターンを試す
                for (int j = 0; j < allPatterns.Count; j++)
                {
                    // 現在の番号の人が不親切である場合、証言は気にしないので次の人へ
                    if (((i >> j) & 1) != 1)
                    {
                        continue;
                    }

                    var aPeople = allPatterns[j];
                    for (int k = 0; k < aPeople.Count; k++)
                    {
                        // まずiを2進数化する
                        // それぞれを証言と突き合わせていく
                        var evidence = aPeople[k];
                        // 人は1～15の番号が与えられている
                        // ので、番号-1桁が対象の状態になる
                        var targetPeople = evidence.Item1;
                        // 証言の内容を取得
                        var isHonest = evidence.Item2;
                        // 対象の人の状態を取得
                        var targetPeopleStatus = (i >> (targetPeople - 1)) & 1;
                        // 対象の人の状態と証言が一致していなければ、okにfalseを入れる
                        if ((targetPeopleStatus ^ isHonest) == 1)
                        {
                            ok = false;
                        }
                    }
                }

                if (ok)
                {
                    max = Math.Max(max, Count(i));
                }
            }
            Console.WriteLine(max);
        }
        static int Count(int n)
        {
            if (n == 0) return 0;
            return Count(n >> 1) + (n & 1);
        }

    }
}



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

#define FOR(VAR,ST,END) for(int VAR=ST; VAR<END; ++VAR)
#define FORI(VAR,ST,END) for(int VAR=ST; VAR<=END; ++VAR)
#define ROF(VAR,ST,END) for(int VAR=ST; VAR>END; --VAR)
#define ROFI(VAR,ST,END) for(int VAR=ST; VAR>=END; --VAR)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define MAXI(a,b) (a=(a>b?a:b))
#define MINI(a,b) (a=(a<b?a:b))
#define MINI_NZ(a,b) {if(a==0) a = b; else a = a<b?a:b;}
#define SWAP_IF(type,x,y,cond) if(cond) {type tmp=x; x=y; y=tmp;}
#define SWAP(type,x,y) {type tmp=x; x=y; y=tmp;}
#define INF 0x3f3f3f3f

#define MAX_N 100
#define MAX_TURNING 20

using namespace std;

int main()
{
    int n;
    cin >> n;
    FOR(i, 0, n)
    {
        char ch;
        cin >> ch;
        if (ch == 'Y')
        {
            cout << "Four" << endl;
            return 0;
        }
    }

    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
def itoa(i):
    return chr(97 + i)


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

    ans = ""
    while N:
        i = (N - 1) % 26
        N = (N - 1) // 26
        ans += itoa(i)

    print(ans[::-1])


if __name__ == "__main__":
    main()

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

int main()
{
    int A,B,C,D,a,c;
    cin >> A >> B >> C >> D;

    while(A>0 && C>0)
    {
        C = C-B;
        A = A-D;
    }

    if(C<=0)
    {
        cout << "Yes" << endl;
    }
    else if(A<=0)
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
N = int(input())
# S = input()
P_list = list(map(int,input().split()))
#print(P_list)
# X2_list = [list(map(int,input().split())) for i in range(N)]
result = 1
tmp = P_list[0]
for i in range(1,N):
     if tmp > P_list[i]:
          result += 1
          tmp = P_list[i]

print(result)

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

typedef unsigned long long Hash;

Hash w[1001000];
Hash h[1001000];
Hash inv[1001000];


Hash bpow(Hash a,Hash b){
	return b?bpow(a*a,b/2)*(b&1?a:1):1;
}
Hash sub(int a,int b){
	if( a == 0 ) return h[b-1];
	return (h[b-1] - h[a-1]) * inv[a];
}
int main(){
	w[0] = 1;
	for(int i = 1 ; i < 1001000 ; i++) w[i] = w[i-1] * 8999;
	inv[0] = 1;
	inv[1] = bpow(8999,(1ull<<63)-1);
	for(int i = 2 ; i < 1001000 ; i++) inv[i] = inv[i-1] * inv[1];
	string s;
	cin >> s;
	int n = s.size();
	for(int i = 0 ; i < n ; i++)
		h[i] = (i?h[i-1]:0) + s[i] * w[i];
	
	for(int i = 1 ; i <= n ; i++){
		if( n / i == 2 && n % i != 0 ){
			int A = n % i;
			int B = i - A;
			if( sub(0,A) == sub(A+B,A+B+A) && sub(0,A) == sub(2*(A+B),2*(A+B)+A) ){
				if( sub(A,A+B) == sub(A+B+A,A+B+A+B) ){
					cout << "Love " << s.substr(0,i) << "!" << endl;
					return 0;
				}
			}
			
		}
	}
	cout << "mitomerarenaiWA" << endl;
}

Measured memory_bytes: 26016
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	//Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	
	void prog()
	{
		//cin = new Scanner();
		string str;
		while (!string.IsNullOrEmpty(str = Console.ReadLine()))
		{
			string[] s = str.Split(' ');
			Console.WriteLine((int.Parse(s[0])+int.Parse(s[1])).ToString().Length);
		}
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    string s;
    cin >> s;
    int n = s.size();
 
    vector<int> ltor(n+1, 0);
    vector<int> rtol(n+1, 0);
 
    int cnt = 0;
    rep(i, n-1){
        if(s[i] == '<' && s[i+1] == '>') {
            ltor[i] += cnt + 1;
            cnt = 0;
        }
        else if(s[i] == '<') ++cnt;
    }
    if(s[n-1] == '<') ltor[n] = cnt + 1;
 
    cnt = 0;
    for(int i = n-1; i >= 1; --i){
        if(s[i] == '>' && s[i-1] == '<'){
            rtol[i-1] += cnt + 1;
            cnt = 0;
        }
        else if(s[i] == '>') ++cnt;
    }
    if(s[0] == '>') rtol[0] = cnt + 1;
 
    // rep(i, n+1) cout << ltor[i] << " ";
    // cout << endl;
    // rep(i, n+1) cout << rtol[i] << " ";
    // cout << endl;
 
    vector<int> res(n+1, 0);
    if(s[0]=='<') res[0] = 0;
    else res[0] = max(ltor[0], rtol[0]);
    
    rep(i, n-1){
        if(s[i] == '<' && s[i+1] == '<') {
            res[i+1] = res[i] + 1;
        }
        if(s[i] == '>' && s[i+1] == '>') {
            res[i+1] = res[i] - 1;
        }
        if(s[i] == '>' && s[i+1] == '<') {
            res[i+1] = 0;
        }
        if(s[i] == '<' && s[i+1] == '>') {
            res[i+1] = max(ltor[i], rtol[i]);
        }
    }
    // cout << endl;
    // rep(i, n+1) cout << res[i] << " ";
    // cout << endl;
 
    if(s[n-1] == '>') res[n] = 0;
    else res[n] = max(ltor[n], rtol[n]);
 
    for(int i = n-1; i >= 1; --i){
        if(s[i] == '>' && s[i-1] == '>'){
            res[i] = min(res[i+1] + 1, res[i]);
        }
    }
 
    // cout << endl;
    // rep(i, n+1) cout << res[i] << " ";
    // cout << endl;
 
    ll ans = 0;
    rep(i, n+1) ans += res[i];
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 6812
def binary_search(item, values):
  top = 0
  bottom = len(values) - 1
  length = bottom - top + 1
  middle = top + (length // 2)
  while length >= 1:
    middle_item = values[middle][1]
    if middle_item == item:
      break
    if middle_item < item:
      top = middle + 1
    else:
      bottom = middle - 1
    length = bottom - top + 1
    middle = top + (length // 2)
  if middle <= (len(values) - 1):
    return middle
  else:
    return -1

n = int(raw_input().rstrip("\n"))
piles = map(int, raw_input().rstrip("\n").split(" "))

limits = [(-1, 0)]
from collections import defaultdict
counter = defaultdict(int)
gaps = defaultdict(int)
for i , count in enumerate(piles):
  position = binary_search(count, limits)
  if position == -1:
    limits.append((i, count))
    counter[i] += 1
  else:
    limit_index, limit = limits[position]
    counter[limit_index] += 1
    gaps[limit_index] -= limit - count
    
results = defaultdict(int)
#print limits
total = 0
for position in xrange(len(limits)-1,0,-1):
  limit_index, limit = limits[position]
  #print (total + counter[limit_index]) ,  (limit - limits[position -1][1]) ,gaps[limit_index]
  results[limit_index] = (total + counter[limit_index]) * (limit - limits[position -1][1]) + gaps[limit_index]
  total += counter[limit_index]

for i in xrange(n):
  print results[i]



Measured memory_bytes: 42924
#include <stdio.h>
int main()
{
	char a,b,c;
	int ans = 0 ;
	scanf("%c%c%c",&a,&b,&c);
	if(a=='1')
	{
		ans++;
	}
	if(b == '1') ans++;
	if(c == '1') ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int a = sc.nextInt();
        int color[] = {0, 0, 0, 0, 0, 0, 0, 0,0};
        int ans = 0,ans2 = 0,tmp;
        for(int i = 0;i < a;i++){
          tmp = sc.nextInt();
          if(tmp / 400 >= 8){
            color[8] += 1;
          }else{
            color[tmp  / 400] = 1;
          }
        }
        
        for(int i = 0; i < 8;i++){
          ans += color[i];
        }
        ans2 = ans + color[8];
        if(ans == 0){
          ans = 1;
        }
      
        System.out.println(ans + " " + ans2);
    }
}

Measured memory_bytes: 38920
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
using namespace std;
int main(void) {
  string s;
  long long int k;
  cin >> s;
  cin >> k;
  for (auto i = s.begin(); i != s.end(); i++) {
    if (*i != '1') {
      if (i - s.begin() < k)
        cout << *i << endl;
      else {
        cout << '1' << endl;
      }
      return 0;
    }
  }
  cout << '1' << endl;
  return 0;
}


Measured memory_bytes: 256