akhauriyash/Code-Regression huggingface dataset:
#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>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#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>
/*
//#if __cplusplus >= 201103L
#include <array>
#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;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  ll ans = 1;
  repl(i,1,sqrt(m)+1){
    if(m%i==0 and i >= n) maxch(ans,m/i);
    if(m%i==0 and m/i >= n) maxch(ans,i);
  }
  cout<<ans<<endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#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 n;
    cin >> n;
    int minp = n+1;
    int ans = 0;
    rep(i,n) {
        int p;
        cin >> p;
        if (p < minp) {
            ans++;
            minp = p;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int d, g;
vector<int>p;
vector<int>c;

int main(){
	cin >> d >> g;
	vector<int>p;
	vector<int>c;
	for (int i = 0; i < d; i++) {
		int pi, ci;
		cin >> pi >> ci;
		p.push_back(pi);
		c.push_back(ci);
	}

	long long res = 1 << 29; // 2^29 infinityとほぼ同義だと思われ

	// ボーナスの取り方を2^10通り試す
	// 例えば 011101101の時は1,3,4,6,7,8番目の問題を全完する
	for (int bit = 0; bit < (1 << d); bit++) {
		long long sum = 0;
		long long num = 0;
		for (int i = 0; i < d; i++) {
			if (bit & (1 << i)) { // 110110101(bit) と 1000(i=4) の論理積など
				sum += c[i] + p[i] * 100 * (i + 1);
				num += p[i];
			}
		}
		if (sum >= g) res = min(res, num);
		else { // cが(ほとんど)関係しない端数 // 関係しても関係ない
			for (int i = d - 1; i >= 0; i--) {
				if (bit & (1 << i)) continue; // すでに全完されている問題は飛ばす
				for (int j = 0; j < p[i]; j++) {
					if (sum >= g) break;
					sum += 100 * (i + 1);
					num++;
				}
			}
			res = min(res, num);
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 500010
using namespace std;
int n, ans, now, p, a[N], s[10][N], x;
char S[N];
inline int get(int x, int l, int r){
	int L=l, R=r, mid;
	while(L<R){
		mid=(L+R)>>1; if(L==R-1)mid++;
		if(s[x][mid]-s[x][l-1]==mid-l+1)L=mid; else R=mid-1;
	}
	return L;
}
int main(){
	scanf("%s", S+1); n=strlen(S+1);
	a[0]=0; for(int i=1; i<=n; i++)a[i]=S[i]-'0';
	for(int i=0; i<=9; i++)s[i][0]=0;
	for(int i=1; i<=n; i++){
		for(int j=0; j<=9; j++)s[j][i]=s[j][i-1];
		s[a[i]][i]++;
	}
	ans=now=0;
	while(now<n){
		now++; ans++;
		x=get(a[now], now, n);
		while(x<n&&a[x]<a[x+1]){now=x+1; x=get(a[x+1], x+1, n);}
		if(x==n)break;
		a[n]++; p=n;
		while(a[p]==10){a[p]=0; p--; a[p]++;}
		for(int i=p; i<=n; i++){
			for(int j=0; j<=9; j++)s[j][i]=s[j][i-1];
			s[a[i]][i]++;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 22144
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(x == 0 && y == 0)
				break;
			if(x <= y)
				System.out.println(x+" "+y);
			else
				System.out.println(y+" "+x);
		}
		}
}

Measured memory_bytes: 27152
MM = input().split()
x1 = int(MM[0])
y1 = int(MM[1])
x2 = int(MM[2])
y2 = int(MM[3])
a = x2 - x1
b = y2 - y1
x3 = x2 - b
y3 = y2 +a
x4 = x1 -b
y4 = y1 + a
print(x3,y3,x4,y4)

Measured memory_bytes: 9128
import java.io.IOException;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);
		String str;
		
		while(sc.hasNextLine()){
			str = sc.nextLine();
			
			char[] c_str = str.toCharArray();
			for(int j = 0;j < 26;j++){
				for(int pos = 0,max = c_str.length;pos < max;pos++){
					if(c_str[pos] >= 'a' && c_str[pos] <= 'z'){
						c_str[pos]++;
						if(c_str[pos] > 'z'){ c_str[pos] = 'a';}
					}
				}
				
				
				String newstr = new String(c_str);
				if(newstr.indexOf("the") != -1 || newstr.indexOf("this") != -1 || newstr.indexOf("that") != -1){
					break;
				}
			}
			System.out.println(c_str);
			
		}
		
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


ll a[16][16];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    int i,j;
    for(i=0; i<n; i++) {
        for(j=0; j<n; j++) {
            scanf("%lld", &a[i][j]);
        }
    }

    vector<ll> dp(1<<n);
    int k;
    for(k=0; k<(1<<n); k++) {
        vector<int> z;
        for(i=0; i<n; i++) {
            if(k & (1<<i)) z.push_back(i); 
        }
        int siz=(int)z.size();

        dp[k]=0;
        for(i=0; i<siz; i++) {
            for(j=i+1; j<siz; j++) {
                dp[k] += a[z[i]][z[j]];
            }
        }

        ll max=0;
        for(i=0; i<(1<<siz); i++) {
            int tmp0=0;
            for(j=0; j<siz; j++) {
                if(i & (1<<j)) tmp0 |= (1<<z[j]);
            }
            ll val = dp[tmp0]+dp[k^tmp0];
            max = MAX(max, val);
        }
        dp[k] = max;
    }
    printf("%lld\n", dp[(1<<n)-1]);

    return 0;
}


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

#define INF 1e9+7

int main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n==0&&m==0)break;
		vector<vector<int> > cost(m,vector<int>(m,INF));
		vector<vector<int> > timea(m,vector<int>(m,INF));
		
		for(int i=0;i<n;i++){
			int a,b;
			cin>>a>>b;
			a--;
			b--;
			cin>>cost[a][b]>>timea[a][b];
			cost[b][a]=cost[a][b];
			timea[b][a]=timea[a][b];
		}
		
		for(int i=0;i<m;i++){
			cost[i][i]=0;
			timea[i][i]=0;
		}
		
		for(int k=0;k<m;k++){
			for(int i=0;i<m;i++){
				for(int j=0;j<m;j++){
					cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
					timea[i][j]=min(timea[i][j],timea[i][k]+timea[k][j]);
				}
			}
		}
		
		int k;
		cin>>k;
		for(int i=0;i<k;i++){
			int p,q,r;
			cin>>p>>q>>r;
			p--;
			q--;
			if(r==0)cout<<cost[p][q]<<endl;
			if(r==1)cout<<timea[p][q]<<endl;
		}
	}
	return 0;
}

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

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *nil;

void insert(int key)
{
    Node *y, *node, *z = (Node*)malloc(sizeof(Node));
    z->key = key;
    z->left = nil;
    z->right = nil;
    node = root;
    y = nil;
    while(node != nil)
    {
        y = node;
        if(node->key > key){
            node = y->left;
        }
        else{
            node = y->right;
        }
    }
    z->parent = y;
    if(y == nil) root = z;
    else{
        if(y->key > key) y->left = z;
        else y->right = z;
    }
}

void preorder(Node *node)
{
    if(node != nil){
        printf(" %d", node->key);
        preorder(node->left);
        preorder(node->right);
    }
}

void inorder(Node *node)
{
    if(node != nil){
        inorder(node->left);
        printf(" %d", node->key);
        inorder(node->right);
    }
}

int find(int key)
{
    Node *node = root;
    while(node != nil){
        if(node->key == key) return 1;
        else if(node -> key > key) node = node->left;
        else node = node->right;
    }
    return 0;
}

int main()
{
    root = nil;
    int n, key;
    char com[10];
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%s", com);
        if(com[0]=='i'){
            scanf("%d", &key);
            insert(key);
        }
        else if (com[0] == 'p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else{
            scanf("%d", &key);
            if(find(key)) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}


Measured memory_bytes: 21520
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
for i in range(N):
    # 食べた料理
    k = A[i] - 1
    # 得た満足度
    ans += B[k]
    # 追加満足度の判定
    if i < N-1 and A[i] == A[i+1]-1:
        ans += C[k]

print(ans)

Measured memory_bytes: 3064
N = int(input())
keta = len(str(N))
if keta==1:
  print(N)
elif keta==2:
  print(9)
elif keta==3:
  print(9+N-100+1)
elif keta==4:
  print(909)
elif keta==5:
  print(909+N-10000+1)
else:
  print(90909)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    cout << (n >= 30 ? "Yes" : "No") << endl;
}


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

#define FIO    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

void solve()
{
	int n,x,t;
	cin>>n>>x>>t;
	int d=(int)ceil((float)n/(float)x);
	cout<<d*t;
	return;
}

int main()
{    
    FIO;

    int t=1;
    // cin>>t;
    while(t--)
    	solve();

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define INF 1e18

int main()
{
    int n, k;
    cin >> n >> k;
    vector<long long> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    vector<long long> dp(n, INF);
    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k && j < n - i; j++){
            int gap = abs(h[i] - h[i + j]);
            dp[i + j] = min(dp[i+j], dp[i] + gap);
        }
    }

    cout << dp[n-1] << endl;

}

Measured memory_bytes: 4804
n = int(input())
mod = 10 ** 9 + 7
import numpy as np
a = list(map(int, input().split()))
s=0
ss=0
for i in range(n):
    if i > 0:
        ss += a[i-1]%mod
    s += ss * a[i] % mod
print(s%mod)


Measured memory_bytes: 49812
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main () {

  double r;
  
  cin >> r;
  cout << fixed << setprecision(6) << pow(r,2.0) * M_PI << " " << 2 * M_PI * r; 

  return 0;
}



Measured memory_bytes: 3216
#include <stdio.h>
#include <math.h> 


main()
{
int h,w;
while(1){
	scanf("%d %d",&h,&w);
	if((h|w)==0)break;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}
}


Measured memory_bytes: 2584
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qui queue<int>
#define vit vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
using namespace std;
int a[100100];
int main()
{
	int n,k,s,t=1;cin>>n>>k;
	fo(i,0,n)cin>>a[i];
	cout<<(n+k-3)/(k-1);
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
const ll INF = 1LL << 60;
const double PI = acos(-1.0);



int main() {
	
	int n; cin >> n;
	vector<int>a(n), b;
	for (int i = 0; i < n; i++)cin >> a[i];
	
	for (int i = n - 1; i >= 0; i -= 2) b.push_back(a[i]);
	for (int i = (n % 2 == 1) ? 1 : 0; i < n; i += 2) b.push_back(a[i]);

	for (int i = 0; i < b.size(); i++) {
		if (i != 0)cout << " ";
		cout << b[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3828
s = gets.chomp.split('')

p1 = []
p2 = []
pp1 = '0'
pp2 = '1'
s.size.times do
    p1.push(pp1)
    p2.push(pp2)

    if pp1 == '0'
        pp1 = '1'
        pp2 = '0'
    else
        pp1 = '0'
        pp2 = '1'
    end
end

res1 = 0
res2 = 0
s.size.times do |i|
    unless s[i] == p1[i]
        res1 += 1
    end
    unless s[i] == p2[i]
        res2 += 1
    end
end

puts res1 < res2 ? res1 : res2

Measured memory_bytes: 18844
#include<stdio.h>
int main()
{
	int e,y;
	scanf("%d%d",&e,&y);
	if(e==0)
	{
		if(y<=1911)
		{
			printf("M%d\n",y-1867);
		}
		else if(y<=1925)
		{
			printf("T%d\n",y-1911);
		}
		else if(y<=1988)
		{
			printf("S%d\n",y-1925);
		}
		else
		{
			printf("H%d\n",y-1988);
		}
	}
else
{
	if(e==1)
	{
		printf("%d\n",y+1867);
	}
	else if(e==2)
	{
		printf("%d\n",y+1911);
	}
	else if(e==3)
	{
		printf("%d\n",y+1925);
	}
	else
	{
		printf("%d\n",y+1988);
	}
}
	return 0;
}

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

typedef long long ll;
int n;
ll S, x[100233], p[100233], ans;
int main() {
  scanf("%d%lld", &n, &S);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &x[i], &p[i]);
  }
  int l = 1, r = n;
  while (x[l] < S && x[r] > S) {
    ans += x[r] - x[l];
    if (p[l] >= p[r]) {
      while (p[l] >= p[r] && x[r] > S) {
        p[l] += p[r--];
      }
    } else {
      while (p[l] < p[r] && x[l] < S) {
        p[r] += p[l++];
      }
    }
  }
  ans += max(abs(S - x[l]), abs(S - x[r]));
  printf("%lld\n", ans);
}


Measured memory_bytes: 1792
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a = sc.chars();
    let b = sc.chars();
    for i in 0..n {
        print!("{}", a[i]);
        print!("{}", b[i]);
    }
    println!();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  
  vector<int>x(N);
  
  for(int i=0;i<N;i++){
    cin>>x[i];
  }
  
  int ans=0;
  
  int a,b;
  
  for(int i=0;i<N;i++){
    int sum=0;
    int sum1=0;
 
 sum+=2*abs(0-x[i]);
    sum1+=2*abs(K-x[i]);
   
    
    if(sum>sum1){
      ans+=sum1;
    }
    else{
ans+=sum;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]

N,M,K=map(int,input().split())
A=[]
B=[]
C=[]
D=[]
for i in range(M):
    p,q=map(int,input().split())
    A.append(p-1)
    B.append(q-1)

for i in range(K):
    p,q=map(int,input().split())
    C.append(p-1)
    D.append(q-1)

Friend=Uf(N)
NG=[set() for _ in range(N)]

for i in range(M):
    Friend.unite(A[i],B[i])
    NG[A[i]].add(B[i])
    NG[B[i]].add(A[i])

for i in range(K):
    if Friend.same(C[i],D[i]):
        NG[C[i]].add(D[i])
        NG[D[i]].add(C[i])

for i in range(N):
    print(Friend.count(i)-len(NG[i])-1)



Measured memory_bytes: 70212
#include <iostream>

using namespace std;

int main()
{
  int cnt = 1, mode = 0, n, tmp1, tmp2;
  cin >> n >> tmp1;
  for(int i = 0; i < n-1; ++i){
    cin >> tmp2;
    if (mode == 0){
      if (tmp2 > tmp1){
        mode = 1;
      }else if (tmp2 < tmp1){
        mode = -1;
      }
    }else if (mode == 1){
      if (tmp2 < tmp1){
        mode = 0;
        ++cnt;
      }
    }else{
      if (tmp2 > tmp1){
        mode = 0;
        ++cnt;
      }
    }
    tmp1 = tmp2;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int eiler(int n){
    int i,k,x;
    k=0;x=1;
    for(i=2;n!=1;){
        if(n%i==0){
            n/=i;
            if(k==0){
                x*=(i-1);
                k=1;
            }else{
                x*=i;
            }
        }else{
            k=0;
            i++;
        }
    }
    return x;
}

int main(void){
    int n,i,c;
    scanf("%d",&n);
    printf("%d\n",eiler(n));
    return 0;
}


Measured memory_bytes: 2108
s = input()

a = s[0:2]
b = s[2:4]

if a == "00":
    if b == "00" or int(b) > 12:
        print("NA")
    else:
        print("YYMM")
elif b == "00":
    if  int(a) > 12:
        print("NA")
    else:
        print("MMYY")
elif int(a) > 12:
    if int(b) >12:
        print("NA")
    else:
        print("YYMM")
elif int(b) > 12:
    if int(a) >12:
        print("NA")
    else:
        print("MMYY")
else:
    print("AMBIGUOUS")

Measured memory_bytes: 3064
const main = (txt: any): void => {
  const input = txt.split('\n')
  for (const i in input) {
    if (parseInt(i) > 0) {
      console.log(input[i])
      console.log(input[i])
    }
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 9260
#include <bits/stdc++.h>
#define pb push_back
//#define MOD 1000000007
//#define pii pair<int,int>
//#define unmap unordered_map<int,int>
//#define ll long long int
using namespace std;

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a > 0 && c > 0)
    {
        c = c - b;
        if (c <= 0)
            break;
        a = a - d;
        if (a <= 0)
            break;
    }
    if (a > 0)
        cout << "Yes" << "\n";

    else
        cout << "No" << "\n";

}





int main()
{


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

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main() {
	ll N, K, ans = 0;
	cin >> N >> K;

	FOR(b, K + 1, N + 1) {
		if (K == 0) {
			ans += N;
		}
		else if (N%b < K) {
			ans += (b - K)*(N / b);
		}
		else {
			ans += (b - K)*(N / b) + (N%b + 1 - K);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int z,x,c,v;
    cin>>z;
    c=0;
    v=2147483647;
    for(x=0;x<v;x=x+1000){
        if(x>=z){
            break;
        }
        }
        if(x>z){
            cout<<x-z<<"\n";
        }
        else{
            cout<<c<<"\n";
        }
         return 0;
    }
   

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

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            string s;
            cin >> s;
            if (s == "snuke") {
                cout << (char) ('A' + j) << i + 1 << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

struct node {
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x) {
	while (x->left != NULL) {
		x = x->left;
	}
	return x;
}

Node treeMaximum(Node x) {
	while (x->right != NULL) {
		x = x->right;
	}
	return x;
}

Node treeSearch(Node u, int k) {
	while (u != NULL && k != u->key) {
		if (k < u->key)u = u->left;
		else u = u->right;
	}
	return u;
}

Node treeSuccessor(Node x) {
	if (x->right != NULL)return treeMinimum(x->right);
	Node y = x->parent;
	y = x->parent;
	while (y != NULL && x == y->right) {
		x = y;
		y = y->parent;
	}
	return  y;

}

void treeDelete(Node z) {
	Node y; // node to be deleted
	Node x; // child of y
	if (z->left == NULL || z->right == NULL)
		y = z;
	else y = treeSuccessor(z);
	if (y->left != NULL)x = y->left;
	else x = y->right;
	if (x != NULL)x->parent = y->parent;
	if (y->parent == NULL)root = x;
	else if (y == y->parent->left)y->parent->left = x;
	else y->parent->right = x;
	if (y != z)z->key = y->key;


}

void insert(int k) {
	Node y = NULL;
	Node x = root;
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->left = NULL;
	z->right = NULL;

	while (x != NULL) {
		y = x;
		if (z->key < x->key)x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if (y == NULL) {
		root = z;
	}
	else {
		if (z->key < y->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}


void inorder(Node u) {
	if (u == NULL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}
void preorder(Node u) {
	if (u == NULL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}


int main() {
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", com);
		if (com[0] == 'f') {
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NULL) printf("yes\n");
			else printf("no\n");
		}
		if (com[0] == 'i') {
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p') {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0] == 'd') {
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}

	return 0;
}


Measured memory_bytes: 20468
#include<bits/stdc++.h> 
#include<random> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back 
#define mod 1000000007 
#define mk(arr,n,type) type *arr=new type[n]; 
#define sl s1.length(); 
#define yes cout<< "Yes"<<endl 
#define no cout<< "No"<<endl 
#define all(v) (v).begin(),(v).end() 
#define mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
using namespace std; 
void fastio() 
{ 
    #ifndef ONLINE_JUDGE 
    freopen("INPUT.txt","r",stdin); 
    freopen("OUTPUT.txt","w",stdout); 
    #endif 
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL) ; 
    cout.tie(NULL); 
    
}
int dp(int a[],int n)
{
    if(n==0)
    return 0;
    if(n==1)
    return a[n-1];
    if(n==2)
    return abs(a[n-1]-a[n-2]);
    if(abs(a[n-1]-a[n-3])<=abs(a[n-1]-a[n-2]))
    return abs(a[n-1]-a[n-3])+dp(a,n-2);//dp(a,n-3));
    else
    return dp(a,n-1)+abs(a[n-1]-a[n-2]);//,dp(a,n-2));
    //return min(abs(a[n-1]-a[n-2])+dp(a,n-1),abs(a[n-1]-a[n-3])+dp(a,n-2));
}
signed main() 
{ 
    fastio(); 
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,x,t;
        cin>>n>>x>>t;
        int p=(n%x>0)+n/x;
        cout<<p*t;
    }
}

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,W;
	cin>>n>>W;
	vector<int> w(n),v(n);
	for(int i =0;i<n;i++)
		cin>>w[i]>>v[i];
	vector<long long> dp(W+1,-1);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j = W;j>=w[i];j--)
		{
			if(dp[j-w[i]]!=-1)
				dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	long long ans = -1;
	for(int i =0;i<=W;i++)
		ans=max(ans,dp[i]);
	cout<<ans<<'\n';
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const ll INF = 1000000000000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int x, n;
    int p[100];
    cin >> x >> n;
    if (n == 0) {
        cout << x << endl;
        return 0;
    }
    bool x_is_ok = true;
    rep(i, n) {
        cin >> p[i];
        if (x == p[i]) x_is_ok = false;
    }
    if (x_is_ok) {
        cout << x << endl;
        return 0;
    }

    int cnt = 1;
    while (true) {
        int a = x - cnt;
        bool a_is_ok = true;
        rep(i, n) {
            if (a == p[i]) a_is_ok = false;
        }
        if (a_is_ok) {
            cout << a << endl;
            return 0;
        }
        int b = x + cnt;
        bool b_is_ok = true;
        rep(i, n) {
            if (b == p[i]) b_is_ok = false;
        }
        if (b_is_ok) {
            cout << b << endl;
            return 0;
        }
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
 
#define ll long long int  
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
 
 
using namespace std;




void util(){
	int d, t, s;

	cin>>d>>t>>s;

	if(t*s >= d){
		cout<<"Yes";
	}
	else
		cout<<"No";
}


int main()
{
	/* code */

	
		util();
	

	return 0;
}

