akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				      3.14159265358979
#define 	mod 			      1000000007
#define 	ll  			      long long
#define 	rep(i, a, b) 	  for(ll i = a ; i < b ; i++)
#define   repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			      1000003
#define   mod2            998244353
#define   inf             2e18
#define 	hi   			      "hello"
#define 	nl 				      "\n"
#define 	ws 				      " "
#define 	ff 				      first
#define 	ss 				      second
#define 	pb 				      push_back
#define 	MP				      make_pair
#define 	B 				      begin()
#define   RB              rbegin()
#define 	E 				      end()
#define   UB              upper_bound
#define   LB              lower_bound
#define   present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			    v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define   pll             pair<ll, ll>
#define   vll             vector<ll>
#define   vpll            vector<pll>
#define 	vs 				      vector<string>
#define   vc              vector<char>
#define   sqr(a)          ((a)*(a))
#define 	print1(a) 		  for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		  for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(10);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 10)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve() {
    ll n;
    cin >> n;
    cout << !n << nl;
}

int main(){
    boost;
    // cal(3);

    // // For getting input from input.txt file 
    // freopen("alchemy_input.txt", "r", stdin); 
  
    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout);

    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}


Measured memory_bytes: 3608
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	int D;
	int[] c;
	int[][] s;

	int[] ans;

	long score(int[] a) {
		int[] last = new int[26];

		long res = 0;

		for (int d = 0; d < D; d++) {
			res += s[d][a[d]];
			last[a[d]] = d + 1;

			for (int j = 0; j < 26; j++) {
				res -= (c[j] * (d + 1 - last[j]));
			}
//			System.err.println(res);
		}
		return Math.max(res + 1000000, 0);
	}

	public void _main(String[] args) {
		long st = System.currentTimeMillis();
		Scanner sc = new Scanner(in);

		D = sc.nextInt();
		c = new int[26];
		for (int i = 0; i < 26; i++) {
			c[i] = sc.nextInt();
		}

		s = new int[D][26];
		for (int i = 0; i < D; i++) {
			for (int j = 0; j < 26; j++) {
				s[i][j] = sc.nextInt();
			}
		}

		sc.close();

		ans = new int[D];

		long max = score(ans);
		Random random = new Random();

		while (System.currentTimeMillis() - st < 1800) {

			for (int d = 0; d < D; d++) {
				int t = ans[d];
				ans[d] = random.nextInt(26);

				long s = score(ans);
				if (s < max) {
					ans[d] = t;
				} else {
					max = s;
				}
			}
		}

//		System.err.println(score(ans));

		for (int x : ans) {
			out.println(x + 1);
		}

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 55816
use std::cmp::min;

fn main() {
    input! {
        d: i32,
        g: i32,
        pc: [[i32; 2];d]
    }
    let target = g / 100;
    let mut dp = vec![vec![10000000; (target + 1) as usize]; 10];

    for k in 0..pc[0][0] + 1 {
        let mut point = k;
        if k == pc[0][0] {
            point += pc[0][1] / 100;
        }
        point = min(point, target);
        dp[0][point as usize] = k;
    }
    for i in 1..d {
        let point = i + 1;
        let idx = i as usize;
        for j in 0..target + 1 {
            let p = pc[idx][0];
            let c = pc[idx][1] / 100;
            for k in 0..p + 1 {
                let mut n_j = j + point * k;
                if k == p {
                    n_j += c;
                }
                n_j = min(n_j, target);

                dp[idx][n_j as usize] = min(dp[idx - 1][j as usize] + k, dp[idx][n_j as usize]);
            }
        }
    }

    println!("{}", dp[(d - 1) as usize][target as usize]);
}

#[macro_export(local_inner_maccros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[macro_export(lcal_inner_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[macro_export(lcal_inner_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


Measured memory_bytes: 6196
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cctype>
#define int long long
#define rg register
using namespace std;
inline int read(){
	rg int s=0,f=0;
	rg char ch=getchar();
	while(!isdigit(ch)) f|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return f?-s:s;
}
int n,ans,cur;
const int MAX=1000015;
int h[MAX];
signed main(){
	n=read();
	for(rg int i=1;i<=n;i=-~i) h[i]=read();
	for(rg int i=1;i<=n;i=-~i){
		if(h[i]>h[i-1]) cur=i;
		ans=max(ans,i-cur);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (H, W) = listOfInt()
    val (h, w) = listOfInt()
    println(H*W - (h*W + w*H - h*w))
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37800
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A,B) << " " << max(0,A+B-N) << endl;
}

Measured memory_bytes: 256
// :pray: :steph:
// :pray: :bakekaga:

#include <iostream>
#include <fstream>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <cmath>

#define ll long long
#define eps 1e-8
#define MOD 1000000007

#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f

// change if necessary
#define MAXN 1000000

using namespace std;

int n, w;
ll dp[100001];
vector<array<int, 2>> vals;

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

    cin >> n >> w;
    vals = vector<array<int, 2>>(n);

    for (int i = 0; i < n; i++) {
        cin >> vals[i][0] >> vals[i][1];
    }

    for (int i = 0; i <= 100000; i++) {
        dp[i] = INF;
    }

    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 100000; j >= vals[i][1]; j--) {
            dp[j] = min(dp[j], dp[j - vals[i][1]] + vals[i][0]);
        }
    }

    int ans = 0;

    for (int i = 0; i <= 100000; i++) {
        if (dp[i] <= w) {
            ans = max(ans, i);
        }
    }

    cout << ans << '\n';

    return 0;
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define all(X) X.begin(),X.end()
#define X first
#define Y second
#define eb emplace_back

