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

int main() {
  int N,i,j,sum;
  cin>>N;
  vector<int> d(N);
  for(i=0;i<N;i++){
    cin>>d.at(i);
  }
  sum=N;
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      if(d.at(i)==d.at(j)){
        sum--;
        d.at(j)=j*1000;
      }
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
N=int(input())
S=list(map(int,input().split()))
first=len(S)
count=0

mokuteki=1
block=0
while count<N:
    if S[count]!=mokuteki:
        
        block+=1
    else:
        mokuteki+=1
        
    count+=1

if mokuteki>1:
    print(block)
else:
    print(-1)

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

using namespace std;

#define int long long

using cd = complex<double>;
const double PI = acos(-1);

struct Template_FFT
{
	void fft(vector<cd> &a, bool invert)
	{
	    int n = a.size();
	
	    for (int i = 1, j = 0; i < n; i++)
	    {
	        int bit = n >> 1;
	        for (; j & bit; bit >>= 1)
	            j ^= bit;
	        j ^= bit;
	
	        if (i < j)
	            swap(a[i], a[j]);
	    }
	                                                   
	    for (int len = 2; len <= n; len <<= 1)
	    {
	        double ang = 2 * PI / len * (invert ? -1 : 1);
	        cd wlen(cos(ang), sin(ang));
	        for (int i = 0; i < n; i += len)
	        {
	            cd w(1);
	            for (int j = 0; j < len / 2; j++)
	            {
	                cd u = a[i + j], v = a[i + j + len / 2] * w;
	                a[i + j] = u + v;
	                a[i + j + len / 2] = u - v;
	                w *= wlen;
	            }
	        }
	    }
	
	    if (invert)
	        for (cd &x : a)
	            x /= n;
	}
	
	vector<int> multiply(vector<int> const& a, vector<int> const& b)
	{
		vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
		int n = 1;
		while(n < a.size() + b.size())
			n <<= 1;
		fa.resize(n);
		fb.resize(n);
	
		fft(fa, false);
		fft(fb, false);
	
		for (int i = 0; i < n; i++)
			fa[i] *= fb[i];
		fft(fa, true);
	
		vector<int> result(n);
		for (int i = 0; i < n; i++)
			result[i] = long(fa[i].real() + 0.5);
		return result;
	}
}FFT;	

const int mod = 200003;

int val_pow[200011], org[200011];

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

	int g = 1;
	val_pow[1] = 0;
	org[0] = 1;
	for (int i = 1; i <= 200001; i++)
	{
		(g *= 2) %= mod;
		val_pow[g] = i;
		org[i] = g;
	}	

	int n;
	cin >> n;
	vector<int> a(200003), arr(200001);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		if (arr[i])
			a[val_pow[arr[i] % mod]]++;
	}	
	vector<int> res = FFT.multiply(a, a); 	
	for (int i = 0; i < n; i++)
		if (arr[i])
			res[val_pow[arr[i] % mod] + val_pow[arr[i] % mod]]--;
	int ans = 0;
	for (int i = 0; i < 200003; i++)
	{
		ans += org[i] * (res[i] + res[i + 200002]);
		/*
		if (i <= 10)
			cerr << org[i] << ' ' << res[i] << ' ' << res[i + 200002] << ' ' << ans << '\n';
		if (109060 <= i && i <= 109060 + 10)
			cerr << org[i] << ' ' << res[i] << ' ' << res[i + 200002] << ' ' << ans << '\n'; 
		*/
	}	
//	cerr << ans << '\n';
	cout << ans / 2;
}

Measured memory_bytes: 30480
n=int(input())
a,f,b=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[1]),1,0
for i in range(n):
    b+=a[i][0] 
    if b>a[i][1]: 
        f=0 
print('Yes' if f==1 else 'No')

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

S,W = inputIL()

if S<=W:
  print("unsafe")
else:
  print("safe")

Measured memory_bytes: 72784
// Author: 23forever
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
typedef long long LL;
const int MAXN = 10;
const int MAXD = 10;
using namespace std;

inline int read() {
  int x = 0, w = 1;
  char c = ' ';
  
  while (!isdigit(c)) {
    c = getchar();
    if (c == '-') w = -1;
  }

  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int x[MAXN + 5][MAXD + 5], n, d;

bool chk(int a, int b, int d) {
  LL ans = 0;
  for (int i = 1; i <= d; ++i) ans += 1LL * (x[a][i] - x[b][i]) * (x[a][i] - x[b][i]);
  //cout << sqrt(ans) * << endl;
  return int(sqrt(ans)) == sqrt(ans);
}

void init() {
  n = read();
  d = read();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= d; ++j) {
      x[i][j] = read();
    }
  }
}

int main() {
#ifdef forever23
  freopen("test.in", "r", stdin);
  //freopen("test.out", "w", stdout);
#endif
  init();

  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (chk(i, j, d)) ++ans;
    }
  }

  printf("%d\n", ans);
  return 0;
}

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

