akhauriyash/Code-Regression huggingface dataset:
/*
Problem : https://atcoder.jp/contests/abc140/tasks/abc140_e
Algorithm : math
Status :
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

int n;
ll ans;
int pos[MAXN],pre[MAXN],nxt[MAXN];

int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		pre[i] = i - 1;
		nxt[i] = i + 1;
		int x;
		scanf("%d",&x);
		pos[x] = i;
	}
	for(int i = 1;i <= n;i++){
		int b = pre[pos[i]],a = pre[b];
		int c = nxt[pos[i]],d = nxt[c];
		if(b != 0)
			ans += 1ll * (b - a) * (c - pos[i]) * i;
		if(c != n + 1)
		    ans += 1ll * (pos[i] - b) * (d - c) * i;
		pre[c] = b;
		nxt[b] = c;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

string seg[] = {
	"1111110",
	"0110000",
	"1101101",
	"1111001",
	"0110011",
	"1011011",
	"1011111",
	"1110010",
	"1111111",
	"1111011",
};

int main(){
	bitset<7> sevensegs[10];
	rep(i, 10){
		sevensegs[i] = bitset<7>(string(rev(seg[i])));
	}

	int n;
	while(cin >> n, n != -1){
		bitset<7> state, change;
		rep(i, n){
			int num;
			cin >> num;
			change = state^sevensegs[num];
			state ^= change;
			cout << change << endl;
		}
	}

	return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;

    priority_queue<ll> pq;
    for(int i = 0; i < N; i++){
        ll a; cin >> a;
        pq.push(a);
    }

    for(int i = 0; i < M; i++){
        ll t = pq.top();
        pq.pop();
        pq.push(t/2);
    }

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1400
//#include <string>
//#include <set>
//#include <map>
//#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int inf = 0x7fffffff;
typedef long long ll;
void Faster( ){ ios_base::sync_with_stdio( false ); cin.tie( nullptr ); }
void iv( vector<int>& p ){ for( int& x: p ) cin >> x; }
void sa( vector<int>& p ){ sort( p.begin(), p.end() ); }
void pv( const vector<int>& p ){ for( int x: p ) cout << x << ' '; cout << '\n'; }

int Find( const vector<int>& p, int n, int x ){
	for( int i = n; i >= 0; i-- ){
		if( p[i] <= x ){
			return i + 1;
		}
	}
	return 0;
}

int main( ){
	Faster( );
	int n, x;
	cin >> n >> x;
	vector<int> p(n+1);
	for( int i = 1; i <= n; i++ ){
		cin >> p[i];
		p[i] += p[i-1];
	}
	cout << Find( p, n, x );
	return 0;
}

// 08-06-2020
// Master Template 14
// kafiulshabbir@phystech.edu



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int s,a[25],b[100],n,k,i; 
int main()
{

  int j,m,t;	 
cin>>a[1]>>a[2]>>a[3];  
  if (a[2]-a[1]==a[3]-a[2])  cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
 return 0;     
} 

Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>), (<*), (*>), (<$))
import Control.Monad
import Data.List
import Data.Array.Unboxed

main :: IO ()
main = do
  [w, h] <- getl $ wrds toInt
  unless (w == 0 && h == 0) $ do
    solve w h <$> replicateM h getLine >>= print
    main

solve :: Int -> Int -> [String] -> Int
solve w h xs = length $ filter (\a -> snd a == '@') $ assocs $ search (iar // [(ipt,'.')]) ipt
  where
    iar = array ((0,0),(w-1,h-1)) [((i,j), xs !! j !! i) | i <- [0..w-1], j <- [0..h-1]] :: UArray (Int,Int) Char
    ipt = fst $ maybe ((-1,-1),'x') id $ find (\a -> snd a == '@') $ assocs iar
    search :: UArray (Int, Int) Char -> (Int, Int) -> UArray (Int, Int) Char
    search ar (i,j)
      | ar ! (i,j) == '.' = foldl search (ar // [((i,j),'@')]) ixs
      | otherwise = ar
      where
        ixs = [(ii,jj) | (ii,jj) <- [(i+1,j),(i-1,j),(i,j+1),(i,j-1)], ii >= 0, ii < w, jj >= 0, jj < h]

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4836
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

ans = 1
bi = 2**ans
while True:
    for i in range(n):
        if a[i] % bi != 0:
            print(ans-1)
            exit()
    ans +=1
    bi = 2**ans


Measured memory_bytes: 3060
import math
import sys
import fractions
inp = input()
N,A,B,K = list(map(int,inp.split()))
# g = math.gcd(A,B)
g = fractions.gcd(A,B)
if K % g != 0:
    print(0)
    sys.exit()
A = A // g
B = B // g
K = K // g
xn = []
yn = []
for i in range(10 ** 100):
    if (A * i- K) % B == 0:
        n = i
        xn.append(n)
        yn.append((K - A *n) // B)
        break
if yn[-1] < 0:
    if K % B == 0 and (K // B <= N):
        print(1)
    else:
        print(0)
    sys.exit()
while True:
    x  = xn[-1] + B
    y  = yn[-1] - A
    if y < 0:
        break
    xn.append(x)
    yn.append(y)
ans = 0
P = 998244353
def inv(n):
  return pow(n, P-2, P)
fact = [1] * (N+1)
for i in range(1, N+1):
  fact[i] = fact[i-1] * i % P
invfact = [inv(fact[N])] * (N+1)
for i in range(N, 0, -1):
  invfact[i-1] = invfact[i] * i % P
def comb(n, k):
  return fact[n] * invfact[k] * invfact[n-k] % P 
 
for x,y in zip(xn,yn):
    if N-x< 0 or N -y < 0:
        continue 
    ans = (ans + (comb(N,x) * comb(N,y))) % P
print(ans)

Measured memory_bytes: 76268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, u, v, u2, v2, ans; sc(n)
    vector<int> vec(n);
    map<int, int> odd, even;
    priority_queue<P> qo, qe;
    for (int i = 0; i < n; i++) sc(vec[i])
    for (int i = 1; i < n; i+=2) ++even[vec[i]];
    for (int i = 0; i < n; i+=2) ++odd[vec[i]];
    for (const auto &x :even) qe.push(P(x.second, x.first));
    for (const auto &x :odd) qo.push(P(x.second, x.first));
    u = qe.top().first; v = qo.top().first;
    ans = u + v;
    if (qe.top().second == qo.top().second) {
        qe.pop(); qo.pop();
        u2 = 0; v2 = 0;
        if (!qe.empty()) u2 = qe.top().first;
        if (!qo.empty()) v2 = qo.top().first;
        ans = max(u2+v, v2+u);
    }
    cout << n - ans << endl;
    return 0;
}

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

void swap(int a[], int i, int j, int* p_cnt) {
    int tmp = a[i];
    a[i] = a[j];
    a[j] = tmp;
    (*p_cnt)++;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    
    int cnt = 0;
    for (int i=0; i<n; i++) {
        for (int j=n-1; j>i; j--) {
            if ( a[j] < a[j-1] ) {
                swap(a, j, j-1, &cnt);
            }
        }
    }
    
    for (int i=0; i<n-1; i++) {
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    cout << cnt << endl;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include <stdlib.h>
 
int main(){
  
  int input,ans=0,cnt1,cnt2;
  
  scanf("%d",&input);
  
  for(cnt1=1;cnt1<=9;cnt1++){
    for(cnt2=1;cnt2<=9;cnt2++){
      if(cnt1*cnt2==input){
        printf("Yes");
		ans=1;
		exit(0);
      }
    }
  }
    if(ans==0){
      printf("No");
    }
    
    return 0;
  }

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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


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



int main() {
	
	int n;
	cin >> n;
	int a[101];

	FOR(i,1, 101) {
		if (i == 1) {
			a[i] = 1;
		}
		else if (i < 4) {
			a[i] = 2;
		}
		else if (i < 8) {
			a[i] = 4;
		}
		else if (i < 16) {
			a[i] = 8;
		}
		else if (i < 32) {
			a[i] = 16;
		}
		else if (i < 64) {
			a[i] = 32;
		}
		else {
			a[i] = 64;
		}
	}

	cout << a[n] << endl;

	return 0;
}



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

using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll a, b;
  cin >> a >> b;
  cout << (a >= 13 ? b : a >= 6 ? b / 2 : 0) << endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {

	int r;
	cin >> r;

	cout << pow(r, 2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int Maxb = 31;
int n;
map <int, int> M;
int res;
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a; scanf("%d", &a);
        M[a]++;
    }
    for (int i = Maxb - 1; i >= 0; i--)
        for (map <int, int>::iterator it = M.begin(); it != M.end() && 2 * it->first <= (1 << i); it++) {
            if (it->second == 0) continue;
            int nd = (1 << i) - it->first;
            if (nd == it->first) {
                int tk = it->second / 2;
                it->second -= 2 * tk;
                res+=tk;
            } else {
                map <int, int>::iterator it2 = M.find(nd);
                if (it2 != M.end()) {
                    int tk = min(it->second, it2->second);
                    it->second -= tk; it2->second -= tk;
                    res += tk;
                }
            }
        }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	int a[n];
	double ue = 1,shita = 0;
	rep(i,n){
		cin >> a[i];
		ue *= a[i];
	}
	vector<double> igai(n);
	rep(i,n){
		igai[i] = ue/a[i];
	}
	rep(i,n){
		shita += igai[i];
	}
	printf("%.12lf\n",(double)(ue/shita));
	return 0;
}

Measured memory_bytes: 3756
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
int read()
{
	int res=0,ch,flag=0;
	if((ch=getchar())=='-')             //判断正负
		flag=1;
	else if(ch>='0'&&ch<='9')           //得到完整的数
		res=ch-'0';
	while((ch=getchar())>='0'&&ch<='9')
		res=res*10+ch-'0';
	return flag?-res:res;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=1e6;
#define int long long
int res[N];
int sum[N];
int n;
signed main()
{
	cin>>n;
	for(int i=0; i<=n; i++)
		cin>>res[i];
	if(n==0)
	{
		if(res[0]==1)
			cout<<1<<endl;
		else
			cout<<"-1"<<endl;
		return 0;
	}
	for(int i=n-1; i>=1; i--)
		sum[i]=sum[i+1]+res[i];
	if(res[0]!=0)
		return puts("-1"),0;
	int ans=1;
	int cnt=1;
	int flag=0;
	for(int i=1; i<n; i++)
	{
		cnt=cnt*2;
		if(cnt<res[i])
		{
			cout<<"-1"<<endl;
			return 0;
		}
		if(cnt-sum[i]>res[n])
			cnt=res[n]+sum[i];
		ans+=cnt;
		cnt-=res[i];
	}
	if(cnt<=res[n]&&2*cnt>=res[n])
		cout<<ans+res[n]<<endl;
	else
		cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 5200
#include <iostream>
#include <string>
#include <set>

using namespace std;

set<string> set_string;

string reverse(string str){
	string res = "";
	for (int i = 0; i < str.size(); i++){
		res += str.substr(str.size() - 1 - i, 1);
	}
	return res;
}


void strage_lines(string up, string down, string depture_line, string reversal_line){
	if (up.size() == 0 && down.size() == 0 && reversal_line.size() == 0){
		set_string.insert(depture_line);
	}
	else{
		if (up.size() != 0){
			strage_lines("", down, depture_line + up, reversal_line);
			strage_lines("", down, depture_line, reversal_line + up);
		}
		if (down.size() != 0){
			strage_lines(up, "", depture_line + down, reversal_line);
			strage_lines(up, "", depture_line, reversal_line + down);
		}
		if (reversal_line.size() != 0){
			strage_lines(up, down, depture_line + reverse(reversal_line), "");
		}
	}
	
}


void arrival_line(string col){
	for (int i = 1; i < col.size(); i++){
		string up = "";
		string down = "";
		up = col.substr(0, i);
		down = col.substr(i, col.size() - i);
		strage_lines(up, down, "", "");
	}
}


int main(void){
	string str;
	int m;
	cin >> m;
	for (int i = 0; i < m; i++){
		cin >> str;
		set_string.clear();
		arrival_line(str);
		cout << set_string.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
#define inf 2000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
int main()
{
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    cout<<60*(h2-h1)+(m2-m1)-k;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	long long area1,area2;
	area1=a*b;
	area2=c*d;
	if(area1>area2)
	cout<<area1;
	else if(area2>area1)
	cout<<area2;
	else
	cout<<area1;
}

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

#define pii pair <int, int>
#define pb push_back
#define ll long long
#define ss second
#define ff first
#define N 100010

using namespace std;

int x, a, b;

int main()
{
	cin >> x >> a >> b;
	
	cout << (x-a)%b;
}

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

using namespace std;

// Function come here..
int p(int a, int b, int c)
{
    return (a + b + c) / 2;
}
int foo(int a, int b, int c)
{
    int pi = p(a, b, c);
    return sqrt(pi * (pi - a) * (pi - b) * (pi - c));
}

int main(int argc, char **argv)
{
    // Problem solution come here...
    int a, b, c;
    cin >> a >> b >> c;
    cout << foo(a, b, c) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long  ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

/*signed*/int main() {
    string s;
    cin >> s;
    bool a = false, b = false;
    int x = (s[0] - '0') * 10 + (s[1] - '0');
    int y = (s[2] - '0') * 10 + (s[3] - '0');
    if (x > 0 && x <= 12) a = true;
    if (y > 0 && y <= 12) b = true;
    if (a && b) cout << "AMBIGUOUS" << endl;
    else if (a) cout << "MMYY" << endl;
    else if (b) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

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

  int k,a,b;
  cin >> k >> a >> b;
  
  for (int i = a; i <= b; ++i) {
    if (i % k ==0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;
}


Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using std::swap;
int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (N*A < B) cout << N * A << "\n";
	else cout << B << "\n";
	return 0;
}

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

const double EPS = 1e-5;

double dp[51][5000];

int main(){
    int X, Y, Z, V[4];
    while(cin >> X >> Y >> Z, X||Y||Z){
        for(int i = 0; i < X; i++){
            cin >> V[i];
        }
        int ev[51], val[51];
        fill(ev, ev+51, 0);
        for(int i = 0; i < Z; i++){
            int a, b, c;
            cin >> a >> b >> c;
            ev[a] = b, val[a] = c;
        }
        for(int i = 0; i <= Y; i++){
            fill(dp[i], dp[i]+5000, 0);
        }
        dp[0][0] = 1;
        for(int i = 0; i < Y; i++){
            for(int j = 0; j < 5000; j++){
                for(int k = 0; k < X; k++){
                    if(abs(dp[i][j])==0) continue;
                    int nx = min(Y, i + V[k]), mn = j;
                    if(ev[nx] == 2) mn += val[nx];
                    else if(ev[nx] == 3) mn = max(0, j-val[nx]);
                    else if(ev[nx] == 1) nx = min(Y, nx + val[nx]);
                    dp[nx][mn] += dp[i][j] / X;
                }
            }
        }
        double ans = 0;
        double prob = 0;
        for(int i = 0; i < 5000; i++) ans += i * dp[Y][i];
        printf("%d\n", (int)(ans+EPS));
    }
    return 0;
}

Measured memory_bytes: 3136
N, Y = list(map(int, input().split()))
a=['-1']*3
for i in range(N+1):
    for j in range(N+1):
        k=N-(i+j)
        if i*10000+j*5000+k*1000==Y and k>=0:
            a[0]=str(i); a[1]=str(j); a[2]=str(k);

b=' '.join(a)
print(b)


Measured memory_bytes: 3060
from bisect import bisect_left as bl

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    if M in A:
        print(*[A[-1],M])
        exit()
    if k == N-1:
        ans = [A[-1],A[k-1]]
        print(*ans)
        exit()
    if k == 0:
        print(*[A[-1],A[0]])
        exit()
    if A[-1]%2 == 0:
        if abs(A[k-1]-M) <= abs(M-A[k]) and abs(A[k-1]-M) <= abs(A[k+1]-M):
            ans = [A[-1],A[k-1]]
        elif abs(A[k+1]-M) <= abs(M-A[k]) and abs(A[k+1]-M) <= abs(A[k-1]-M):
            ans = [A[-1],A[k+1]]
        elif abs(A[k]-M) <= abs(M-A[k-1]) and abs(A[k]-M) <= abs(A[k+1]-M):
            ans = [A[-1],A[k]]
    else:
        if abs(A[k-1]-M) < abs(M-A[k]) and abs(A[k-1]-M) < abs(A[k+1]-M):
            ans = [A[-1],A[k-1]]
        elif abs(A[k+1]-M) <= abs(M-A[k]) and abs(A[k+1]-M) <= abs(A[k-1]-M):
            ans = [A[-1],A[k+1]]
        elif abs(A[k]-M) <= abs(M-A[k-1]) and abs(A[k]-M) <= abs(A[k+1]-M):
            ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14068
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;

void main() {
  auto S = readln.chomp;
  auto easy = true;

  for(int i=0; i<S.length; i++) {
    if (i%2 == 0 && S[i] == 'L') easy = false;
    if (i%2 == 1 && S[i] == 'R') easy = false;
  }
  
  writeln(easy ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N,W;
	cin >> N >> W;
	llint w[N],v[N];

	for(int i=0;i<N;i++){
		cin >> w[i] >> v[i];
	}

	llint dp[N][1000*N+1];
	for(int i=0;i<N;i++){
		for(int k=0;k<=1000*N;k++){
			if(i==0){
				if(k==v[i]){
					dp[i][k]=w[i];
				}else if(k==0){
					dp[i][k]=0;
				}else{
					dp[i][k]=1000000001LL;
				}
			}else{
				if(k>=v[i]){
					llint costA=dp[i-1][k-v[i]]+w[i];
					llint costB=dp[i-1][k];
					if(costB==0){
						dp[i][k]=costA;
					}else{
						if(costA<costB){
							dp[i][k]=costA;
						}else{
							dp[i][k]=costB;
						}
					}
				}else{
					dp[i][k]=dp[i-1][k];
				}
			}
		}
	}

	for(int i=1000*N;i>=0;i--){
		if(0<dp[N-1][i] && dp[N-1][i]<=W){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 78336
db = {}
n = int(input())
for i in range(n):
  si, pi = input().split()
  if not si in db:
    db[si] = []
  db[si].append({"order": i, "score": int(pi)})

sorted_keys = sorted(db.keys(), key=lambda x: x)
for key in sorted_keys:
  #print("key={}".format(key))
  sorted_by_score = sorted(db[key], key=lambda x: x["score"], reverse=True)
  for ans in sorted_by_score:
    print("{}".format(ans["order"] + 1))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
char s[12345];
int main(){
	cin>>s;
	int len=strlen(s);
	long long ans=0;
	for(int t=0;t<(1<<(len-1));t++){
		long long num=s[0]-'0';
		for(int i=0;i<len-1;i++){
			if(t&(1<<i)){
				ans+=num;
				num=0;
			}
			num=num*10+s[i+1]-'0';
		}
		ans+=num;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
	val n = readLine()!!.toInt()
	val s = readLine()!!.trim().split(' ').map{ x -> x.toLong() }

	var dp = Array<LongArray>(n) { LongArray(n) { 0L } }

	for (i in 0..n - 1) {
		dp[i][i] = s[i]
	}

	for (i in (n - 2) downTo 0) {
		for (j in (i + 1) .. (n - 1)) {
			var a = s[i] - dp[i + 1][j]
			var b = s[j] - dp[i][j - 1]
			dp[i][j] = if (a > b) a else b
		}
	}

	println(dp[0][n - 1])
}

Measured memory_bytes: 116452
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    int a = 0, b = 0;
    rep(i, N){
        int A;
        cin >> A;
        if(A%4 == 0) a++;
        elif(A%2 == 0) b++;
    }
    if(b == 0){
        if(a >= N/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        if(2*a >= N-b) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define STACK 100
#define MAX 500

int stack[STACK];
int top = 0;

int pop(void);
void push(int);
void suuji(char*);
void calcu(char);


int main(){
    int i;
	char s[MAX];
fgets(s,MAX,stdin);
    suuji(s);
	printf("%d\n",stack[0]);

}
//データ取り出し
int pop(void)
{
    top--;
	return stack[top];
}
//テータ挿入
void push(int num)
{
	stack[top] = num;
	top++;
}
//数字判定
void suuji(char *s)
{
    int i,k=0;
    for(i=0;;i++){
		if(s[i+1]=='\0') break;
		else {
         if(s[i]=='+' || s[i]=='-' || s[i]=='*' || s[i]==' '){
			  calcu(s[i]);  
		 }
		 else if(s[i]>='0' && s[i]<='9') {
				k=k+(s[i]-48);
				k=k*10;
				if(s[i+1]==' ') {
					push(k/10);
					k=0;
				}
		    }  

	    }   
	}
}
//逆ポーランド計算
void calcu(char s)
{	
	int a,b;
			switch (s) {
			case '+':
				a = pop();
				b = pop();
				push(b+a);
				break;
			case '-':
				a = pop();
				b = pop();
				push(b-a);
				break;
			case '*':
				a = pop();
				b = pop();
				push(b*a);
				break;
			default :
			break;
			}
}



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

ll solve() {
    ll N;
    cin >> N;
    auto digit = [](ll x) -> ll {
        return (ll)to_string(x).size();
    };
    ll m = digit(N);
    for ( ll a = 1; a * a <= N; a++ ) {
        if ( N % a == 0 ) {
            m = min(m, max(digit(a), digit(N/a)));
        }
    }
    return m;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D){
    cout << "Left" << endl;
  }else if(A + B < C + D){
	cout << "Right" << endl;
  }else{
      cout << "Balanced" << endl;
    }
}

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

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")

const int INF = 1000000000;

#define vi vector<int>
#define ll long long int
#define vvi vector<vi>
#define pi pair<int,int>
#define vp vector<pi>
#define vvp vector<vp>
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>

#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define fe first
#define se second
#define all(x) x.begin(),x.end()

bool not_equal(int i,int j,int k,vector<ll> &arr){
    if(arr[i]==arr[j]) return false;
    if(arr[j]==arr[k]) return false;
    if(arr[k]==arr[i]) return false;
    return true;
}

bool satisfy_tri(int i,int j,int k,vector<ll> &arr){
    if(arr[i]+arr[j]<=arr[k]) return false;
    if(arr[i]+arr[k]<=arr[j]) return false;
    if(arr[j]+arr[k]<=arr[i]) return false;
    return true;
}

int main()
{
    int n;
    cin >> n;
    vector<ll> arr(n,0);
    for(int i=0;i<n;++i) cin >> arr[i];
    if(n<3) {return cout<<0<<endl,0;}
    int ans = 0;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            for(int k=j+1;k<n;++k){
                if(not_equal(i,j,k,arr))
                {
                    if(satisfy_tri(i,j,k,arr))
                        ans += 1;
                }
            }
        }
    }

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

Measured memory_bytes: 3628
import numpy as np

A = [0] * 3
A[0] = list(map(int,input().split()))
A[1] = list(map(int,input().split()))
A[2] = list(map(int,input().split()))
N = int(input())
bn = []
for n in range(N):
  bn.append(int(input()))
for i in range(3):
  for j in range(3):
    A[i][j] = A[i][j] in bn
A = np.array(A)
if sum(np.prod(A,1)) != 0:
  print('Yes')
elif sum(np.prod(A,0)) != 0:
  print('Yes')
elif A[0][0] * A[1][1] * A[2][2] != 0:
  print('Yes')
elif A[2][0] * A[1][1] * A[0][2] != 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 12508
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define sz(x) x.size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}
template <class T> inline T gcd(T a, T b) {if (b) return gcd(b, a % b); else return a;}
template <class T> inline T lcm(T a, T b) {return (a * b) / gcd(a,b);}

signed main()
{
//	freopen("THREEPRIMES.inp", "r", stdin); freopen("THREEPRIMES.out", "w", stdout);
	fastio();

	string s; cin >> s;
	for (char c : s) cout << 'x';
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine();
            var N = S.Length;
            var ans = N;
            for (var i = 1; i < N; ++i)
                if (S[i - 1] != S[i])
                    ans = Min(ans, Max(i, N - i));
            WriteLine(ans);
        }
    }
}

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

using namespace std;

const int N = 1e5 + 5;
const long long INF = 1e18 + 5;
const int MAXN = 1e6;
const int base = 317;

typedef long long ll;

const ll bs = 1e5 + 1;
const ll mod = 1e9 + 7;

int n, a[N];
ll q;
ll dp[3005][3005], d[3005][3005];
ll ans;

ll bpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b % 2)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll inv = bpow(2, mod - 2);
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (a[i] > a[j]) {
                dp[i][j] = 1;
            }
        }
    }
    for (int i = 1; i <= q; i++) {
        int u, v;
        cin >> u >> v;
        for (int j = 1; j <= n; j++) {
            d[u][j] = 0;
            d[v][j] = 0;
            d[j][u] = 0;
            d[j][v] = 0;
        }
        ll t = dp[u][v] + dp[v][u];
        d[u][v] = d[v][u] = t * inv % mod;
        for (int j = 1; j <= n; j++) {
            if (u == j || j == v)
                continue;
            if (u != j) {
                d[u][j] = (d[u][j] + (dp[u][j] * inv) % mod) % mod;
                d[u][j] = (d[u][j] + (dp[v][j] * inv) % mod) % mod;
            }
            if (v != j) {
                d[v][j] = (d[v][j] + (dp[v][j] * inv) % mod) % mod;
                d[v][j] = (d[v][j] + (dp[u][j] * inv) % mod) % mod;
            }
            if (j != u) {
                d[j][u] = (d[j][u] + (dp[j][u] * inv) % mod) % mod;
                d[j][u] = (d[j][u] + (dp[j][v] * inv) % mod) % mod;
            }
            if (j != v) {
                d[j][v] = (d[j][v] + (dp[j][v] * inv) % mod) % mod;
                d[j][v] = (d[j][v] + (dp[j][u] * inv) % mod) % mod;
            }
        }
        for (int j = 1; j <= n; j++) {
            dp[u][j] = d[u][j];
            dp[v][j] = d[v][j];
            dp[j][u] = d[j][u];
            dp[j][v] = d[j][v];
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ans = (ans + dp[i][j]) % mod;
        }
    }
    cout << (ans * bpow(2, q)) % mod;
    return 0;
}