using namespace std;
typedef pair<int,int> pii;
typedef vector<vector<pii>> Graph;

int h,w;
int mp[33][33];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
inline int fun(int y,int x,int dir){
  if(y<0 || y>=h || x<0 || x>=w) return h*w*4;
     return h*w*dir+w*y+x;
}
const int INF=1e9;

void dij(const Graph &g,int s,vector<int> &d){
  typedef pii Que;
  priority_queue<Que,vector<Que>,greater<Que> > que;
  int n=g.size();
  d.resize(n);
  fill(all(d),INF);
  d[s]=0;
  que.emplace(0,s);
  while(que.size()){
    Que p=que.top(); que.pop();
    if(d[p.Y]<p.X) continue;
    for(pii e:g[p.Y]) if(d[e.X]>d[p.Y]+e.Y){
        d[e.X]=d[p.Y]+e.Y;
        que.emplace(d[e.X],e.X);
      }
  }
}

int main() {
  while(cin>>w>>h,h||w){
    rep(i,h)rep(j,w) cin>>mp[i][j];
    vector<int> cost(4);
    rep(i,4) cin>>cost[i];
    Graph g(h*w*4+1);
    rep(y,h)rep(x,w)rep(d,4)rep(c,4){
      int e=(d+c)%4;
      g[fun(y,x,d)].eb(fun(y+dy[e],x+dx[e],e),cost[c]*(mp[y][x]!=c));
    }
    //for(pii p:g[fun(0,0,0)])cout<<"("<<p.X<<","<<p.Y<<"),";cout<<endl;
    int re=INF;
    vector<int> d;
    dij(g,fun(0,0,0),d);
    //for(int x:d)cout<<x<<",";cout<<endl;
    rep(i,4) re=min(re,d[fun(h-1,w-1,i)]);

    // rep(di,4){
    //   rep(i,h){rep(j,w)cout<<d[fun(i,j,di)]<<",";cout<<endl;}
    //   cout<<endl;
    // }
    cout<<re<<endl;
  }
  return 0;
}

Measured memory_bytes: 3288
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


def divide(X, s):
    ans = 0
    for i in X:
        ans *= 2
        i = int(i)
        ans += i
        ans = ans % s
    return ans


def popcount(n):
    ans = 0
    while(n > 0):
        ans += n & 1
        n = n >> 1
    return ans


def count(n):
    cnt = 1
    while(n > 0):
        n = n % popcount(n)
        cnt += 1
    return cnt


N = ni()
X = ns()

cnt = X.count("1")

if cnt == 0:
    for i in range(N):
        print(1)
    exit()


cnt_plus = cnt + 1
cnt_minus = cnt - 1
p = 1
m = 1
p_array = []
if cnt_minus > 0:
    m_array = []