int main() {
  ll h;
  int n;
  cin >> h >> n;
  int tmpa;
  int suma = 0;
  for(int i = 0; i < n; i++){
        cin >> tmpa;
        suma += tmpa;
  }
  if(suma >= h){
      cout << "Yes" << endl;
  }else{
      cout << "No" << endl;
  }
  return 0;
}

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

int main() {
	long long H, W, A, B;
	cin >> H >> W >> A >> B;
	for (int i = 0; i < H - B; i++) {
		for (int j = 0; j < W - A; j++) {
			cout << 0;
		}
		for (int j = W - A; j < W; j++) {
			cout << 1;
		}
		cout << endl;
	}
	for (int i = H - B; i < H; i++) {
		for (int j = 0; j < W - A; j++) {
			cout << 1;
		}
		for (int j = W - A; j < W; j++) {
			cout << 0;
		}
		cout << endl;
	}
}

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

int main() {
  int x1, y1, x2, y2, x3, y3, x4, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int vec_x = x2 - x1, vec_y = y2 - y1;
  
  x3 = x2 - vec_y, y3 = y2 + vec_x;
  x4 = x3 - vec_x, y4 = y3 - vec_y;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << " " << endl;
  
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int n,m;
string b[1024],r[1024],p[1024][3],s,s2,s3;

int main(){
	while(cin>>n>>m&&(n+m)){
		rep(i,n){
			cin>>b[i]>>s>>s2;
			r[i]=s+s2;
		}
		int ans=0;
		rep(i,m){
			cin>>s>>s2>>s3;
			s+=s2;
			int f=0;
			for(int j=n-1;j>=0;j--){
				int f2=1;
				rep(k,16)if(s[k]!=r[j][k]&&r[j][k]!='?'){f2=0;}
				if(f2){f=(b[j]=="permit");break;}
			}
			if(f){p[ans][0]=s.substr(0,8);p[ans][1]=s2;p[ans++][2]=s3;}
		}
		cout<<ans<<endl;
		rep(i,ans)cout<<p[i][0]<<" "<<p[i][1]<<" "<<p[i][2]<<endl;
	}
}

Measured memory_bytes: 1068
import java.util.*;
import static java.lang.System.*;
import java.io.*;
import java.math.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        long min = Integer.MAX_VALUE;
        long sum = 0;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
        	long num = sc.nextLong();
        	if (num <= 0) {
        		cnt++;
        		num = -num;
        	}
        	if (min > num) {
        		min = num;
        	}
        	sum += num;
        }
        if (cnt % 2 == 0) {
        	out.println(sum);
        } else {
        	out.println(sum - min * 2);
        }
            
        
        out.close();
}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}


Measured memory_bytes: 23124
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
	int a, b, c,N;
	string s, t;
	cin >>N>> s;
	for (int i = 0; i < s.size(); i++)
	{
		s[i] += N;
		if (s[i] > 'Z')s[i] -= 26;
	}
	cout << s;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[1000006];
int b[1001003];
int n, m, k;
int x, y, z;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    for (int i = 1; i <= n; ++i) {
        int tmp = lower_bound(b + 1, b + 1 + n, a[i]) - b;
        if (tmp > n / 2) {
            printf("%d\n", b[n / 2]);
        } else {
            printf("%d\n", b[n / 2 + 1]);
        }
    }
    return 0;
}

Measured memory_bytes: 7040
n = int(input())

n_1nokurai = n % 10

hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]

if n_1nokurai in hon:
    print('hon')
elif n_1nokurai in pon:
    print('pon')
elif n_1nokurai in bon:
    print('bon')


Measured memory_bytes: 9176
#include<iostream>
using namespace std;
int main(){
 int n, A[100];
 cin >> n;
 for ( int i = 0; i < n; i++ ) cin >> A[i];

 for ( int i = n-1; i >= 0; i-- ) {
   if ( i != n-1 ) cout << " ";
   cout << A[i];
 }
 cout << endl;
 return 0;
}
  

Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int a, b;
string s;

