akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int dice[6][6]={
{0,1,2,4,3,5},
{2,0,1,5,4,3},
{1,2,0,3,5,4},
{4,5,3,0,2,1},
{5,3,4,2,1,0},
{3,4,5,1,0,2},
};
int q[4];
string str[4][6];
char in[30];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)for(int j=0;j<6;j++){
			scanf("%s",in);
			str[i][j]=in;
		}
		//swap(str[0][3],str[0][4]);
		if(a==1){
			printf("0\n");continue;
		}
		int ret=99999999;
		for(int i=0;i<24;i++){
			q[1]=i;
			if(a>2){
				for(int j=0;j<24;j++){
					q[2]=j;
					if(a>3){
						for(int k=0;k<24;k++){
							q[3]=k;
							vector<string>v[6];
							int val=0;
							for(int t=0;t<a;t++)
								for(int x=0;x<6;x++){
									if(x==0||x==5)v[x].push_back(str[t][dice[q[t]/4][x]]);
									else v[x].push_back(str[t][dice[q[t]/4][1+(q[t]+x)%4]]);
								}
							for(int t=0;t<6;t++){
								int tmp=0;
								for(int x=0;x<v[t].size();x++){
									int t2=0;
									for(int y=0;y<v[t].size();y++)if(v[t][x]==v[t][y])t2++;
									tmp=max(tmp,t2);
								}
								val+=v[t].size()-tmp;
							}
							ret=min(ret,val);
						}
					}else{
						vector<string>v[6];
						int val=0;
						for(int t=0;t<a;t++)
							for(int x=0;x<6;x++){
								if(x==0||x==5)v[x].push_back(str[t][dice[q[t]/4][x]]);
								else v[x].push_back(str[t][dice[q[t]/4][1+(q[t]+x)%4]]);
							}
						for(int t=0;t<6;t++){
							int tmp=0;
							for(int x=0;x<v[t].size();x++){
								int t2=0;
								for(int y=0;y<v[t].size();y++)if(v[t][x]==v[t][y])t2++;
								tmp=max(tmp,t2);
							}
							val+=v[t].size()-tmp;
						}ret=min(ret,val);
					}
				}
			}else{
				vector<string>v[6];
				for(int t=0;t<a;t++)
					for(int x=0;x<6;x++){
						if(x==0||x==5)v[x].push_back(str[t][dice[q[t]/4][x]]);
						else v[x].push_back(str[t][dice[q[t]/4][1+(q[t]+x)%4]]);
					}
				int val=0;
				for(int t=0;t<6;t++){
					int tmp=0;
					for(int x=0;x<v[t].size();x++){
						int t2=0;
						for(int y=0;y<v[t].size();y++)if(v[t][x]==v[t][y])t2++;
						tmp=max(tmp,t2);
					}
					val+=v[t].size()-tmp;
				}
				ret=min(ret,val);
			}
		}
		printf("%d\n",ret);
	}
}

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

class Program {
    static void Main(string[] args) {
        long n = Cin.Ni();
        long k = Cin.NextLong();
        SortedDictionary<long, long> dic = new SortedDictionary<long, long>();

        for (int i = 0; i < n; i++) {
            long a = Cin.Ni();
            long b = Cin.Ni();
            if (dic.ContainsKey(a)) {
                dic[a] += b;
            } else {
                dic[a] = b;
            }
        }
        foreach (var item in dic) {
            k -= item.Value;
            if (k <= 0) {
                Console.WriteLine(item.Key);
                return;
            }
        }
    }
}