for i in range(N):
    p_array.append(p)
    p = p * 2 % cnt_plus
    if cnt_minus > 0:
        m_array.append(m)
        m = m * 2 % cnt_minus

plus_first = divide(X, cnt_plus)
if cnt_minus > 0:
    minus_first = divide(X, cnt_minus)


for i, x in enumerate(X):
    if x == "0":
        first = (plus_first + p_array[-(i+1)]) % cnt_plus
        print(count(first))
    else:
        if cnt_minus == 0:
            print(0)
        else:
            first = (minus_first - m_array[-(i+1)]) % cnt_minus
            print(count(first))


Measured memory_bytes: 94804
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        public static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = input[0];
            var M = input[1];

            var s = new int[M][];
            for (int i = 0; i < M; i++)
            {
                s[i] = Console.ReadLine().Split(' ').Select(int.Parse).Skip(1).ToArray();
            }

            var p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var result = 0;
            for (int i = 0; i < Math.Pow(2, N); i++)
            {
                var c = Convert.ToString(i, 2).PadLeft(N, '0').ToCharArray();

                var flag = true;
                for (int j = 0; j < M; j++)
                {
                    var temp = 0;
                    for (int k = 0; k < s[j].Length; k++)
                    {
                        temp += c[s[j][k] - 1];
                    }
                    if (temp % 2 != p[j])
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    result++;
                }
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13524
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
#include<unordered_set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	while(true) {
		string s;
		cin >> s;
		if(s == "#") break;

		int left = -1, right = -1, ret = 0, tmp = 0;
		bool isleft = false;
		left = s[0] - '0' - 1;
		FOR(i, 1, s.size()) {
			if(isleft) {
				//?¬?????????????????????¨?????????????¶???????????????????
				if((s[i]-'0'-1)%3 > right%3) {
					right = s[i] - '0' - 1;
					tmp++;
				} else {
					left = s[i] - '0' - 1;
					isleft = false;
				}
			} else {
				if((s[i]-'0'-1)%3 < left%3) {
					left = s[i] - '0' - 1;
					tmp++;
				} else {
					right = s[i] - '0' - 1;
					isleft = true;
				}
			}
		}
		ret = tmp;
		tmp = 0;
		isleft = true;
		right = s[0] - '0' - 1;
		FOR(i, 1, s.size()) {
			if(isleft) {
				//?¬?????????????????????¨?????????????¶???????????????????
				if((s[i]-'0'-1)%3 > right%3) {
					right = s[i] - '0' - 1;
					tmp++;
				} else {
					left = s[i] - '0' - 1;
					isleft = false;
				}
			} else {
				if((s[i]-'0'-1)%3 < left%3) {
					left = s[i] - '0' - 1;
					tmp++;
				} else {
					right = s[i] - '0' - 1;
					isleft = true;
				}
			}
		}
		cout << min(ret, tmp) << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> xs, ys;
  xs.resize(n);
  for(int i = 0; i < n; i++) cin >> xs[i];
  ys.resize(m);
  for(int i = 0; i < m; i++) cin >> ys[i];
  bool good = false;
  for(int z = x+1; z <= y; z++) {
    bool ret = true;
    for(int out: xs) {
      ret &= out < z;
    }
    for(int out: ys) {
      ret &= out >= z;
    }
    good |= ret;
  }
  if(good) cout << "No War\n";
  else cout << "War\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
program ABC145B
    implicit none
    integer(8)::N
    character(100)::S
    read(5,*)N
    read(5,*)S

    if(mod(N,2)==1)then
        print'(A)',"No"
    else
        if(S(1:N/2)==S(N/2+1:N))then
            print'(A)',"Yes"
        else
            print'(A)',"No"
        end if
    end if
end program ABC145B

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


int main(){
    int a,b;
    cin >> a >> b;
    string A,B;
    rep(i,b) A += to_string(a);
    rep(i,a) B += to_string(b);
    cout << min(A,B) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 100009
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef vector<long long> vl;

multiset<ll> s;
vector<ll> v;

int main() {
    ll n;
    cin >> n;

    v.resize(n);
    for(int i = 0; i < n; ++i)
        cin >> v[i];
        
    for(int i = n-1; i >= 0; --i) {
        s.insert(v[i]);
        auto it = s.upper_bound(v[i]);

        if(it != s.end())
            s.erase(it);
    }

    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 5760
def main():
    s = input()
    
    m = int(s[5]+s[6])
    d = int(s[8]+s[9])

    if m < 4:
        print("Heisei")
    elif m == 4 and d <= 30:
        print("Heisei")
    else:
        print("TBD")




if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n,m,l=[int(i) for i in input().split()]
x=[[int(0) for i in range(m)]for j in range(n)]
z=[[int(0) for i in range(l)]for j in range(n)]
y=[[int(0)for i in range(l)]for j in range(m)]
for i in range(n):
    k=input().split()
    for j in range(m):
        x[i][j]=int(k[j])
for i in  range(m):
    k=input().split()
    for j in range(l):
        y[i][j]=int(k[j])
        
for i in range(n):
    for j in range(l):
        count=int(0)
        for v in range(m):
            count=count+x[i][v]*y[v][j]
        z[i][j]=count
        
for i in range(n):
    for j in range(l-1):
        print(z[i][j],"",end="")
    print(z[i][l-1])

Measured memory_bytes: 9184
import sys
sys.setrecursionlimit(10**6)
H, W = map(int, input().split())
S = [[c for c in input()] for _ in range(H)]
B = [[False] * W for _ in range(H)]

R = [['6', '3', '1', '4'], ['1', '3', '6', '4']]
C = [['6', '2', '1', '5'], ['1', '2', '6', '5']]
G = [['6', '3', '1', '4'], ['2', '-1', '2', '-1'],
     ['1', '3', '6', '4'], ['5', '-1', '5', '-1']]

dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]


def dfs(y, x):
    if y < 0 or H <= y or x < 0 or W <= x:
        return
    if S[y][x] == '#':
        return
    if B[y][x] == True:
        return

    m4y = y % 4
    m4x = x % 4

    if S[y][x] != G[m4y][m4x]:
        return

    # R
    # if y % 2 == 0:
    #    if not(y % 4 != 0 or y % 4 == 0 and S[y][x] == R[0][x % 4]):
    #        return
    #    if not(y % 4 != 2 or y % 4 == 2 and S[y][x] == R[1][x % 4]):
    #        return
    # C
    # if y % 2 == 1:
    #    if not(y % 4 != 1 or y % 4 == 1 and S[y][x] == '2'):
    #        return
    #    if not(y % 4 != 3 or y % 4 == 3 and S[y][x] == '5'):
    #        return

    B[y][x] = True

    for i in range(4):
        dfs(y+dy[i], x+dx[i])


dfs(0, 0)
#print(*B, sep='\n')
print('YES' if B[H-1][W-1] else 'NO')



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

using namespace std;

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (n == 0)
      break;
    long long sum = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
      cin >> a[i];
      sum += a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
      if (a[i] <= sum / n)
        ans++;
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3120
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  while (getline(cin, s), s != ".") {
    stack<char> t;
    rep(i, s.size()) {
      if (s[i] == '[' || s[i] == '(') t.push(s[i]);
      if (s[i] == ')') {
        if (t.size() && t.top() == '(') {
          t.pop();
        } else {
          cout << "no" << endl;
          goto next;
        }
      }
      if (s[i] == ']') {
        if (t.size() && t.top() == '[') {
          t.pop();
        } else {
          cout << "no" << endl;
          goto next;
        }
      }
    }
    cout << (t.size() ? "no" : "yes") << endl;
  next:;
  }
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;

struct edge {
    int from, to, cost;
};

struct UniTree {
    int *par, *rank;

    UniTree(int n) {
        par = new int[n];
        rank = new int[n];
        for(int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x) {
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    void merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            par[x] = y;
        }else {
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
};


bool comp(const edge& e1,const edge& e2) {
    return e1.cost < e2.cost;
}

edge g[400000];

int main() {
    int n;
    cin >> n;
    P x[100000];
    P y[100000];
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        x[i] = P(a, i);
        y[i] = P(b, i);
    }
    sort(x, x + n);
    sort(y, y + n);
    rep(i, n - 1) {
        int a = x[i].second;
        int b = x[i + 1].second;
        int c = x[i].first;
        int d = x[i + 1].first;
        g[i * 2] = {a, b, abs(d - c)};
        g[i * 2 + 1] = {b, a, abs(d - c)};
    }
    rep(i, n - 1) {
        int a = y[i].second;
        int b = y[i + 1].second;
        int c = y[i].first;
        int d = y[i + 1].first;
        g[i * 2 + n * 2 - 2] = {a, b, abs(d - c)};
        g[i * 2 + n * 2 - 1] = {b, a, abs(d - c)};
    }
    sort(g, g + (n * 4 - 4), comp);

    UniTree uni(n);
    ll ans = 0;
    rep(i, n * 4 - 4) {
        if(!uni.same(g[i].from, g[i].to)) {
            uni.merge(g[i].from, g[i].to);
            ans += g[i].cost;
        }
    }

    cout<< ans << endl;

    return 0;
}


Measured memory_bytes: 7296
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    string a,b,c; cin >> a >> b >> c;
    cout << a.front() << b.front() << c.front() << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int a[]=new int[n];
			ArrayList<String>Al=new ArrayList<String>();
			for(int i=0; i<n; i++)
				a[i]=in.nextInt();

			for(int i=0;i<n;i++)
			{
				int first=a[i];
				boolean quote=false;
				for(;;)
				{

					if(i+1<n&&a[i]+1==a[i+1])
					{
						quote=true;
						i++;
					}
					else
					{
						if(quote)
							Al.add(first+"-"+a[i]);
						else
							Al.add(first+"");
						break;
					}

				}
			}
			for(int i=0;i<Al.size()-1;i++)
				System.out.print(Al.get(i)+" ");
			System.out.println(Al.get(Al.size()-1));
		}
	}
}