int main() {
	cin >> a >> b >> s;
	rep(i, s.size()) {
		if (i == a) {
			if (s[i] != '-') {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			if (!(s[i] >= '0' && s[i] <= '9')) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define mod (ll)(1e9+7)
#define debug(x) cerr << #x << " is " << x << endl;
using namespace std;
int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    int k;
    cin >> k;

    int cnt = 0;
    while(b <= a){
        b *= 2;
        cnt+=1;
    }
    
    while(c <= b){
        c*= 2;
        cnt+=1;
    }

    if(cnt <= k)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
  	return 0;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  
  if ((N * A) > B) {
    cout << B << endl;
  }
  
  else if ((N * A) < B) {
    cout << N * A << endl;
  }
  
  else {
    cout << B << endl;
  }
}


Measured memory_bytes: 256
m,n=map(int,input().split())
sm=m
sn=n
l=[]
while sn!=0:
  l.append(sn%2)
  sn=sn//2
x=2
l1=[sm]
while x<=n:
  sm=((sm%(10**9+7))*(sm%(10**9+7)))%(10**9+7)
  l1.append(sm)
  x=2*x
for i in range(len(l)-1):
  if l[i]==1:
    sm=(sm*l1[i])%(10**9+7)
print(sm)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
long long a[2000001]={},n; 
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=2;i<=n;i++)
      if(a[i]==a[i-1]) 
      {
        cout<<"NO";
        return 0;
      }
    cout<<"YES";
    return 0;	
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  	string s;
  	cin >> s;
  	int Z_length;
  	int A_length;
  	for(int i=1;i <= s.size();i++){
    	if(s[i-1] == 'A'){
        	A_length = i;
          	break;
        }
    }
  	reverse(begin(s),end(s));
  	for(int i=0;i < s.size();i++){
    	if(s[i] == 'Z'){
        	Z_length =s.size() -i;
          	break;
        }
    }
  	cout << Z_length - A_length + 1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int N,M,p;
	cin>>N>>M>>p;
	int d[10001];
	d[0]=p;
	for(int i=1;i<=M;i++)
		cin>>d[i];
	sort(d,d+M+1);
	
	int c_min=N-1;
	for(int i=0;i<M+1;i++){
		int q=d[i];
		int r1=d[(i-1+M+1)%(M+1)];
		int r2=d[(i+1)%(M+1)];
		int c1=((p-q+N)%N)*2+(r1-p+N)%N;
		int c2=((q-p+N)%N)*2+(p-r2+N)%N;
		c_min=min(c_min,min(c1,c2));
	}
	cout<<c_min*100<<endl;
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{

	int A, B;
	cin >> A >> B;

	if (1 <= A && A <= 9 && 1 <= B && B <= 9) {
		cout << A * B << endl;
	}
	else {
		cout << -1 << endl;
	}
	

	
}


Measured memory_bytes: 3672
#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>;

string s = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll N;
    cin >> N;
    string out;
    while (N) {
        N--;
        out = s[N % 26] + out;
        N = N / 26;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


class UnionFind{
    public:
    vector<ll> par;
    UnionFind(ll size) : par(size,-1){}
    bool unite(ll x,ll y){
        x = root(x),y = root(y);
        if(x == y)return false;
        if(par[y] < par[x])swap(x,y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool find(ll x,ll y){
        return root(x) == root(y);
    }
    ll root(ll x){
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }
    ll size(ll x){
        return -par[root(x)];
    }
};

int main(){
  
  int n,m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m){
    int a,b;cin >> a >> b;
    a--,b--;
    uf.unite(a,b);
  }
  int mx = 0;
  rep(i,n)mx = max(mx*1ll,uf.size(i));
  cout << mx << "\n";


  return 0;
}

Measured memory_bytes: 4836
X  = int(input())

if 400 <= X <= 599:
    print("8")
elif 600 <= X <= 799:
    print("7")
elif 800 <= X <= 999:
    print("6")
elif 1000 <= X <= 1199:
    print("5")
elif 1200 <= X <= 1399:
    print("4")
elif 1400 <= X <= 1599:
    print("3")
elif 1600 <= X <= 1799:
    print("2")
else:
    print("1")

Measured memory_bytes: 9112
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigDecimal a = sc.nextBigDecimal();
		BigDecimal b = sc.nextBigDecimal();		
		BigDecimal c = a.multiply(b);
		System.out.println(c.toBigInteger());
	}
}


Measured memory_bytes: 37568
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int A,B,K; cin>>A>>B>>K;
	rep(i,K){
		if(i % 2 == 0){
			A /= 2;
			B += A;
		}else{
			B /= 2;
			A += B;
		}
	}
	cout<<A<<' '<<B<<endl;
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int n, col[2007], tot[2007], sum[2007], res = 1e9;
char s[2007];
vector<int>e[2007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int dfs(int w, int f)
{
	tot[w] = col[w];
	sum[w] = 0;
	for (int i = 0, lim = e[w].size(); i < lim; i++)
		if (e[w][i] != f)
		{
			dfs(e[w][i], w);
			tot[w] += tot[e[w][i]];
			sum[w] += sum[e[w][i]] + tot[e[w][i]];
		}
	return 0;
}
int check(int w, int f)
{
	int mx = 0;
	for (int i = 0, lim = e[w].size(); i < lim; i++)
		if (e[w][i] != f && (!mx || sum[e[w][i]] > sum[mx]))mx = e[w][i];
	if (!mx)return 0;
	int val = check(mx, w) + tot[mx];
	if (sum[w] - sum[mx] - tot[mx] >= val)return sum[w] & 1;
	else return val - (sum[w] - sum[mx] - tot[mx]);
}
int main()
{
	n = read();
	scanf("%s", s + 1);
	for (int i = 1; i <= n; i++)
		col[i] = s[i] - '0';
	for (int i = 2; i <= n; i++)
	{
		int a = read(), b = read();
		e[a].push_back(b);
		e[b].push_back(a);
	}
	for (int i = 1; i <= n; i++)
	{
		dfs(i, 0);
		if (check(i, 0) == 0)
			res = min(res, sum[i] / 2);
	}
	if (res < 1e9)cout << res << endl;
	else cout << -1 << endl;
	return 0;
}

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

#define MAXN 200010
typedef long long LL;

int a[MAXN], father[MAXN];
bool vis[MAXN];
vector<int> lis[MAXN];

int find(int x){return x == father[x]? x: father[x] = find(father[x]);}

int main()
{
	//freopen("in.txt", "r", stdin);
	
	int n, m, x, y;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", &a[i]);
		father[i] = i;
	}
	
	int ans = 0;
	for (int i = 1; i <= m; ++i)
	{
		scanf("%d %d", &x, &y);
		x = find(x), y = find(y);
		father[x] = y;
	}
	
	for (int i = 1; i <= n; ++i)
	{
		lis[find(i)].push_back(i);
	}
	for (int i = 1; i <= n; ++i)
	{
		if (father[i] == i)
		{
			for (auto v: lis[i]) vis[v] = true;
			for (auto v: lis[i]) ans += vis[a[v]];
			for (auto v: lis[i]) vis[v] = false;
		}
	}
	cout << ans << endl;
	
	return 0;
}
 

Measured memory_bytes: 9472
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

int F[10004];

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   FOR(x, 1, 100) {
      FOR(y, 1, 100) {
         FOR(z, 1, 100) {
            int n = x*x + y*y + z*z + x*y + y*z + z*x;
            if (n <= 10000)
               F[n]++;
         }
      }
   }

   int N;
   cin >> N;
   FOR(n, 1, N)
      cout << F[n] << '\n';

   return 0;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<ll,ll> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

ll dp[3030][3030][4], item[3030][3030];
void Main(){
    ll R,C,K; cin >> R >> C >> K;
    REP(i,K){
        ll r,c,v; cin >> r >> c >> v;
        item[r][c] = v;
    }

    FOR(i,1,R+1)FOR(j,1,C+1){
        REP(k,4){
            chmax(dp[i][j][k], dp[i-1][j][k]);
            chmax(dp[i][j][k], dp[i][j-1][k]);
        }

        if(item[i][j]>0){
            chmax(dp[i][j][1], max(dp[i-1][j][3],dp[i][j-1][0])+item[i][j]);
            REP(k,2){
                chmax(dp[i][j][k+2], dp[i][j-1][k+1]+item[i][j]);
            }
            REP(k,3) chmax(dp[i][j][k+1], dp[i][j][k]);
        }
    }

    ll ans = 0; REP(i,4) chmax(ans, dp[R][C][i]);
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 358464
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long gcd(long long a,long long b) {
  if(a<b) {
    swap(a,b);
  }
  if(a%b==0) {
    return b;
  }
  return gcd(b,a%b);
}
 
long long power(long long a,long long b) {
  long long ans=1;
  while(b) {
    if(b%2) {
      ans=ans*a%mod;
    }
    a=a*a%mod;
    b/=2;
  }
  return ans;
}
 
int main() {
  long long n,k;
  cin>>n>>k;
  vector<long long> a(k+1,0);
  for(long long i=k;i>=1;i--) {
    a[i]=power(k/i,n);
    int j=2;
    while(i*j<=k) {
      a[i]=(a[i]-a[i*j])%mod;
      if(a[i]<0) {
		a[i]+=mod;
      }
      j++;
    }
  }
  long long ans=0;
  for(long long i=1;i<=k;i++) {
    ans+=a[i]*i%mod;
    ans%=mod;
  }
  cout<<ans;
  return 0;
}

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

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => -x).ToList();

        int[] Table = new int[1001];
        int temp = 0; int count = 0;

        for (int i = L[0]; i >= 1; i--)
        {
            while (true)
            {
                if (count < L.Count() && L[count] == i)
                {
                    temp++;
                    count++;
                }
                else
                {
                    Table[i] = temp;
                    break;
                }
            }
        }

        long Sum = 0;
        for (int i = 0; i < L.Count() - 2; i++)
        {
            int goal = L[i] + 1;
            for (int j = i + 1; j < L.Count() - 1; j++)
            {
                int need;
                if ((need = goal - L[j]) > L[j])
                    break;
                Sum += Table[need] - (j + 1);
            }
        }

        Console.WriteLine(Sum);
    }
}