Measured memory_bytes: 141568
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define heap_min priority_queue<int,vector<int>,greater<int>>
#define heap_max priority_queue<int>
#define precision(x) cout << setprecision(x) << fixed;
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif

   int a,b,c,d;
   cin >> a >> b >> c >> d;
   int a1 = a*1LL*c;
   int a2 = a*1LL*d;
   int a3 = b*1LL*c;
   int a4 = b*1LL*d;
   cout << max({a1,a2,a3,a4});
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){
    
    int cards[4][14];
    for(int i=0; i<4; i+=1){
        for(int j=0; j<14; j+=1){
            cards[i][j] = 0;
        }
    }
    
    int n, b;
    char a;
    cin >> n;
    
    for(int count=1; count<=n; count+=1){
        cin >> a;
        int i;
        if(a=='S') i=0;
        else if(a=='H') i=1;
        else if(a=='C') i=2;
        else if(a=='D') i=3;
        
        cin >> b;
        int j=b;
        
        cards[i][j] = 1;
    }
    
    char marks[4] = {'S', 'H', 'C', 'D'};
    
    for(int i=0; i<4; i+=1){
        for(int j=1; j<14; j+=1){
            if(cards[i][j] == 0){
                cout << marks[i] << " " << j << endl;
            }
        }
    }
    
    return 0;
    
}



Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long x = Math.abs(scanner.nextLong());
        long k = scanner.nextLong();
        long d = scanner.nextLong();
        if (x == 0) {
            if (k % 2 == 0) {
                System.out.println(0);
            } else {
                System.out.println(d);
            }
            return;
        }
        long req = x / d;
        if (req >= k) {
            System.out.println(x - k * d);
            return;
        }
        long step = k - req;
        long r = x % d;
        if (step % 2 == 0) {
            System.out.println(r);
        } else {
            System.out.println(d - r);
        }


    }
}