Measured memory_bytes: 26144
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int start = Math.max(a, c);
		int end = Math.min(b, d);
		int on = 0;
		if (end > start) {
			on = end - start;
		}
		System.out.println(on);
	}
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd				double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll				vector<long long>
#define vpii			vector<pair<int,int>>
#define vpll			vector<pair<long long,long long>>
#define vvi				vector<vector<int>>
#define vvl				vector<vector<long long>>
#define mii             map<int,int>
#define mll  			map<long long,long long>
#define umii			unordered_map<int,int>
#define umll			unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)		for(int i=0;i<n;i++)
#define rep2(i,a,b)		for(int i=a;i<b;i++)
#define rev(i,n)		for(int i=n;i>=0;i--)
#define rev2(i,a,b)		for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl			'\n'
#define all(x)			x.begin(),x.end()
#define d0(x)			cout <<x<<" "
#define d1(x)			cout <<x<<endl
#define d2(x,y)			cout <<x<<" "<<y<<endl
#define d3(x,y,z)		cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)		cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
const ll mod=1e9+7;
const dd pi=M_PI;
void i_o()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
} 
ll MOD=998244353;
ll pow2[100005]={0};
ll fre[100005]={0};
int main()
{
	fio
   	i_o();
	int n;
	cin>>n;
	vi A(n+1);
	mii m;
	rep2(i,2,n+1){ cin>>A[i]; m[A[i]]++;}
	rep2(i,1,n+1) cout <<m[i]<<endl;


    
	return 0;
}



