akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;


typedef long long ll;

const int M = 1e9+7 ;


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    
    unsigned long long  a , b , c; 
    

    cin >> a >> b >> c ;

    if (a + b > c){
        cout << "No"<<"\n";
        return 0 ;
    }

    unsigned long long  lt = a + b - c ;
    lt = lt * lt ;

    unsigned long long  rt = 4 * a * b ;

    // cout <<"lt : "<<lt << " , rt : "<< rt << "\n";

    if (lt > rt){
        cout << "Yes" << "\n";
    }
    else {
        cout << "No"<<"\n";
    }



    
  
    return 0;
}



Measured memory_bytes: 256
//In the Name of Allah Most Gracious, Most Merciful//
/*If you want something you've never had, you have  to do something you never did.*/

#include<bits/stdc++.h>
using namespace std;


#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 100007
#define INF 1e9
#define INFL 1e18
#define PI acos(-1)
#define mp make_pair

//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
int n;
int dp[100100];
int arr[100100];



int mydp(int i)
{
    if(i>=n)
    {
        return 0;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    int ret1=INF,ret2=INF;
    if(i+2<=n)
    {
        ret1=abs(arr[i+2]-arr[i])+mydp(i+2);
    }
    if(i+1<=n)
    {
        ret2=abs(arr[i+1]-arr[i])+mydp(i+1);
    }
    dp[i]=min(ret1,ret2);
    return dp[i];
}
int main()
{

   //  #ifndef ONLINE_JUDGE
   //    freopen("input.txt","r",stdin);
   //    freopen("output.txt","w",stdout);
  //   #endif
  cin>>n;
  for(int i=1;i<=n;i++)
  {
      cin>>arr[i];
  }
  dp[0]=0;
  dp[1]=0;
  for(int i=0;i<=100000;i++)
  {
      dp[i]=INF;
  }
  arr[0]=arr[1];
  dp[0]=0;
  dp[1]=0;
  for(int i=1;i<=n;i++)
  {
      if(i-2>=0)
      {
          dp[i]=min(dp[i],dp[i-2]+abs(arr[i]-arr[i-2]));
      }
      if(i-1>=0)
      {
          dp[i]=min(dp[i],dp[i-1]+abs(arr[i]-arr[i-1]));
      }
  }
  cout<<dp[n]<<endl;


}



Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,int>;
using ll = long long;
const auto INF =(ll)1e5;
int main(){
  int n;
  cin>> n;
  auto a = vector<int>(n,0);
  auto b = vector<int>(n,0);
  auto c = vector<int>(n,0);

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if(i==0){
        cin >> a[j];
        a[j]--;
      } else if(i==1){
        cin >> b[j];
      }else if(i==2){
        cin >> c[j];
      }
    } 
  }

  auto sum = 0;
  auto before = INF;
  for (int i = 0; i < n; i++)
  {
    sum+=b[a[i]];
    if(before+1==a[i]){
      sum+=c[before];
    }
    before=a[i];
  }
  
  cout << sum;

  
}

Measured memory_bytes: 256
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

mod = 10 ** 9 + 7
max_A = 2000
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

# internal inversion
bit = Bit(max_A)
X = 0
for i, p in enumerate(A):
    bit.add(p, 1)
    X += i + 1 - bit.sum(p)

# external inversion
Y = -X
for i, p in enumerate(A):
    bit.add(p, 1)
    Y += i + N + 1 - bit.sum(p)