Measured memory_bytes: 36056
/*  ex4_2
    pptenshi  */

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

int main(void) {
    int len_hour_hand,    // A
        len_minute_hand,  // B
        hour,             // H
        minute;           // M
    
    double  angle_hour_hand,    // 0時からの角度
            angle_minute_hand,  // 0分からの角度
            angle_hands,        // 時針と分針がなす角
            distance;           // 短点の距離

    double pi = acos(-1);  // define pi

    //input
    scanf("%d%d%d%d", 
        &len_hour_hand, 
        &len_minute_hand, 
        &hour, 
        &minute
    );

    // calculate angle    
    angle_hour_hand = 2 * pi * (hour + minute / 60.0) / 12;
    angle_minute_hand = 2 * pi * minute / 60;
    angle_hands = fabs(angle_hour_hand - angle_minute_hand);

    // calculete distance using law of cosines
    distance = sqrt(
            pow(len_hour_hand, 2) + 
            pow(len_minute_hand, 2) -
            2 * len_hour_hand * len_minute_hand * cos(angle_hands)
        );
    
    // output
    printf("%.15lf\n", distance);

    return 0;
}

Measured memory_bytes: 2592
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Apr 29 12:28:08 2018
//
package main

import (
	"fmt"
)

var S string

const s string = "CODEFESTIVAL2016"