Measured memory_bytes: 13552
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

Int N;
Int K;
vector<Int> A;

const int B = 200000;

void solve(){
	vector<int> npos(B+1,N), next(N);
	vector<int> q;
	for(int i = N - 1;i >= 0;i--){
		if(npos[A[i]] != N)next[i] = npos[A[i]];
		else q.push_back(i);
		npos[A[i]] = i;
	}
	for(auto &&i:q){
		next[i] = npos[A[i]] + N;
	}
	int t = 0;
	Int u = 0;
	do{
		u += next[t] - t + 1;
		t = u % N;
	}while(t!=0);
	K %= (u/N);
	Int M = K * N;
	for(Int i = 0;i < M;){
		int j = i % N;
		Int ni = i + next[j] - j;
		if(ni<M){
			i = ni + 1;
			continue;
		}else{
			for(Int j = i;j < M;j++){
				int k = j % N;
				Int nj = j + next[k] - k;
				if(nj<M){
					j = nj;
				}else{
					cout<<A[k]<<" ";
				}
			}
			cout<<endl;
			break;
		}
	}
}
//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
    cin >> K;
    A.assign(N-1-0+1,Int());
    for(int i = 0 ; i < N-1-0+1 ; i++){
        cin >> A[i];
    }
	solve();
	return 0;
}
//}}}

