akhauriyash/Code-Regression huggingface dataset:
#include <iostream>


using namespace std;
 

int main(){
string S, T, U;
int A, B;
cin>> S>> T;
cin>> A>> B;
cin>> U;

if(U==S){
   A-=1;
}else{
   B-=1;
}
cout<< A<<" "<< B;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[33;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
char maze[1005][1005];
int h,w;
int vis[1005][1005];
struct P{
	int x,y;
};
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
void solve()
{
	memset(vis,-1,sizeof(vis));
	queue<P> q;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(maze[i][j]=='#')
			{
				q.push(P {i,j});
				vis[i][j]=0;
			}
		}
	}
	while(!q.empty())
	{
		P u=q.front();q.pop();
		for(int i=0;i<4;i++)
		{
			int nx=u.x+dx[i],ny=u.y+dy[i];
			if(nx<0||ny<0||nx>=h||ny>=w) continue;
			if(vis[nx][ny]!=-1) continue;
			q.push(P {nx,ny});
			vis[nx][ny]=vis[u.x][u.y]+1;
		}
	}
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>h>>w;
	for(int i=0;i<h;i++)
		cin>>maze[i];
	solve();
	int ans=0;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			ans=max(ans,vis[i][j]);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 13328
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int width = in.nextInt();
            int height = in.nextInt();
            int n = in.nextInt();
            TaskD.Obstacle[] obstacles = new TaskD.Obstacle[n];
            for (int i = 0; i < n; ++i) {
                obstacles[i] = new TaskD.Obstacle();
                obstacles[i].x = in.nextInt();
                obstacles[i].y = in.nextInt();
            }
            Arrays.sort(obstacles, new Comparator<TaskD.Obstacle>() {

                public int compare(TaskD.Obstacle o1, TaskD.Obstacle o2) {
                    int z = o1.x - o2.x;
                    if (z == 0) z = o1.y - o2.y;
                    return z;
                }
            });
            int delta = 0;
            for (TaskD.Obstacle o : obstacles) {
                int curDelta = o.x - o.y;
                if (curDelta == delta) {
                    ++delta;
                } else if (curDelta > delta) {
                    out.println(o.x - 1);
                    return;
                }
            }
            out.println(width);
        }

        static class Obstacle {
            int x;
            int y;

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 52644
/*
	Auth: Loxilante
	Time: 2020/09/
	Prog: 
	Lang: cpp
*/
#include <bits/extc++.h>
#include <atcoder/all>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...) 97
#endif
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn = int> inline tn next(void) { tn k; cin>>k; return k; }
signed main(void)
{
	clock_t Begin = clock();

	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m;
	cin>>n>>m;

	dsu f(n+5);
	hrp(i, 1, n) f.merge(i, i);
	
	while(m--)
	{
		int a, b;
		cin>>a>>b;
		f.merge(a, b);
	}
	set<int> st;
	hrp(i, 1, n) st.insert(f.leader(i));
	cout<<st.size()-1<<endl;

	
	clock_t InputFinished = clock();
	
	
	
	clock_t End = clock();
	
	D((double)(End-Begin)/CLOCKS_PER_SEC);
	D((double)(End-InputFinished)/CLOCKS_PER_SEC);
	
	return 0;
}
/*
3 1
1 2
 */

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

int main() {
	int n, k;
	cin >> n >> k;
	bool used[10] = {};
	REP(i, k) {
		int in; cin >> in;
		used[in] = true;
	}
	int ans = n;
	while (true) {
		bool flag = true;
		int keta = log10(ans) + 1;
		REP(i, keta) {
			if (used[ans / (int)pow(10, i) % 10]) flag = false;
		}
		if (flag) break;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;

namespace abc088b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(s => int.Parse(s)).ToList();
            int alice, bob = 0;
            int sum = a.Sum();
           // a.Sort();
            alice = a.OrderByDescending(o=>o).Where((num, index) => index % 2 == 0).Sum();
            bob = sum - alice;
            Console.WriteLine(alice - bob);
        }
    }
}