Measured memory_bytes: 3632
N = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(N[K-1])


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

const int64_t MOD = 1000000007;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int N;
    cin >> N;
    map<pair<int64_t, int64_t>, int> mp;
    int za = 0, zb = 0, zab = 0;
    for(int i=0; i<N; i++){
        int64_t a, b;
        cin >> a >> b;
        if(a == 0 && b == 0){
            zab++;
        }else if(a == 0){
            za++;
        }else if(b == 0){
            zb++;
        }else{
            int64_t g = gcd(abs(a), abs(b));
            if(a < 0) g *= -1;
            mp[{a/g, b/g}]++;
        }
    }
    int64_t ans = 1 + power_mod(2, za) - 1 + power_mod(2, zb) - 1;
    while(mp.size()){
        auto p1 = mp.begin()->first;
        int64_t res = power_mod(2, mp[p1]);
        mp.erase(p1);
        auto p2 = make_pair(p1.second, -p1.first);
        if(p2.first < 0){
            p2.first *= -1;
            p2.second *= -1;
        }
        if(mp.count(p2)){
            add(res, power_mod(2, mp[p2])-1);
            mp.erase(p2);
        }
        mul(ans, res);
    }
    add(ans, zab);
    add(ans, MOD-1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16128
n, m = map(int, input().split())
mod = 10 ** 9 + 7
if abs(n - m) >= 2:
    print(0)
elif abs(n - m) == 1:
    num = 1
    for i in range(n):
        num *= (i + 1)
        num %= mod
    for i in range(m):
        num *= (i + 1)
        num %= mod
    print(num)
else:
    num = 2
    for i in range(n):
        num *= (i + 1)
        num %= mod
    for i in range(m):
        num *= (i + 1)
        num %= mod
    print(num)

Measured memory_bytes: 38768
n,*d=map(int,open(0).read().split())
a,b,c=0,0,0
ans=1
for i in d:
    ans=ans*[a,b,c].count(i)%1000000007
    if i==a:
        a+=1
    elif i==b:
        b+=1
    elif i==c:
        c+=1
print(ans) 

Measured memory_bytes: 14068
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)

	fmt.Println(answer(n, k))
}