Measured memory_bytes: 5620
def main():
    X, Y = map(int, input().split())

    for crane in range(X + 1):
        turtle = X - crane
        if Y == crane * 2 + turtle * 4:
            print('Yes')
            return

    print('No')


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 9032
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    int a[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)cin>>a[i][j];
    }
    vector<vector<int>>move;
    bool b=false;
    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int j=0;j<w;j++){
                if(a[i][j]%2){
                    if(b)b=false;
                    else b=true;
                }
                if(b){
                    if(j<w-1)move.push_back({i+1,j+1,i+1,j+2});
                    else if(i<h-1)move.push_back({i+1,j+1,i+2,j+1});
                }
            }
        }
        else{
            for(int j=w-1;j>=0;j--){
                if(a[i][j]%2){
                    if(b)b=false;
                    else b=true;
                }
                if(b){
                    if(j>0)move.push_back({i+1,j+1,i+1,j});
                    else if(i<h-1)move.push_back({i+1,j+1,i+2,j+1});
                }
            }
        }
    }
    cout<<move.size()<<endl;
    for(int i=0;i<move.size();i++){
            cout<<move[i][0]<<" "<<move[i][1]<<" "<<move[i][2]<<" "<<move[i][3]<<endl;
        }
    return 0;
}

Measured memory_bytes: 11080
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

namespace ndifix{

}