func main() {
	fmt.Scan(&S)
	count := 0
	for i := range S {
		if S[i] != s[i] {
			count++
		}
	}
	fmt.Println(count)
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  string a, b, c;
  cin >> a >> b >> c;
  cout << 'A' << b[0] << 'C' << endl;
}

Measured memory_bytes: 3544
//
//  main.cpp
//  ABC172D
#include <iostream>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
ll g(ll x){
    return x*(x+1)/2;
}
int main(int argc, const char * argv[]) {
    ll n;
    cin>>n;
    vector<ll>d(n+1);
    ll ans=0;
    for(ll i=1;i<=n;i++){
        d.at(i)=i*g(n/i);
        ans+=d.at(i);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 81000
while True:
	n=input()
	if n==0:
		break
	else:
		d=0
		e=0
		for a in range(1, n+1):
			b,c=map(int,raw_input().split())
 			if b>c:
 				d=d+b+c
 			elif b<c:
 				e=e+b+c
			else:
 				d=d+c
 				e=e+c
 		print "%d %d" %(d,e)

Measured memory_bytes: 4508
N=int(input())
S,T=map(str,input().split())
S,T=list(S),list(T)
x=list("a"*(N*2))
for i in range(0,N*2):
    if i%2==0:
        x[i]=S[i//2]
    else:
        x[i]=T[i//2]
x="".join(x)
print(x)



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

#define endl '\n'
using namespace std;
using ll = long long;

const int N = 450;
const ll INF = 1ll<<60;
int n;
ll arr[N], prefix[N];
ll dp[N][N];

void init();
void process();

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n;
    for(int i = 1; i <= n; i++) 
    {
        cin >> arr[i];
        prefix[i] = prefix[i-1] + arr[i];
    }
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            dp[i][j] = INF;
}

ll f(int l, int r)
{
    if(l >= r) return dp[l][r] = 0;
    if(dp[l][r] != INF) return dp[l][r];

    for(int i = l; i < r; i++)
    {
        // arr[r] merge with (arr[i] ... arr[r-1])
        dp[l][r] = min(dp[l][r], f(l, i) + f(i+1, r));
    }
    dp[l][r] += prefix[r]-prefix[l-1];
    return dp[l][r];
}

void process()
{
    cout << f(1, n) << endl;
}



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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  vector<pair<int, int>> vp;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    vp.emplace_back(a, b);
  }
  int ans = 0;
  queue<int> que;
  vector<int> visited(N, 0);
  vector<int> cs(N, 0);
  map<pair<int, int>, int> e;
  visited[0] = 1;
  que.emplace(0);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    int c = 1;
    ans = max(ans, (int)G[u].size());
    for (int v : G[u]) {
      if (visited[v] == 0) {
        if (c == cs[u]) c++;
        cs[v] = e[make_pair(u, v)] = e[make_pair(v, u)] = c++;
        visited[v] = 1;
        que.emplace(v);
      }
    }
  }
  cout << ans << endl;
  for (auto p : vp) {
    cout << e[p] << endl;
  }
}

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

  solve();

  return 0;
}


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