func answer(n int, k int) int {
	var rest = n % k

	if k - rest < rest {
		return k - rest
	}
	return rest
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int H,W; cin>>H>>W;
    vector<vector<bool>> Grid(H+1,vector<bool>(W+1,true));
    rep(h,1,H+1)rep(w,1,W+1){
        char c; cin>>c;
        if(c=='#') Grid.at(h).at(w)=false;
    }

    vector<vector<int>> Dp(H+1,vector<int>(W+1,100000));
    Dp.at(0).at(1)=Dp.at(1).at(0)=0;
    rep(h,1,H+1){
        rep(w,1,W+1){
            Dp.at(h).at(w)=min(Dp.at(h-1).at(w)+(Grid.at(h-1).at(w) && !Grid.at(h).at(w)),Dp.at(h).at(w-1)+(Grid.at(h).at(w-1) && !Grid.at(h).at(w)));
        }
    }

    cout<<Dp.at(H).at(W)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>


#define ll long long int

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

ll x[100001];

int main() {
  ll n,a,b;
  cin >> n >> a >> b;
  for(int i = 0; i < n; i++) {
    cin >> x[i];
  }

  ll result = 0;
  for(int i = 0; i < n-1; i++) {
    if(a*(x[i+1]-x[i]) > b) {
      result += b;
    } else {
      result += a*(x[i+1]-x[i]);
    }
  }

  cout << result << endl;
}


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

int main() {
    int t, n;
    while (cin >> t >> n) {
        if (t == 0) break;
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            int s, f;
            cin >> s >> f;
            sum += f - s;
        }
        if (sum < t)
            cout << t - sum << endl;
        else
            cout << "OK"s << endl;
    }
}