Measured memory_bytes: 13416
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>

using namespace std;

int is_prime(int x) {
  int end = (int) sqrt(x);
  for (int i = 2; i <= end; ++i) {
    if (x%i == 0) {
      return 0;
    }
  }
  return 1;
}

int main() {
  int N;
  cin >> N;
  vector<int> v;
  for (int i = 0; i < N; ++i) {
    string n;
    cin >> n;
    v.push_back(stoi(n));
  }
  int count = 0;
  for (auto elem : v) {
    if (is_prime(elem)) {
      count++;
    }
  }
  cout << count << endl;
}

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

using namespace std;
int A,B,C;
int main()
{
  cin>>A>>B>>C;
  for(int i=1;i<=1000;i++){
  	if((i*A)%B==C){
      cout<<"YES";
      return 0;
    }
  }
  cout<<"NO";
  return 0;
}


Measured memory_bytes: 3572
n,m=map(int,input().split());d,ans=[],0
for i in range(n):d.append(list(map(int,input().split())))
d.sort()
for i in range(n):
  if d[i][1]<=m:
    ans+=d[i][0]*d[i][1]
    m-=d[i][1]
  else:
    ans+=d[i][0]*m
    m=0
  if m<=0:break
print(ans)

Measured memory_bytes: 27756
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define tottori signed
#define totori main
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
ll dx[4]={0,1,-1,0};
ll dy[4]={1,0,0,-1};