public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

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

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

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 19020
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b;
    DL x;
   cin>>a>>b;
   a+=b;
   stringstream (a)>>x;
   if(ceil(sqrt(x))==floor(sqrt(x)))
   {
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    ll po = 26ll;
    int count = 1;
    while(n > po)n-=po,po *= 26,count++;
    string ret(count,'0');
    n--;
    for(int i=count-1;i>=0;--i){
        char c = 'a' + n%26;
        ret[i] = c;
        n /= 26;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
    int n, k;
    scanf("%d%d", &n, &k);
    double a = 0;
    for(int i = 1; i <= n; i++){
        double b = 1.0/n;
        int c = i;
        while(c < k){
            c *= 2;
            b /= 2;
        }
        a += b;
    }
    printf("%.12f\n",a);
}


Measured memory_bytes: 128
ans = ''
while True:
    h, w = map(int, input().split(' '))
    if h == 0 and w == 0:
        break
    else:
        ans += '#' * w + '\n'
        i = 0
        while i < h-2:
            ans += '#' + '.' * (w-2) + '#\n'
            i += 1
        ans += '#' * w + '\n\n'
if ans != '':
    print(ans[:-1])


Measured memory_bytes: 5712
n = int(input())
import string
A = [chr(i) for i in range(ord("a"),ord("a")+10)]
B = {}
for i in range(10):
    B[A[i]] = i

def d(s,t,ANS):
    if len(s) == n:
        ANS.append(s)
    else:
        for i in range(t+2):
            d(s + A[i],max(i,t),ANS)
ANS = []

d("",-1,ANS)

ANS.sort()
for i in ANS:
    print(i)

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

int fib(int dp[50],int n){
    if(n<=1)return dp[n]=1;
    if(dp[n]!=-1)return dp[n];
    return dp[n]=fib(dp,n-1)+fib(dp,n-2);
}

int main(){
    int n;
    int dp[50];
    memset(dp,-1,sizeof(dp));

    scanf("%d",&n);
    printf("%d\n",fib(dp,n));
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define MM <<" "<<
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setpercision(x)
using ll=long long;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using pl=pair<ll,ll>;
template<class T> inline bool chmin(T& a, T b){
    if(a>b){a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){
    if(a<b){a=b;return true;}return false;}
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};

const ll MAX=1100000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    repl(i,2,MAX){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k)return 0;
    if(n<0 or k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
int main(){
    COMinit();
    ll N,K;cin>>N>>K;
    ll info[N];
    rep(i,N)cin>>info[i];
    sort(info,info+N);
    ll ans=0;
    rep(i,N){
        ll now=(COM(i,K-1)-COM(N-i-1,K-1))*info[i];
        ans+=now%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 26752
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let s: String = read!(String);

    // ランレングス圧縮
    let mut encoded = String::with_capacity(s.len());
    let mut prev = 'X';
    for c in s.chars() {
        if prev == c {
            continue;
        }
        encoded.push(c);
        prev = c;
    }

    println!("{}", encoded.len() - 1);
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  ll K, Q; cin >> N >> K >> Q;

  vector<ll> v(N,0);

  for(int i = 0; i < Q; i++){
    int tmp; cin >> tmp;
    tmp--;
    v[tmp]++;
  }

  for(int i = 0; i < N; i++){
    if(K - (Q-v[i]) > 0){
      cout << "Yes" << endl;
    } else { 
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3968
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(unreachable_code)]
#![allow(unused_variables)]

use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        N: usize,
        K: usize,
        mut S: Chars,
    }

    S[K - 1] = match S[K - 1] {
        'A' => 'a',
        'B' => 'b',
        'C' => 'c',
        c => c,
    };

    println!("{}", S.iter().collect::<String>());
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };  

ll a[300010];
ll cumsum[65][300010],cnt[65];

int main() {
    int n;cin>>n;
    rep(i,n) cin>>a[i];
    rep(i,64) {
        rep(j,n) {
            if((a[j]>>i)&1) cumsum[i][j+1]=cumsum[i][j]+1;
            else cumsum[i][j+1] = cumsum[i][j];
        }
    }
    rep(i,n-1) {
        rep(j,64) {
            if((a[i]>>j)&1) {
                ll num = (n-cumsum[j][n]-(i+1)+cumsum[j][i+1]);
                cnt[j] += num;
            } else {
                cnt[j] += (cumsum[j][n]-cumsum[j][i+1]);
            }
            cnt[j]%=MOD;
        }
    }
    ll ans = 0;
    // rep(i,64) {
    //     rep(j,cnt[i]) {
    //         ans = (ans + (1LL<<i)) % MOD;
    //     }
    // }
    ll two = 1;
    rep(i,64) {
        ans = (ans + (cnt[i]*two)%MOD) %MOD;
        two=(two*2) %MOD;
    }
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 155948
#include<cstdio>
using namespace std;

int main(){
  bool grid[1000][1000];
  int num[2][1000],i,j,h,w,n,t;
  while(scanf("%d%d%d",&h,&w,&n) && (h||w||n)){
    for(i=0;i<h;i++)
      for(j=0;j<w;j++){
	scanf("%d",&t);
	grid[i][j] = t?true:false;
      }

    for(i=0;i<w;i++)num[0][i] = num[1][i] = 0;
    num[0][0] = n-1;
    for(i=0;i<h;i++)
      for(j=0;j<w;j++){
	t = i&1;
	int N=num[t][j];
	if(grid[i][j]){
	  num[1-t][j] += N/2;
	  num[t][j+1] += N-N/2;
	}else{
	  num[t][j+1] += N/2;
	  num[1-t][j] += N-N/2;
	}
	if(N&1)grid[i][j] = !grid[i][j];
	num[t][j] = 0;
      }

    i=j=0;
    while(i<h && j<w)grid[i][j]?j++:i++;
    printf("%d %d\n",i+1,j+1);
  }
}

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

int main() {
	long long N, h, n, w = 0;
	cin >> N;

	for (int i = 1; i <= 3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			h = i;
			n = j;
			double a = -1*N*h*n;
			double b = (N*n + N*h - 4 * h*n);
			a /= b;
			//cout << " h:" << h << " n:" << n << " a:" << a << " b:" << b << endl;
			if (a-(int)a == 0 && a > 0 && a <= 3500) {
				w = a;
				break;
			}
		}
		if (w != 0)break;
	}

	cout << h << " " <<  n << " " << w << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 3e3 + 11;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, t, a[N], b[N], dp1[N][N], ans, dp2[N][N];	

main () {
	cin >> n >> t;
	--t;
	forn (i, 1, n) 
		cin >> a[i] >> b[i]; 

	dp1[0][0] = 0;
	forn (i, 1, n) {
		forn (j, 0, t)
			dp1[i][j] = dp1[i - 1][j];
		forn (j, 0, t - a[i]) 
			dp1[i][j + a[i]] = max(dp1[i][j + a[i]], dp1[i - 1][j] + b[i]);  
		
	}
		
	dp2[n + 1][0] = 0;
	forev (i, n, 1) {
		forn (j, 0, t)
			dp2[i][j] = dp2[i + 1][j];
		forn (j, 0, t - a[i])
			dp2[i][j + a[i]] = max(dp2[i][j + a[i]], dp2[i + 1][j] + b[i]); 
	}

	forn (i, 1, n)                      	
		forn (j, 1, t) {
			dp1[i][j] = max(dp1[i][j], dp1[i][j - 1]);								 
			dp2[i][j] = max(dp2[i][j], dp2[i][j - 1]);								 		
		}

	forn (i, 1, n) 
		forn (x, 0, t) 
			ans = max(ans, dp1[i - 1][x] + dp2[i + 1][t - x] + b[i]);
	

	cout << ans << endl;
}


Measured memory_bytes: 71040
#include <iostream>
#include <vector>
#include <numeric>
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
using namespace std;
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;

int main() {
    int N; cin >> N;
    vector<int> L;
    REP(i, N) {
        int l; cin >> l;
        L.push_back(l);
    }
    sort(L.begin(), L.end());

    if(accumulate(L.begin(), L.end()-1, 0) > L[L.size()-1]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

void dijkstra(vector<vector<int>> v, vector<vector<int>> c, vector<int> &d) {
	d[0] = 0;
	priority_queue<P, vector<P>, greater<P>> pq;
	pq.push(P(0, 0));
	while (!pq.empty()) {
		int s = pq.top().second;
		int dis = pq.top().first;
		pq.pop();
		if (dis > d[s]) continue;
		REP(j, v[s].size()) {
			int u = v[s][j];
			int w = c[s][j];
			if (d[u] > d[s] + w) {
				d[u] = d[s] + w;
				pq.push(P(d[u], u));
			}
		}
	}
}

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

	int n;
	cin >> n;
	vector<vector<int>> v(n), c(n);
	REP(i, n) {
		int u, k;
		cin >> u >> k;
		v[u] = vector<int>(k);
		c[u] = vector<int>(k);
		REP(j, k) cin >> v[u][j] >> c[u][j];
	}
	vector<int> d(n, INF);
	dijkstra(v, c, d);
	REP(i, n) {
		cout << i << " " << d[i] << "\n";
	}
	
	return 0;
}



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


using namespace std;
typedef long long ll;

int main(){
  string res;
  int k;
  string s;

  cin >> k >> s;

  if(s.size() <= k) res = s;
  else{
    res = s.substr(0,k) + "...";
  }

  cout << res <<  endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<int>())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

vector<pii> v1(100001);
vector<pii> v2(100001);

int main(void)
{
    int n;
    cin >> n;
    REP(i, n/2){
        int a,b;
        cin >> a >> b;
        v1[a].first++;
        v1[a].second = a;
        v2[b].first++;
        v2[b].second = b;
    }
    
    SORT(v1);
    SORT(v2);

    int ans = 0;
    if(v1[v1.size()-1].second != v2[v2.size()-1].second){
        for (int i = v1.size()-2; i > 0; i--) {
            ans += v1[i].first + v2[i].first;
        }
    }else if(v1[v1.size()-2].first > v2[v2.size()-2].first){
        for (int i = v1.size()-2; i > 0; i--) {
            ans += v1[i].first + v2[i].first;
        }
        ans -= v1[v1.size()-2].first;
        ans += v1[v1.size()-1].first;
    }else{
        for (int i = v1.size()-2; i > 0; i--) {
            ans += v1[i].first + v2[i].first;
        }
        ans -= v2[v2.size()-2].first;
        ans += v2[v2.size()-1].first; 
    }

    pr(ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

bool tf(long long lim, int n, long long k, vector<long long>& l){
    long long ans=0;
    for(int i=0;i<n;i++)
        if(l[i]%lim==0)
            ans+=(l[i]/lim)-1;
        else ans+=(l[i]/lim);
    return ans<=k;
}

void solve(){
    int n; long long k;
    cin>>n>>k;
    vector<long long> l(n,0); for(int i=0;i<n;i++) cin>>l[i];
    long long ll=1,rr=MOD,mid;
    while(rr-ll>1){
        mid=(ll+rr)/2;
        if(tf(mid,n,k,l)) rr=mid;
        else ll=mid;
    }
    if(tf(ll,n,k,l)) rr=ll;
    cout<<rr<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

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

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

  vector<int> v(n), c(n);
    for (int i = 0; i < n; i++)
    {
      cin >> v[i];
    }
    for (int i = 0; i < n; i++)
    {
      cin >> c[i];
    }
  int ans = 0;
    for (int i = 0; i < n; i++)
    {
      if (v[i] > c[i]) {
        ans += v[i] - c[i];
      }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
def main():
    s = input()
    comp_num = 753
    min_diff = 754

    for i in range(len(s)-2):
        n = int(s[i:i+3])
        diff = abs(comp_num - n)
        if min_diff > diff:
            min_diff = diff

    print(min_diff)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61720
#include<bits/stdc++.h>
using namespace std;
int m,n,k,ans[1005];
string s; 

int main()
{
	cin>>m>>n;
	if(m>8||n>8)
	{
	cout<<":("<<endl;
	return 0;
	}
	cout<<"Yay!"<<endl;
	
    return 0;
	} 

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
b = sum(A) / n
if b - int(b) < 0.5:
    b = int(b)
else:
    b = int(b) + 1
ans = 0
for a in A:
    ans += (b - a) ** 2
print(ans)

Measured memory_bytes: 9168
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int ctoi(char);

struct btn
{
    int next;
    int flag;
};

int main()
{
    int N;
    cin >> N;
    vector<int> vec;
    rep(i, N)
    {
        int d;
        cin >> d;
        vec.push_back(d);
    }
    stable_sort(vec.begin(), vec.end());
    int before = -1;
    int ans = 0;
    rep(i, N)
    {
        if (before != vec[i])
        {
            ans++;
        }
        before = vec[i];
    }
    cout << ans << endl;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}


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

using namespace std;
typedef long long ll;

int calcNumOfCombination(int n, int r){
    int num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

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

    int ans = 0;

    int tempN,tempM;
    tempN=calcNumOfCombination(N,2);
    tempM=calcNumOfCombination(M,2);

    ans=tempN+tempM;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    V< V<char> > c(h, V<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) cin >> c[i][j];
    }
    // assert(w == 3);
    
    ll ans = 0;
    for (int wi = 0; wi < w - 1; wi++) {
        V< V<int> > cost(h + 1, V<int>(h + 1, 0));
        // cost[i][j] := cost[i + 1][j + 1] + (c[h - i - 1][0] == c[h - j - 1][1]);
        for (int i = h - 1; i >= 0; i--) {
            for (int j = h - 1; j >= 0; j--) {
                cost[i][j] = cost[i + 1][j + 1] + (c[h - i - 1][wi] == c[h - j - 1][wi + 1]);
            }
        }

        V< V<int> > dp(h + 1, V<int>(h + 1, INF));
        dp[0][0] = 0;
        for (int i = 0; i <= h; i++) {
            for (int j = 0; j <= h; j++) {
                if (i < h) chmin(dp[i + 1][j], dp[i][j] + cost[i][j]);
                if (j < h) chmin(dp[i][j + 1], dp[i][j] + cost[i][j]);
            }
        }
        ans += dp[h][h];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,2){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << ((A[0]+A[1])%3==0 ||  A[0]%3==0 ||A[1]%3==0 ? "Possible" : "Impossible" ) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
bool palindrome(int N, string str) {
	if (N % 2 == 0) {
		bool judge = true;
		for (int i = 0; i < N / 2; i++) {
			if (str[i] != str[N - i - 1]) {
				judge = false;
				break;
			}
		}
		if (judge)
			return true;
		else
			return false;
	}

	else {
		bool judge = true;
		for (int i = 0; i < N / 2 - 1; i++) {
			if (str[i] != str[N - i - 1]) {
				judge = false;
				break;
			}
		}
		if (judge)
			return true;
		else
			return false;
	}
}

int main() {
	string S, S2, S3;
	int N;
	bool a, b, c;
	cin >> S;
	N = S.size();
	S3 = S.substr(0, (N - 1) / 2);
	S2 = S.substr((N + 3) / 2 - 1, N - (N + 3) / 2 + 1);
	a = palindrome(N, S);
	b = palindrome((N - 1) / 2, S3);
	c = palindrome(N - (N + 3) / 2 + 1, S2);
	if (a && b && c)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
function main(input){
  const args=input.split(" ");
  const A = parseInt(args[0], 10);
  const B = parseInt(args[1], 10);
  const T = parseInt(args[2], 10);
  console.log(Math.floor((T/A))*B);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i=0; i<N; i++){
    cin >> P.at(i);
  }
  sort(P.begin(), P.end());
  set<int> D;
  for(int i=0; i<N-1; i++){
    if(P.at(i)==P.at(i+1)){
      D.insert(P.at(i));
    }
  }
  set<int> Q;
  for(int i=0; i<N; i++){
    Q.insert(P.at(i));
  }
  int Ans=0;
  set<int> W;
  while(Q.size()!=0){
    int t=*Q.begin();
    W.insert(t);
    int r=2;
    int u=t;
    while(u<=1000000){
      u=r*t;
      Q.erase(u);
      r++;
    }
    Q.erase(t);
    Ans++;
  }
  while(D.size()!=0){
    int g=*D.begin();
    if(W.count(g)!=0){
      Ans--;
    }
    D.erase(g);
  }
  cout << Ans << endl;
}

Measured memory_bytes: 13464
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	vector<int>v;
	for (int i=0;i<3*n;i++){
		int x;scanf("%d",&x);
		v.push_back(x);
	}
	sort(v.begin(),v.end());
	long long sum=0;
	for (int i=0;i<n;i++){
		v.pop_back();sum+=v.back();v.pop_back();
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 2420
/*
t.me/ivanesipovvpered
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;

const double EPS = 1e-5;
const int mod = 1e9 + 7;
const ll INFLL = 1e18;
const int INF = 1e9;
const int maxn = 1e6 + 3;

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

ll lcm(ll a, ll b){
    return (a / gcd(a, b) )* b;
}

bool is_prime(ll a){
    if (a == 2 | a == 3 || a == 5 || a == 7) return true;
    if (a % 2 == 0 || a%3 == 0 || a%5 == 0 || a%7 == 0)
        return false;
    for (ll i = 11; i * i <= a; i += 2){
        if (a % i == 0)
            return false;
    }
    return true;
}

ll binpow(ll a, int n){
    if (a == 0)
        return 1;
    if (a % 2 == 0){
        ll q = binpow(a, n / 2);
        return (q * q)  ;
    }else return (a * binpow(a, n - 1) ) ;
}





















main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n){
        cin >> a[i];
    }
    int ans = 0;
    rer(i, 1, n){
        if (a[i - 1] == a[i]){ans++; a[i] = -1;}
    }
    cout << ans;



}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<tuple<int, int, int> > v(n);
    for(int i=0; i<n; ++i){
        int a, b;
        cin >> a >> b;
        v[i] = make_tuple(a+b, a, b);
    }

    sort(v.rbegin(), v.rend());
    long long ans = 0;
    for(int i=0; i<n; ++i){
        if(i % 2 == 0)
            ans += get<1>(v[i]);
        else
            ans -= get<2>(v[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String Y = sc.next();
        String[] A = new String[2];
        A[0] = Y.substring(0,2);
        A[1] = Y.substring(2,4);
        
        System.out.println(judgement(A));    
        
    }
    
    public static String judgement(String[] Application){
        int bef = Integer.parseInt(Application[0]);
        int aft = Integer.parseInt(Application[1]);
        int befres = bunki(bef);
        int aftres = bunki(aft);
        String result = "";
        
        if(befres == 0 && aftres == 0){
            result = "NA";
        }else if(befres == 0 && aftres == 1){
            result = "YYMM";
        }else if(befres == 1 && aftres == 0){
            result = "MMYY";
        }else if(befres == 1 && aftres == 1){
            result = "AMBIGUOUS";
        }else if(befres == 2 && aftres == 1){
            result = "YYMM";
        }else if(befres == 1 && aftres == 2){
            result = "MMYY";
        }else if(befres == 2 && aftres == 2){
            result = "NA";
        }else if(befres == 2 && aftres == 0){
            result = "NA";
        }else if(befres == 0 && aftres == 2){
            result = "NA";
        }else{
            result = "MMYY";
        }
        
        return result;
    }
    
    public static int bunki(int num){
        int resnum = 0;
        if(num == 00){
            resnum = 0;
        }else if(0 < num && num <= 12){
            resnum = 1;
        }else if(num > 12){
            resnum = 2;       
        }
        return resnum;
    }
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

	int L,N,sum = 0,x,w;
	scanf("%d",&L);
	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%d %d",&x,&w);
		sum += x*w;
	}

	if(sum == 0){
		printf("0\n");
		return 0;
	}else if(sum < 0){
		printf("%d\n",abs(sum));
		for(int i = 1; i <= abs(sum); i++)printf("1 1\n");
	}else{ //sum > 0
		printf("%d\n",sum);
		for(int i = 1; i <= abs(sum); i++)printf("-1 1\n");
	}
	return 0;
}

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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

using ll = long long;

int main() {
    IN(int, n);
    IN(int, k);
    int aja;
    int ans = 0;
    REP(i,n){
        cin >> aja;
        if(aja >= k) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)
	s := nextMega()
	n := len(s)

	ans := 1
	prev := string(s[0])
	for i := 1; i < n; i++ {
		for j := i + 1; j <= n; j++ {
			if prev != s[i:j] {
				prev = s[i:j]
				if j-i == 1 {
					i = j - 1
				} else {
					i = j - 1
				}
				ans++
				break
			}
		}
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <math.h>
int main(){
    int x1,y1,x2,y2;
    
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    
    int y = y1-y2;
    int x = x1-x2;
    

    
    int x3 = x2 + y;
    int y3 = y2 - x;
    
    int x4 = x3 + x;
    int y4 = y3 + y;
    
    printf("%d %d %d %d\n",x3,y3,x4,y4);
    return 0;
 }

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 1e5 + 5;

int n, m, u, v, visited[N], dp[N];
std::vector<int> g[N], comp;

void dfs(int v) {
    visited[v] = true;
    for (int u : g[v]) {
        if (!visited[u])
            dfs(u);
    }
    comp.push_back(v);
}

void topological_sort() {
    comp.clear();
    for (int i = 1; i <= n; ++i) {
        if (!visited[i])
            dfs(i);
    }
    reverse(comp.begin(), comp.end());
}

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

    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> u >> v;
        g[u].push_back(v);
    }

    topological_sort();

    for(int x : comp){
        for(int adj : g[x])
            dp[adj] = max(dp[adj], dp[x] + 1);
    }

    int ans = 0;
    for(int i = 1; i <= n; i++)
        ans = max(ans, dp[i]);
    cout << ans;
}

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

using namespace std;

const int maxn = 5e5 + 10;

int n;
long long k;
int a[maxn], lst[maxn], f[44][maxn];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i + n] = a[i];
    }
    for (int i = 2 * n - 1; i >= n; --i) lst[a[i]] = i;
    for (int i = n - 1; i >= 0; --i) {
        int x = lst[a[i]] + 1;
        if (x >= n) f[0][i] = x - n;
        else f[0][i] = f[0][x];
        lst[a[i]] = i;
    }
    f[0][n] = 0;
    for (int i = 1; i < 44; ++i) for (int j = 0; j <= n; ++j) 
        f[i][j] = f[i - 1][f[i - 1][j]];
    
    int now = 0; k--;
    for (int i = 40; i >= 0; --i) if (k >> i & 1) {
        now = f[i][now];
        k -= 1ll << i;
    }
    memset(lst, 0, sizeof lst);
    vector <int> result;
    for (int i = now; i < n; ++i) {
        if (lst[a[i]] > 0) {
            while (result.size() && lst[a[i]] > 0) {
                lst[result.back()]--;
                result.pop_back();
            }
        } else {
            result.push_back(a[i]);
            lst[a[i]]++;
        }
    }
    for (int it : result) cout << it << " ";
    return 0;
}

Measured memory_bytes: 90740
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  vector<string> s(3);
  rep(i, 3) cin >> s[i];

  cout << 'A' << s[1][0] << 'C' << endl;
}

Measured memory_bytes: 256
def main():
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    bcs = [[int(i) for i in input().split()] for _ in range(M)]
    bcs.sort(reverse=True,key=lambda c:c[1])

    ans = 0
    sel = []
    for a in A:
        if a < bcs[0][1]:
            sel.append(a)
        else:
            ans += a
    sel.sort()
    stock = len(sel)
    cards = []
    for b,c in bcs:
        cards.extend([c] * b)
        if len(cards) >= stock:
            break
    from itertools import zip_longest
    cnt = 0
    for a,card in zip_longest(sel,cards,fillvalue=0):
        if cnt == stock:
            break
        if a < card:
            ans += card
        else:
            ans += a
        cnt += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 93676
def magic(a,b,c,k):
	for i in range(k):
		if(a>=b):
			b*=2
		elif(b>=c):
			c*=2
	if(a < b and b < c):
		print("Yes")
	else:
		print("No")
d,e,f = map(int,input().split())
j = int(input())
magic(d,e,f,j)



Measured memory_bytes: 9164
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int manhattan(int x1, int y1, int x2, int y2){
    return abs(x2 - x1) + abs(y2 - y1);
}

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

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);

    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < m; i++){
        cin >> c[i] >> d[i];
    }

    for(int i = 0; i < n; i++){
        int ans = 0;
        int min_dis = manhattan(a[i], b[i], c[0], d[0]);
        for(int j = 1; j < m; j++){
            int v = manhattan(a[i], b[i], c[j], d[j]);
            if(v < min_dis){
                min_dis = v;
                ans = j;
            }
        }
        cout << (ans + 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  ll a, b, c; cin >> a >> b >> c;
  if (a + b > c) {
    cout << "No\n";
  } else {
    cout << (a * b * 4 < (c - a - b) * (c - a - b) ? "Yes\n" : "No\n");
  }
  return 0;
}


Measured memory_bytes: 256
d = [0]*10**5

a = set()
w = 0

for t in open(0):
    p, s = t.split()
    p = int(p)
    if "AC" == s and p not in a:
        w += d[p]
        a.add(p)
    if "WA" == s:
        d[p] += 1

print(len(a), w)

Measured memory_bytes: 12652
#include<iostream>
#include<cmath>
#include<vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
    int n;
    int a;
    cin >> n;
    vector<int> num;
    long long sum = 0;
    double ave;
    for(int i=0; i < n;i++ ){
        cin >> a;
        num.push_back(a);
    }
    ave = round( double(accumulate(num.begin(),num.end(),0.0)/num.size()));
    
    for(int i=0; i < num.size();i++ ){
        sum += pow((num[i] - ave),2);
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

const int MAX_N = 51;

//隣接リストでもつ
struct edge {
    int to; 
    edge(int to) : to(to) {};
}; 
vector<vector<edge> > G(MAX_N, vector<edge>());
void add_edge(int from, int to) {
    G[from].push_back(edge(to));
    G[to].push_back(edge(from)); //無向グラフのとき
}

void clear_edge() {
    for (int i = 0; i < MAX_N; i++) {
        G[i].clear();
    }
}

vector<int> color(MAX_N, -1); //初期値:-1
void dfs_reachability(int v, int c) {
    color[v] = c;
    for(int i = 0; i < (int)G[v].size(); ++i) { //頂点vから出る各辺を走査
        int u = G[v][i].to;
        if (color[u] < 0) { 
            dfs_reachability(u, c); //同じ色に塗る
        }
    }
}

int main () {

    int n,m; cin >>n>>m;
    vector<int> a(m); vector<int> b(m);
    REP(i,m) cin >> a[i] >> b[i];
    REP(i,m) a[i]--;
    REP(i,m) b[i]--;

    int count = 0;
    for (int i = 0; i < m; i++) {
        color.assign(n, -1);
        for (int j = 0; j < m; j++) {
            if (i != j) {
                add_edge(a[j], b[j]);
            } 
        }
        dfs_reachability(0, 0);
        for (int j = 0; j < n; j++) {
            if (color[j] != 0) {
                count++;
                break;
            } 
        }
        clear_edge();
    }
    
    cout << count << endl;
    return 0;
}


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

int main() {
	int a, b, c;
	
	cin >> a >> b >> c;

	if (a > b) swap(a, b);
	if (a > c) swap(a, c);
	if (b > c) swap(b, c);

	cout << a << " " << b << " " << c << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string.h>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<assert.h>
using namespace std;
typedef long long ll;

const int max_n = 1e5 + 1;
const ll INF = 2*1e9;
 
int N;
int a[max_n], b[max_n], c[max_n];
ll d[max_n][3];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i] >> b[i] >> c[i];
 
	d[0][0] = a[0], d[0][1] = b[0], d[0][2] = c[0];
	for (int i = 1; i < N; i++)
	{
		d[i][0] = max(d[i - 1][1], d[i - 1][2]) + a[i];
		d[i][1] = max(d[i - 1][0], d[i - 1][2]) + b[i];
		d[i][2] = max(d[i - 1][0], d[i - 1][1]) + c[i];
	}
	ll ans = 0;
	for (int i = 0; i < 3; i++)
		ans = max(ans, d[N - 1][i]);
	cout << ans;
}


Measured memory_bytes: 3840
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];
double w[1000],v[1000];
double box[200010];


#define MAX 100000
#define NIL -1

struct Node{ int p,l,r; };
struct Node T[MAX];
int N;

void preParse(int u){
  if(u == NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int v,l,r;
  cin >> N;
  for(int i = 0;i < N;i++)T[i].p = NIL;
  for(int i = 0;i < N;i++){
    cin >> v >> l >> r;
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)T[l].p = v;
    if(r != NIL)T[r].p = v;
  }
  
  int root;

  for(int i = 0;i < N;i++){
    if(T[i].p == NIL)root = i;
  }

  printf("Preorder\n");
  preParse(root);
  puts("");
  printf("Inorder\n");
  inParse(root);
  puts("");
  printf("Postorder\n");
  postParse(root);
  puts("");
  
  return 0;
}


Measured memory_bytes: 3204
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cctype>
#include<cstdlib>
#include<cmath>
#include<queue>
using namespace std;
typedef long long ll;

inline ll read() {
	char ch = getchar(); ll x = 0; int op = 1;
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') op = -1;
	for(; isdigit(ch); ch = getchar()) x = x*10+ch-'0';
	return x*op;
}
inline void write(ll a) {
	if(a < 0) putchar('-'), a = -a;
	if(a >= 10) write(a/10); putchar('0'+a%10);
}

const int N = 105;
int n;
int a[3][N], f[3][N];

int main() {
	n = read();
	for(int i = 1; i <= 2; i ++)
		for(int j = 1; j <= n; j ++) a[i][j] = read();
	for(int i = 1; i <= 2; i ++)
		for(int j = 1; j <= n; j ++) {
			if(i) f[i][j] = max(f[i][j], f[i-1][j]+a[i][j]);
			if(j) f[i][j] = max(f[i][j], f[i][j-1]+a[i][j]);
		}
	write(f[2][n]);
	return 0;
}

Measured memory_bytes: 256
n,m,l = gets.split.map(&:to_i)
a = Array.new
b = Array.new

for i in 1..n
 a << gets.split.map(&:to_i)
end

for j in 1..m
 b << gets.split.map(&:to_i)
end

for i in 1..n
 for j in 1..l
 if j != 1
 print " "
end
 mul = 0
for k in 1..m
 mul += a[i-1][k-1] * b[k-1][j-1]
end
print mul 
end
puts "\n"

end


Measured memory_bytes: 7120