ans = (X * K + Y * K * (K - 1) // 2) % mod
print(ans)


Measured memory_bytes: 3188
#include <cstdio>
int main() {
	int n, a, b;
	scanf("%d%d%d",&n,&a,&b);
	a = __builtin_ctz(a);
	b = __builtin_ctz(b);
	int c[4] {}, k = 0, m = n * n; n <<= 1;
	for (int x = 0; x < n; x++)
		for (int y = 0; y < n; y++)
			c[((a&1 ? x : x+y) >> (a>>1) & 1) << 1 |
			  ((b&1 ? x : x+y) >> (b>>1) & 1)]++;
	for (int i = 1; i < 4; i++)
		if (c[i] > c[k]) k = i;
	for (int x = 0; x < n; x++)
		for (int y = 0; y < n; y++)
			if ((((a&1 ? x : x+y) >> (a>>1) & 1) << 1 |
				 ((b&1 ? x : x+y) >> (b>>1) & 1)) == k) {
				printf("%d %d\n",x,y);
				if (!--m) return 0;
			}
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline int read(){
	int  ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
int a[300005],n;
inline bool check(int l,int r)
{
	int mn=n+1,mx=0;
	for(int i=l;i<=r;i++) mn=min(mn,a[i]),mx=max(mx,a[i]);
	if(mn!=l||mx!=r) return 0;
	int x=0,y=0;
	for(int i=l;i<=r;i+=2)
	{
		if(x<a[i]&&y<a[i]) y=a[i];
		else if(x<a[i]) x=a[i];
		else return 0;
	}
	return 1;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
	}
	for(int i=1;i<=n;i++)
	{
		if((a[i]&1)!=(i&1)){cout<<"No";return 0;}
	}	
	for(int i=1;i<=n-2;i++)
	{
		if(a[i]==i) continue;
		int k=i;
		while(k<=n-2)
		{
			if(a[k+1]!=k+1) break;
			if(a[k+2]==k+2) break;
			k+=2;
		}
		if(!check(i,k)){cout<<"No";return 0;}
		i=k;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 1408
#!/user/bin/env pypy3
import sys
from typing import List


def fast_input():
    return sys.stdin.readline()[:-1]


def solve(mochi_list: List[int]) -> int:
    sorted_mochi_list = sorted(mochi_list)
    kagamimochi = set(sorted_mochi_list)
    return len(kagamimochi)


def main():
    n = int(fast_input())
    d = []
    for i in range(n):
        d.append(int(fast_input()))
    result = solve(d)
    print(result)


main()


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

int main() {
  int N;
  cin >> N;
  vector<long long>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  cout << A.at(N - 1) - A.at(0);
}

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

using namespace std;

typedef long long ll;

#define INF (int)1e9+7
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
//#define N 100005
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795



ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}






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

ll n;cin>>n;

string s,t="";cin>>s;

if(s.size()<=n)cout<<s<<"\n";
else 
{
t=s.substr(0,n);
t+="...";
cout<<t<<"\n";
}



return 0;

}

Measured memory_bytes: 3660
s = input()
counter = 0

if len(s) % 2 == 0:
  s_foward = s[:len(s)//2]
  s_back = s[len(s)//2:]
  
  for i in range(len(s_foward)):
    if s_foward[i] != s_back[len(s_back)-i-1]:
      counter += 1
else:
  s_foward = s[:(len(s)-1)//2]
  s_back = s[(len(s)+1)//2:]
  
  for i in range(len(s_foward)):
    if s_foward[i] != s_back[len(s_back)-i-1]:
      counter += 1
    
print(counter)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include <bits/stdc++.h>
#include<vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  int h[1000000];
  int i,ma[1000000];
  for(i=1;i<=n;i++){
    cin >> h[i];
    ma[i]=0;
  }

  for(i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    ma[a]=max(ma[a],h[b]);
    ma[b]=max(ma[b],h[a]);
  }
  int ans = 0;
  for(i=1;i<=n;i++){
    if(h[i]>ma[i]){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4416
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstring>

using namespace std;

int main() {
    int N;
    cin >> N;
    int h[N];
    for (int i=0; i<N; i++) {
        cin >> h[i];
    }
    int m[N];
    memset(m, 0, N);
    m[0] = 0;
    m[1] = abs(h[1] - h[0]);
    
    for (int i=2; i<N; i++) {
        m[i] = min(m[i-1] + abs(h[i] - h[i-1]), m[i-2] + abs(h[i] - h[i-2]));
    }
    
    cout << m[N-1] << "\n";
    
    return 0;
}


Measured memory_bytes: 1024
search_char = ('A', 'T', 'G', 'C')
ans = 0
comp = 0
input_str = input()
for c in input_str:
    if c in search_char:
        comp += 1
    else:
        if ans < comp:
            ans = comp
            comp = 0
else:
    if ans < comp:
        ans = comp
print(ans)


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

int main(){
  int n, m; cin >> n >> m;
  vector<int> start(m);
  vector<int> endi(m);
  for(int i=0; i<m; i++){
    cin >> start[i] >> endi[i];
  }
  int max_start = *max_element(start.begin(), start.end());
  int min_end = *min_element(endi.begin(), endi.end());
  int ans; ans = min_end - max_start + 1;
  if(ans < 0){
    ans = 0;
  }
  cout << ans << endl;
}

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

int main() {
  vector<int>a(3);
  for(int i=0;i<3;i++) cin>>a[i];
  sort(a.begin(),a.end());
  if((a[0]==a[1] && a[2]!=a[1])||(a[0]!=a[1] && a[1]==a[2])) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from math import gcd

def main():
		n = int(input())
		s = input()
		ans = 0
		b = [0]*n
		g = [0]*n
		r = [0]*n
		for i in range(n):
			if s[i]=="B":
				b[i]=1
			if s[i]=="G":
				g[i]=1
			if s[i]=="R":
				r[i]=1
		pre_r = [r[0]]
		pre_b = [b[0]]
		pre_g = [g[0]]
		for i in range(1,n):
			pre_r.append(pre_r[i-1]+r[i])
			pre_g.append(pre_g[i-1]+g[i])
			pre_b.append(pre_b[i-1]+b[i])	
		ms = {"R", "G", "B"}
		ans = 0
		for i in range(n):
			for j in range(i+1, n):
				if (s[i]!=s[j]):
					z = set([s[i], s[j]])
					x = list(ms.difference(z))[0]
					# print(i, j, ans)
					if x=="B":
						tmp = pre_b[j]-pre_b[i]
						if (i+j)/2 == int((i+j)/2):
							if b[(i+j)//2] == 1:
								tmp-=1
						ans += max(0, tmp)
					if x=="G":
						tmp = pre_g[j]-pre_g[i]
						# print((i+j)/2, "bahar")
						if (i+j)/2 == int((i+j)/2):
							# print("andar")
							# print()
							if g[(i+j)//2] == 1:
								tmp-=1
								# print("tmp", tmp)
						ans += max(0, tmp)					
					if x=="R":
						tmp = pre_r[j]-pre_r[i]
						if (i+j)/2 == int((i+j)/2):
							if r[(i+j)//2] == 1:
								tmp-=1
						ans += max(0, tmp)
		print(ans)
		
		


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = "x" in file.mode or "r" not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b"\n") + (not b)
			ptr = self.buffer.tell()
			self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode("ascii"))
		self.read = lambda: self.buffer.read().decode("ascii")
		self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
	main()

Measured memory_bytes: 69932
import sys
import math
N,M = map(int, input().split())
if N==1:
  print(M)
  sys.exit()
tmax = int(M/N)
t = tmax
divisor_list = [1]
for i in range(2, int(math.sqrt(M)) + 1):
  if M % i == 0:
    divisor_list.append(i)
    divisor_list.append(M//i)
divisor_list.sort(reverse = True)
for nums in divisor_list:
  if nums <= tmax:
    print(nums)
    sys.exit()

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import java.lang.*;

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

        String s = sc.next();

        int len = s.length();

        for (int i = 0; i<len; i++)
            System.out.print('x');
    }
}

Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;
long long GCD_(long long a, long long b) {
    return b ? GCD_(b, a % b) : a;
}
int n;
int arr[100005][5];
long long dp[100005][5];
long long solve(int i,int prv){
   if(dp[i][prv]!= -1) return dp[i][prv];
   if(i == n+1) return dp[i][prv] = 0;
   if(prv == 1) return dp[i][prv] = max(solve(i+1,2)+arr[i][2],solve(i+1,3)+arr[i][3]);
   else if(prv == 2)return dp[i][prv] = max(solve(i+1,1)+arr[i][1],solve(i+1,3)+arr[i][3]);
   else if(prv == 3)return dp[i][prv] = max(solve(i+1,2)+arr[i][2],solve(i+1,1)+arr[i][1]);
   return dp[i][prv] = max( max(solve(i+1,1)+arr[i][1], solve(i+1,2) + arr[i][2]),solve(i+1,3)+arr[i][3] );
}
int main(){
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(int i=1;i<=n;i++)cin>>arr[i][1]>>arr[i][2]>>arr[i][3];
    cout<<solve(1,0);
 return 0;
}


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

int main()
{
	bool even = true;
	int N, counter=0;
	int A[210];

	cin >> N;

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

	while (even)
	{
		for (int i = 0; i < N; i++)
		{
			if (A[i] % 2 != 0)
			{
				even = false;
			}
			A[i] /= 2;
		}
		counter++;
	}

	cout << counter-1 << endl;

	return 0;
}

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

int main() {
	string N;
	
	while (cin >> N) {
		if (N == "0000") break;
		int ok = 1, ans = 0;
		unordered_set< string > strs;
		
		while (ok) {
			if (N == "6174") break;
			strs.insert(N);
			
			string L = N, S = N;
			sort(L.begin(), L.end(), greater< char >());
			sort(S.begin(), S.end());
			
			stringstream ss;
			ss << L << " " << S;
			int l, s;
			ss >> l >> s;
			
			int n = l - s;
			stringstream sss;
			sss << n;
			N = sss.str();
			
			while (N.size() < 4) N = "0" + N;
			
			++ans;
			
			if (strs.find(N) != strs.end()) ok = 0;
		}
		
		if (ok) cout << ans << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 1268
import itertools
N = int(input())
if N < 3:
    print(0)
    exit()
L = list(map(int, input().split()))
r = 0
for x, y, z in itertools.combinations(L, 3):
    if x == y or x == z or y == z:
        continue
    if x + y > z and y + z > x and z + x > y:
        r += 1
print(r)

Measured memory_bytes: 67812
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int c[10][10];
int d[10][10];
int main() {
  int h,w;
  cin >> h >> w;
  rep(i,10)rep(j,10){
    cin >> c[i][j];
  }
  int n = 10;
  for (int k = 0; k < n; k++){       
    for (int i = 0; i < n; i++) {   
      for (int j = 0; j < n; j++) {  
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }
  int wall[h][w];
  rep(ih,h)rep(jw,w){
    cin >> wall[ih][jw];
  }

  int ans = 0;
  rep(ih,h)rep(jw,w){
    if(abs(wall[ih][jw]) == 1) continue;
    ans+=c[wall[ih][jw]][1];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret
N,K = map(int,input().split())

ans=0
MOD=10**9+7

F= FactMod(N,MOD)

for k in range(0,min(N,K+1)):
    ans += F.comb(N,k)*F.comb(N-1,k)%MOD
    ans%=MOD
print(ans)


Measured memory_bytes: 54512
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

long long modPow(long long x, long long n, long long mod = MODV){
    if(n == 0) return 1;
    if(n%2 == 0) return modPow(x*x%mod, n/2, mod)%mod;
    return x%mod * modPow(x%mod, n-1, mod)%mod;
}

int main(){
    Init();
    ll n, m; cin >> n >> m;
    cout << ((n-m)*100+1900*m)*modPow(2, min(m, 5LL), INFLL) << endl;
}

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

namespace AtCoder.Abc
{
    class A_DuplexPrinting_157
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            long result;

            if (n % 2 == 0)
            {
                result = n / 2;
            }
            else
            {
                result = n / 2 + 1;
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27412
import math
def comb(n, r): #comb(int, int)
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,p = map(int,input().split())
a = list(map(int,input().split()))
a_even = 0
a_odd = 0
for i in range(n):
    if a[i]%2 == 0:
        a_even += 1
    else:
        a_odd += 1
ans = 0
if p%2 == 0:
    k = 0
    for i in range(10**10):
        if 2*i > a_odd:
            break
        k += comb(a_odd, 2*i)
    print(k*2**a_even)
else:
    k = 0
    for i in range(10**10):
        if 2*i+1 > a_odd:
            break
        k += comb(a_odd, 2*i+1)
    print(k*2**a_even)

Measured memory_bytes: 9168
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

vector<int> v,y;
int N;

int main () {
    cin >> N;
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        v.push_back(x);
        y.push_back(x);
    }
    sort(y.rbegin(),y.rend());

    for(int i=0;i<N;i++){
        if(v[i] == y[0]) {
            cout << y[1] << endl;
        } else cout << y[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 5064
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	double a,b;
	double kari;
	double menseki;

	cin >> a >> b;

	kari = a * b;

	menseki = kari / 3.305785;

	printf("%.6f\n", menseki);

	return 0;
}

Measured memory_bytes: 1236
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
char s[101];int na,tou;
bool bz;
int main()
{
	na=strlen(gets(s+1));
	bz=false;
	for(int i=1;i<=na;i++)
	{
		if(s[i]=='C')
		{
			tou=i+1;bz=true;break;
		}
	}
	if(bz==false)
	{
		printf("No\n");return 0;
	}
	bz=false;
	for(int i=tou;i<=na;i++)
	{
		if(s[i]=='F')
		{
			bz=true;break;
		}
	}
	if(bz==false)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		int A=sc.nextInt();
		int B=sc.nextInt();
		int K=sc.nextInt();

		System.out.println(Divisor(A,B,K));

		sc.close();

	}

	public static int Divisor(int a,int b,int k) {

		int ans=0;

		for(int i=100;i>0;i--) {
			if(a%i==0 && b%i==0) {

				//System.out.println(i+" "+k);

				k--;
				ans=i;
				if(k==0) break;
			}
		}

		return ans;

	}

}


Measured memory_bytes: 23636
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>

typedef long long ll;
using std::vector;
using std::string;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

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

template<typename T>
struct CumSum2D {
    int xnum, ynum;
    vector<vector<T>> data;
    vector<vector<T>> cumsum;
    
    CumSum2D(int xnum, int ynum) : xnum(xnum), ynum(ynum) {
        ndarray(data, xnum+1, ynum+1);
        ndarray(cumsum, xnum+1, ynum+1);
    }
    
    int add(int x, int y, T value) {
        //x,y 0~_num-1
        ++x;
        ++y;
        if (x > xnum || y > ynum) return -1;
        data[x][y] += value;
        return 0;
    }
    
    int add_imos(int startx, int starty, int endx, int endy) {
        //start_ 0~_num-1
        //end_ 1~_num
        if (add(endx, endy, (T) 1) == 1) return -1;
        if (add(startx, endy, (T) 1) == -1) return -1;
        if (add(endx, starty, (T) 1) == -1) return -1;
        if (add(startx, starty, (T) 1) == 1) return -1;
        return 0;
    }
    
    void build() {
        for (int i = 0; i < xnum; i++) {
            for (int j = 0; j < ynum; j++) {
                cumsum[i+1][j+1] = data[i+1][j+1] + cumsum[i+1][j] + cumsum[i][j+1] - cumsum[i][j];
            }
        }
    }
    
    T get(int startx, int starty, int endx, int endy) {
        //[(startx, starty) ~ (endx, endy))のdataの和を返す
        //start_ 0~_num-1
        //end_ 1~_num
        return (cumsum[endx][endy] - cumsum[endx][starty] - cumsum[startx][endy] + cumsum[startx][starty]);
    }
    
    void print() {
        std::cout << "cumsum" << std::endl;
        for (auto vec : cumsum) {
            for (auto val : vec) {
                std::cout << val << " ";
            }
            std::cout << std::endl;
        }
    }
    void print_data() {
        std::cout << "data" << std::endl;
        for (auto vec : data) {
            for (auto val : vec) {
                std::cout << val << " ";
            }
            std::cout << std::endl;
        }
    }
};

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

int main() {
    //std::ifstream in("0_normal_2");
    //std::cin.rdbuf(in.rdbuf());
    
    int N, M, Q;
    std::cin >> N >> M >> Q;
    CumSum2D<int> cs(N,N);
    
    for (int i = 0; i < M; i++) {
        int l, r;
        std::cin >> l >> r;
        cs.add(l-1, r-1, 1);
    }
    cs.build();
    vector<vector<int>> question(Q, vector<int>(2, 0));
    for (int i = 0; i < Q; i++) {
        int l, r;
        std::cin >> l >> r;
        question[i] = {l, r};
    }
    for (int i = 0; i < Q; i++) {
        auto l = question[i][0];
        auto r = question[i][1];
        std::cout << cs.get(l-1, l-1, r, r) << std::endl;
    }
    
    return 0;
}



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

int main() {
    for(int N; cin >> N, N; ) {
        vector<int> vs;
        while(N >= 8) {
            vs.push_back(N % 8);
            N /= 8;
        }
        if(N != 0) vs.push_back(N);
        reverse(vs.begin(), vs.end());

        for(int c : vs) {
            if(c >= 4) c++;
            if(c >= 6) c++;
            cout << c;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

bool solve(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  vector<int> u(n),v(m);
  rep(i,n) cin>>u[i];
  rep(i,m) cin>>v[i];

  for(int z=x+1; z<=y; z++){
    bool ok = true;
    rep(i,n) ok &= u[i] < z;
    rep(i,m) ok &= v[i] >= z;
    if(ok) return true;
  }
  return false;
}

int main(){
  cout << (solve() ? "No War" : "War") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	using lli = long long;
	#define rep(i,n) for(int i=0;i<n;i++)
	
	int d, n;
	
	int main(void){
		cin >> d >> n;
		if(n == 100){
			n += 1;
		}
		rep(i, d) n*=100;
		cout << n << endl;
		return 0;
	}


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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

const int N = 3010;

bool vis[N][N][4];
int n,m,k;
vector <int> v[N][N];
ll mem[N][N][4];

ll dp(int i,int j,int cnt)
{
    if( i == n+1 || j == m+1 )
        return 0LL;

    ll &ret = mem[i][j][cnt];
    if( vis[i][j][cnt] )
        return ret;
    vis[i][j][cnt] = 1;

    ret = max( dp(i+1,j,0) , dp(i,j+1,cnt) );

    ll x = 0;
    for(int k=0;k<min(3-cnt,(int)(v[i][j].size()));k++)
    {
        x += v[i][j][k];
        ret = max( ret , x + max( dp(i+1,j,0) , dp(i,j+1,cnt+k+1)) );
    }

    return ret;
}

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=k;i++)
    {
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);
        v[x][y].push_back(w);
    }

    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            sort(v[i][j].begin(),v[i][j].end());
            reverse(v[i][j].begin(),v[i][j].end());
        }

    printf("%lld\n",dp(1,1,0));
}


Measured memory_bytes: 540108
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 21 20:57:37 2020

@author: naoki
"""
import math
#f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")
H,W = map(int,input().split())
tizu = [list(str(input().replace('\n',''))) for _ in range(H)]

memo = [[0 for _ in range(W)] for _ in range(H)]

if tizu[0][0] == "#":
    memo[0][0] = 1
else:
    memo[0][1] = 0

for i in range(1,W):
    if tizu[0][i] == tizu[0][i-1]:
        memo[0][i] = memo[0][i-1]
    else:
        memo[0][i] = memo[0][i-1] + 1

for k in range(1,H):
    for j in range(W):
        if tizu[k][j] == tizu[k-1][j]:
            memo[k][j] = memo[k-1][j]
        else:
            memo[k][j] = memo[k-1][j] + 1
    for j in range(1,W):
        if tizu[k][j] == tizu[k][j-1]:
            temp = memo[k][j-1]
        else:
            temp = memo[k][j-1] + 1
        if temp < memo[k][j]:
            memo[k][j] = temp
for k in range(H):
    for j in range(W):
        memo[k][j] = int(math.ceil(memo[k][j]/2))


print(memo[-1][-1])

Measured memory_bytes: 3444
<?php
$p='';
while(1){
  list($a,$o,$b)=explode(' ',trim(fgets(STDIN)));
  if($o=='?'){break;}
  $a=(int)$a;
  $b=(int)$b;
  switch($o){
    case '+':$p.=$a+$b;break;
    case '-':$p.=$a-$b;break;
    case '*':$p.=$a*$b;break;
    case '/':$p.=floor($a/$b);break;
  }
  $p.=PHP_EOL;
}
print $p;

Measured memory_bytes: 15456
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;
 
#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;
 
#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000
 
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
 
int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};
 
string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};
 
ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}
 
ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}
 
void yes() {
  cout << "Yes" << endl;
}
 
void no() {
  cout << "No" << endl;
}
 
void print_array(int array[], int len) {
 
  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }
 
}
 
ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}
 
//g++ AtCoder.cpp -o AtCoder
//AtCoder
 
//--------------------------
//提出するときC++に帰る
//--------------------------
 
int main() {
 
  ll X;
  cin >> X;
 
  for(ll i=-1000; i<1001; ++i) {
    for(ll j=-1000; j<1001; ++j) {
      ll A = i*i*i*i*i;
      ll B = j*j*j*j*j;
      if(A-B==X) {
        cout << i << " " << j << endl;
        return  0;
      }
    }
  }
 
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

int pop[24*3600+5];

inline int ss(char c) { return c-'0'; }

int stoi(string s) {
    return (ss(s[0])*10+ss(s[1]))*3600 + (ss(s[3])*10 + ss(s[4]))*60
        + ss(s[6])*10 + ss(s[7]);
}

int main() {
    int n;
    string s,t;
    while(cin>>n, n) {
        memset(pop, 0, sizeof(pop));
        for(int i=0; i<n; ++i) {
            cin>>s>>t;
            int ts = stoi(s), tt = stoi(t);
            for(int i=ts; i<tt; ++i) pop[i]++;
        }

        int ans = 0;
        for(int i=0; i<=24*3600; ++i) ans = max(ans, pop[i]);
        cout<<ans<<endl;
    }
}

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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (itn)i;k>=(int)j;k--)
#define line puts("")
#define ll long long

const int INF = 1e9+7;
const ll INFLL = 1e16;

using namespace std;

int n;

const int maxn = 1e5+5;
vector<pii> adj[maxn];

ll val[maxn];
int size[maxn];
void dfs(int a,int p){
	size[a] = 1;
	for(auto b : adj[a])if(b.fi!=p)val[b.fi] = val[a] + b.se,dfs(b.fi,a),size[a] += size[b.fi];
}
void set_root(int st){
	val[st] = 0;
	dfs(st,st);
}


int main(){
	scanf("%d",&n);
	
	rep(k,1,n){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		adj[a].pb(mp(b,c));
		adj[b].pb(mp(a,c));
	}
	
	set_root(1);
	
	ll ans = 0;
	rep(k,1,n+1){
		vector<int> arr;
		int tot = 0;
		for(auto  a  : adj[k]){
			int sz = size[a.fi];
			if(sz>size[k])sz = n - size[k];
			arr.pb(sz);
			
			tot += sz;
		}
		
		sort(arr.begin(),arr.end());
		reverse(arr.begin(),arr.end());
		if(arr[0]>n/2)continue;
		
		//for(auto  a : arr)printf("%d ",a);line;
		set_root(k);
		//rep(i,1,n+1)printf("%d ",size[i]);line;
		ll ret = 0;
		ll mins = INFLL;
		rep(i,1,n+1)if(i!=k)ret += val[i]*2,mins = min(mins,val[i]);
		
		if(tot - arr[0] < arr[0]){
			mins = INF;
			for(auto a : adj[k]){
				int sz = size[a.fi];
				if(sz>size[k])sz = n - sz;
				if(sz==arr[0])mins = min(mins,(ll)a.se);
			}
		}
		
		ret -= mins;
		ans = max(ans,ret);
	}
	
	cout<<ans<<endl;;
}

Measured memory_bytes: 12288
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long s = sc.nextLong();
		long c = sc.nextLong();
		if(2 * s >= c) System.out.println(c/2);
		else {
			long c2 = c - (2 * s);
			System.out.println(s + c2 / 4);
		}
	}
}


Measured memory_bytes: 23508
#include <stdio.h>

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

int main(void)
{
   int q1, b, c1, c2, q2;
   int qa;
   int hi, lo, ce;

   while(scanf("%d", &q1)){
      if(q1==0) break;
      scanf("%d %d %d %d", &b, &c1, &c2, &q2);

      qa=0;
      hi=q2;
      lo=1;
      //while(hi>=lo){
         ce=(hi+lo)/2;
	 if(c1*ce+c2*max(q1-ce, 0)<=b){
	    //lo=ce+1;
	    //qa=ce;
            for(qa=q2; qa>=ce; qa--){
               if(c1*qa+c2*max(q1-qa, 0)<=b) break;
            }
	 }
	 else {
	    //if(c1>=c2) hi=ce-1;
	    //else lo=ce+1;
	    if(c1>=c2){
            for(qa=ce-1; qa>0; qa--){
               if(c1*qa+c2*max(q1-qa, 0)<=b) break;
            }}
	    else {
            for(qa=q2; qa>0; qa--){
               if(c1*qa+c2*max(q1-qa, 0)<=b) break;
            }}
	 }
      //}
      if(qa==0) printf("NA\n");
      else printf("%d %d\n", qa, (b-c1*qa)/c2);
   }
   return 0;
}

Measured memory_bytes: 612
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()

int main() {
	// ABC074D
	int n;
	cin >> n;
	vector<vector<ll>>a(n, vector<ll>(n, 0));
	rep(i, n)rep(j, n)cin >> a[i][j];
	vector<vector<ll>>b(a);
	//vector<vector<ll>>b(n, vector<ll>(n, LLONG_MAX / 2 - 1));
	//rep(i, n)b[i][i] = 0;
	rep(k, n)rep(i, n)rep(j, n) b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
	rep(i, n) {
		rep(j, n) {
			if (b[i][j] < a[i][j]) {
				cout << -1 << endl; return 0;
			}
		}
	}
	vector<vector<bool>> del(n, vector<bool>(n, false));
	rep(k, n) {
		rep(i, n) {
			rep(j, n) {
				if (b[i][k] > 0 && b[k][j] > 0 && b[i][j] == b[i][k] + b[k][j]) {
					del[i][j] = del[j][i] = true;
				}
			}
		}
	}
	ll sum = 0;
	rep(i, n)rep(j, n)if (!del[i][j])sum += b[i][j];

	cout << sum / 2 << endl;

	return 0;
}





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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  ll N;
  cin >> N;
  
  if (N==1) {
    cout << "Hello World\n";
    return 0;
  }
  ll A, B;
  cin >> A >> B;
  cout << (A+B);
  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 << "Balanced" << endl;}
  else {cout << "Right" << endl;}
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  string S; cin >> S;
  reverse(S.begin(), S.end());
  int N = S.size();
  vector<int[2]> DP(N+1);

  DP[0][0] = S[0]-'0';
  DP[0][1] = 11 - (S[0]-'0');

  REP(i, N-1) {
    DP[i+1][0] = S[i+1]-'0' + min(DP[i][0], DP[i][1]);
    DP[i+1][1] = 11 - (S[i+1]-'0') + min(DP[i][0], DP[i][1] - 2);
  }
  cout << min(DP[N-1][0], DP[N-1][1]) << endl;
  return 0;
}


Measured memory_bytes: 9220
n,m=map(int,input().split())
x=[[] for _ in range(n+1)]
ans=[-1]*m
for i in range(m):
    p,y=map(int,input().split())
    x[p].append([y,i])

for p in range(1,n+1):
    tmp=sorted(x[p])
    for j in range(len(tmp)):
        ans[tmp[j][1]]=str(p).zfill(6)+str(j+1).zfill(6)

for i in range(m):
    print(ans[i])


Measured memory_bytes: 81952
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long gcd(long long N, long long M){
    while (true){
        if (min(N,M)==0){
            return max(N,M);
        }else if (N>M){
            N%=M;
        }else{
            M%=N;
        }
    }
}

long long lcm(long long N, long long M){
    return N*M/gcd(N,M);
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    int ans=A[0];
    for(int i=1; i<N; i++){
        ans=gcd(ans,A[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
// input macro
// ref: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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


#[allow(unused_mut)]
fn main() {
    input!(
        n: usize,
        xyh: [(isize, isize, isize); n],
    );

    let mut xhigh: isize = 101;
    let mut yhigh: isize = 101;
    let mut hmax: isize = 0;

    for &(x,y,h) in xyh.iter() {
        if h > hmax {
            xhigh = x;
            yhigh = y;
            hmax = h;
        }
    }

    let mut ans = (0, 0, 0);

    for xcent in 0..101 {
        for ycent in 0..101 {
            let hcent = hmax + (xcent-xhigh).abs() + (ycent-yhigh).abs();
            let mut consis = true;

            for &(x,y,h) in xyh.iter() {
                if h != std::cmp::max(0, hcent - (x-xcent).abs() - (y-ycent).abs()) {
                    consis = false;
                    break;
                }
            }

            if consis {
                ans = (xcent, ycent, hcent);
            }
        }
    }

    println!("{} {} {}", ans.0, ans.1, ans.2);
}


Measured memory_bytes: 4352
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
// constexpr ll inf = 1ll<<61;
// constexpr ll mod = 1e9+7;

// rank無しなのでlog n
class UnionFind{
public:
  vi data;

  UnionFind(int size){
    data.resize(size,-1);
    //rep(i, size) data[i] = -1;
  }

  bool unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x != y){
      if(data[y] < data[x]) swap(x,y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }

  bool find(int x, int y){
    return root(x) == root(y);
  }

  int root(int x){ // どの集合か
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }

  int size(int x){
    return -data[root(x)];
  }
};

signed main(){
  int n,m; cin >> n >> m;

  UnionFind uf(n+m);
  vs num(m);
  vector<pair<pii,int>> in;

  rep(i,m){
    int p,y; cin >> p >> y;
    in.pb(mp(pii(y,p-1),i));
  }

  sort(all(in));
  rep(i,m){
    int a = in[i].fst.snd;
    int b = in[i].snd;
    uf.unite(a,n+b);
    string tmp = to_string((int)pow(10,6)*(a+1)+uf.size(a)-1);
    while(tmp.size() < 12) tmp = "0" + tmp;
    num[b] = tmp;
  }

  for(auto s : num)
    cout << s << endl;
}

Measured memory_bytes: 11376
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.Arrays;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N =scan.nextInt();
        int[] a = IntStream.range(0,N).map(i->scan.nextInt()).toArray();
        Arrays.sort(a);
        int ans =0;
        for(int i=a.length-1;i>=0;i-=2)ans+=a[i];
        for(int i=a.length-2;i>=0;i-=2)ans-=a[i];
        System.out.println(ans);
    }
}

Measured memory_bytes: 29396
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <time.h>
#include <stdio.h>
#define int long long
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}

/*Library End!*/

signed main(){
	string s;
	cin >> s;
	if (s == "KIHBR" || s == "AKIHBR" || s == "KIHABR" || s == "KIHBAR" ||s=="KIHBRA"|| s == "KIHABRA" || s == "AKIHABR" || s == "AKIHBAR" || s == "AKIHBRA" || s == "KIHABAR" || s == "KIHABRA" || s == "KIHBARA" || s == "KIHABARA" || s == "AKIHBARA" || s == "AKIHABRA" || s == "AKIHABAR" || s == "AKIHABARA") {
		puts("YES");
	}
	else puts("NO");
end:;
	system("PAUSE");
	return 0;
}


Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> x(n), mem(n);
	for(int i=0; i<n; i++){
		cin >> x.at(i);
		mem.at(i)=x.at(i);
	}
	sort(x.begin(), x.end());

	if(n==2){
		cout << mem.at(1) << endl;
		cout << mem.at(0) << endl;
		return 0;
	}

	int mid = (n-1)/2;
	for(int i=0; i<n; i++){
		if(mem.at(i)<=x.at(mid)){
			cout << x.at(mid+1) << endl;;
		}else{
			cout << x.at(mid) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int l,r,p[2020],ans=1e9;
int main(){
    int i,j;
    scanf("%d %d",&l,&r);
    for(i=l;i<=min(l+2019,r);i++){
        p[i%2019]=1;
    }
    for(i=0;i<=2019;i++)if(p[i]){
        for(j=i+1;j<=2019;j++)if(p[j]){
            ans=min(ans,i*j%2019);
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(int *x, int *y){
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

int gcd(int x, int y){
    int temp;

    if(x < y) swap(&x, &y);
    while(y > 0){
        temp = x % y;
        x = y;
        y = temp;
    }
    return x;
}

int main() {
    int x, y;
    scanf("%d%d", &x, &y);
    printf("%d\n", gcd(x, y));
    return 0;
}

Measured memory_bytes: 592