template<typename T>
struct BIT{
    vector<T> bit;
    BIT(int n) : bit(n+1) {}
    void add(int a,T w){
        for(int x=++a; x < bit.size(); x+=(x&(-x)) ){
            bit[x] += w;
        }
    }
    // return v[0]+v[1]+...+v[a-1];
    T sum(int a){
        T ret=0;
        for(int x=a;x>0;x-=(x&(-x)) ){
            ret+=bit[x];
        }
        return ret;
    }
};
class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    int size(int A){
        return -parent[root(A)];
    }

    bool unite(int A, int B) {
        A = root(A), B = root(B);
        if(A == B) return false; 

        if(size(A) < size(B)) swap(A,B);
        parent[A] += parent[B];
        parent[B] = A;
        return true;
    }

    bool same(int A, int B){
        return root(A)==root(B);
    } 
};

tottori totori(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    array<int,3> a[n];
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        a[i] = {x,y,i};
    }
    sort(a,a+n);

    UnionFind uni(n);
    map<int,int> mp;
    mp[a[0][1]] = a[0][2];
    mp[0] = -15;

    for(int i=1;i<n;i++){
        auto itr = mp.lower_bound(a[i][1]);
        if(itr == mp.end())itr--;
        {
            set<int> era;
            while(true){
                if(itr->first <= 0)break;
                if((itr->first) < a[i][1]){
                    uni.unite(a[i][2],(itr->second));
                    era.insert(itr->first);
                    //cerr << "d " << i << " " << (itr->first) << " " << (itr->second) << " " << a[i][1] << endl;
                }
                if(itr == mp.begin())break;
                itr--;
            }
            era.insert(a[i][1]);
            if(*era.begin() == a[i][1]){
                mp[a[i][1]] = a[i][2];
            }
            era.erase(era.begin());
            for(int j:era) mp.erase(j);
            
        }
        // else mp[a[i][1]] = a[i][2];
    }
    for(int i=0;i<n;i++)cout << uni.size(i) << "\n";
}

Measured memory_bytes: 17044
r,c = map(int,input().split());

A = [];
for i in range(0,r):
    a = list(map(int, input().split()));
    A.extend(a);

B = [];
for j in range(0,r):
    B.append(sum(A[j*c:j*c+(c-1)+1]));

for k in range(0,r): 
    A.insert(c*(k+1)+k, B[k]);

        
C = [];
for m in range(0,c+1):
    b = 0;
    for l in range(0,r):
        b += A[l*(c+1)+m];
    A.append(b);

t =  [str(n) for n in A];

for x in range(0, r+1):
    result = ' '.join(t[x*(c+1):x*(c+1)+(c+1)]);
    print(result);


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

#define N 100010
#define MP make_pair
typedef long long LL;

int fa[N], rk[N], pa[N], vis[N];
LL w[N];

struct edge
{
	int x, y, z;
	bool operator < (const edge &t)const
	{
		return z < t.z;
	}
}e[N];

int find(int x)
{
	while (fa[x] ^ x) x = fa[x];
	return x;
}