Measured memory_bytes: 3176
#include <stdio.h>
#include <string.h>

int main()
{
    char a[5];
    int i,j,k,n,m,b,c;

    scanf("%s",&a);

    n=((a[0]-'0')*10)+a[1]-'0';
    m=((a[2]-'0')*10)+a[3]-'0';

    b=0;c=0;
    if(n>=1 && n<=12)
    {
        c=1;
    }
    if(m>=1 && m<=12)
    {
        b=1;
    }
    
    if(b==1 && c==0)
    {
        printf("YYMM\n");
    }
    else if(b==1 && c==1)
    {
        printf("AMBIGUOUS\n");
    }
    else if(b==0 && c==1)
    {
        printf("MMYY\n");
    }
    else
    {
        printf("NA\n");
    }

}


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

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;

#define pb push_back

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, x, t;
	cin >> n >> x >> t;
	cout << t * ((n + x - 1) / x);
   return 0;
}

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

class Line{
public:
	int h,p,q;
	friend istream& operator>>(istream &in,Line &a){
		in>>a.h>>a.p>>a.q;
		return in;
	}
};
bool cmp(Line a,Line b){
	return b.h<a.h;
}
int main(){
	int n,m,a;
	Line line[1000];
	while(cin>>n>>m>>a,n|m|a){
		for(int i=0;i<m;i++)cin>>line[i];
		sort(line,line+m,cmp);
		for(int i=0;i<m;i++){
			if(line[i].p==a)a=line[i].q;
			else if(line[i].q==a)a=line[i].p;
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 884
#include <bits/stdc++.h>
using namespace std;
int C(int x,int y){
    if(x < y)
        return 0;
    else{
        int sum = 1;
        for(int i = x; i > x - y; i--){
            sum *= i;
        }
        return sum/2;
    }

}
int main(){
    int n,m,ans = 0;
    cin >> n >> m;
    ans = C(n,2)+C(m,2);
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b,c,w;
	cin>>a>>b>>c;
	while(true){
		if(c%(a+b)>a)
			c+=60;
		if(c%(a+b)<=a){
			w=c;
			break;
		}
		if(c>60*(a+c)){
			w=-1;
			break;
		}
	}
	cout<<w<<endl;
    return 0;
}

Measured memory_bytes: 1160
n,m = map(int,input().split())

x = list(map(int,input().split()))

x.sort()
cnt = 0
l = [0] * (len(x)-1)

if n < m :
  for i in range(len(x)-1):
    l[i] = x[i+1] - x[i] 
  
  l.sort()
  cnt = l[0:m-n]
  
  print(sum(cnt))
else :
  print(cnt)
  

Measured memory_bytes: 13968
/**
 * @author torith
 * @date 2018-10-26
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vector<int> edge[200000];
    for (int i = 0; i < M; ++i) {
        int a,b;
        cin >> a >> b;
        edge[a].push_back(b);
    }

    for(auto &e : edge[1]){
        for(auto &e2 : edge[e]){
            if(e2 == N){
                cout << "POSSIBLE" << "\n";
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << "\n";

    return 0;
}



Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(100000);
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[a[i]]++;    
  }
   int ans=0;
  for(int i=0;i<100000;i++){
    ans=max(ans,b[i-1]+b[i]+b[i+1]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> p(n);
  for(auto &x: p) cin >> x.first >> x.second;
  vector<pair<int, int>> ch(n);
  ll mxx = -1e+9, mnx = 1e+9;
  ll mxy = -1e+9, mny = 1e+9;
  for(int i=0; i<n; i++){
    ll x = p[i].first + p[i].second;
    ll y = p[i].first - p[i].second;
    mxx = max(mxx, x);
    mnx = min(mnx, x);
    mxy = max(mxy, y);
    mny = min(mny, y);
  }
  cout << max(mxx - mnx, mxy - mny) << endl;
}


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

int main() {
  ll n; cin >> n;
  vector<P> p(n);
  rep(i,n){
    cin >> p[i].first; 
    p[i].second = i+1;
  }
  
  sort(p.rbegin(), p.rend());
  
  rep(i, n){
    if(i+1 == p[0].second){
      cout << p[1].first << endl;
    }
    else
      cout << p[0].first << endl;
  }
}

Measured memory_bytes: 6360
while True:
    n = int(raw_input())
    if n == 0:
        break
    s = [raw_input() for i in range(n)]
    dp = [[0] * (n + 1) for i in range(n + 1)]
    for i in range(n):
        for j in range(n):
            if s[i][j] == '.':
                dp[i][j] = min(dp[i][j - 1], dp[i - 1][j], dp[i - 1][j - 1]) + 1
    print max(map(max, dp))

Measured memory_bytes: 32976
#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<string>
using namespace std;

int main(){
    int a[3], k;
    cin >> a[0] >> a[1] >> a[2];
    cin >> k;
    int max = -1;
    int ind = -1;

    for(int i = 0; i < 3; i++){
        if(max < a[i]){
            max = a[i];
            ind = i;
        }
    }

    int sum = 0;
    for(int j = 0; j < 3; j++){
        if(j == ind){
            for(int i = 0; i < k; i++){
                max *= 2;
            }
            sum += max;
        }else{
            sum += a[j];
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a,b,c,d,e,f;
int s,t;
double u;
bool visited[3001][3001];
void dfs(int x, int y)
{
    if(x+y>f || visited[x][y] || 100.0*y/x>e) return;
    visited[x][y]=true;
    if(100.0*y/(x+y)>=u){
        u=100.0*y/(x+y);
        s=x, t=y;
    }
    dfs(x+a*100, y);
    dfs(x+b*100, y);
    dfs(x, y+c);
    dfs(x, y+d);
}
int main()
{
    cin>>a>>b>>c>>d>>e>>f;
    dfs(0, 0);
    cout<<s+t<<' '<<t<<endl;
}


Measured memory_bytes: 6400
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int n,m;
long long ans;
priority_queue<int>q;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		q.push(x);
	}
	while(m)
	{
		int t=q.top()/2;
		q.pop();
		q.push(t);
		m--;
	}
	while(!q.empty())
	{
		ans+=q.top();
		q.pop();
	}
	printf("%lld",ans);
 } 

Measured memory_bytes: 892
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n;
vector<ll> a;
priority_queue<ll,vector<ll>, greater<ll>> quep,quem;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll zerocount=0;
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        a.push_back(temp);
        if(temp>=0)
        quep.push(temp);
        if(temp<0)
        quem.push(-temp);
    }
    sort(ALL(a));
    vector<ll> ansp,ansm;
    if(n==2){
        cout<<a[1]-a[0]<<"\n";
        cout<<a[1]<<" "<<a[0]<<"\n";
        return 0;
    }
    if(quep.empty()){
        ll temp=quem.top();
        quem.pop();
        ll temp1=quem.top();
        quem.pop();
        ansp.push_back(-temp);
        ansm.push_back(-temp1);
        quep.push(temp1-temp);
    }
    if(quem.empty()){
        ll temp=quep.top();
        quep.pop();
        ll temp1=quep.top();
        quep.pop();
        ansp.push_back(temp1);
        ansm.push_back(temp);
        quem.push(temp1-temp);
    }
        while(true){
        if(quep.size()==1){
            if(quem.empty())break;
                ansp.push_back(quep.top());
                ansm.push_back(-quem.top());
                ll temp=quep.top()+quem.top();
                quep.pop();
                quem.pop();
                quep.push(temp);
        }
        else{
            ansp.push_back(-quem.top());
            ansm.push_back(quep.top());
            ll temp=quep.top()+quem.top();
            quep.pop();
            quem.pop();
            quem.push(temp);
        }
        }
    cout<<quep.top()<<"\n";
    rep(i,ansp.size())
    cout<<ansp[i]<<" "<<ansm[i]<<"\n";
}


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


int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> vba;
    for (int i = 0;i < n; ++i) {
        int a,b;
        cin >> a >> b;
        vba.push_back({b,a});
    }
    sort(vba.begin(), vba.end());
    ll tot = 0;
    string ret = "Yes";
    for (auto& ab : vba) {
        tot += ab.second;
        if (tot > ab.first) {
            ret = "No";
            break;
        }
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 3444
#include <stdio.h>

int main() {
    int x1, y1, x2, y2, x3, y3, x4, y4;
    int a, b;

    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

    a = x2 - x1;
    b = y2 - y1;

    x3 = x2 - b;
    y3 = y2 + a;
    x4 = x1 - b;
    y4 = y1 + a;

    printf("%d %d %d %d\n", x3, y3, x4, y4);
    
    return 0;
}




Measured memory_bytes: 128
import sys
def input():
    return sys.stdin.readline()[:-1]
n,a,b=map(int,input().split())
if abs(a-b)%2==0:
    print(abs(a-b)//2)
else:
    tmp=min(max(a-1,b-1),max(n-a,n-b))
    tmp2=min(a+(b-a-1)//2,n-b+1+(b-a-1)//2)
    print(min(tmp,tmp2))

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

vector<long long> F, RF;
long long MOD = 1000000007;

long long Calc(long long X, long long Y) {
	if (Y == 0) return 1;
	if (Y % 2 == 0) {
		long long Z = Calc(X, Y / 2);
		return (Z * Z) % MOD;
	}
	return (X * Calc(X, Y - 1)) % MOD;
}

void init(long long N) {
	F.resize(N + 1), RF.resize(N + 1);
	F[0] = F[1] = RF[0] = RF[1] = 1;
	for (int i = 2; i <= N; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		RF[i] = Calc(F[i], MOD - 2);
	}
}

long long Comb(long long X, long long Y) {
	return ((F[X] * RF[X - Y]) % MOD * RF[Y]) % MOD;
}

int main() {
	long long N, K, RN;
	cin >> N >> K;
	RN = Calc(N, MOD - 2);
	init(N);
	vector<long long> A(K);
	vector<vector<long long> > DP(K + 1, vector<long long>(N + 1, 0));
	for (int i = 0; i < K; i++) cin >> A[i];
	DP[0][0] = 1;
	for (int i = 0; i < K; i++) {
		for (int j = 0; j <= N; j++) {
			for (int k = 0; k <= A[i] && j + k <= N; k++) {
				DP[i + 1][j + k] = (DP[i + 1][j + k] + (((DP[i][j] * Comb(N - j, k)) % MOD) * Comb(N - k, A[i] - k)) % MOD) % MOD;
			}
		}
	}
	cout << DP[K][N] << endl;
}

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

char solve(int m,int e,int j){
	if( m == 100 || e == 100 || j == 100 )
		return 'A';
	if( (m+e)>=180 || (m+e+j)>=240)
		return 'A';
	if( (m+e+j)>=210 || ( (m+e+j)>=150 && (m>=80||e>=80) ) )
		return 'B';
	return 'C';
}

int main(){
	int n,m,e,j;
	while( cin >> n , n ){
		for(int i=0 ; i<n ; ++i ){
			cin >> m >> e >> j;
			cout << solve(m,e,j) << endl;
		}
	}
}

Measured memory_bytes: 0