#define ll long long
#define MOD 1000000007
const int maxn = 200005;
int N;
ll A[maxn];

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

    cin >> N;
    ll total = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        total += A[i];
    }

    ll sum = 0;
    for (int i = 0; i < N-1; i++) {
        total -= A[i];
        sum += A[i] * (total % MOD);
        sum %= MOD;
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 5212
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int total = M * (M-1) + N * (N-1);
    cout << total / 2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<int> A(N+1), B(N+1), C(N);
  for(int i=1; i<=N; ++i) cin >> A[i];
  for(int i=1; i<=N; ++i) cin >> B[i];
  for(int i=1; i<=N-1; ++i) cin >> C[i];
  int ans = 0, prev = 0;
  for(int i=1; i<=N; ++i) {
    ans += B[A[i]];
    if(A[i]-prev == 1) ans += C[prev];
    prev = A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
#define int long long
using namespace std;
map<int,int>memo;
int a,b,c,d;
int dfs(int n){
	if(n==0)
		return 0;
	if(n==1)
		return d;
	if(memo.count(n))
		return memo[n];
	int l2=(n/2)*2;
	int r2=((n+1)/2)*2;
	int l3=(n/3)*3;
	int r3=((n+2)/3)*3;
	int l5=(n/5)*5;;
	int r5=((n+4)/5)*5;
	int res=1e18;
	if(n<res/d)
		res=n*d;
	res=min(res,llabs(l2-n)*d+a+dfs(l2/2));
    res=min(res,llabs(r2-n)*d+a+dfs(r2/2));
    res=min(res,llabs(l3-n)*d+b+dfs(l3/3));
    res=min(res,llabs(r3-n)*d+b+dfs(r3/3));
    res=min(res,llabs(l5-n)*d+c+dfs(l5/5));
    res=min(res,llabs(r5-n)*d+c+dfs(r5/5));
    memo[n]=res;
    return res;
}
signed main(){
	int t;
	cin>>t;
	while(t--){
		memo.clear();
		int n;
		cin>>n>>a>>b>>c>>d;
		cout<<dfs(n)<<endl;
	}
}

Measured memory_bytes: 4424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		int inputText1 = scanner.nextInt();
		int inputText2 = scanner.nextInt();

		int result = inputText1 * inputText2;

		if(result%2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
		scanner.close();

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p.at(i);
  }
  int answer = 0;
  vector<int> q(3);
  
  for(int i=1;i<n-1;i++){
    q = {p.at(i-1), p.at(i), p.at(i+1)};
    sort(q.begin(), q.end());
    if(q.at(1) == p.at(i)){
      answer++;
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256