void merge(int x, int y, int i)
{
	x = find(x), y = find(y);
	if (x == y) return;
	
	vis[i] = 1;
	if (rk[x] < rk[y]) swap(x, y);
	fa[y] = x; w[x] += w[y];
	if (rk[x] == rk[y]) rk[x]++;
	pa[i] = y;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i)
		scanf("%lld", &w[i]), fa[i] = i;
	for (int i = 1; i <= m; ++i)
		scanf("%d %d %d", &e[i].x, &e[i].y, &e[i].z);
	sort(e + 1, e + m + 1);
	
	for (int i = 1; i <= m; ++i)
	{
		merge(e[i].x, e[i].y, i);
	}
	int ans = 0;
	for (int i = m; i >= 1; --i)
	{
		int s = find(e[i].x);
		if (e[i].z > w[s])
		{
			++ans;
			if (vis[i]) 
			{
				w[s] -= w[pa[i]];
				fa[pa[i]] = pa[i];
			}
		}
	}
    cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int find(vector<int>& grp, int x) {
    if (grp[x] != x)
        return grp[x] = find(grp, grp[x]);
    return x;
}
int main() {
    int n, x, y;
    cin >> n;
    vector<vector<int>> arr;
    vector<int> grp(n, 0);
    for(int i = 0; i < n; i++) {
        grp[i] = i;
        cin >> x >> y;
        arr.push_back({x, y, i});
    }
    sort(arr.begin(), arr.end(), [](vector<int>& a, vector<int>& b){
        return a[0] < b[0];
    });
    vector<vector<int>> e;
    for(int i = 1; i < n; i++) {
        e.push_back({arr[i][0]-arr[i-1][0], arr[i][2], arr[i-1][2]});
    }
    sort(arr.begin(), arr.end(), [](vector<int>& a, vector<int>& b){
        return a[1] < b[1];
    });
    for(int i = 1; i < n; i++) {
        e.push_back({arr[i][1]-arr[i-1][1], arr[i][2], arr[i-1][2]});
    }
    sort(e.begin(), e.end());
    int cnt = 0, ans = 0;
    for(auto vec: e) {
        int r1 = find(grp, vec[1]);
        int r2 = find(grp, vec[2]);
        if (r1 != r2) {
            cnt += 1;
            ans += vec[0];
            grp[r1] = grp[r2] = min(r1, r2);
            if (cnt == n-1)
                break;

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




Measured memory_bytes: 18732
///******* In the name of Allah *******///

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

int main()
{
    int n,a[113],i,j,k,sum = 0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            sum = sum + (a[i]*a[j]);
        }
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char s[1000]; 
int main()
{
	scanf("%s",s);
	int n=strlen(s);
	int flag=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='7')
		{
			flag=1;
			break;
		}
	}
	if(flag)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N, P;
	string S;
	cin >> N >> P;
	cin >> S;
	ll ans = 0;
	if (P == 5) {
		rep(i, N) {
			if (S[i] == '0' || S[i] == '5')
				ans += (i + 1);
		}
		cout << ans << endl;
		return 0;
	}
	else if (P == 2) {
		rep(i, N) {
			if ((int)(S[i] - '0') % 2 == 0)
				ans += (i + 1);
		}
		cout << ans << endl;
		return 0;
	}
	vl i_modP(N + 1, 1);
	rep(i, N) {
		i_modP[i + 1] = i_modP[i] * 10LL;
		i_modP[i + 1] %= P;
	}
	vl SmodP(N + 1, 0);
	ll Stmp = 0;
	map<ll, ll> modcount;
	modcount[0]++;
	rep(i, N) {
		ll n = S[N - i - 1] - '0';
		SmodP[i + 1] = SmodP[i];
		SmodP[i + 1] += i_modP[i] * n;
		SmodP[i + 1] %= P;
		modcount[SmodP[i + 1]]++;
	}
	rep(i, P) {
		if (modcount[i] > 0)
			ans += modcount[i] * (modcount[i] - 1LL) / 2LL;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4228
a,b,c,x,y = gets.chomp.split.map(&:to_i)
p_min = 1000000000000
n = x > y ? x : y
(0..n).each do |i|
  p = i*2*c + a*[0,x-i].max + b*[0,y-i].max
  p_min = p if p_min > p
end
puts p_min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;


int main() {
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  sort(all(a));
  reverse(all(a));

  ll ans = a[0];

  int cnt = (n - 2) / 2;
  int remain = n % 2;

  for (int i = 1; i <= cnt; ++i) {
    ans += (a[i] * 2);
  }

  if (remain == 1) ans += a[cnt + 1];
  

  cout << ans << endl;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

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

    int sumY = 0;
    double sumB = 0.0;
    rep(i, N) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            sumY += x;
        } else {
            sumB += x;
        }
    }
    double result = sumY + (380000.0 * sumB);
    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x1,x2,x3,x4; 
  cin >> N;
  x1=N/1000;
  x2=N/100-N/1000*10;
  x3=N/10-N/100*10;
  x4=N%10;

  if( x1==x2 && x1==x3){
		cout << "Yes" << endl;
  }
  else if(x2==x3 && x2==x4){
	cout << "Yes" << endl;
  }
  else{
	cout << "No" << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L;
    cin >> L;
    vector<tll> answers;
    ll nodeIndex = 1;
    ll filled = 1; //半開
    while (filled * 2 <= L)
    {
        answers.emplace_back(nodeIndex, nodeIndex + 1, 0);
        answers.emplace_back(nodeIndex, nodeIndex + 1, filled);
        nodeIndex++;
        filled *= 2;
    }
    while (filled < L)
    {
        ll targetIndex = 1;
        ll targetValue = 1; //半開
        while (targetValue <= L - filled)
        {
            targetValue *= 2;
            targetIndex++;
        }
        targetValue /= 2;
        targetIndex--;
        answers.emplace_back(targetIndex, nodeIndex, filled);
        filled += targetValue;
    }
    cout << nodeIndex << " " << answers.size() << " " << endl;
    for (auto answer : answers)
    {
        ll node1, node2, value;
        tie(node1, node2, value) = answer;
        cout << node1 << " " << node2 << " " << value << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

void draw(int h, int w){
    int i, j;
    for(j = 0; j < w; j++) putchar('#'); putchar('\n');
    for(i = 1; i < h - 1; i++){
        putchar('#');
        for(j = 1; j < w - 1; j++) putchar('.');
        putchar('#');
        putchar('\n');
    }
    for(j = 0; j < w; j++) putchar('#'); putchar('\n');
}

int main(void){
    while(true){
        int h, w; scanf("%d%d", &h, &w);
        if(h == 0 and w == 0) break;
        draw(h, w); putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 3132
#include<iostream>

using namespace std;

int main(){
    int H,W;
    
    while(1){
        cin >> H >> W;
        if(H==0 && W==0) break;
    
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                if(i==0 || i==H-1 || j==0 ||j==W-1){
                    cout<<"#";
                }else{
                    cout<<".";
                }
            }
            cout << "\n";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
int main(){
    int w=0;
    int a=0;
    int b=0;
    scanf("%d %d %d", &w,&a,&b);
    int mi=min(a, b);
    int ma=max(a+w,b+w);
    if (ma-mi>2*w){
        printf("%d", ma-mi-2*w);
    }
    else{
        printf("0");
    }
}

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

using namespace std;

int main()

{
    int x;
    cin>>x;
    if(x<1200){
        cout<<"ABC"<<endl;
    }
    else if(x<2800){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"AGC"<<endl;
    }
    return 0;
}


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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    for(auto &e : S) cin >> e;
    auto f = [&](auto &&f, int bit, int pos) -> int {
        if(pos == H - 1) {
            int res = __builtin_popcount(bit);
            int N = res + 1;
            vector<int> cnt(N);
            rep(j, W) {
                int now = 0, tmp = 0;
                rep(i, H) {
                    cnt[now] += S[i][j] == '1';
                    tmp += S[i][j] == '1';
                    if(tmp > K) return H + W;
                    if(bit & (1 << i)) now++, tmp = 0;
                }
                if(*max_element(cnt.begin(), cnt.end()) > K) {
                    res++, j--;
                    cnt.assign(N, 0);
                }
            }
            return res;
        }
        return min(f(f, bit, pos + 1), f(f, bit | (1 << pos), pos + 1));
    };
    cout << f(f, 0, 0) << '\n';
    return 0;
}


Measured memory_bytes: 256
r = int(input())
s = input()
s_length = len(s)

if(s_length % 2 != 0):
    print("No")
else:
    s_length_half = s_length // 2
    first, last = s[:s_length_half], s[s_length_half:]
    if(first == last):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
#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>;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);

  printf("%d %d %d", x, y, z);
  return 0;
}

Measured memory_bytes: 256
import sys
inf = sys.maxsize

h,n = map(int,input().split())
a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
    a[i], b[i] = map(int,input().split())

dp = [inf for _ in range(h + max([a[i] for i in range(n)]) + 10)] #dp[体力i削るのに必要な魔力]
dp[0] = 0

for i in range(1, len(dp)):
    for j in range(n):
        dp[i] = min(dp[i], dp[max(0, i-a[j])] + b[j])

#print(dp)
print(min(dp[h:]))

Measured memory_bytes: 42476
#include <stdio.h>

int main(void) {
  int N, M, X, i;
  int Asum[110] = {0};
  int min;
  
  scanf("%d %d %d", &N, &M, &X);
  for(i = 0; i < M; i++) {
    int A;
    scanf("%d", &A);
    Asum[A]++;
  }
  for(i = 0; i < N; i++) Asum[i + 1] += Asum[i];
  if(Asum[X - 1] <= Asum[N] - Asum[X]) printf("%d\n", Asum[X - 1]);
  else printf("%d\n", Asum[N] - Asum[X]);
  
  return 0;
}
  
  
  

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

using namespace std;

const int mod = 1e9 + 7;

class BinomialCoefficients{
  int max;
  int mod;
  long long *factorial;
  long long *factorial_inverse;
  long long *inverse;

public:
  int get(int n, int k){
    if(n < 0 || k < 0 || k > n) return 0;
    else return factorial[n] * (factorial_inverse[k] * factorial_inverse[n - k] % mod) % mod;
  }

  BinomialCoefficients(int max = 1'000'000, int mod = 1'000'000'007) : max(max), mod(mod){
    factorial = new long long[max + 1];
    factorial_inverse = new long long[max + 1];
    inverse = new long long[max + 1];

    factorial[0] = factorial[1] = 1;
    factorial_inverse[0] = factorial_inverse[1] = 1;
    inverse[1] = 1;

    for(int k = 2; k <= max; k++){
      factorial[k] = factorial[k - 1] * k % mod;
      inverse[k] = mod - inverse[mod % k] * (mod / k) % mod;
      factorial_inverse[k] = factorial_inverse[k - 1] * inverse[k] % mod;
    }
  }

  ~BinomialCoefficients(){
    delete [] factorial;
    delete [] factorial_inverse;
    delete [] inverse;
  }
};

int main(){
  int n;
  cin >> n;
  vector<int> a(n + 1);
  vector<int> num(n + 1, 0);
  for(int i = 0; i < n + 1; i++){
    cin >> a[i];
    num[a[i]]++;
  }
  
  int two;
  for(int i = 1; i <= n; i++){
    if(num[i] == 2){
      two = i;
      break;
    }
  }
  
  int l = -1, r = -1;
  for(int i = 0; i < n + 1; i++){
    if(l == -1 && a[i] == two){
      l = i;
    }else if(l != -1 && a[i] == two){
      r = n - i;
    }
  }
  
  BinomialCoefficients binom(n + 1, mod);
  for(int k = 1; k <= n + 1; k++){
    cout << (mod + binom.get(n + 1, k) - binom.get(l + r, k - 1)) % mod << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4352
from collections import defaultdict
class Unionfind:
  def __init__(self,n):
    self.Tree=[i for i in range(n)]
    self.rank=[0]*n

  def find(self,x):
    if x==self.Tree[x]:
      return x
    else:
      root=self.find(self.Tree[x])
      self.Tree[x]=root
      return root

  def unite(self,x,y):
    s1=self.find(x)
    s2=self.find(y)
    if s1==s2:
      pass
    else:
      if self.rank[s1]>self.rank[s2]:
        self.Tree[s2]=s1
      elif self.rank[s1]<self.rank[s2]:
        self.Tree[s1]=s2
      else:
        self.Tree[s2]=s1
        self.rank[s1]+=1
N,K,L=map(int,input().split())       
uf1=Unionfind(N)
uf2=Unionfind(N)
for i in range(K):
  p,q=map(int,input().split())
  uf1.unite(p-1,q-1)
for j in range(L):
  r,s=map(int,input().split())
  uf2.unite(r-1,s-1)
d=defaultdict(int)
ans=[0]*N
for i in range(N):
  d[(uf1.find(i),uf2.find(i))]+=1
for i in range(N):
  ans[i]=d[(uf1.find(i),uf2.find(i))]
print(" ".join(map(str,ans)))        

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

int main(){
int E,Y;
cin>>E>>Y;

if(E==0 && 1989 <= Y) cout<<"H"<<Y-1989+1<<endl; 
if(E==0 && 1926 <= Y && Y <=1988) cout<<"S"<<Y-1926+1<<endl;
if(E==0 && 1912 <= Y && Y <=1925) cout<<"T"<<Y-1912+1<<endl;
if(E==0 && 1868 <= Y && Y <=1911) cout<<"M"<<Y-1868+1<<endl;


if(E==1) cout<<Y+1868-1<<endl;
if(E==2) cout<<Y+1912-1<<endl;
if(E==3) cout<<Y+1926-1<<endl;
if(E==4) cout<<Y+1989-1<<endl;

return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  rep(i,s.size() ){
    if(i%2==0 && s[i]=='L'){cout<<"No"<<endl;return 0;}
    else if(i%2==1 && s[i]=='R'){cout<<"No"<<endl;return 0;}
  }
  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
readline = open(0).readline
writelines = open(1, 'w').writelines
N, Q = map(int, readline().split())
ans = []
A = [[] for i in range(N)]
def push(t, x):
    heappush(A[t], -x)
def get_max(t):
    A[t] and ans.append("%d\n" % -A[t][0])
def delete_max(t):
    A[t] and heappop(A[t])

C = [push, get_max, delete_max].__getitem__
for i in range(Q):
    t, *a=map(int, readline().split())
    C(t)(*a)
writelines(ans)



Measured memory_bytes: 15760