akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        solve();
    }
    static Scanner cin;
    static int N;

    static void input()
    {
        cin = new Scanner();
        N = cin.nextInt();
    }
    static void solve()
    {
        input();
        int sum = 0;
        if (N >= 10)
            sum += 9;
        else
        {
            sum += N;
            WriteLine(sum);
            return;
        }

        if (N >= 1000)
            sum += 900;
        else if(N >= 100)
        {
            sum += N - 99;
            WriteLine(sum);
            return;
        }

        if (N >= 100000)
            sum += 90000;
        else if(N >= 10000)
        {
            sum += N - 9999;
            WriteLine(sum);
            return;
        }
        WriteLine(sum);
    }
    class Scanner
    {
        string[] s;
        int i;

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

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

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

        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

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

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for(int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

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

        public double[] ArrayDounble(int N, int add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
int main()
{
	int a,b;
	char s[10],t[10];

	scanf("%s%s%d%d%s",s,t,&a,&b,s);

	if(strcmp(s,t)==0)
		printf("%d %d",a,b-1);
	else
		printf("%d %d",a-1,b);
	return 0;
}

Measured memory_bytes: 1696
#include <iostream>
#include <cstring>
#include <string>
#include <sstream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <set>
#include <vector>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <queue>
#define maxn 5005
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int m,n;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}

int main()
{
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        if(n==m)
        {
            printf("-1\n");
            continue;
        }
        ll tmp=gcd(n,m);
        if(n>m&&tmp==m)
        {
            printf("-1\n");
            continue;
        }
        ll tn=n/tmp;
        ll tm=m/tmp;
        printf("%lld\n",(ll)tn*n);
    }
    return 0;
}


Measured memory_bytes: 256
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

al = []

for i in range(n):
    a = raw_input()
    a = int(a)
    al.append(a)

al.sort()

num = 0

i = 0
while i < n:
    if i == n-1:
        num += 1
        break
    if al[i] == al[i+1]:
        i += 2
    else:
        num += 1
        i += 1

print num


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18
#define NINF INT_MIN

#define nax 200005


void solve(){
	
	 int x;
	 cin>>x;
	 int i=1;
	 while(1){
	 	int temp = 360*i;
	 	if(temp%x==0){
	 		cout<<temp/x<<endl;
	 		return;
	 	}
	 	i++;
	 }
	
}	

signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
def f(i, qs):
    ss = str(i)
    for s, c in qs:
        if ss[s-1] != c:
            return False
    return True

def main():
    N, M = map(int, input().split())
    qs = []
    for _ in range(M):
        s, c = input().split()
        qs.append((int(s), c))

    if N == 1:
        if f(0, qs):
            return 0
    for i in range(10**(N-1), 10**N):
        if f(i, qs):
            return i
    return -1

print(main())


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

#define ll long long
#define mk make_pair
#define pb push_back


using namespace std;


int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   
   string d; cin >> d;
   map<string, int> days;
   days["MON"] = 1;
   days["TUE"] = 2;
   days["WED"] = 3;
   days["THU"] = 4;
   days["FRI"] = 5;
   days["SAT"] = 6;
   days["SUN"] = 7;

   if(d == "SUN") cout << 7;
   else cout << days["SUN"] - days[d];

   return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n;
    cin >> n;
    vector<int> perm(n);
    vector<int> p(n);
    vector<int> q(n);
    rep(i, n) perm[i] = i + 1;
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    int idx_p = 0;
    int idx_q = 0;
    int i = 0;
    do {
        if (perm == p) idx_p = i;
        if (perm == q) idx_q = i;
        i++;
    } while (next_permutation(perm.begin(), perm.begin() + n));
    int ans = abs(idx_p - idx_q);
    out(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int A , B;
	scanf("%d %d",&A , &B);
	    if(A==B)
        {
          cout<<"Draw";
        }
        else if(A==1 || (A>B && B!=1) )
        {
           cout<<"Alice";
        }
        else if(B==1 || (B>A && A!=1) )
        {
          cout<<"Bob";
        }


}


Measured memory_bytes: 256
/*
Author: CNYALI_LK
LANG: C++
PROG: C.cpp
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>void chkmin(T &a,T b){a=a<b?a:b;}
template<class T>void chkmax(T &a,T b){a=a>b?a:b;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
int tot[102424],*s=tot+1;
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	int n,x;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&x);
		++s[x-1];
		++s[x];
		++s[x+1];
	}
	int ans=0;
	for(int i=-1;i<=100000;++i)chkmax(ans,s[i]);
	printf("%d\n",ans);
	return 0;
}



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

int main() {
  int n,d,a,b;
  cin >> n >> d;
  a = 2*d + 1;
  b = n % a;
  if (b == 0)
  	cout << n / a << endl;
  else
    cout << (n / a) + 1 << endl;
}

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

string S;
int N, cnt;

int main()
{
    cin >> N >> S;

    for (int i = 0; i < 1000; i++)
    {
        int c[3] = {i / 100, (i / 10) % 10, i % 10};
        int f = 0;
        for (int j = 0; j < N; j++)
        {
            if (S[j] == ('0' + c[f]))
                f++;

            if (f == 3)
                break;
        }
        if (f == 3)
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	double x,s=0.0;
	char u[10];

	scanf("%d",&n);
	while(n--){
		scanf("%lf%s",&x,u);
		s+=(u[0]=='J')?x:x*380000.0; 
	}
	printf("%lf",s);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	static char S[1000000];
	scanf("%s", S);
	int nagasa, j;
	int hikkurikaesi[2] = {0, 0};

	for (int i = 0; ; ++i) {
		if (S[i] == 0) {
			nagasa = i;
			break;
		}
	}

	for (j = 0; j < nagasa; ++j) {//101010~
		if (j % 2 == 0) {
			if (S[j] == 49)
				hikkurikaesi[0]++;
		} else {
			if (S[j] == 48)
				hikkurikaesi[0]++;
		}
	}

	for (j = 0; j < nagasa; ++j) {//010101~
		if (j % 2 == 1) {
			if (S[j] == 49)
				hikkurikaesi[1]++;
		} else {
			if (S[j] == 48)
				hikkurikaesi[1]++;
		}
	}

	int kekka;

	if (hikkurikaesi[0] < hikkurikaesi[1])
		kekka = hikkurikaesi[0];
	else
		kekka = hikkurikaesi[1];

	printf("%d\n", kekka);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		sc.close();
		String ans[] = { "YES", "NO"};
		int a = 0;
		int r = n % 2;
		r = (n / 2) + r;
		if(r < k)a = 1;
		System.out.println(ans[a]);
	}

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int mod = 1e9+7;
int main() {
	int h,w;
	cin>>h>>w;
	vector<vector<char>> wall(h,vector<char> (w));
	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++) {
			cin>>wall[i][j];
		}
	}
	vector<vector<int>> dp(h,vector<int>(w,-1));
	dp[0][0] = 1;
	for(int i=1;i<w;i++) {
		if(wall[0][i] == '#') {
			break;
		}
		dp[0][i] = dp[0][i-1];
	}
	for(int i=1;i<h;i++) {
		if(wall[i][0] == '#') {
			break;
		}
		dp[i][0] = dp[i-1][0];
	}
	for(int i=1;i<h;i++) {
		for(int j=1;j<w;j++) {
			if(wall[i][j] != '#') {
				dp[i][j] = 0;
				if(dp[i-1][j] != -1) {
					dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
				}
				if(dp[i][j-1] != -1) {
					dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
				}
			}
		}
	}
	cout<<dp[h-1][w-1];
} 

Measured memory_bytes: 8564
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
void dfs(long long x,long long a,long long b,long long c){
  if(x>n) return;
  if(a&&b&&c) ++ans;
  dfs(10*x+3,1,b,c);
  dfs(10*x+5,a,1,c);
  dfs(10*x+7,a,b,1);
}
int main(){
  cin>>n;
  dfs(0,0,0,0);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"
import "sort"

func main(){
	var N int
	//var count int
	
	fmt.Scan(&N)
	S  := make([]string, N)
	m := make(map[string]int)

	for i := 0 ; i < N ; i++{
		fmt.Scan(&S[i])
	}
	sort.Strings(S)
	//fmt.Println(S)
	max := 0 
	for i := 0 ; i < N ; i++{
		m[S[i]]++
		if max < m[S[i]]{
			max = m[S[i]]
		}
	}
	key := make([]string, 0, len(m))
	for k := range m{
		key = append(key, k)
	}
	sort.Strings(key)
	for _, k := range key {
		if m[k] == max {
			fmt.Println(k)
		}
	}
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;


int main(){
  lli a,b;
  cin >> a >> b;
  if(a <= 8 && b <= 8) cout << "Yay!" << endl;
  else cout << ":(" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){  a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N=2*1e5+3;
vector<pii> a[N];
int d[N];
bool vis[N];
int sol[N];
void dfs(int x)
{
      vis[x]=true;
      for(auto y:a[x])
      {
            if(!vis[y.fi])
            {
                  dfs(y.fi);
                  if(d[y.fi]) sol[y.se]=1;
                  d[x]^=d[y.fi]; 
            }
      }
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n,m;
      cin>>n>>m;
      int uu[m],vv[m];
      for(int i=0;i<m;i++)
      {
            int x,y;
            cin>>x>>y;
            uu[i]=x;
            vv[i]=y;
            d[x]^=1;
            a[x].pb({y,i});
            a[y].pb({x,i});
      }
      int cnt=0;
      for(int i=1;i<=n;i++)
      {
            if(d[i]) cnt++;
      }
      if(cnt&1)
      {
            cout<<"-1";
            return 0;
      }
      dfs(1);
      for(int i=0;i<m;i++)
      {
            if(sol[i])
            {
                  cout<<vv[i]<<" "<<uu[i]<<"\n";
            }
            else{
                  cout<<uu[i]<<" "<<vv[i]<<"\n";
            }
      }
}     
// I never lose. I either win or I learn

Measured memory_bytes: 19456
n = int(input())
ans = [0] * (10**4 + 1)

for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i+j*j+k*k+i*j+j*k+k*i
            if v < 10001:
                ans[v]+=1

for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 9208
N = int(input())
L = sorted(list(map(int, input().split())))[::-1]
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i] < L[j] + L[k]:
                if L[i] != L[j] != L[k]:
                    cnt += 1
print(cnt)

Measured memory_bytes: 9192
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {


    ll a, b, c;
    cin >> a >> b >> c;
    for (int i = 0; i < b; i++) {
        cout << c << ' ';
    }
    for (int i = 0; i < a - b; i++) {
        if (c+1 <= 1000000000)
            cout << c+1 << ' ';
        else
            cout << c-1 << ' ';
    }
    cout << '\n';

}


Measured memory_bytes: 1280
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

let [n, m] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

n = n > m ? m : n

const x = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = () => {
  const sorted = x.sort((a, b) => a - b)

  const diffs = getDiffs(sorted)

  const splitLines = getSplitLines(diffs)

  let count = 0
  for (let i = 0; i < splitLines.length; i++) {
    const begin = splitLines[i]
    const end = i === splitLines.length - 1 ? sorted.length - 1 : splitLines[i + 1] - 1

    count += sorted[end] - sorted[begin]
  }

  console.log(count)
}

const getDiffs = arr => {
  const diffs = []

  for (let i = 1; i < arr.length; i++) {
    const diff = arr[i] - arr[i - 1]

    diffs.push({
      diff,
      index: i,
    })
  }

  return diffs
}

const getSplitLines = diffs => {
  const sDiffs = diffs.sort((a, b) => b.diff - a.diff)

  const splitLines = [0]
  for (let i = 0; i < n - 1; i++) {
    const idx = sDiffs[i].index

    splitLines.push(idx)
  }

  return splitLines
}

ans()


Measured memory_bytes: 29816
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main()
{
    ll n, x;
    cin >> n >> x;
    vector<ll> b(n);
    vector<ll> l(n);
    vector<ll> u(n);
    vector<ll> score(n);
    ll ascore = 0;
    ll bsum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> b[i] >> l[i] >> u[i];
        score[i] = l[i] * b[i] + (u[i] * (x-b[i]));
        ascore += b[i] * l[i];
        bsum += b[i];
    }
    vector<int> ord(n);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(), [&](int lhs, int rhs)
    {
        return score[lhs] > score[rhs];
    });
    vector<ll> sum(n+1);
    for(int i = 0; i < n; i++) sum[i+1] = sum[i] + score[ord[i]];
    ll h = bsum;
    ll le = -1;
    while(h - le > 1)
    {
        ll mid = (h + le) >> 1;
        ll num = mid / x;
        ll y = mid % x;
        ll tmax = 0;
        for(int i = 0; i < n; i++)
        {
            ll tmp;
            if(num > i) tmp = sum[num+1] - score[ord[i]];
            else tmp = sum[num];
            int nn = ord[i];
            if(y > b[nn]) tmp += b[nn] * l[nn] + (y - b[nn]) * u[nn];
            else tmp += y * l[nn];
            tmax = max(tmax, tmp);
        }
        if(tmax - ascore >= 0)
        {
            h = mid;
        }
        else
        {
            le = mid;
        }
    }
    cout << h << endl;
}


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

int main(){
  string S;
  cin >> S;

  int posA = 0;
  bool findA = false;
  int posZ = 999999;

  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) == 'A' && !findA){
      posA = i;
      findA = true;
    }

    if (S.at(i) == 'Z'){
      posZ = i;
    }
  }
  cout << posZ - posA + 1 << endl;
  
}

Measured memory_bytes: 3724
while True:
    n, x, = map(int, input().split())
    if n == 0 and x == 0: break
    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5596
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;
 
int n;
vector<int> G[MAX];
int color[MAX];
 
void dfs(int r, int c) {
    stack<int> S;
    S.push(r);
    color[r] = c;
    int i, u, v;
    while ( !S.empty() ) {
        u = S.top();
        S.pop();
        for ( i = 0; i < G[u].size(); i++ ) {
            v = G[u][i];
            if ( color[v] == NIL ) {
                color[v] = c;
                S.push(v);
            }
        }
    }
}
 
void assignColor() {
    int id = 0;
    int i, u;
    for ( i = 0; i < n; i++ ) color[i] = NIL;
    for ( u = 0; u < n; u++ ) {
        if ( color[u] == NIL ) dfs(u, id++);
    }
}
 
int main() {
    int s, t, m, q, i;
 
    cin >> n >> m;
 
    for ( i = 0; i < m; i++ ) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
 
    assignColor();
 
    cin >> q;
 
    for ( i = 0; i < q; i++ ) {
        cin >> s >> t;
        if ( color[s] == color[t] ) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 8924
S = input()
year = int(S[0]+S[1]+S[2]+S[3])
mon = int(S[5]+S[6])
day = int(S[8]+S[9])
if year <= 2019 and 1 <= mon <= 4 and 1 <= day <= 30:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 2940
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	ll sum=100000;
	double t;
	for(int i=1;i<=n;i++)
	{
		t=sum*0.05;
		t=t/1000;
		t=ceil(t);
		t=t*1000;
		sum=sum+t;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3108
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner in;
	static PrintWriter out;
	static String INPUT = "";

	static int count(int r1, int c1, int r2, int c2)
	{
		out.printf("? %d %d %d %d\n", r1, c1, r2, c2);
		out.flush();
		return ni();
	}
	
	static void end(boolean[][] map, int mod)
	{
		long h = 0;
		long t = 1;
		for(int i = 0;i < map.length;i++){
			for(int j = 0;j < map[0].length;j++){
				h += (map[i][j] ? 1 : 0) * t;
				h %= mod;
				t = t * 2 % mod;
			}
		}
		out.println("! " + h);
		out.flush();
	}
	
	static void solve()
	{
		int h = ni(), w = ni(), n = ni(), K = ni();
		boolean[][] map = new boolean[h][w];
		for(int i = 0;i < h;i+=2){
			for(int j = 0;j < w;j+=2){
				int lc = count(i, j, i+1, j+1);
				if(lc == 0)continue;
				if(lc == 4){
					for(int k = 0;k < 2;k++){
						for(int l = 0;l < 2;l++){
							map[i+k][j+l] = true;
						}
					}
					continue;
				}
				if(lc == 1){
					int llc = count(i, j, i+1, j);
					int q = llc^1;
					int lruc = count(i, j+q, i, j+q);
					map[i+(lruc^1)][j+q] = true;
					continue;
				}
				if(lc == 3){
					for(int k = 0;k < 2;k++){
						for(int l = 0;l < 2;l++){
							map[i+k][j+l] = true;
						}
					}
					int llc = count(i, j, i+1, j);
					int q = 2-llc^1;
					int lruc = count(i, j+q, i, j+q);
					map[i+(1-lruc^1)][j+q] = false;
					continue;
				}
				int rem = 2;
				for(int k = 0;k < 2;k++){
					for(int l = 0;l < 2;l++){
						int co = k == 1 && l == 1 ? rem : count(i+k, j+l, i+k, j+l);
						rem -= co;
						map[i+k][j+l] = co == 1;
					}
				}
			}
		}
		end(map, K);
	}
	
	public static void main(String[] args) throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	static int ni() { return Integer.parseInt(in.next()); }
	static long nl() { return Long.parseLong(in.next()); }
	static double nd() { return Double.parseDouble(in.next()); }
	static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}


Measured memory_bytes: 21172
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
cum = [0] * (N-1)
cum[0] = A[0]%mod
for i in range(1,N-1):
    cum[i] = cum[i-1] + A[i]
    cum[i] %= mod
ans = 0
for i in range(1,N):
    ans += cum[i-1]*A[i]
    ans %= mod
print(ans)

Measured memory_bytes: 93960
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int a, b, i, deg[10];

int main() {
for (i=1;i<=3;i++) {
	scanf("%d %d", &a, &b);
	deg[a-1]++;
	deg[b-1]++;
}
sort(deg, deg + 4);
if (deg[0] == 1 && deg[1] == 1 && deg[2] == 2 && deg[3] == 2) printf("YES\n"); else printf("NO\n");	
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100
#define MO 1000000007
using namespace std;
typedef long long LL;
int a[MAXN+5],n;
LL f[MAXN+5][MAXN+5][MAXN+5];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n-1;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+2*n);
	f[n][1][0]=1;
	LL t;
	for(int i=n-1;i>=1;i--)
	{
		int al=(a[i]!=a[i+1]),ar=(a[2*n-i]!=+a[2*n-i-1]);
		for(int l=0;l<=2*n-1;l++)
			for(int r=0;l+r<=2*n-1;r++)
				if(f[i+1][l][r])
				{
					t=f[i+1][l][r];
					for(int dl=1;dl<=l+al;dl++)
					{
						f[i][l+al-dl+1][r+ar+(dl>1)]+=t;
						f[i][l+al-dl+1][r+ar+(dl>1)]%=MO;
					}
					for(int dr=1;dr<=r+ar;dr++)
					{
						f[i][l+al+1][r+ar-dr]+=t;
						f[i][l+al+1][r+ar-dr]%=MO;
					}
				}
	}
	LL ans=0;
	for(int l=0;l<=2*n-1;l++)
		for(int r=0;l+r<=2*n-1;r++)
			ans=(1LL*ans+1LL*f[1][l][r])%MO;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll h,w;
  cin >> h >> w;
  if (h == 1 || w == 1){
    cout << 1 << endl;
    return 0;
  }

  ll h1 = (h+1)/2, h2 = h/2, w1 = (w+1)/2, w2 = w/2;
  ll ans = h1*w1 + h2*w2;
  cout << ans << endl;
}


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

typedef long long ll;

int main(){
  int n;   cin >> n;
  int a[n+1];
  for(int i=1; i<=n; i++) cin >> a[i];

  ll p1=0, p2=0, sum1=0, sum2=0;
  for(int i=1; i<=n; i++){
    sum1 += a[i]; sum2 += a[i];
    if(i%2){
      p1 += max(-sum1+1, 1LL*0); sum1 = max(1LL, sum1);
      p2 += max(sum2+1, 1LL*0); sum2 = min(-1LL, sum2);
    }
    else{
      p1 += max(sum1+1, 1LL*0); sum1 = min(-1LL, sum1);
      p2 += max(-sum2+1, 1LL*0); sum2 = max(1LL, sum2);
    }
  }

  cout << min(p1, p2) << endl;

  return 0;
}


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

vector<int> C(26);
vector<int> last(26);
vector<vector<int>> S(365, vector<int>(26));

int down(int day){
    day++;
    ll ret = 0;
    rep(i, 26){
        ret += C[i] * (day - last[i]);
    }
    return ret;
}

int check(int day){
    ll ret = 0;
    ll tmp = 0;
    ll tmp2 = 0;
    rep(i, 26){
        tmp2 = last[i];
        last[i] = i+1;
        tmp = S[day][i];
        tmp -= down(i);
        last[i] = tmp2;
        ret = max(ret, tmp);
    }
    return ret;
}

int main(){
    int D;
    cin >> D;
    rep(i, 26) cin >> C[i];
    rep(i, D){
        rep(j, 26){
            cin >> S[i][j];
        }
    }  
    ll ans = 0;

    vector<int> T(D);
    rep(i, D) cin >> T[i];
    rep(i, D) T[i]--;

    rep(i, D){
        last[T[i]] = i+1;
        ans += S[i][T[i]];
        ans -= down(i);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a,b,c,d,sign=1;
    cin>>a>>b>>c>>d;
    while(1){
        if(sign==1){
            sign=0;
            c-=b;
        }
        else{
            sign=1;
            a-=d;
        }
        if(a<=0 || c<=0) break;
    }
    if(sign==1) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>

using namespace std;

int main(){
    int S;
    cin >> S;

    bool Q1 = false, Q2 = false;
    if(1 <= (S%100) && (S%100) <= 12)
        Q1 = true;
    if(1 <= (S/100) && (S/100) <= 12)
        Q2 = true;

    if(Q1 == true){
        if(Q2 == true){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "YYMM" << endl;
        }
    }else{
        if(Q2 == true){
            cout << "MMYY" << endl;
        }else{
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define sp cout<< " ";
#define rep(i, a, b) for(int i=a; i< b; i++)


using namespace std;
int main()
{
        long long a, s=0;
        cin>> a;
        rep(i, 1, a+1)
        {
            if(i%3!=0 && i%5!=0)
                s+=i;
        }

        cout<< s<< endl;

    return 0;
}



Measured memory_bytes: 3648
uses math;
var a,f:array[0..130]of longint;
    n,i,j:longint;
    s:string;
begin
  readln(n);
  fillchar(f,sizeof(f),$3f);
  for i:=1 to n do
  begin
    readln(s);
    fillchar(a,sizeof(a),0);
    for j:=1 to length(s) do
      inc(a[ord(s[j])]);
    for j:=97 to 122 do
      f[j]:=min(ord(a[j]),f[j]);
  end;
  for i:=97 to 122 do
    for j:=1 to f[i] do
      write(chr(i));
end.

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int k;
void solve(){
	cin >> k;
	
	queue<i64> q;
	for(int i = 1; i < 10; i++) q.push(i);
	while(1){
		i64 p = q.front(); q.pop();
		k--;
		if(k == 0){
			cout << p << endl;
			break;
		}
		for(int i = 0; i < 10; i++){
			if(abs(p%10 - i) < 2) q.push(p*10+i);
		}
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
    string s[51];
    int h,w;

char f(int y,int x)
{
    char sum='0';
    REP(i,8)
    {
        int yy=y+dy[i],xx=x+dx[i];
        if(yy<0||yy>=h||xx<0||xx>=w)continue;
        if(s[yy][xx]=='#')sum++;
    }
    return sum;
}

int main()
{
    cin>>h>>w;
    REP(i,h) cin>>s[i];
    REP(i,h)REP(j,w)if(s[i][j]=='.')s[i][j]=f(i,j);
    REP(i,h) cout<<s[i]<<endl;;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,m;
	while(cin>>n>>m,n,m){
		int a[120],b[120];
		int A = 0,B = 0;
		for(int i = 0;i < n;i++){
			cin>>a[i];
			A += a[i];
		}
		for(int i = 0;i < m;i++){
			cin>>b[i];
			B += b[i];
		}
		sort(a,a+n);
		sort(b,b+m);
		int best = 1e9,x = -1,y = -1;
		for(int i = 0;i < n;i++){
			for(int j = 0;j < m;j++){
				int X = A-a[i]+b[j];
				int Y = B-b[j]+a[i];
				if(X==Y){
					if(a[i]+b[j]<best){
						best = a[i]+b[j];
						x = a[i],y = b[j];
					}
				}
			}
		}
		cout<<x;
		if(x!=-1)cout<<" "<<y;
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 1180
#include<vector>
#include<string>
#include<iostream>
using namespace std;
int main()
{
  string s;
  int k = 0;
  cin >> s;
  if(s[0] == 'o')
    k++;
  if(s[1] == 'o')
    k++;
  if(s[2] == 'o')
    k++;
  cout << 700 + 100 * k;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; i++) cin >> X[i];
    sort(X.begin(),X.end());
    int left = X[0];
    int right = X[N -1];
    int ans = 100000000;
    for(int i = left; i <= right; i++)
    {
        int res = 0;;
        for(int j = 0; j < N; j++)
        {
            res += (X[j] - i) * (X[j] - i);
        }
        ans = min(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
  N, K, S = (int(_) for _ in input().split())
  output = []
  for _ in range(K):
    output.append(S)
  if S == 10 ** 9: a = S - 1
  else:
    a = S + 1
  for _ in range(N - K):
    output.append(a)
  print(*output)
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 6552
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 20){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}



void solve(){
  ll N;
  cin >> N;
  vector<ll> A(N), B(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];

  ll ans = 0;
  for(ll i = 0; i < 29; i++){
    ll add = 0;
    vector<ll> D(N);
    rep(j, N) D[j] = B[j] % (1<<(i+1));
    sort(D.begin(), D.end());
    rep(j, N){
      vector<ll> cnt(4);
      ll a = A[j] % (1<<(i+1));
      cnt[3] = N - (lower_bound(D.begin(), D.end(), (1<<(i+1)) + (1<<i) - a) - D.begin());
      cnt[2] = N - (lower_bound(D.begin(), D.end(), (1<<(i+1)) - a) - D.begin());
      cnt[1] = N - (lower_bound(D.begin(), D.end(), (1<<i) - a) - D.begin());
      add += cnt[3] - cnt[2] + cnt[1];
      add %= 2;
    }
    ans += (1<<i) * add;
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 4992
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(max(0, a-b*2))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
int a[1<<18][2];
void mergeto(int x,int y){
	vector<int> vs;
	vs.pb(a[x][0]);
	vs.pb(a[x][1]);
	vs.pb(a[y][0]);
	vs.pb(a[y][1]);
	sort(all(vs),greater<int>());
	rep(i,2) a[x][i] = vs[i];
}
int main(){
	cin>>N;
	rep(i,1<<N) cin>>a[i][0];
	rep(i,N){
		for(int j=(1<<N)-1;j>=0;j--) if((j>>i)&1){
			mergeto(j,j^(1<<i));
		}
	}
	vector<int> ans(1<<N);
	rep(i,1<<N) ans[i] = a[i][0]+a[i][1];
	rep1(i,(1<<N)-1){
		chmax(ans[i],ans[i-1]);
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 6144
#include <cstdio>
#include <cstring>
#include <algorithm>

using std::max;
using std::min;

const int MAXN=1e5+5,MAXM=1e7+5;
int n,m,ans,s;
int he[MAXN],col[MAXN];
bool cannt[MAXN],vis[MAXN],flag;

struct line{int to,nex;}ed[MAXM<<1];

inline void addE(int u,int v){
	static int cnt=0;
	ed[++cnt]=(line){v,he[u]};
	he[u]=cnt;
}

void DFS(int u,int c){
	for(int i=he[u],v;i;i=ed[i].nex){
		v=ed[i].to;
		if(!col[v]) col[v]=c,DFS(v,c^1);
		else{
			if(col[v]!=col[u]) continue;
			else flag=true;
		}
	}
}

int main(){
//#ifdef DEBUG
//	freopen("c.in","r",stdin);
//	freopen("c.out","w",stdout);
//#endif
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;++i){
		scanf("%d%d",&u,&v);
		addE(u,v),addE(v,u);
	}
	col[1]=1;
	DFS(1,0);
	if(flag) printf("%lld",(long long)n*(n-1)/2-m);
	else{
		long long cnt=0;
		for(int i=1;i<=n;++i){
			if(col[i]) ++cnt;
		}
		printf("%lld",(long long)cnt*(n-cnt)-m);
	}
	return 0;
}

Measured memory_bytes: 8320
#include <iostream>
using namespace std;
const long long MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    bool broken[n + 1] = {false};
    for(int i = 0; i < m; i++) {
        int a;
        cin >> a;
        broken[a] = true;
    }

    long long ans[n + 1];
    ans[0] = 1;

    if(broken[1]) ans[1] = 0;
    else ans[1] = 1;

    for(long long i = 2; i <= n; i++) {
        if(broken[i]) ans[i] = 0;
        else ans[i] = (ans[i - 2] + ans[i - 1]) % MOD;
        // cout << i << ": " << ans[i] << endl;
    }

    cout << ans[n] << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(){

    int H,W;

    scanf("%d %d",&H,&W);

    while(!(H==0&&W==0)){
        for(int i=0;i<H;i++){
            for(int f=0;f<W;f++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d",&H,&W);
    }
}


Measured memory_bytes: 2104
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if A >= 13:
        ret = B
    elif A >= 6:
        ret = B // 2
    else:
        ret = 0
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define V vector<int>
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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int d, n; cin >> d >> n;
	if (d == 0) {
		if(n!=100)cout << n << endl;
		else cout << 101 << endl;
	}
	else if (d == 1) {
		if(n!=100)cout << n * 100 << endl;
		else cout << 10100 << endl;
	}
	else {
		if(n!=100)cout << n * 10000 << endl;
		else cout << 1010000 << endl;
	}
	return 0;
}

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

using namespace std;


int main()
{
    int num;
    int tmp;
    vector<int> store_num;
    
    cin >> num;
    for (int i = 0; i < num; i++)
    {
        store_num.clear();
        for (int j = 0; j < 3; j++)
        {
            cin >> tmp;
            store_num.push_back(tmp);
        }
        
        sort(store_num.begin(), store_num.begin() + 3);
        if ((store_num[0] * store_num[0]) + (store_num[1] * store_num[1]) == (store_num[2] * store_num[2]))
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp61 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            int now_num = 0;

            int ans = 753;

            for (int i = 0; i < S.Length - 2; i++) {
                now_num = int.Parse(S[i].ToString() + S[i + 1].ToString() + S[i + 2].ToString());
                ans = Math.Min(ans, Math.Abs(now_num - 753));
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())

P = [int(input()) for i in range(N)]

T = [0]*(N-1)

E = [0]*N

for i in range(N):
    E[P[i]-1] = 1
    if P[i]<N:
        if E[P[i]]==1:
            T[P[i]-1] = 1

max_score = 0
prev = -1

for i in range(N-1):
    if T[i]==1:
        max_score=max(max_score,i-prev)
        prev = i

max_score = max(max_score,N-1-prev)

print(N-max_score)

Measured memory_bytes: 54364
#include<cstdio>
const int LIMIT = int(1E9);
typedef long long ll;
int main() {
	ll S; scanf("%lld", &S);
	if( S == 1LL*LIMIT*LIMIT )
		printf("0 0 %d 0 0 %d\n", LIMIT, LIMIT);
	else printf("%d %d %d %d %d %d\n", 1, 0, S/LIMIT+1, S%LIMIT, 0, LIMIT);
}

Measured memory_bytes: 128
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//233
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22)cout<<"bust";
	else cout<<"win";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3624
import scala.io.StdIn.{readInt,readLine}

object Main {
  def main(args:Array[String]) = {
    val n = for(i<-1 to 5) yield readInt
    val m = if(n(0)>n(1)) n(1) else n(0)
    val pasta = if(m>n(2)) n(2) else m
    val juice = if(n(3)>n(4)) n(4) else n(3)
    println(pasta+juice-50)
  }
}

Measured memory_bytes: 43532
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define print(a) {\
    for (auto i : a) cout << i << ' ';\
    cout << '\n';\
}
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define pii pair<int,int> 
#define pdd pair<ld,ld> 
#define ld long double
#define pll pair<lli,lli>
#define tiii tuple<int,int,int>
#define all(a) a.begin(), a.end()
#define X first
#define Y second
#define oset tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
auto SEED = chrono::steady_clock::now().time_since_epoch().count();
mt19937 rng(SEED);
const int x = 864197532, N = 50000;
const long long mod = 9223372036854775807;
const double eps = 1e-6, Pi = 3.1415926535;
 
int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	lli a;
	ld b;
	cin >> a >> b;
	lli ans = a * b;
	cout << ans << endl; 
}

Measured memory_bytes: 3748
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int A[100100]; rep(i, N) cin >> A[i];
    map<int, int> mp;
    rep(i, N) {
        mp[A[i]] ++;
    }
    int cnt = 0, ans = 0;
    for(auto p : mp) {
        cnt += p.sc - 1;
        ans ++;
    }
    if(cnt & 1) ans --;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5376
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=[list(map(int,input().split())) for i in range(m)]
for i in a:
  cnt=2*(10**16)
  ans=0
  for j in range(len(b)):
    if abs(i[0]-b[j][0])+ abs(i[1]-b[j][1])<cnt:
      cnt=abs(i[0]-b[j][0])+ abs(i[1]-b[j][1])
      ans=j+1
  print(ans)


Measured memory_bytes: 9148
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

const int INF = 1001001001;
int h, w, b[1001][1001], que[1001001], l=0, r=0, dx[]={0,1,0,-1}, dy[]={1,0,-1,0}, ans=0;
char a[1001][1001];

int main(){
	scanf("%d%d", &h, &w);
	for(int i=0; i<h; i++){
		scanf("%s", a[i]);
		for(int j=0; j<w; j++){
			b[i][j] = INF;
			if(a[i][j] == '#'){
				b[i][j] = 0;
				que[r] = i * 10000 + j;
				r++;
				r %= 1001001;
			}
		}
	}
	while(r != l){
		int x=que[l]/10000, y=que[l]%10000;
		l++;
		l %= 1001001;
		for(int i=0; i<4; i++){
			int nx=x+dx[i], ny=y+dy[i];
			if(0<=nx&&nx<h && 0<=ny&&ny<w && a[nx][ny]=='.' && b[nx][ny] > b[x][y] + 1){
				b[nx][ny] = b[x][y] + 1;
				que[r] = nx*10000 + ny;
				r++;
				r %= 1001001;
			}
		}
	}
	for(int i=0; i<h; i++)for(int j=0; j<w; j++)ans = max(ans, b[i][j]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8960
#include<stdio.h>

int main(void)
{
 int leng,wid,area,cir;
 scanf("%d %d",&leng, &wid);
 area = leng * wid;
 cir = 2 * (leng + wid);
 printf("%d %d\n",area, cir);
 return 0;
}

Measured memory_bytes: 596