Measured memory_bytes: 13396
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt();
      const S = readToken();
      
      auto nxt = new int[][](10, N + 1);
      foreach (d; 0 .. 10) {
        nxt[d][N] = N;
        foreach_reverse (i; 0 .. N) {
          nxt[d][i] = (S[i] - '0' == d) ? i : nxt[d][i + 1];
        }
      }
      
      int ans;
      foreach (a; 0 .. 10) foreach (b; 0 .. 10) foreach (c; 0 .. 10) {
        int i = 0;
        i = nxt[a][i] + 1;
        if (i < N) {
          i = nxt[b][i] + 1;
          if (i < N) {
            i = nxt[c][i] + 1;
            if (i <= N) {
              debug {
                writeln(a, b, c);
              }
              ++ans;
            }
          }
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

int N, i, j, k, tmp, h, w, t;

int main(void) {
	int K, X, ans;
	scanf("%d %d", &K, &X);
	
	tmp = X - K + 1;
	for (i = tmp; i <= X + K - 1; i++) {

		printf("%d ", i);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 1000000007;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int x, n;
  cin >> x >> n;
  int a[n];
  bool vis[101] = {0};
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
    vis[a[i]] = 1;
  }
  if (n == 0)
    cout << x ;
  else
  {
    int ans = 1e9;
    int out;
    for (int i = 0; i <= 200; ++i)
    {
      if (vis[i] == 0)
      {
        for (int j = 0; j < n; ++j)
        {
          int temp = abs(x - i);
          if (temp < ans)
          {
            ans = temp;
            out = i;
          }
        }
      }
    }
    cout << out ;
  }

}

Measured memory_bytes: 3648
### classes

class Room
  attr_accessor :id, :dist, :n, :k, :nbrs

  def initialize(dist, n)
    @id = $newid
    $newid += 1
    @dist = dist
    @n = n
    @k = 0
    @nbrs = []
  end

  def connect(room)
    @nbrs << room.id
    @k += 1
    room.nbrs << @id
    room.k += 1

    if @k > @n || room.k > room.n
      puts 'error'
      exit
    end
  end

  def full?
    @n == @k
  end
end

### main

n = gets.to_i

n.times do
  rcds = []
  loop do
    line = gets.split.map(&:to_i)
    rcds += line
    break if line.last == 0
  end

  $newid = 0

  rooms = []
  drooms = []
  dist = -1
  
  for rcd in rcds
    #p [rcd, dist]
    break if rcd == 0

    if rcd > 0
      dist += 1
      room = Room.new(dist, rcd)
      #p ["new", room]
      room.connect(drooms[dist - 1]) if dist > 0
      rooms[room.id] = room
      drooms[dist] = room
    else
      room = drooms[dist]
      #p ["coonect", room, drooms[dist + rcd]]
      room.connect(drooms[dist + rcd])
    end

    while dist >= 0 && drooms[dist].full?
      dist -= 1
    end
    #p rooms
    #p drooms
  end

  rooms.each_with_index do |room, i|
    puts ([i + 1] + room.nbrs.sort.map{|id| id + 1}).join(' ')
  end
end

Measured memory_bytes: 6248
#include<iostream>
#include<algorithm>
using namespace std;
long M=1e9+7;
long dp[55][2];
string a,b,c;
main()
{
	while(cin>>a,a!="0")
	{
		cin>>b>>c;
		for(int i=0;i<=a.size();i++)dp[i][0]=dp[i][1]=0;
		dp[0][0]=1;
		for(int i=0;i<a.size();i++)
		{
			for(int A=a[i]=='?'?!i:a[i]-'0';A<=(a[i]=='?'?9:a[i]-'0');A++)
				for(int B=b[i]=='?'?!i:b[i]-'0';B<=(b[i]=='?'?9:b[i]-'0');B++)
					for(int C=c[i]=='?'?!i:c[i]-'0';C<=(c[i]=='?'?9:c[i]-'0');C++)
			{
				if((A+B)%10==C)
				{
					dp[i+1][0]=(dp[i+1][0]+dp[i][A+B>=10])%M;
				}
				if((A+B+1)%10==C)
				{
					dp[i+1][1]=(dp[i+1][1]+dp[i][A+B+1>=10])%M;
				}
			}
		}
		cout<<dp[a.size()][0]<<endl;
	}
}



Measured memory_bytes: 2984
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

string s;

signed main() {

    cin >> s;
    int maxi = 0;
    string a = "ACGT";
    for(int i = 0; i < s.size(); i++) {
        for(int j = i; j < s.size(); j++) {
            bool f = true;
            for(int k = i; k <= j; k++)
                if(a.find(s[k]) == string::npos) f = false;
            if(f) chmax(maxi, j - i+1);
        }
    }

    cout << maxi << endl;
  
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long mins , H , W , s1 , s2 , s3 ;

int main()
{
    mins = 1e12;
    cin >> H >> W;
    for (int i = H/3 ; i <= H-1 ; i++)
    {
        s1 = i*W;
        s2 = (W/2)*(H-i);
        s3 = H*W - s1 - s2;
        mins = min(mins , (max(s1,max(s3,s2)) - min(s1 , min(s2 , s3))));
        s2 = ((H-i)/2)*W;
        s3 = H*W - s1 - s2;
        mins = min(mins , (max(s1,max(s3,s2)) - min(s1 , min(s2 , s3))));
    }
    for (int i = W/3 ; i <= W-1 ; i++)
    {
        s1 = i*H;
        s2 = (H/2)*(W-i);
        s3 = H*W - s1 - s2;
        mins = min(mins , (max(s1,max(s3,s2)) - min(s1 , min(s2 , s3))));
        s1 = i*H;
        s2 = ((W-i)/2)*H;
        s3 = H*W - s1 - s2;
        mins = min(mins , (max(s1,max(s3,s2)) - min(s1 , min(s2 , s3))));
    }
    cout << mins;
}

Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    s = input()

    s1 = int(s[-1])
    if s1 in (2,4,5,7,9):
        u = "hon"
    elif s1 in (0, 1, 6, 8):
        u = "pon"
    else:
        u = "bon"
    print(u)

if __name__ == "__main__":
    resolve()


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

int main() {
  int64_t N,A,B;
  cin >> N >> A >> B; 
  
  int64_t amari = N % (A + B);
  
  if (amari <= A) {
    cout << N / (A + B) * A + N % (A + B) << endl;
  }
  else if (amari > A) {
    cout << N / (A + B) * A + A << endl;
  }
  
}












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

int main(void){
    long long n;
    cin >> n;
    vector<long long> a(n+10), b(n+10);
    long long asum = 0, bsum = 0;
    for(long long i=0;i<n;++i){
        cin >> a[i];
        asum += a[i];
    }
    for(long long i=0;i<n;++i){
        cin >> b[i];
        bsum += b[i];
    }
    long long cnt = 0;
    if(asum > bsum){
        cout << "No\n";
        return 0;
    }else{
        cnt = bsum - asum;
    }
    long long tmp = 0;
    for(long long i=0;i<n;++i){
        if(a[i]==b[i]) continue;
        if(a[i]<b[i]){
            tmp += (b[i]-a[i])/2;
        }else{
            tmp -= (a[i]-b[i]);
        }
    }
    if(tmp >= 0) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
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...));
}

int main() {
    ll n;
    cin >> n;
    ll ans = LINF;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) chmin(ans, i + n / i - 2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/* Isn't passion overrated?*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll k;
    ll a,b;
    cin>>k>>a>>b;
    ll m = b%k;
    b -= m;
    if( b >= a)
        cout<<"OK";
    else
        cout<<"NG";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long 
#define FF first
#define SS second
#define MOD 1000000007

using namespace std;

int gcd(int a, int b) {
  while (a > 0 && b > 0)
    if (a > b) a %= b;
    else b %= a;
  return a + b;
}

ll modpower(ll x, ll y, ll p) //x^y mod p
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y %2!= 0)
            res = (res*x) % p;
 
        // y must be even now
        y = y/2;
        x = (x*x) % p;  
    }
    return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	cin>>n;
	ll arr[n];
	ll sm=0;
	for(int i=0;i<n;i++)cin>>arr[i],arr[i]-=i,sm+=arr[i];
	sort(arr,arr+n);
	ll ans = 0;
	if(n%2!=0)
	{
		ans = arr[n/2];
	}
	else
	{
		ll mini = 0;
		for(int i=0;i<n;i++)
		{
			mini+=abs(arr[i]-arr[n/2]);
		}
		ll tmp= 0;
		for(int i=0;i<n;i++)
		{
			tmp+=abs(arr[i]-arr[n/2-1]);
		}
		if(tmp>mini)
		{
			ans = arr[n/2];
		}else ans = arr[n/2-1];
	}
	ll tt = 0;
	for(int i=0;i<n;i++)tt+=abs(arr[i]-ans);
	cout<<tt;
}


Measured memory_bytes: 1792
#![allow(unused_imports)]
#![allow(dead_code)]

use std::collections::*;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let ma: usize = sc.read();
    let mb: usize = sc.read();
    let abc: Vec<(usize, usize, i32)> = (0..n).map(|_| (sc.read(), sc.read(), sc.read())).collect();
    let mut init = vec![vec![std::i32::MAX; 401]; 401];
    init[0][0] = 0;
    let dp = abc.iter().fold(init, |acc, v| {
        let &(a, b, c) = v;
        (0..401)
            .map(|i| {
                (0..401)
                    .map(|j| {
                        let mut res = acc[i][j];
                        if i >= a && j >= b && acc[i - a][j - b] < std::i32::MAX {
                            res = std::cmp::min(res, acc[i - a][j - b] + c);
                        }
                        res
                    })
                    .collect()
            })
            .collect()
    });
    let mut mul = 1;
    let mut ans = std::i32::MAX;
    while mul * ma <= 400 && mul * mb <= 400 {
        ans = std::cmp::min(ans, dp[mul * ma][mul * mb]);
        mul += 1;
    }
    if ans == std::i32::MAX {
        ans = -1;
    }
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4476
# -*- coding:utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
ans = []
for tmp in range(len(a)):
    b = a[tmp]
    c = 0
    while True:
        if b%2 != 0:
            ans.append(c)
            break
        else:
            b /= 2
            c += 1
print(min(ans))

Measured memory_bytes: 3060
N = int(input())
Red = [list(map(int, input().split())) for _ in range(N)]
Blue = [list(map(int, input().split())) for _ in range(N)]

Red.sort(key=lambda x: x[1], reverse=True)
Blue.sort(key=lambda x: x[0])

ans = 0
for blue in Blue:
    for red in Red:
        if red[0] < blue[0] and red[1] < blue[1]:
            ans += 1
            Red.remove(red)
            break

print(ans)


Measured memory_bytes: 3064
from collections import defaultdict as dic
n, m = map(int, input().split())
ac = 0
pena = 0
d = dic(list)
for i in range(m):
    pi, si = input().split()
    d[pi].append(si)

for (k, v) in d.items():
    pe = 0
    flag = False
    for aw in v:
        if aw == 'WA':
            pe += 1
        else:
            ac += 1
            flag = True
            break

    if flag:
        pena += pe

print(ac, pena)


Measured memory_bytes: 36464
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	if(a<b)swap(a,b);
	if(b==0)return a;
	else return gcd(b,a%b);
}
const int MAX=100500;
int main()
{
	int n;
	int a[MAX],left[MAX],right[MAX],cnt[MAX];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	left[0]=a[0];
	for(int i=1;i<n;i++)
		left[i]=gcd(left[i-1],a[i]);
	right[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)
		right[i]=gcd(right[i+1],a[i]);
	cnt[0]=right[1];
	cnt[n-1]=left[n-2];
	for(int i=1;i<n-1;i++)
		cnt[i]=gcd(left[i-1],right[i+1]);
	int res=0;
	for(int i=0;i<n;i++)
		res=max(res,cnt[i]);
	cout<<res<<endl;
	return 0;
}	

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define PB push_back
#define fst first
#define sec second
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ms(a,x) memset(a,x,sizeof(a))
typedef long long LL;
#define pi pair < int ,int >
#define MP make_pair

using namespace std;
const double eps = 1E-8;
const int dx4[4]={1,0,0,-1};
const int dy4[4]={0,-1,1,0};
const int inf = 0x3f3f3f3f;
const int N=1e5+10;

int n,k;

struct node
{
	int x,y;
}d_pos[N];

pair<int,int>a[123456];

int main()
{
	LL ans=-1;
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	{
		cin>>d_pos[i].x>>d_pos[i].y;
	}
	int nn=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			a[nn++]=make_pair(d_pos[i].x,d_pos[j].y);
		}
	}

	for (int i=1;i<=nn;i++)
	{
		for (int j=1;j<=nn;j++)
		{
			if (j!=i)
			{
				int res=0;
				int mi_x=min(a[i].first,a[j].first);
				int ma_x=max(a[i].first,a[j].first);
				int mi_y=min(a[i].second,a[j].second);
				int ma_y=max(a[i].second,a[j].second);
				for (int k=1;k<=n;k++)
				{
					int t_x=d_pos[k].x,t_y=d_pos[k].y;
					if (mi_x<=t_x&&t_x<=ma_x&&mi_y<=t_y&&t_y<=ma_y) res++;
				}
				if (res>=k)
				{
					LL fuck=1LL*(ma_x-mi_x)*(ma_y-mi_y);
					if (ans==-1) ans=fuck;
					else ans=min(ans,fuck);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php

$N = fgets(STDIN);
$S = fgets(STDIN);

$x = 0;
$maxX = $x;

for ($index = 0; $index < $N; $index++) {

    if ($S[$index] === 'I') {
        $x++;
    } else if ($S[$index] === 'D') {
        $x--;
    }

    if ($maxX < $x) {
        $maxX = $x;
    }
}

echo $maxX;

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

const int maxn = 2e5 + 3, lo = 0x40000;

struct dmt {
    int a[maxn], l;
    void add(int v) {
        a[l++] = v;
    }
    void init() {
        std::sort(a, a + l);
        l = std::unique(a, a + l) - a;
    }
    int query(int v) {
        return std::lower_bound(a, a + l, v) - a;
    }
} dm;

struct segtree {
    int a[lo * 2];
    void modify(int k, int v) {
        a[k + lo] = v;
        for(int i = (k + lo) / 2; i > 0; i /= 2) {
            a[i] = std::max(a[i * 2], a[i * 2 + 1]);
        }
    }
    int query(int l, int r) {
        int ans = 0;
        for(int i = l + lo, j = r + lo; i < j; i /= 2, j /= 2) {
            if(i & 1)
                ans = std::max(ans, a[i++]);
            if(j & 1)
                ans = std::max(ans, a[--j]);
        }
        return ans;
    }
} seg, val;

int n, a[maxn], p[maxn], d[maxn], fans[maxn];

std::vector<int> E[maxn];

void dfs(int u) {
    auto segw = seg.query(0, a[u]) + 1;
    auto valw = val.query(0, d[u]);
    fans[u] = std::max(valw, segw);
    int old_seg = seg.query(a[u], a[u] + 1);
    val.modify(d[u], fans[u]);
    seg.modify(a[u], std::max(old_seg, segw));
    for(auto &&v : E[u]) {
        if(v == p[u])
            continue;
        d[v] = d[u] + 1;
        p[v] = u;
        dfs(v);
    }
    seg.modify(a[u], old_seg);
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        dm.add(a[i]);
    }
    dm.init();
    for(int i = 1; i <= n; ++i) {
        a[i] = dm.query(a[i]);
    }
    for(int i = 0; i < n - 1; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        E[u].emplace_back(v);
        E[v].emplace_back(u);
    }
    dfs(1);
    for(int i = 1; i <= n; ++i) {
        printf("%d\n", fans[i]);
    }
    return 0;
}

Measured memory_bytes: 34580
#include <bits/stdc++.h>
#define N 5005

using namespace std;
typedef long long ll;

template <class T> inline void read(T &x) {
	char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	if (flag) x = -x;
}

inline int input() {
	int x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

const int mod = 1e9 + 7;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; }
inline void inc(int &x, int y) { x += y; x -= x >= mod ? mod : 0; }

inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = (ll) res * x % mod;
		x = (ll) x * x % mod, y >>= 1;
	} return res;
}

template <class T> void chkmax(T &x, T y) { x = x > y ? x : y; }
template <class T> void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> T gcd(T x, T y) { return !y ? x : gcd(x % y, y); }

int n;
vector<int> G[N];
int f[N][N][2], cur[N][2], g[N];
int size[N];

inline void AddEdge(int x, int y) {
	G[x].push_back(y);
	G[y].push_back(x);
}

void dfs(int u, int fa) {
	size[u] = 1, f[u][1][1] = 1;
	for (int v : G[u]) {
		if (v == fa) continue;
		dfs(v, u);
		memset(cur, 0, sizeof cur);
		for (int i = 1; i <= size[u]; ++i) {
			for (int j = 1; j <= size[v]; ++j) {
				inc(cur[i + j][0], (ll) f[v][j][1] * f[u][i][0] % mod);
				inc(cur[i + j][0], (ll) f[v][j][0] * f[u][i][1] % mod);
				inc(cur[i + j][1], (ll) f[v][j][0] * f[u][i][0] % mod);
				inc(cur[i + j][1], (ll) f[v][j][1] * f[u][i][1] % mod);
				inc(cur[i][0], (ll) g[j] * f[v][j][0] % mod * f[u][i][0] % mod);
				inc(cur[i][0], (ll) g[j] * f[v][j][1] % mod * f[u][i][1] % mod);
				inc(cur[i][1], (ll) g[j] * f[v][j][0] % mod * f[u][i][1] % mod);
				inc(cur[i][1], (ll) g[j] * f[v][j][1] % mod * f[u][i][0] % mod);
			}
		}
		memcpy(f[u], cur, sizeof cur);
		size[u] += size[v];
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1, x, y; i < n; ++i) {
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	
	g[0] = 1;
	for (int i = 2; i <= n; i += 2)
		g[i] = (ll) g[i - 2] * (i - 1) % mod;

	dfs(1, 0);
	
	int ans = 0;
	for (int i = 2; i <= n; ++i)
		inc(ans, (ll) g[i] * (f[1][i][1] - f[1][i][0] + mod) % mod);
	printf("%d\n", ans);
	return 0;
}






















Measured memory_bytes: 196864
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	X *= 2; Y *= 2;
	int x = 0, y = 0;
	ll ans = 0;
	if (C*2 <= A+B)
	{
		while (x < X && y < Y)
		{
			ans += (ll)C;
			x++;
			y++;
		}
	}
	if (C*2 <= A)
	{
		while (x < X)
		{
			ans += (ll)C;
			x++;
		}
	}
	else
	{
		while (x < X)
		{
			ans += (ll)A;
			x += 2;
		}
	}
	if (C*2 <= B)
	{
		while (y < Y)
		{
			ans += (ll)C;
			y++;
		}
	}
	else
	{
		while (y < Y)
		{
			ans += (ll)B;
			y += 2;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
x, n = gets.split.map(&:to_i)
pp = gets.split.map(&:to_i)


unless pp.include?(x)
  puts x
  exit 0
end

unless n > 0
  puts x
  exit 0
end

1.upto(n) do |i|
  x_minus = x - i
  x_plus = x + i
  unless pp.include?(x_minus)
    puts x_minus
    exit 0
  end
  unless pp.include?(x_plus)
    puts x_plus
    exit 0
  end
end


Measured memory_bytes: 14376
#include <bits/stdc++.h>
using namespace std;
string s;
int n,k;
bool chk(int x){
	int a1,a2,cnt=0,b=0,e=0;
	
	// inital count
	int prev=1;
	for(a1=0;a1<x;++a1){
		if(s[a1]=='1') prev=1;
		else{
			if(prev==1) ++cnt;
			prev=0;
		}
	}
	if(cnt<=k) {return true;}

	if(s[0]=='1') b=1;
	if(s[x-1]=='1') e=1;
	for(a1=1;a1+x-1<n;++a1){
		if(s[a1]=='0'){
			b=0;
		}
		else{
			if(b==0) --cnt;
			b=1;
		}
		if(s[a1+x-1]=='0'){
			if(e==1) ++cnt;
			e=0;
		}
		else{
			e=1;
		}
		if(cnt<=k) {return true;}		
	}
	return false;
}
int main(){
	cin>>n>>k;
	cin>>s;
	int ans=0,low=0,high=n;
	while(low<=high){
		int mid=(low+high)/2;
		// cout<<mid<<" ";
		if(chk(mid)){
			low=mid+1;
			ans=mid;
		}
		else{
			high=mid-1;
		}
		// cout<<"\n";
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
const long long MOD=998244353;
typedef pair<long long,long long>P;
int main(){
  long long n,k;
  long long dp[555555]={0};
  P seg[20];
  cin>>n>>k;
  for(int i=0;i<k;i++){
    long long l,r;
    cin>>l>>r;
    seg[i]=P(l,r);
  }
  
  dp[1]=1;
  dp[2]=-1;
  for(int i=1;i<=n;i++){
    dp[i]=(dp[i]+dp[i-1])%MOD;
    for(int j=0;j<k;j++){
      long long l=seg[j].first;
      long long r=seg[j].second;
      dp[i+l]=(dp[i+l]+dp[i])%MOD;
      dp[i+r+1]=(dp[i+r+1]-dp[i])%MOD;
    }
  }
  while(dp[n]<0){
    dp[n]+=MOD;
  }
  cout<<dp[n]<<endl;
  return(0);
}

Measured memory_bytes: 7976
#include <stdio.h>

int main() {
	int N;
	scanf("%d",&N);
	int flag = 0;
	for (int i = 1; i <= 9; i++) {
		double tmp = (double)N/(double)i;
		if (tmp == (int)tmp) {
			int val = tmp/10;
			if (val == 0) {
				printf("Yes\n");
				flag = 1;
				break;
			}
		}
	}
	if (flag == 0) printf("No\n");
	return 0;
}

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

typedef long long int lli;
#define pb push_back
#define gcd __gcd
#define MOD 1000000007
#define mod2 998244353
#define forz(i,n) for(long long int i=0;i<n;i++)

double mod(double a){
    if(a<0) return -1*a;
    return a;
}

bool prime[100000000+1];

void SieveOfEratosthenes() 
{ 
    lli n=100000000;
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
}

bool aa(string a,string b){
    for(int i=0;i<7;i++){
        if(a[i]=='?') continue;
        else if(a[i]==b[i]) continue;
        else return 0;
    }
    return 1;
}

bool bb(string t2){
    map<string,lli> solve;
    map<string,lli>::iterator itr;
    for(int i=0;i<t2.size()-6;i++){
        solve[t2.substr(i,7)]++;
    }
    string s="abacaba";
    if(solve[s]==1) return 1;
    return 0;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t=1,u,j;
    
    
    //cin>>t;
    ///SieveOfEratosthenes();
    for(u=1;u<=t;u++){
        lli m,n, i,j,a,b,c,k,p=0,q=0,p1=0,p2=0,p3=0,ans=0,l,r,index=-1;
        cin>>n>>k;
        lli A[n];
        for(i=0;i<n;i++) cin>>A[i];
        for(i=0;i<n-k;i++){
            if(A[i+k]>A[i]) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 5220
#include <bits/stdc++.h>
#define FOR(i, x, y) for (ll i = x; i < y; i++)
typedef long long ll;
using namespace std;

ll a[200001];
map<ll, ll> cnt;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    FOR(i, 0, n) {
        cin >> a[i];
        a[i] -= i;
        cnt[a[i]]++;
    }
    ll ans = 0;
    FOR(i, 0, n) {
        ans += cnt[- 2 * i - a[i]];
        cnt[a[i]]--;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 27924
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000009;
using namespace std;
vector<pair<long long, long long>>juice;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
long long stair[100009];
long long outo[100009];
long long memo = 1;

string S;
int main() {
	long long a = 0, b = 0;
	cin >> a >> b;
	for (int i = 0; i < b; i++) {
		cin >> outo[i];
		
		stair[outo[i]] = INF;
		stair[outo[i]+1] = INF;
		stair[outo[i] + 2] = INF;
		if (i != 0) {
			if (outo[i] - 1 == outo[i - 1]) {
				cout << '0' << endl;
				return 0;
			}
		}
	}
	stair[0] = 1;
	stair[1] = 1;
	for (int i = 1; i <= a; i++) {
		if (stair[i]==1000000009) {
			stair[i] = stair[i - 1];
		}
		else {
			stair[i] = (stair[i - 1] + stair[i - 2])%1000000007;
		}
	}
	cout << stair[a] << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>

using namespace std;

int main(void) {

	long long int N;

	cin >> N;

	int A = 0;



		long long int M;
		M = N;

		while (M > 0) { A += M % 10; M /= 10; }
	
		if (N%A == 0) {
			cout<<"Yes"<<endl;}
		else { cout << "No" << endl; }

	

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInteger()
    val pList = readIntegerList().joinToString()
    val qList = readIntegerList().joinToString()

    val permutationList = permutationListFrom(Array(n) { it + 1 }).map {
        it.joinToString()
    }

    println(Math.abs(permutationList.indexOf(pList) - permutationList.indexOf(qList)))

}

fun <T : Comparable<T>> permutationListFrom(array: Array<T>): List<Array<T>> {
    val current = array.copyOf()
    val permutationList = mutableListOf<Array<T>>()
    do {
        permutationList += current.copyOf()
    } while (nextPermutation(current))

    return permutationList
}

fun <T : Comparable<T>> nextPermutation(currentPermutation: Array<T>): Boolean {
    fun <T> Array<T>.reverse(start: Int, end: Int) {
        val midPoint = ((start + end) / 2) - 1
        if (midPoint < 0) return
        var reverseIndex = end - 1
        for (index in start..midPoint) {
            val tmp = this[index]
            this[index] = this[reverseIndex]
            this[reverseIndex] = tmp
            reverseIndex--
        }
    }

    val n = currentPermutation.size

    var i = n - 2
    while (i >= 0) {
        if (currentPermutation[i] < currentPermutation[i + 1]) break
        i--
    }

    if (i < 0) return false

    var j = n
    do {
        j--
    } while (currentPermutation[i] > currentPermutation[j])

    if (currentPermutation[i] < currentPermutation[j]) {
        val tmp = currentPermutation[i]
        currentPermutation[i] = currentPermutation[j]
        currentPermutation[j] = tmp
        currentPermutation.reverse(i + 1, n)
        return true
    }

    return false
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 53036
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
  ll N, A;
  cin >> N;
  ll max_a = -1;
  ll ans = 0;
  for (int i=0; i<N; i++){
    cin >> A;
    max_a = max(max_a, A);
    ans += (max_a - A);
  }
  
  cout << ans << "\n";
  return 0;
}

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

int32_t main()
{
    int k;cin>>k;
  string s;cin>>s;
  
  int d=s.size();
  if(d<=k)
    cout<<s<<endl;
  else
  {
    string str=s.substr(0,k);
    str+="...";
    cout<<str<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3600
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
const pair<int, int> arienai = make_pair(inf, -inf);
bool vis[209][209]; pair<int, int> dp[209][209];
pair<int, int> solve(int l, int r, string& s) {
	if (r - l == 0) return arienai;
	if (r - l == 1) return('0' <= s[l] && s[l] <= '9' ? make_pair(int(s[l] - '0'), int(s[l] - '0')) : arienai);
	if (vis[l][r]) return dp[l][r];
	pair<int, int> ans = arienai;
	for (int i = l + 1; i < r - 1; ++i) {
		if (s[i] == '+') {
			pair<int, int> lc = solve(l, i, s);
			pair<int, int> rc = solve(i + 1, r, s);
			if (lc != arienai && rc != arienai) {
				ans.first = min(ans.first, lc.first + rc.first);
				ans.second = max(ans.second, lc.second + rc.second);
			}
		}
		if (s[i] == '-') {
			pair<int, int> lc = solve(l, i, s);
			pair<int, int> rc = solve(i + 1, r, s);
			if (lc != arienai && rc != arienai) {
				ans.first = min(ans.first, lc.first - rc.second);
				ans.second = max(ans.second, lc.second - rc.first);
			}
		}
	}
	for (int i = 1; i < 4; ++i) {
		if ((i & 1) && s[l] != '(') continue;
		if ((i & 2) && s[r - 1] != ')') continue;
		pair<int, int> res = solve(l + (i & 1 ? 1 : 0), r - (i & 2 ? 1 : 0), s);
		if (res != arienai && (r - (i & 2 ? 1 : 0)) - (l + (i & 1 ? 1 : 0)) >= 2) {
			ans.first = min(ans.first, res.first);
			ans.second = max(ans.second, res.second);
		}
	}
	vis[l][r] = true;
	dp[l][r] = ans;
	return ans;
}
int main() {
	string s;
	cin >> s;
	pair<int, int> ans = solve(0, s.size(), s);
	cout << ans.second << endl;
	return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    if (N <= 9) {
        cout << N << endl;
    } else if (N <= 99) {
        cout << 9 << endl;
    } else if (N <= 999) {
        cout << 9 + (N-99) << endl;
    } else if (N <= 9999) {
        cout << 909 << endl;
    } else if (N <= 99999) {
        cout << 909 + (N-9999) << endl;
    } else {
        cout << 90909 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int n, ans, h, w, number;
double ans_BMI, BMI;

int main() {
	while ( ~scanf( "%d", &n ) && n ) {
		ans_BMI = INF;
		ans = INF;
		for ( int i = 0; i < n; i++ ) {
			scanf( "%d %d %d", &number, &h, &w );
			BMI = ( 1. * w / ( sq( 1. * h / 100 ) ) );
			if ( fabs( ans_BMI - 22 ) > fabs( BMI - 22 ) || ( fabs( ans_BMI - 22 ) == fabs( BMI - 22 ) && ans > number ) ) {
				ans_BMI = BMI;
				ans = number;
			}
		}
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1188
/*
 * ABC097_A.cpp
 *
 *  Created on: May 21, 2018
 *      Author: 13743
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



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

	int a,b,c,d;
	cin >> a >> b >> c >> d;

	bool yes = false;
	if(a-c<=d && c-a<=d) {
		yes = true;
	}
	else if(a-b<=d && b-a<=d && b-c<=d && c-b<=d) {
		yes = true;
	}

	if(yes) cout << "Yes" << endl;
	else cout << "No" << endl;
}






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

using namespace std;

#define endl '\n'
#define cw(x) cout << (x) << endl
#define cww(x,y) cout << (x) << ' ' << y << endl
#define cwa(x) for(auto a:x) cout << a << ' ';cout << endl
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef unordered_set<int> usi;
typedef vector<pi> vpi;

int a[100000],n,i;

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

    for(cin >> n;n--;){
        cin >> i;
        a[i]++;
        a[i+1]++;
        a[i-1]++;
    }

    cout << *max_element(a,a+100000);

    return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff first
#define ss second
using namespace std;
typedef pair<int,int> pii;


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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
                while (true) {
                    int n = sc.nextInt();
                    if (n == 0) { break; }
                    int[] scores = new int[n];
                    for (int i = 0; i < scores.length; i++) {
                        scores[i] = sc.nextInt();
                    }
                    double average = 0.0, variance = 0.0;

                    double sum = 0.0;
                    n = scores.length;

                    for(int j = 0; j < n;j++){
                        sum += (double)scores[j];
                    }
                    average =  sum/n;

                   double sum1 = 0.0;
                    for(int k = 0; k < n;k++){
                        sum1 += (double)((scores[k] - average)*(scores[k] - average));
                    }
                    variance = sum1/ n;
                    System.out.println(Math.sqrt(variance));
                }
            }
    }
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    bool ok = true;
    int a[5],k;
    for(int i = 0; i < 5; i++)
    {
        cin>>a[i];
    }
    cin>>k;
    for(int i = 0; i < 5; i++)
    {
        for(int j = 0; j < i; j++)
        {
            if(abs(a[i]-a[j])>k)
            {
                ok=false;
            }
        }
    }
    if(ok) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
 
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int r = 0, b = 0;
    rep(i, s.size()){
        if (s[i] == '0') r++;
        else b++;
    }
    cout << min(r, b) * 2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()

typedef unsigned long long ll;

int main(){
   string N; cin >> N;
   int sum = 0;
   rep(i,N.length()){
        sum += N[i] - '0';
   }
   if(stoi(N) % sum == 0) cout << "Yes" << endl;
   else cout << "No" << endl;
}



Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
namespace whatever{
    int readu(){
		char ch=getchar();
		while(!isdigit(ch))
			ch=getchar();
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value;
	}
	void writeull(long long n){
		if(n<10)
			putchar(n+'0');
		else{
			writeull(n/10);
			putchar(n%10+'0');
		}
	}
	void run(){
	//	freopen(".in","r",stdin);
	//	freopen(".out","w",stdout);
        int n=readu();
		int m=readu();
        map<int, int> cnt;
		cnt[0]=1;
		long long sum=0;
		long long result=0;
		while(--n!=-1){
			int a=readu();
			sum+=a;
			result+=cnt[sum%m];
			++cnt[sum%m];
		}
		writeull(result);
		putchar('\n');
	}
}
int main(){
	whatever::run();
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array

int main() {
	int n;
	cin >> n;
	ar<int, 2> a[n];
	for (int i=0; i<n; i++) {
		cin >> a[i][0] >> a[i][1];
	}
	for (int i=0; i+2<n; i++) {
		bool done=1;
		for (int k=0; k<3; k++) {
			if (a[i+k][0]!=a[i+k][1]) {
				done=0;
				break;
			}
		}
		if (done) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include<cmath>
int main(){
    for(int l = 0;;l++){
        char s[1001];
        int m = 0;
        scanf("%s",s);
            
        if(s[0] == '0'){
            break;
        }
    
        for(int i = 0;s[i] != '\0';i++){
            char c = s[i];
        
            if(48 <= c && c <= 57){
                m += c - 48;
            }
        }
            
        printf("%d\n",m);
        
    }
    return 0;
}



Measured memory_bytes: 2740