int main(){
    int n,k;cin>>n>>k;
    vector<int> h(n),ans(n);for(int i=0;i<n;i++)cin>>h[i];
    for(int i=1;i<n;i++)ans[i]=1e9;
    for(int i=0;i<n;i++)
    for(int j=i+1;j<n && j<=i+k;j++)
    ans[j]=min(ans[j], ans[i]+abs(h[j]-h[i]));

    cout<<ans[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<cmath>
#include<deque>
#include<set>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
#define mod 1000000007
ll power(ll x,ll p){ll a=1;while(p>0){if(p%2==0){x*=x;p/=2;}else{a*=x;p--;}}return a;}
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 0, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll k) { ll a = 1, b = 1; rep(i, 0, k) { a = a * (n - i + 1) % mod; b = b * i % mod; }return a * mpower(b, mod - 2) % mod; }

const double PI = 3.14159265358979323846;
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
int main() {
	int N;
	scanf("%d", &N);
	vector<int> A(N);
	ll s = 0, t = 0, ans;
	rep(i, 0, N)scanf("%d", &A[i]), s += A[i];
	//abs(2 * t - s)
	ans = abs(2 * A[0] - s);
	rep(i, 0, N - 1) {
		t += A[i];
		if(i)ans = min(ans, abs(2 * t - s));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1024
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main=print.solve 0 1.tail.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve k i(a1:a2:as)=if i==a1 then solve(k+1)(i+2)as else solve k(i+1)(a2:as)
solve k i as=if null as || i/=head as then k else k+1

Measured memory_bytes: 2172
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int n; cin >> n;
	vector<int> v = {111,222,333,444,555,666,777,888,999};
	int mini = 100000;
	int best = -1;
	forn(i, v.size()){
		if(v[i]-n < mini && v[i] >= n){
			mini = v[i]-n;
			best = v[i];
		}
	}
	cout << best << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include<iterator>
#include<utility>
#include<math.h>
#include <cmath>
#include<algorithm>


using namespace std;

typedef long long ll; // %lld
typedef vector<int> vi;
typedef pair<int, int> pi;

#define mod (pow(10,9)+7);
#define PB push_back
#define POB pop_back
#define MP make_pair
#define itri std::vector<int>::iterator
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)


void showpq(vector <ll> gq)
{
	vector <ll> g = gq;
	reverse(g.begin(), g.end());
	while (!g.empty())
	{
		cout << g.back() << " ";
		g.pop_back();
	}
	cout << '\n';
}

double findMedian(vector <ll> a, ll n)
{
	// First we sort the array
	//sort(a, a + n);
	sort(a.begin(), a.end());

	// check for even case
	if (n % 2 != 0)
		return a[ (n - 1) / 2];

	return   (  ( a[n / 2] + a[(n / 2) - 1] )   );
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("inno.in", "r", stdin);
	freopen("ottu.txt", "w", stdout);
#endif

	ll n, L, H, m, diff;
	cin >>  n;
	m = n;
	vector<ll> low, high;
	while (n--)
	{
		cin >> L >> H ;
		low.PB(L);
		high.PB(H);
	}
	diff = ll(findMedian(high, m) - findMedian(low, m));
	if (m % 2 == 0)
	{
		cout <<  ((diff) + 1)  << endl;
	}
	if (m % 2 != 0)
	{
		cout <<  (diff + 1)  << endl;
	}


	return 0;
}


Measured memory_bytes: 9544
n = int(input())
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
l3 = [0]*n
for i in range(n):
  if l1[i] - l2[i] > 0:
    l3[i] = l1[i] - l2[i]
print(sum(l3))

Measured memory_bytes: 3060
function Main(input){
  
  var str = input;
  var tmp = str.split("\n");
  var n = parseInt(tmp[0],10);
  var a = parseInt(tmp[1],10);
  var b = parseInt(tmp[2],10);
  var c = parseInt(tmp[3],10);
  var d = parseInt(tmp[4],10);
  var e = parseInt(tmp[5],10);
  
  var arr_time = [a,b,c,d,e];
    //console.log("arr_time");  
  //console.log(arr_time);  
  
  var min_index = arr_time.indexOf(Math.min.apply(null,arr_time));
    //console.log("min_index");
  //console.log(min_index);
  var bottle_time = Math.ceil(n/arr_time[min_index]);
      //console.log("bottle_time");
  //console.log(bottle_time);
  var kekka = bottle_time + 4;
  
  console.log(kekka);

  
}//function end
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string s;
  std::cin >> s;

  ll ans = 0LL;
  std::string check = "CODEFESTIVAL2016";
  for (ll i = 0; i < (ll)s.size(); i++) {
    if (check[i] != s[i]) ans++;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
/* AOJ0009 Prime Number */

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>

using namespace std;

const int N = 1e6;
const int SQRTN = ceil(sqrt((double) N));
bool isPrime[N + 1];
int prefixsum[N + 1];

// Eratosthenes筛选法
void esieve(void)
{
    memset(isPrime, true, sizeof(isPrime));

    isPrime[0] = isPrime[1] = false;
    for(int i=2; i<=SQRTN; i++) {
        if(isPrime[i]) {
            for(int j=i*i; j<=N; j+=i)  //筛选
                isPrime[j] = false;
        }
    }
}

void maketable()
{
    prefixsum[0] = 0;
    for(int i = 1; i <= N; i++)
        prefixsum[i] = isPrime[i] ? prefixsum[i - 1] + 1 : prefixsum[i - 1];
}

int main()
{
    esieve();

    maketable();

    int n;
    while(~scanf("%d", &n))
        printf("%d\n", prefixsum[n]);

    return 0;
}


Measured memory_bytes: 8060
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
	return *(char*)a - *(char*)b;
}

int compare_r(const void *a, const void *b) {
	return *(char*)b - *(char*)a;
}

int main() {
	char s[9];
	int n, under, upper;

	scanf("%d ", &n);
	while (n--) {
		scanf(" %8s ", s);
		qsort(s, 8, sizeof(char), compare);
		under = atoi(s);
		qsort(s, 8, sizeof(char), compare_r);
		upper = atoi(s);
		printf("%d\n", upper - under);
	}
	return 0;
}

Measured memory_bytes: 608
#!/bin/env python

def main():
    N = int(raw_input())
    A = map(int, raw_input().split(" "))
    retval = 1e9
    for a in A:
        cnt = 0
        while a % 2 == 0:
            a /= 2
            cnt += 1
        retval = min(cnt, retval)
    print retval

if __name__ == '__main__':
    main()

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

int main() {
  int a,b,c,d,e,f;
  string op;
  cin >> a >>b>>c;
	e = a*b;
    f = c+d;
  if(e<=c){
  cout<<e<<endl;}
    else if (e>c){
    cout<<c<<endl;}
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>
#include<iostream>
#include<iomanip>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;
using pll=pair<ll,ll>;
using vpll=vector<pll>;

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}

#define PI 3.1415926535897932384626433832795

struct solve
{
	solve(){}
	ll operator()(ll n, ll x, ll d) {
		if(d==0)
		{
			if(x==0) return 1;
			return n+1;
		}
		if(d<0) x=-x,d=-d;

		ll ans=0;
		map<int,vpll> m;
		for(ll i=0;i<=n;i++)
		{
			ll base=x*i;
			ll s=i*(i-1)/2;
			ll e=(n-1)*i-i*(i-1)/2;
			int r=base%d;
			if(r<0) r+=d;
			m[r].push_back(make_pair((base-r)/d+s, (base-r)/d+e));
		}

		for(auto&mm:m)
		{
			auto&v=mm.second;
//cout << "r=" << r << "  v.size()=" << v.size() << "\n";
			sort(v.begin(), v.end());
			int vs=v.size();
			ll s, e;
			tie(s, e)=v[0];
			for(int i=1;i<vs;i++)
			{
				ll cs, ce;
				tie(cs, ce)=v[i];
				if(e+1<cs)
				{
					ans+=e-s+1;
					tie(s, e)=v[i];
				}
				else
				{
					max_u(e, ce);
				}
			}
			ans+=e-s+1;
		}
		return ans;
	}
};

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

	for(;;)
	{
		int n, x, d;
		cin >> n >> x >> d;
		if(cin.fail()) break;

		cout << solve()(n, x, d) << "\n";
	}
	return 0;
}


Measured memory_bytes: 22144
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1ll << 61;

int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<vector<pair<int, ll>>> G(N), rG(N);
    for (int i = 0; i < M; i++) {
      int a, b;
      ll c;
      cin >> a >> b >> c;
      --a;
      --b;
      G[a].emplace_back(b, -c);
      rG[b].emplace_back(a, -c);
    }
    vector<bool> used(N, false);
    function<void(int)> dfs = [&](int v) {
      if (used[v]) return;
      used[v] = true;
      for (auto &e : rG[v]) dfs(e.first);
    };
    dfs(N - 1);
    int V = count(used.begin(), used.end(), true);
    vector<ll> dist(N, INF);
    dist[0] = 0;
    bool hasNegativeCycle = false;
    for (int k = 1; k <= V; k++) {
      for (int v = 0; v < N; v++) {
        for (auto &e : G[v]) {
          if (used[v] && used[e.first] && dist[v] != INF &&
              dist[e.first] > dist[v] + e.second) {
            dist[e.first] = dist[v] + e.second;
            if (k == V) {
              hasNegativeCycle = true;
            }
          }
        }
      }
    }
    if (hasNegativeCycle) {
      cout << "inf" << endl;
    } else {
      cout << -dist[N - 1] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 384
use std::cmp;
use std::collections::HashMap;
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

fn main() {
    let n: usize;
    input!(n);
    let mut m = HashMap::new();
    for _ in 0..n {
        let s = input_line_str();
        let p = m.entry(s).or_insert(0);
        *p += 1;
    }
    let n: usize;
    input!(n);
    for _ in 0..n {
        let s = input_line_str();
        let p = m.entry(s).or_insert(0);
        *p -= 1;
    }
    let mut max_item = 0;
    for (i, x) in &m {
        max_item = cmp::max(*x, max_item);
    }
    p(max_item);
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  bool flag=false;
  rep(i,3){
    if(n%10==7)flag=true;
    n/=10;
  }
  	if(flag){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  return 0;
}


Measured memory_bytes: 3652
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

//container util
//------------------------------------------
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define rep(i,n)  for(int i=0;i<(n);i++)




int main(){
    int n;
    cin>>n;
    vector<int> p(n), q(n), a(n, 0);
    
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i<n;i++){
        cin>>q[i];
    }
    for(int i=0;i<n;i++){
        a[i]+=i+1;
    }
    
    int indp = 0, indq = 0, ind=0;
    
    while(true){
        if(p==a) indp = ind;
        if(q==a) indq = ind;
        ind++;
        if(!next_permutation(a.begin(), a.end()))break;
    }
    
    cout<<abs(indp - indq)<<endl;
    return 0;
}

Measured memory_bytes: 256