akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
        mut a: [usize;n],
    }

    a.sort_by_key(|&e| core::cmp::Reverse(e));

    let mut sum = 0;
    for i in 0..n - 1 {
        sum += a[(i + 1) / 2];
    }
    println!("{}", sum);
}


Measured memory_bytes: 6192
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N: u8 = iter.next().unwrap().parse().unwrap();
    let mut numbers: Vec<u8> = (0..N)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();

    let mut alice = 0;
    let mut bob = 0;
    let mut tern = 0;
    while numbers.len() > 0 {
        // ココで参照取ると、numbers.removeでmutable参照が取れない
        let max: u8 = *numbers.iter().max().unwrap();
        let max_index: usize = numbers.iter().position(|&s| s == max).unwrap();
        numbers.remove(max_index);
        if tern % 2 == 0 {
            alice += max;
        } else {
            bob += max;
        }
        tern += 1;
    }
    println!("{}", alice - bob);
}


Measured memory_bytes: 4352
/*input
5
11 1 2 4 8
11 1 2 2 8
32 10 8 5 4
29384293847243 454353412 332423423 934923490 1
900000000000000000 332423423 454353412 934923490 987654321
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll a, b, c, d;
map<ll, ll> mp;
vector<ll> divs = {2, 3, 5}, costs(3);

ll dfs (ll n) {
		if(n == 0)
			return 0;
		if(n == 1)
			return d;
		if(mp.count(n))
			return mp[n];
		ll ret = 2e18;
		if(n < 3e9) ret = n * d;
		for(int i=0; i<3; i++) {
			ll x = divs[i];
			ll cost = costs[i];
			for(ll diff = -(x-1); diff <= x-1; diff++) {
				if(n + diff < 0 || (n + diff) % x != 0) continue;
				ll y = (n + diff) / x;
				ret = min(ret, cost + abs(diff)*d + dfs(y));
			}
		}
		return mp[n] = ret;
	};

void run() {
	ll N;
	cin >> N >> a >> b >> c >> d;
	costs = {a, b, c};	
	mp.clear();
	cout << dfs(N) << endl;
}

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


Measured memory_bytes: 4444
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
  ll A=0,B=0,C=0,D=0,E=0,F=0,N=0,M=0,K=0,L=0,R=0,H=0,W=0;
  string S,T;
  cin >> A >> B;
  if(A+B==15){
    cout << "+" << endl;
  }
  else if(A*B==15){
    cout << "*" << endl;
  }
  else{
    cout << "x" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define F first
#define S second
#define ld long double
#define rep(i,a,n) for (ll i= (a) ; i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(),(v).end()
#define M_PI 3.14159265358979323846
const ll MOD = 1e9 + 7;
const ll INF = 1e18L + 5;

void solve() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	rep(i, 0, s.size()) {
		if ( s[i] != t[i])
			ans++;
	}

	cout << ans<<endl;
}


int main() {

	int t = 1;

	//cin >> t;
	ll k = 1;
	while (t--) {
		//cout << "Case #" << k++ << ": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3904
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int A[][]=new int[3][3];
		boolean cout[][]=new boolean[3][3];
		boolean key=true;
		int ans=0;
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				A[i][j]=stdIn.nextInt();
			}
		}
		int N=stdIn.nextInt();
		for(int i=0;i<N;i++){
			int b=stdIn.nextInt();
			for(int k=0;k<3;k++){
				for(int j=0;j<3;j++){
					if(A[k][j]==b)
						cout[k][j]=true;
				}
			}
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(cout[i][j]==false)
					key=false;
			}
			if(key){
				System.out.println("Yes");
				System.exit(0);
			}
			key=true;
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(cout[j][i]==false)
					key=false;
			}
			if(key){
				System.out.println("Yes");
				System.exit(0);
			}
			key=true;
		}
		if(cout[0][0]&&cout[1][1]&&cout[2][2]){
			System.out.println("Yes");
			System.exit(0);
		}
		if(cout[0][2]&&cout[1][1]&&cout[2][0]){
			System.out.println("Yes");
			System.exit(0);
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 23380
#include <iostream>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;

    int la = A * 100 / 8;
    int ua = (A+1) * 100 /8;
    int lb = B * 100 / 10;
    int ub = (B+1)*100/10;

    for(int i=la; i<ua; i++){
        for(int j=lb; j<ub; j++){
            if(i*8/100 < A) continue;
            if(j*10/100 < B) continue;
            if(i==j){
                cout << i << endl;
                return 0;
            }
        }
    }

    cout << -1 << endl;

    return 0;
}

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

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

    string s[n];
    int min_size = 50;
    int index;
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }

    string ans = "";
    for(char i = 'a'; i <= 'z'; i++){

        int min_count_char = 50;
        for(int j = 0; j < n; j++){
            int count_char = 0;
            for(int k = 0; k < s[j].size(); k++){
                if(s[j][k] == i){
                    count_char++;
                }
            }
            min_count_char = min(min_count_char, count_char);
        }

        for(int l = 0; l < min_count_char; l++){
            ans.push_back(i);
        }
    }
    
    cout << ans << endl;
   
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int w, h, x, y, r; //横、縦、x座標、y座標、半径
    
    //入力
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    
    //出力
    if (x + r <= w && x - r >= 0) {
        if (y + r <= h && y - r >= 0) {
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }else{
        printf("No\n");
    }
    
    return 0;
}



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

int main()
{
  int n;
  cin>>n;
  long long a=0;
  for(int i=0;i<n;i++){
    if(a==0){
      a=1;
    }else{
      a=a*(i+1)%1000000007;
    }
  }
  cout<<a<<endl;
 
	return 0;
}

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

int main(void) {
	char s[100000];
	int i, l;

	scanf("%s", s);

	l = strlen(s);

	for (i = 0; i < l; i++) {
		if (i % 2 == 0) {
			printf("%c", s[i]);
		}
	}
}


Measured memory_bytes: 1696
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
cou=0
for i in range(n):
    a=list(map(int,input().split()))
    x=c
    for j in range(m):
        x+=a[j]*b[j]
    if x>0:
        cou+=1
print(cou)



Measured memory_bytes: 3060
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 3e5 + 10; 

int R[N],C[N];
vector<int> G[N];

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int h,w,m;
   cin >> h >> w >> m;
   multiset<int> mx;
   vector<pair<int, int>> A(m);
   for(auto &i : A){
      cin >> i.F >> i.S;
      G[i.F].push_back(i.S);
      R[i.F]++;
      C[i.S]++;
   }
   vector<int> K;
   for(int i = 1; i < N; ++i){
      if(R[i]){
         K.push_back(i);
      }
      if(C[i]){
         mx.insert(C[i]);
      }
   }
   int ans = 0;
   for(int e : K){
      for(int v : G[e]){
         auto k = mx.find(C[v]);
         mx.erase(k);
         C[v]--;
         mx.insert(C[v]);
      }
      if(mx.empty()){
         ans = max(ans,R[e]);
      }else{
         ans = max(ans,R[e]+*mx.rbegin());
      }
      for(int v : G[e]){
         auto k = mx.find(C[v]);
         mx.erase(k);
         C[v]++;
         mx.insert(C[v]);
      }
   }
   cout << ans << '\n';
   return 0;
} 

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = 1000005;

ll A[MAX];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll Q;
    cin >> Q;
    ll front = MAX / 2, back = MAX / 2 + 1;
    REP(_, Q) {
        ll q;
        cin >> q;
        if (q == 0) {
            ll d, x;
            cin >> d >> x;
            if (d == 0)
                A[front--] = x;
            else
                A[back++] = x;
        }
        else if (q == 1) {
            ll p;
            cin >> p;
            cout << A[front + 1 + p] << endl;
        }
        else {
            ll d;
            cin >> d;
            if (d == 0)
                front++;
            else
                back--;
        }
    }
    return 0;
}


Measured memory_bytes: 6248
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <cstring>
#include <vector>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e8, cnt;

ll ans1;
int main(){
	ll n;
	cin>>n;
	string b,s;
	cin>>b;
	s=b;
	for(ll i=0; i<n; i++){
		if(s[i]==')'){
			bool ok=false;
			for(ll j=0; j<i; j++){
				if(s[j]=='('){
					s[j]='#';
					ok=true;
					s[i]='#';
					break;
				}
			}
			if(ok==false) ans++;
		}
		else if(s[i]=='('){
			bool ok1=false;
			for(ll j=i; j<n; j++){
				if(s[j]==')'){
					s[i]='#';
					s[j]='#';
					ok1=true;
					break;
				}
			}
			if(ok1==false) ans1++;
		}
	}
	for(ll i=0; i<ans; i++) cout<<'(';
	cout<<b;
	for(ll i=0; i<ans1; i++) cout<<')';
	
}


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

int main() {
    int mtod[]={0,31,60,91,121,152,182,213,244,274,305,335};
    string wd[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    while (1) {
        int m,d;
        cin>>m>>d;
        if (m==0)
            break;
        int day=mtod[m-1]+d;
        cout<<wd[day%7]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		double sockets = in.nextDouble();
		double total_req = in.nextDouble();	
		double mid = total_req-sockets;
		if(total_req == 1.0) {
			System.out.println(0);
			System.exit(0);
		}
		//System.out.println(mid);
		double total = Math.ceil(mid/(sockets-1));
		//System.out.println(total);
		if(sockets>=total_req) {
			System.out.println(1);
			System.exit(0);
		}
//		if(total < 1.0 && total != 0) {
//			total = 1.0;
//		}
		total++;
		System.out.println((int)(total));
		

	}

}


Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;

typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define REP(i,l,r) for(int i=l;i>=r;i--)
#define fi first
#define se second
#define eb emplace_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define int ll
const int mod = 1e9+7 ;

int n,m,a,b;
int fft[199999], fft_sz = 1;
int fact(const int& n){
	for(;n > fft_sz; ++fft_sz) fft[fft_sz+1] = (fft[fft_sz]*(fft_sz+1)) % mod;
	return fft[n];
}
int mul (const int& a, const int& b){
	return a * b %mod;
}
int mi(const int& a, const int& b){
	int ans = (a-b) % mod;
	return (ans < 0 ? ans + mod : ans);
}
int binpow(int a, int b){
	int res = 1;
	while(b){
		if (b & 1) res = mul(res,a);
		a = mul(a,a), b >>= 1;
	}
	return res;
}
int divide(const int& a, const int& b){
	assert(b > 0);
	return mul(a,binpow(b,mod-2)); 
}
int c(const int& a, const int& b){
	assert(b >= a);
	return divide(fact(b), mul(fact(a), fact(b-a)));
}
int path0(const int& n, const int& m){
	return c(n-1, n+m-2);
}
int path(const int& r, const int& c, const int& row, const int& col){
	return path0(row-r+1, col-c+1);
}

signed main() {
	fastio ;
	fft[0] = fft[1] = 1LL;
	cin >> n >> m >> a >> b;
	int ans = path0(n,m);
	for(int i = 0, r = n, c = b; i < a; ++i, --r){
		ans = mi(ans, mul(path(1,1 ,r,c), path(r,c+1, n,m)));
	}
	cout << (ans % mod) << endl;
}



Measured memory_bytes: 5204
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int k;
  cin >> k;
  int a = k / 2;
  int b = (k + 1) / 2;
  cout << a * b << endl;
  return 0;
}


Measured memory_bytes: 3140
#include<stdio.h>
#define MAX 2001
#define BLACK -1
#define WHITE 0

int main(){
  int i,j,n,x,min2,sum=0;
  int a[100][100];
  int min[100];
  int color[100];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a[i][j]);
      if(a[i][j]==-1)
	a[i][j]=MAX;
    }
  }

  for(i=0;i<n;i++){
    min[i]=MAX;
    color[i]=WHITE;
  }
  min[0]=0;
  
  while(1){
    min2=MAX;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && min[i]<min2){
	min2=min[i];
	x=i;
      }
    }
    if(min2==MAX)
      break;
    
    color[x]=BLACK;
    
    for(j=0;j<n;j++){
      if(color[j]!=BLACK && a[x][j]<min[j]){
	min[j]=a[x][j];
      }
    }
  }
  
  for(i=0;i<n;i++){
    sum+=min[i];
  }
  
  printf("%d\n",sum);
  
  return 0;
}
  



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

namespace ABC147A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a + b + c  >= 22)
                Console.WriteLine("bust");

            else 
                Console.WriteLine("win");

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long mod=1000000007;
	long long a=1,b=1,c=1;
	for(int i=0;i<n;++i){
		a=(a*10)%mod;
		b=(b*9)%mod;
		c=(c*8)%mod;
	}
	cout<<(2*mod+a-2*b+c)%mod<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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

int n,m;map<int, int> c, d;
int t[110000];vector<int> vec;
signed main(){
  cin>>n>>m;
  rep(i,n){
    int x;cin>>x;
    c[x%m]++;
    t[x]++;
    if(t[x]%2 == 0)d[x%m]++;
  }
  int ans = 0;
  for(auto p : c)vec.push_back(p.first);
  for(auto md : vec){
    if(c[md] == -1)continue;
    int op = (m-md)%m;
    assert(0 <= op && op < m);
    if(md == op){
      ans += c[md]/2;
      c[md] = -1;
    }else{
      int dc = min(c[md], c[op]);
      ans += dc;
      c[md] -= dc;
      c[op] -= dc;
      ans += max(min(d[op], c[op]/2), min(d[md], c[md]/2));
      c[md] = c[op] = -1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 14328
#include<bits/stdc++.h>
using namespace std;
main(){
 long long n,t[1000],a[1000],j;
 cin>>n>>t[0]>>a[0];
 for(int i=1;i<n;i++){
  cin>>t[i]>>a[i];
  j=max((a[i-1]-1)/a[i],(t[i-1]-1)/t[i])+1;
  a[i]*=j;t[i]*=j;
 }
 cout<<a[n-1]+t[n-1]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int a = 0;
        int b = 0;
        int c = 0;
        int e = 0;

        for(int i = 0; i < str.length(); i++){
            char ch = str.charAt(i);

            switch(ch){
            case 'a' : a++; break;
            case 'b' : b++; break;
            case 'c' : c++; break;
            default  : e++; break;
            }
        }

        if(a < 2 && b < 2 && c < 2 && e == 0 )
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int n=0;
  for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
      for(int k=0;k<=c;k++)
        if(500*i+100*j+50*k==x)
          n++;
  cout<<n<<endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

int main(){
	
    long long int n, i, cnt = 0, ans = 10000000000, k = 0;
    char s[310000];
    cin >> n;
    REP(i, n) cin >> s[i];

    REP(i, n){
        if(s[i] == 'E') k++;
    }
    REP(i, n){
        if(s[i] == 'E') k--;
        if(s[i-1] == 'W') k++;
        ans = min(ans, k);
    }
    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.buffer.readline
import heapq

def main():
    N,M,S = map(int,input().split())
    edge = [[] for _ in range(N)]
    for _ in range(M):
        u,v,a,b = map(int,input().split())
        edge[u-1].append((v-1, a, b))
        edge[v-1].append((u-1, a, b))
    
    change = [tuple(map(int,input().split())) for _ in range(N)]
    MAX_COST = 50*50
    S = min(S, MAX_COST)
    
    q = [(0,(0,S))]
    ans = [-1]*N
    visited = set()
    heapq.heapify(q)
    
    while q:
        time, data = heapq.heappop(q)
        now, money = data
        if ans[now] == -1:
            ans[now] = time
            if -1 not in ans:
                break
        if data in visited:
            continue
        visited.add(data)
        for fol, a, b in edge[now]:
            if money >= a:
                fol_data = (fol, money-a)
                if fol_data in visited:
                    continue
                heapq.heappush(q, (time+b, fol_data))
        c, d = change[now]
        if money+c > MAX_COST:
            continue
        heapq.heappush(q, (time+d, (now, money+c)))
    
    print(*ans[1:], sep="\n")

if __name__ == "__main__":
    main()


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

int main () {
	int n, b,math[52] = { 0 };
	char a;
	while ( cin >> n){
		for ( int i = 0; i < n; i++){
			cin >> a >> b;
			if ( a == 'S'){
				math[b-1] = 1;
			}
			else if ( a == 'H'){
				math[b+12] = 1;
			}
			else if ( a == 'C'){
				math[b+25] = 1;
			}
			else if ( a == 'D'){
				math[b+38] = 1;
			}
		}
		for ( int o = 0; o <= 52; o++){
			if ( o <= 12 && math[o] == 0) {
				cout << "S " << o+1 << endl;
			}
			else if ( o > 12 && o <= 25 && math[o] == 0){
				cout << "H " << o-12 << endl;
			}
			else if ( o > 25 && o <= 38 && math[o] == 0){
				cout << "C " << o-25 << endl;
			}
			else if ( o > 38 && math[o] == 0){
				cout << "D " << o-38 << endl;
			}
		}
	}
	return 0;
} 


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
template <class Key, class Compare = less<Key>> // find_by_order, order_of_key (for multiset: pair(val, time of insertion))
using Tree = tree<Key, null_type, Compare, rb_tree_tag, tree_order_statistics_node_update>;






void Solution() {

  int n;
  cin >> n;

  if (n % 2 == 0) {
    cout << n;
  } else {
    cout << 2*n;
  }



}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Solution();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int n;
	cin >>n;
	int ans=0;
	map<int,int>D;
	int bef;
	for(int i=0;i<n;i++){
		cin >>bef;
		D[bef]+=0;
		if(D[bef]==0){
			D[bef]=1;
		}else{
			D[bef]=0;
		}
	}
for(auto itr =D.begin();itr!=D.end();itr++){
	if(itr->second==1){
		ans++;
	}
}
	cout<<ans<<endl;
}

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

    cout << (A * 3 + P) / 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
using namespace std;

vector<int> V[1000];

int hmToM(int d, int h, int m) {
  return (d*24+h)*60 + m;
}

pair<int,int> sToHM(string s) {
  if(s == "24:00") cout << "!" << endl;
  replace(s.begin(), s.end(), ':', ' ');
  stringstream ss;
  ss << s;
  pair<int,int> p;
  ss >> p.first >> p.second;
  return p;
}

int getM(int day,string s) {
  pair<int,int> p = sToHM(s);
  return hmToM(day, p.first, p.second);
}

int solve() {
  int ans = 0;
  for(int i = 0; i == 0; ++i) {
    for(int j = i+1; j < 1000; ++j) {
      int sum = 0;
      for(int k = 0; k < V[i].size(); k += 2) {
	for(int l = 0; l < V[j].size(); l += 2) {
	  if(V[i][k+1] <= V[j][l]) continue;
	  if(V[j][l+1] <= V[i][k]) continue;
	  if(V[i][k] <= V[j][l] && V[j][l+1] <= V[i][k+1])
	    sum += V[j][l+1] - V[j][l];
	  else if(V[j][l] <= V[i][k] && V[i][k+1] <= V[j][l+1])
	    sum += V[i][k+1] - V[i][k];
	  else
	    sum += min(V[i][k+1] - V[j][l], V[j][l+1] - V[i][k]);
	}
      }
      ans = max(sum, ans);
    }
  }
  return ans;
}

int main() {
  int n;
  while(cin >> n && n) {
    string pre = "";
    int day = 1;
    for(int i = 0; i < 1000; ++i) V[i].clear();
    for(int i = 0; i < n; ++i) {
      string in[3];
      int id;
      cin >> in[0] >> in[1] >> in[2] >> id;
      if(pre != in[0]) {
	pre = in[0];
	for(int j = 0; j < 1000; ++j) {
	  if(V[j].size() % 2 != 0)
	    V[j].push_back(hmToM(day,24,0));
	}
	++day;
      }
      V[id].push_back(getM(day, in[1]));
    }
    for(int j = 0; j < 1000; ++j) {
      if(V[j].size() % 2 != 0)
	V[j].push_back(hmToM(day, 24,0));
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 968
#include <stdio.h>
int main(){
    int a[5],i,c,d;
    for(i=0;i<5;i++){
    scanf("%d\n",&a[i]);
    }
c=a[1]/a[3];
if(a[1]%a[3]>0)c++;

d=a[2]/a[4];
if(a[2]%a[4]>0)d++;

if(c>=d){i=a[0]-c;}
else i=a[0]-d;

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

Measured memory_bytes: 1792
def calc_digit_sum(num):
    length = len(str(num))
    digit_sum = 0

    for i in range(1, length + 1):
        digit_sum += num % 10
        num //= 10

    return digit_sum

N, A, B = map(int, input().split())
ans = 0

for i in range(1, N + 1):
    digit_sum = calc_digit_sum(i)

    if digit_sum >= A and digit_sum <= B:
        ans += i

print(ans)


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let si: Vec<String> = (0..n).map(|_| read()).collect();

    let mut map: HashMap<String, usize> = HashMap::new();

    let mut max_count = 0;
    for s in si {
        if map.contains_key(&s) {
            if let Some(x) = map.get_mut(&s) {
                *x += 1;
                if *x > max_count { 
                    max_count = *x;
                }
            }
        } else {
            map.insert(s, 1);
            if 1 > max_count {
                max_count = 1;
            }
        }
    }
    // println!("{} {:?}", max_count, map);

    let mut ans_vec = Vec::new();
    for (k, v) in map {
        if v == max_count {
            ans_vec.push(k);
        }
    }

    ans_vec.sort();

    for ans in ans_vec {
        println!("{}", ans);
    }
}


Measured memory_bytes: 28428
import itertools

N = int(input())
NP = list(itertools.permutations(range(N), N))
P = tuple(map(lambda s: int(s) - 1, input().split()))
Q = tuple(map(lambda s: int(s) - 1, input().split()))

ans = abs(NP.index(P) - NP.index(Q))
print(ans)

Measured memory_bytes: 8052
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int a, b, c, k;
int main() {
	cin>>a>>b>>c>>k;
	int sum = a + b + c;
	int mx = max(a, max(b, c));
	printf("%d", sum - mx + (mx << k));
	return 0;
}

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

using namespace std;

void dfs(const int cur, const int prev, const vector<vector<int>> &G, vector<int> &ans, const vector<int> &cost, int& ptr) {
    ans[cur] = cost[ptr++];
    for (auto nxt : G[cur]) if (nxt != prev) {
        dfs(nxt, cur, G, ans, cost, ptr);
    }
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    vector<int> c(N);
    for_each(begin(c), end(c), [](auto &e) {
        cin >> e;
    });
    sort(rbegin(c), rend(c));

    vector<int> ans(N);
    int tmp = 0;
    dfs(0, -1, G, ans, c, tmp);

    int M = 0;
    for (int i = 1; i < N; i++) {
        M += c[i];
    }

    printf("%d\n", M);
    for (int i = 0; i < N; i++) {
        printf("%d%c", ans[i], (i + 1 == N ? '\n' : ' '));
    }
}


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

void solv() {
    int r;
    cin >> r;
    cout << r * r << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int n,m,cnt;
vector<pint> v[101010];
ll a[101010];
int color[101010];
bool ok,nibu;

void dfs(int x){
    for(auto y:v[x]){
        int to=y.second;
        ll c=y.first;
        if(!color[to]){
            a[to]=c-a[x];
            color[to]=-color[x];
            dfs(to);
        }
        else{
            if(color[to]!=color[x]){
                if(c!=a[to]+a[x])ok=false;
            }
            else{
                nibu=false;
                if(c==a[to]+a[x])continue;
                if(cnt==0) {
                    if((c-a[to]-a[x])%2==0){
                        cnt++;
                        ll r=(c-a[to]-a[x])/2+a[x];
                        rep(i,n)color[i]=0;
                        rep(i,n)a[i]=0;
                        a[x]=r;
                        color[x]=1;
                        ok=true;
                        dfs(x);
                    }
                }
                else ok=false;
            }
        }
    }
}

int main(){
   cin>>n>>m;
   rep(i,m){
       int x,y,z;
       cin>>x>>y>>z;
       x--;y--;
       v[x].push_back({z,y});
       v[y].push_back({z,x});
   }
   a[0]=1;
   color[0]=1;
   nibu=true;
   ok=true;
   dfs(0);
   if(!ok){cout<<0<<endl;return 0;}
   if(nibu){
       ll mi1=longinf,mi0=longinf;
       rep(i,n){
           if(color[i]==1)mi1=min(mi1,a[i]);
           if(color[i]==-1)mi0=min(mi0,a[i]);
       }
       cout<<max(0LL,mi1+mi0-1)<<endl;
   }
   else{
       ll mi=longinf;
       rep(i,n)mi=min(mi,a[i]);
       if(mi>0)cout<<1<<endl;
       if(mi<=0)cout<<0<<endl;
   }
   return 0;
}


Measured memory_bytes: 14080
import sys, math


def main():
    N = input()
    heights = map(int, raw_input().split())

    dpMin = [9999999999 for i in range(N)]
    dpMin[0] = 0
    
    for i in range(1, N):
        if i >= 1:
            dpMin[i] = min(dpMin[i], dpMin[i - 1] + math.fabs(heights[i] - heights[i - 1]))

        if i >= 2:
            dpMin[i] = min(dpMin[i], dpMin[i - 2] + math.fabs(heights[i] - heights[i - 2]))
        
    
    print int(dpMin[N - 1])
   

if __name__ == '__main__':
    main()


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

int main(void)
{
  int n; cin >> n;
  int k; cin >> k;
  int min=114514;
  for(int i=0; i<=n; i++){
    for(int j=n-i; j>=0; j--){
      int tmp=1;
      for(int cnt=0; cnt<i; cnt++){tmp*=2;}
      tmp+=k*j;
      if(tmp<min){min=tmp;}
      break;
    }
  }
  cout << min << endl;
  return 0;
}


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

int main(int argc,char *argv[]){

  int s[10000],t[500],n,q,i,j;
  int count = 0;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&s[i]);
    for(j = 0;j < i;j++){
      if(s[i] == s[j]){
	i--;
	n--;
      }
    }
  }

  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&t[i]);
    for(j = 0;j < i;j++){
      if(t[i] == t[j]){
	i--;
	q--;
      }
    }
  }

  for(i = 0;i < n;i++){
    for(j = 0;j < q;j++){
      if(s[i] == t[j]){
	count++;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        int rootN = root(n);
        int ans = 0;
        for(int i=2; i<rootN; i++) {
            int c = 0;
            while(n%i == 0) {
                n = n / i;
                c++;
            }
            for(int j=1; j<100; j++) {
                if(c>=j) {
                    ans++;
                    c-=j;
                }
                else {
                    break;
                }
            }
        }
        if(n>1) {
            ans++;
        }
        System.out.println(ans);
    }
    private static int root(long n) {
        return (int)Math.ceil(Math.sqrt(n));
    }
}


Measured memory_bytes: 35860
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from fractions import gcd
import math
def resolve():
    N,M=pin()
    students=[tupin() for i in range(N)]
    checkpoints=[tupin() for j in range(M)]
    for stu in range(N):
        temp=10**10
        ind=0
        for pt in range(M):
            dis=abs(students[stu][0]-checkpoints[pt][0])\
            +abs(students[stu][1]-checkpoints[pt][1])
            #print(dis)
            if dis<temp:
                temp=dis
                ind=pt+1
        print(ind)
            
            
#%%submit!      
resolve()

Measured memory_bytes: 64748
import bisect
ind = {}
s = input()
t = input()
for i, c in enumerate(s):
    if c in ind:
        ind[c].append(i+1)
    else:
        ind[c] = [i+1]
k = len(s)
nk = 0
if not t[0] in ind:
    print(-1)
    exit()
nw = ind[t[0]][0]
pv = nw
for i in range(1, len(t)):
    c = t[i]
    if not c in ind:
        print(-1)
        exit()
    if ind[c][-1]>pv:
        pv = ind[c][bisect.bisect_left(ind[c], pv+1)]
    else:
        nk += k
        pv = ind[c][0]
    nw = pv + nk
print(nw)

Measured memory_bytes: 13552
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

ll r, g, b, n;

int main() {
    cin >> r >> g >> b >> n;
    int ans = 0;
    for (int i = 0; i <= 3000; i++) {
        for (int j = 0; j <= 3000; j++) {
            if (r * i + g * j > n) continue;
            if ((n - r*i - g*j) % b == 0) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, k;
int a[N], cache[N];

int dp(int cur)
{
	int &ans=cache[cur];
	if(ans!=-1)
		return ans;
	ans=0;
	for(int i=1;i<=n;i++)
	{
		if(cur-a[i]<0)
			break;
		ans|=(dp(cur-a[i])==0);
	}
	return ans;
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	if(dp(k))
		cout<<"First";
	else
		cout<<"Second";
	return 0;
}

Measured memory_bytes: 4224
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
struct Item {
  int w, v;
};
int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, w;
  cin >> n >> w;
  int64_t dp[101][100001];
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 100001; j++) {
      if (j == 0) {
        dp[i][j] = 0;
      } else {
        dp[i][j] = INT64_MAX / 2;
      }
    }
  }
  std::vector<Item> item;
  item.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> item[i].w >> item[i].v;
  }
  dp[1][item[1].v] = item[1].w;
  for (int i = 1; i <= n * 1000; i++) {
    for (int j = 1; j <= n; j++) {
      if (i - item[j].v >= 0) {
        dp[j][i] = std::min(dp[j - 1][i], dp[j - 1][i - item[j].v] + item[j].w);
      } else {
        dp[j][i] = dp[j - 1][i];
      }
      // cout << dp[i][j] << endl;
    }
  }
  int64_t result = 0;
  for (int i = 0; i <= 100000; i++) {
    if (dp[n][i] <= w) {
      result = i;
    }
  }
  cout << result << endl;

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    pair<pair<string, int>, int> p[110];
    for (int i = 0; i < n; i++) {
        cin >> p[i].first.first >> p[i].first.second;
        p[i].first.second = p[i].first.second * (- 1);
        p[i].second = i + 1;
    }

    sort(p, p + n);
    for (int i = 0; i < n; i++) {
        cout << p[i].second << endl;
    }
    return 0;
}

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

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
using namespace std;

int main(void){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b>c+d)
    cout<<"Left"<<endl;
  else if(a+b<c+d)
    cout<<"Right"<<endl;
  else 
    cout<<"Balanced"<<endl;

  
}

Measured memory_bytes: 256
import math
n, d = list(map(int, input().split(' ')))
uuu = []
for i in range(n):
    uuu.append(list(map(int, input().split(' '))))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        temp = 0.0
        for k in range(d):
            temp += (uuu[i][k] - uuu[j][k]) ** 2
        temp = temp ** 0.5
        ans += temp == math.ceil(temp)
print(ans)
        

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

int rem[80005];

int main() {
    string s;
    while(cin>>s, s!="0") {
        if(s.length() == 1) {
            cout<<"0"<<endl;
            continue;
        }
        
        int tr = 0;
        vector<vector<int> > rr(11, vector<int>(0));
        rr[0].push_back(0);
        for(int i=1; i<=s.length(); ++i) {
            tr += (s[i-1] - '0')*(i%2 ? 1 : -1) + 11;
            tr %= 11;
            rem[i-1] = tr;
            rr[tr].push_back(i);
        }

        int ans = 0;
        for(int i=0; i<11; ++i) {
            for(int j=0; j<rr[i].size(); ++j) {
                if(j == s.length()) continue;
                if(s[rr[i][j]] == '0') continue;
                ans += rr[i].size()-j-1;
            }
        }

        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1756
N = int(input())
X_list = list(map(int, input().split()))
X_list_min = sorted(X_list)

ans = 10**8+1

for i in range(X_list_min[0], X_list_min[-1]+1):
    ans_temp = 0
    for j in range(N):
        ans_temp += (X_list_min[j] - i)**2
    ans = min(ans, ans_temp)
print(ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int r;
	cin >> r;
	cout << (r < 1200 ? "ABC" : r < 2800 ? "ARC" : "AGC") << endl;
	return 0;
}
 

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

int a[60], b[60];
int ans[60], cnt[60];

int main () {
        int n, m;
        cin >> n >> m;
        for (int i = 1; i <= n; i++) {
                cin >> a[i] >> b[i];
        }
        for (int i = 1; i <= m; i++) {
                int x, y;
                cin >> x >> y;
                for (int j = 1; j <= n; j++) {
                        int now = max (x, a[j]) + max (y, b[j]) - min (x, a[j]) - min (y, b[j]);
                        if (i == 1) {
                                ans[j] = 1;
                                cnt[j] = now;
                        } else {
                                if (now < cnt[j])       cnt[j] = now, ans[j] = i;
                        }
                }
        }
        for (int i = 1; i <= n; i++) {
                printf ("%d\n", ans[i]);
        }
        return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func divisor(x int) []int {
	ret := make([]int, 0)
	for i := 1; i*i < x; i++ {
		if x%i == 0 {
			ret = append(ret, i)
			if x/i != i {
				ret = append(ret, x/i)
			}
		}
	}
	return (ret)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	ans := 0
	for i := 1; i <= N; i += 2 {
		if len(divisor(i)) == 8 {
			ans++
		}
	}
	out(ans)
}


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

int main()
{
  long n, ga, sa, ba, gb, sb, bb;
  cin >> n >> ga >> sa >> ba >> gb >> sb >> bb;
  vector<long> dp(n * 5000 + 1);
  for (int i = 1; i <= n; i++) {
    dp.at(i) = dp.at(i - 1);
    if (i >= ga && dp.at(i - ga) + gb - ga > dp.at(i)) dp.at(i) = dp.at(i - ga) + gb - ga;
    if (i >= sa && dp.at(i - sa) + sb - sa > dp.at(i)) dp.at(i) = dp.at(i - sa) + sb - sa;
    if (i >= ba && dp.at(i - ba) + bb - ba > dp.at(i)) dp.at(i) = dp.at(i - ba) + bb - ba;
  }
  n += dp.at(n);
  for (int i = 1; i <= n; i++) {
    dp.at(i) = dp.at(i - 1);
    if (i >= gb && dp.at(i - gb) + ga - gb > dp.at(i)) dp.at(i) = dp.at(i - gb) + ga - gb;
    if (i >= sb && dp.at(i - sb) + sa - sb > dp.at(i)) dp.at(i) = dp.at(i - sb) + sa - sb;
    if (i >= bb && dp.at(i - bb) + ba - bb > dp.at(i)) dp.at(i) = dp.at(i - bb) + ba - bb;
  }
  cout << n + dp.at(n) << endl;
}


Measured memory_bytes: 195584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    static int n;
    static int[] A;

    static boolean solve(int i, int m) {
        if (m == 0) return true;
        else if (i >= n) return false;
        // A[i]を使わないパターンと使うパターン
        else return solve(i + 1, m) || solve(i + 1, m - A[i]);
    }

    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            n = Integer.parseInt(in.readLine());
            A = new int[n];
            String[] line = in.readLine().split(" ");
            for (int i = 0; i < n; i++) {
                A[i] = Integer.parseInt(line[i]);
            }

            int q = Integer.parseInt(in.readLine());
            line = in.readLine().split(" ");
            for (int i = 0; i < q; i++) {
                int m = Integer.parseInt(line[i]);
                if (solve(0, m))
                    System.out.println("yes");
                else
                    System.out.println("no");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 24720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        static void SolveA(string[] args)
        {
            string s = Console.ReadLine();
            var dic = new HashSet<char>();
            dic.Add(s[0]);
            dic.Add(s[1]);
            dic.Add(s[2]);
            string ans = dic.Count == 3 ? "Yes" : "No";
            Console.WriteLine(ans);
        }
        
    }
}


Measured memory_bytes: 11476
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a[9];
	int b[9], c[9];
	for (int i = 0; i < 9; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	for (int i = 0; i < 9; i++){
		cout << a[i] << " " << b[i] + c[i] << " " << b[i] * 200 + c[i] * 300 << endl;
	}
	cin >> a[1];
	return 0;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
#define mod 998244353
#define ll long long int
#define N 200100
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	int x=1;
	while(x<1001){
		float c=x*0.08;
		float d=x*0.1;
		// cout<<c<<" "<<d<<endl;
		int w=floor(c);
		int y=floor(d);
		if(w==a && y==b){
			cout<<x<<endl;
			return 0;
		}
		x++;
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 256
from math import gcd
from functools import reduce


def facs(n):
    """試し割り法における割る数を生成する。"""
    yield 2
    for x in range(3, n, 2):
        yield x


def main():
    input()  # N
    array = [int(x) for x in input().split()]
    MAX_A = 10 ** 6 + 1
    histogram = [0] * MAX_A
    for x in array:
        histogram[int(x)] += 1

    for divider in facs(MAX_A):
        count = sum(histogram[divider::divider])
        if count > 1:
            break
    else:
        return 'pairwise coprime'

    gcd_total = reduce(gcd, array)
    if gcd_total == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'


if __name__ == '__main__':
    print(main())


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

using ll = long long;

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

  ll l[100];
  l[0] = 2, l[1] = 1;
  for (int i = 2; i <= N; i++) {
    l[i] = l[i-1] + l[i-2];
  }

  cout << l[N] << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline())
l = sys.stdin.readlines()
s = ""
for i in l:
  x, y, z = sorted(map(lambda x:x*x,map(int, i.split())))
  if x + y == z:
      s += "YES\n"
  else:
      s += "NO\n"

print(s,end="")

Measured memory_bytes: 7644
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  vector<char> d(26);
  vector<char> dd(26);

  for(int i = 0; i < s.size(); i++)
  {
    int a = s[i] - 'a';
    if(d[a] == 0)
    {
      d[a] = t[i];
      continue;
    }
    if(d[a] != t[i])
    {
      cout << "No" << endl;
      return 0;
    }
  }
  for(int i = 0; i < t.size(); i++)
  {
    int a = t[i] - 'a';
    if(dd[a] == 0)
    {
      dd[a] = s[i];
      continue;
    }
    if(dd[a] != s[i])
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 776