akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  //ll ans;
  string S, T;
  cin >> N;
  double x[N];
  string u[N];
  double ans = 0;
  rep(i, N){
    cin >> x[i] >> u[i];
    if (u[i] == "JPY") ans+=x[i];
    else ans+= 380000*x[i];
  }
  cout << ans << endl;
  

}


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

const int DIM = 1e5 + 5;
const int MOD = 1e9 + 7;

pair<int, bool> dp1[DIM << 2], dp2[DIM << 2];

void updatel(pair<int, bool> sgt[DIM << 2], int nd, int le, int ri)
{
    if (sgt[nd].second) {
        sgt[nd].first = 0;;
        
        if (le != ri) {
            sgt[nd << 1].second = true;
            sgt[nd << 1 | 1].second = true;
        }
        
        sgt[nd].second = false;
    }
}

void update(pair<int, bool> sgt[DIM << 2], int nd, int le, int ri, int ps, int vl)
{
    updatel(sgt, nd, le, ri);
    if (ri < ps or ps < le or ri < le)
        return;
    
    if (le == ri) {
        sgt[nd].first = (sgt[nd].first + vl) % MOD;
        return;
    }
    
    int md = (le + ri) >> 1;
    
    update(sgt, nd << 1, le, md, ps, vl);
    update(sgt, nd << 1 | 1, md + 1, ri, ps, vl);
    
    sgt[nd].first = (sgt[nd << 1].first + sgt[nd << 1 | 1].first) % MOD;
}

void updatelazy(pair<int, bool> sgt[DIM << 2], int nd, int le, int ri, int st, int en)
{
    updatel(sgt, nd, le, ri);
    if (ri < st or en < le or ri < le or en < st)
        return;
    
    if (st <= le and ri <= en) {
        sgt[nd].second = true;
        updatel(sgt, nd, le, ri);
        return;
    }
    
    int md = (le + ri) >> 1;
    
    updatelazy(sgt, nd << 1, le, md, st, en);
    updatelazy(sgt, nd << 1 | 1, md + 1, ri, st, en);
    
    sgt[nd].first = (sgt[nd << 1].first + sgt[nd << 1 | 1].first) % MOD;
}

int query(pair<int, bool> sgt[DIM << 2], int nd, int le, int ri, int st, int en)
{
    updatel(sgt, nd, le, ri);
    if (ri < st or en < le or ri < le or en < st)
        return 0;
    
    if (st <= le and ri <= en)
        return sgt[nd].first;
    
    int md = (le + ri) >> 1;
    
    int val1 = query(sgt, nd << 1, le, md, st, en);
    int val2 = query(sgt, nd << 1 | 1, md + 1, ri, st, en);
    
    return (val1 + val2) % MOD;
}

long long arr[DIM];

int main(void)
{
    int n; long long a, b;
    cin >> n >> a >> b; arr[0] = -1e18;
    
    update(dp1, 1, 0, n, 0, 1);
    update(dp2, 1, 0, n, 0, 1);
    for (int i = 1; i <= n; ++i)
        cin >> arr[i];
    
    for (int i = 1, p = 0, q = 0; i < n; ++i) {
        while (p + 1 < i and arr[i + 1] - arr[p + 1] >= b) ++p;
        while (q + 1 < i and arr[i + 1] - arr[q + 1] >= a) ++q;
        
        int val1 = query(dp1, 1, 0, n, 0, p),
            val2 = query(dp2, 1, 0, n, 0, q);
        
        if (arr[i + 1] - arr[i] < a)
            updatelazy(dp1, 1, 0, n, 0, i - 1);
        if (arr[i + 1] - arr[i] < b)
            updatelazy(dp2, 1, 0, n, 0, i - 1);
        
        update(dp2, 1, 0, n, i, val1);
        update(dp1, 1, 0, n, i, val2);
    }
    
    cout << (query(dp1, 1, 0, n, 0, n - 1) + query(dp2, 1, 0, n, 0, n - 1)) % MOD;
    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, m;
ll a[maxn];
priority_queue < ll > q;

int main() {
    n = read(), m = read();
    for (reg int i = 1; i <= n; i++) a[i] = read(), q.push(a[i]);
    q.push(0);
    while (m) {
        reg int u = q.top(); q.pop();
        u /= 2; q.push(u);
        m--;
    }
    reg ll Ans = 0;
    while (!q.empty()) Ans += q.top(), q.pop();
    printf("%lld\n", Ans);
    return 0;
}


Measured memory_bytes: 1912
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, M: int, X: int, Y: int, x: "List[int]", y: "List[int]"):
    xs = set(x)
    xs.add(X)
    ys = set(y)
    ys.add(Y)
    x1 = min(xs)
    x2 = max(xs)
    y1 = min(ys)
    y2 = max(ys)
    print("No War" if (x2 < y1 or y2 < x1) else "War")


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    y = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, X, Y, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int p,q;
  while(cin>>p>>q){
    int a[100];
    memset(a,0,sizeof(a));
    while(p+q){
      p--;
      q--;
      a[p]++;
      a[q]++;
      cin>>p>>q;
    }
    if(a[0]%2&&a[1]%2){
      for(i=2;i<100;i++){
	if(a[i]%2)
	  break;
      }
      if(i==100)
	cout<<"OK"<<endl;
      else
	cout<<"NG"<<endl;
    }else{
      cout<<"NG"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
function Main(input){
  var In = input.split('\n');
  var cardStr = In[1].split(' ');
  var N = parseInt(In[0], 10);
  var cards = [];
  var Alice = 0;
  var Bob = 0;
  
  for(var i = 0; i < N; i++){
    var card = parseInt(cardStr[i], 10);
    cards.push(card);
  }
  
  cards.sort(function(a, b){
    return (b-a);
  });
  
  for(var j = 0; j < N; j++){
    if(j%2 == 0){
      Alice += cards[j];
    } else {
      Bob += cards[j];
    }
  }
  
  var result = Alice - Bob;
  console.log(result);
  
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7748
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int t = 1;
		for (int i = 1; i <= t; ++i) {
			String a = in.next();
			String b = in.next();
			String r = solve(a, b);
			System.out.println(r);
		}
		in.close();
	}

	private static String solve(String a, String b) {
		int[][] path = new int[a.length() + 1][b.length() + 1];
		int[][] state = new int[a.length() + 1][b.length() + 1];
		for (int i = 1; i <= a.length(); i++) {
			for (int j = 1; j <= b.length(); j++) {
				state[i][j] = state[i - 1][j];
				path[i][j] = 0;
				if (state[i][j] < state[i][j - 1]) {
					state[i][j] = state[i][j - 1];
					path[i][j] = 1;
				}
				if (a.charAt(i - 1) == b.charAt(j - 1) && state[i][j] < state[i - 1][j - 1] + 1) {
					state[i][j] = state[i - 1][j - 1] + 1;
					path[i][j] = 2;
				}
			}
		}
		String r = getStr(a, b, path, a.length(), b.length());
		return r;
	}

	private static String getStr(String a, String b, int[][] path, int i, int j) {
		if (i == 0 || j == 0) {
			return "";
		} else if (path[i][j] == 2) {
			String r = getStr(a, b, path, i - 1, j - 1);
			if (a.charAt(i - 1) == b.charAt(j - 1)) {
				r += a.charAt(i - 1);
			}
			return r;
		} else if (path[i][j] == 0) {
			return getStr(a, b, path, i - 1, j);
		} else {
			return getStr(a, b, path, i, j - 1);
		}
	}

	static String str(int[] a) {
		String[] str = new String[a.length];
		for (int i = 0; i < a.length; i++) {
			str[i] = a[i] + "";
		}
		return String.join(" ", str);
	}

	static int[] getIntArr(Scanner in, int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

	static int[][] getIntArr(Scanner in, int row, int col) {
		int[][] arr = new int[row][];
		for (int i = 0; i < row; i++) {
			arr[i] = getIntArr(in, col);
		}
		return arr;
	}

	static char[] getCharArr(Scanner in, int size) {
		char[] arr = in.next().toCharArray();
		return arr;
	}

	static String[] getStringArr(Scanner in, int size) {
		String[] arr = new String[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.next();
		}
		return arr;
	}

	static Map<Integer, List<Integer>> getEdges(Scanner in, int size, boolean directed) {
		Map<Integer, List<Integer>> edges = new HashMap<>();
		for (int i = 0; i < size; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			if (!edges.containsKey(from)) {
				edges.put(from, new ArrayList<Integer>());
			}
			edges.get(from).add(to);
			if (!directed) {
				if (!edges.containsKey(to)) {
					edges.put(to, new ArrayList<Integer>());
				}
				edges.get(to).add(from);
			}

		}
		return edges;
	}
}


Measured memory_bytes: 140752
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

const int INF = 0x7fffffff;
const int _INF = 0x7fffffff + 1;

int main()
{
    int k, s;
    cin>>k>>s;
    int ans = 0;
    for(int i = 0; i <= k; i++)
        for(int j = 0; j <= k; j++)
            if(s - (i + j) <= k && s - (i + j) >= 0)
                    ans++;
    printf("%d", ans);
    return 0;
}


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

int main(){
	int n,w,d;
	while(cin>>n>>w>>d&&w){
		pair<int,int> p[n+2];
		p[1]=make_pair(w,d);
		for(int i=2;i<n+2;i++){
			int num,len; cin>>num>>len;
			int width=p[num].first,depth=p[num].second;
			int cut=len%(width+depth);
			for(int j=num+1;j<i;j++){
				p[j-1]=p[j];
			}
			if(cut<=width){
				p[i-1]=make_pair(min(cut,width-cut),depth);
				p[i]=make_pair(max(cut,width-cut),depth);
			}else{
				cut-=width;
				p[i-1]=make_pair(width,min(cut,depth-cut));
				p[i]=make_pair(width,max(cut,depth-cut));
			}
		}
		//rep(i,n) cout<<p[i+1].first<<" "<<p[i+1].second<<endl;
		int ans[n+1];
		rep(i,n+1){
			ans[i]=p[i+1].first*p[i+1].second;
		}
		sort(ans,ans+n+1);
		rep(i,n+1) i?cout<<" "<<ans[i]:cout<<ans[i];
		cout<<endl;
	}
	return 0;
}



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

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> city(N);
  for(int i = 0; i < N; ++i){
    cin >> city.at(i);
  }
  city.push_back(X);
  sort(city.begin(),city.end());
  vector<int> dcity(N);
  for(int i = 0; i < N; ++i){
    dcity.at(i) = city.at(i+1)-city.at(i);
  }
  int GCD;
  if(N > 1){
    GCD = gcd(dcity.at(0),dcity.at(1));
  } else {
    GCD = dcity.at(0);
  }
  for(int i = 0; i < N; ++i){
    if (dcity.at(i)) GCD = gcd(GCD,dcity.at(i));
  }
  cout << GCD << endl;
  
  
}

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

/*
H N
A1 A2 … AN

*/
bool Rackoon_fight(vector<int>& damage, int& H)
{
   sort(damage.begin(),damage.end());
   for(int i=0; i<damage.size();i++) 
   {
   		H-=damage[i];
   		if(H<=0) return true;
   }
   return false;
   
}

int main()
{
   int H, N,d;
   vector<int> damage(N);
   cin>> H >> N;
   for(int i=0; i<N;i++) 
   {
   	cin>>d;
   	damage.push_back(d);
   }
   
   if(Rackoon_fight(damage,H))
	cout<< "Yes"<<endl;
   else
	cout<< "No" <<endl;
  return 0;

}

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

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  vector<double> a(5);
  rep(i,5)
    cin>>a[i];
  int b=0;
  rep(i,5){
  a[i]/=10;
    b+=ceil(a[i])*10;
    a[i]*=10;
  }
  int c=INF; 
  vector<int> d(5);
  rep(i,5){
  d[i]=a[i];
  }
  rep(i,5){
  if(!(d[i]%10==0))
    c=min(c,d[i]%10);
  }
  if(c==INF){
    c=0;
  b+=10;
  }
  b+=c;
  b-=10;
  out(b);
}


Measured memory_bytes: 256
import math

def plot(x,y):
    print(f'{x:.8f} {y:.8f}')

def koch(n,ax,ay,bx,by):
    if n==0:
        plot(ax,ay)
        return
    
    sx=(2*ax+bx)/3
    sy=(2*ay+by)/3
    tx=(ax+2*bx)/3
    ty=(ay+2*by)/3
    ux=((tx-sx)*math.cos(math.radians(60)))-((ty-sy)*math.sin(math.radians(60)))+sx
    uy=((tx-sx)*math.sin(math.radians(60)))+((ty-sy)*math.cos(math.radians(60)))+sy

    koch(n-1, ax,ay, sx,sy)
    koch(n-1, sx,sy, ux,uy)
    koch(n-1, ux,uy, tx,ty)
    koch(n-1, tx,ty, bx,by)
    
n=int(input())
koch(n, 0,0, 100,0)    
plot(100,0)



Measured memory_bytes: 5776
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

bool compare_by_second(pair<int,int> a,pair<int,int> b){
    if(a.second!=b.second)return a.second>b.second;
    else return a.first>b.first;
}
int main(){
    int N;cin>>N;
    pair<int,int> a[N],b[N];
    rep(i,N)cin>>a[i].first>>a[i].second;
    rep(i,N)cin>>b[i].first>>b[i].second;
    sort(a,a+N,compare_by_second);
    sort(b,b+N);
    int ans=0;
    rep(i,N){
        rep(j,N){
            if(a[j].first<b[i].first and a[j].second<b[i].second){
                ans++;
                a[j].first=201;a[j].second=201;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

template<class T>
struct graph{
    struct edge{
        int to;
        T cost;
        edge(int to, T cost) : to(to), cost(cost){}
        bool operator<(const edge& r)const{
            return cost < r.cost;
        }
    };
    int V;
    vector< vector< edge > > adj;
    vector< T > dist;

    graph(int n){
        init(n);
    }

    void init(int size){
        V = size;
        adj.assign(size, vector<edge>());
    }

    void add_edge(int from, int to, T cost){
        adj[from].push_back(edge(to, cost));
    }

    void Dijkstra(int from, T inf){
        typedef pair<T, int> P;
        priority_queue<P, vector<P>, greater<P> > q;
        dist.assign(V, inf);
        dist[from] = 0;
        q.push(P(0, from));
        while(!q.empty()){
            P p = q.top();
            q.pop();
            int v = p.second;
            if(p.first > dist[v]) continue;
            for(edge e: adj[v]){
                if(dist[e.to] > dist[v] + e.cost){
                    dist[e.to] = dist[v] + e.cost;
                    q.push(P(dist[e.to], e.to));
                }
            }
        }
    }

};
int n, m, s;
int f(int x, int y){
    return x*2501+y;
}

int main(void){
    cin >> n >> m >> s;
    if(s > 2500) s = 2500;
    graph<long long> g(n*2501);
    for(int i=0;i<m;i++){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;
        v--;
        for(int j=a;j<2500;j++){
            g.add_edge(f(u, j), f(v, j-a), b);
        }
        for(int j=a;j<2500;j++){
            g.add_edge(f(v, j), f(u, j-a), b);
        }
        g.add_edge(f(u, 2500), f(v, 2500), b);
        g.add_edge(f(v, 2500), f(u, 2500), b);
    }
    for(int i=0;i<n;i++){
        int c, d;
        cin >> c >> d;
        for(int j=0;j+c<=2500;j++){
            g.add_edge(f(i, j), f(i, j+c), d);
        }
    }
    g.Dijkstra(f(0, s), 1e18);
    for(int i=1;i<n;i++){
        long long ans = 1e18;
        for(int j=0;j<=2500;j++){
            ans = min(ans, g.dist[f(i, j)]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 23352
def isStrong(S):
    N = len(S)
    if S == S[::-1]:
        left = S[:(N-1)//2]
        right = S[(N+3)//2-1:]
        if left == left[::-1] and right == right[::-1]:
            return True
        else:
            return False
    else:
        return False
        
S = input()
print("Yes") if isStrong(S) else print("No")

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll a, b;
	scanf("%lld %lld", &a, &b);
	if(a<=b){
		puts("Impossible");
		printf("%lld %lld", a, b);
		return 0;
	}
	ll n = a+b, p = 1;
	ll a2 = a, b2 = b;
	char c;
	vector<ll> v;
	v.push_back(0);
	while(p<n){
		printf("? %lld %lld\n", v.back(), p); fflush(stdout);
		scanf(" %c", &c);
		if(c=='Y'){
			v.push_back(p++);
		} else {
			v.pop_back();
			if(v.empty()){
				v.push_back(p+1);
				p++;
			}
			p++;
		}
	}
	ll h = v.back();
	string res = "";
	rep(i, n){
		printf("? %lld %lld\n", h, i); fflush(stdout);
		scanf(" %c", &c);
		res += (c=='Y'?'1':'0');
	}
	printf("! %s\n", res.c_str());
	return 0;
}

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

int main(void){
    string num;
    cin>>num;
    int a[num.size()];

    for (int i = 0; i < num.size(); i++){
      a[i]=(int)num[i]-48;
    }
    
    long int sum=0;
    for (int i = 0; i < num.size(); i++)sum+=a[i];
    
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double EPS= (1e-9);
using namespace std;
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=200000+9;
const ll inf=1e15;
int arr[N];
ll mem[N][5],n;
ll solve(int id,int f){

   if(id>=n){
     if(n%2==0)
    return 0;
     if(f!=2) return 0;
     return -inf;
   }
   ll &ret=mem[id][f];
   if(ret!=-inf) return ret;

   ll ans=-inf;
   ans=max(ans,arr[id]+solve(id+2,f));
   if(f)
   ans=max(ans,solve(id+1,f-1));
   return ret=ans;
}
int main(){
    GO();
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    for(int i=0;i<=n;i++) for(int j=0;j<5;j++) mem[i][j]=-inf;
    cout<<solve(0,(n%2==0?1:2))<<"\n";
}




















Measured memory_bytes: 18500
import sys
input = sys.stdin.readline

def digit_sum(n, b):
    if b == 1:
        return n
    res = 0
    while n > 0:
        res += n % b
        n //= b
    return res

def main():
    n = int(input())
    s = int(input())
    
    ans = -1
    if n == s:
        ans = n + 1
    else:
        for b in range(2, int(n**0.5) + 1):
            if digit_sum(n, b) == s:
                ans = b
                break
        
        else:
            for p in range(1, int(n**0.5)+1):
                b = (n - s) // p + 1
                if b >= 2 and digit_sum(n, b) == s:
                    if ans == -1:
                        ans = b
                    else:
                        ans = min(ans, b)
                
                if b >= 1 and digit_sum(n, b+1) == s:
                    if ans == -1:
                        ans = b+1
                    else:
                        ans = min(ans, b+1)

    print(ans)



if __name__ == "__main__":
    main()


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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

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

int main(){
    int n; cin >> n; 
    vector<int> lis(n+1), anslis(n+1, 0);
    REP(i, 1, n+1){cin >> lis[i];}
    for(int i = n; i >= 1; i--){
        int k = 0;
        int c = 2 * i;
        while(c < n+1){
            if(anslis[c] == 1){
                k++;
            }
            c += i;
        }
        k %= 2;
        if(lis[i] == 1){
            if(k == 1){
                anslis[i] = 0;
            }else{
                anslis[i] = 1;
            }
        }else{
            if(k == 1){
                anslis[i] = 1;
            }else{
                anslis[i] = 0;
            }
        }
    }
    int m = 0;
    REP(i, 1, n+1){
        if(anslis[i] == 1) m++;
    }
    cout << m << endl;
    REP(i, 1, n+1){
        if(anslis[i] == 1){
            cout << i << " ";
        }
    }
}

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

int main()
{
	char s;
	int n, r, c;
	cin.tie(0);
	cin >> n;

	int a[4][13] = { 0 };
	for (int i = 0; i < n; i++) {
		cin >> s >> c;
		if (s == 'S') r = 0;
		else if (s == 'H') r = 1;
		else if (s == 'C') r = 2;
		else if (s == 'D') r = 3 ;
		a[r][c - 1] = c;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (a[i][j] > 0) {
				continue;
			}

			if (i == 0) cout << 'S';
			else if (i == 1) cout << 'H';
			else if (i == 2) cout << 'C';
			else if (i == 3) cout << 'D' ;
			cout << " " << j + 1 << "\n";
		}
	}
}



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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vector<vector<int>> x(10, vector<int>(10));
  for (auto&& v : x) {
    for (auto&& e : v) {
      cin >> e;
    }
  }
  auto check = [&](int a, int b, int c, int d, int e) {
    return x[x[x[x[x[0][a]][b]][c]][d]][e];
  };
  int res = 0;
  for (int a = 0; a < 10; ++a) {
    for (int b = 0; b < 10; ++b) {
      for (int c = 0; c < 10; ++c) {
        for (int d = 0; d < 10; ++d) {
          int e = x[x[x[x[0][a]][b]][c]][d];
          bool ok = true;
          for (int i = 0; i < 10; ++i) {
            if (i != a and check(i, b, c, d, e) == 0) {
              ok = false;
            }
            if (i != b and check(a, i, c, d, e) == 0) {
              ok = false;
            }
            if (i != c and check(a, b, i, d, e) == 0) {
              ok = false;
            }
            if (i != d and check(a, b, c, i, e) == 0) {
              ok = false;
            }
            if (i != e and check(a, b, c, d, i) == 0) {
              ok = false;
            }
          }
          if (a != b and check(b, a, c, d, e) == 0) {
            ok = false;
          }
          if (b != c and check(a, c, b, d, e) == 0) {
            ok = false;
          }
          if (c != d and check(a, b, d, c, e) == 0) {
            ok = false;
          }
          if (d != e and check(a, b, c, e, d) == 0) {
            ok = false;
          }
          res += not ok;
        }
      }
    }
  }
  cout << res << '\n';
}



Measured memory_bytes: 3216
import Control.Applicative

main :: IO ()
main = do
    [a, b, c] <- map read . words <$> getLine
    putStrLn $ solve a b c 
    
solve :: Int -> Int -> Int -> String
solve a b c = if (c-b) <= 0 then "delicious" else if (c-b) > a then "dangerous" else "safe"

Measured memory_bytes: 508
#include<stdio.h>
int main(){
  int a[101],i,j,temp;
  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
  }
   for(i=0;i<9;i++){
    for(j=0;j<9-i;j++){
      if(a[j]<a[j+1]){
	temp=a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }
   for(i=0;i<3;i++){
     printf("%d\n",a[i]);
   }
   return 0;
}
       

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

namespace ABC135A
{
    class Program
    {
        static void Main(string[] args)
        {

            int a, b;
            string[] A = Console.ReadLine().Split(' ');
            a = int.Parse(A[0]);
            b = int.Parse(A[1]);
            if ((a + b) % 2 == 0)
                Console.WriteLine((a + b) / 2);
            else if ((a + b) % 2 != 0)
                Console.WriteLine("IMPOSSIBLE");
            Console.ReadKey();

        }
    }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using G=vector<vector<int>>;

int Dreyfus_wagner(const G &graph,const auto &term){
	using W=int; W inf=1<<28;
	const int n=int(graph.size()),t=int(term.size());
	if(t<=1) return 0;
	auto dist=graph;
	vector<vector<W>> opt(1<<t,vector<W>(n,inf));

	rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]);
	
	map<int,int> dict;
	rep(i,t){
		dict[term[i]]=1<<i;
		rep(j,n) opt[1<<i][j]=dist[term[i]][j];
		rep(j,t) opt[(1<<i)|(1<<j)][term[j]]=dist[term[i]][term[j]];
	}

	auto next_combination=[&](int s){
		int x=s&-s,y=s+x;
		return ((s&~y)/x>>1)|y;
    };

	rep(k,2,t){
		for(int s=(1<<k)-1;s<(1<<t);s=next_combination(s)){
			rep(i,n){
				int ns=s|dict[i];
				if(dict[i] and s==ns) continue;
				for(int u=(s-1)&s;u!=0;u=(u-1)&s){
					int c=s&(~u);
					chmin(opt[ns][i],opt[u][i]+opt[c][i]);
				}
			}
		}
		for(int s=(1<<k)-1;s<(1<<t);s=next_combination(s)){
			rep(i,n){
				int ns=s|dict[i];
				if(dict[i] and s==ns) continue;
				rep(j,n) chmin(opt[ns][i],opt[s][j]+dist[j][i]);
			}
		}
	}

	const int mask=(1<<t)-1;
	W ans=opt[mask][0];
	rep(i,n) chmin(ans,opt[mask][i]);
	return ans;
}

int main(void){
	int h,w;
	while(cin >> h >> w){
		if(h==0) break;
		const int inf=1<<28;

		G graph(h*w,vector<int>(h*w,inf));
		rep(i,h*w) graph[i][i]=0;
		vector<int> term;

		rep(i,h*w){
			int in;
			cin >> in;
			if(in) term.push_back(i);
		}
		
		rep(i,h)rep(j,w){
			const int cur=w*i+j;
			if(i+1<h) graph[cur][cur+w]=graph[cur+w][cur]=1;
			if(j+1<w) graph[cur][cur+1]=graph[cur+1][cur]=1;
		}
		int res=Dreyfus_wagner(graph,term);
		cout << h*w-1-res << endl;
	}
	return 0;
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define UM unordered_map
#define MP map
#define ST set
#define US unordered_set
#define V vector
#define S string
#define D deque
#define L list
#define Q queue
#define PQ priority_queue
#define DB double
#define LDB long double
#define FOR(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define FFOR(i, n) for (int(i) = 0; (i) <= (n); ++(i))
#define RFOR(i, n) for (int(i) = (n)-1; (i) >= 0; --(i))
#define all(v) (v).begin(), (v).end()

const int dr[] = {0, 1, 0, -1};
const int dc[] = {1, 0, -1, 0};

int nxt()
{
    int n;
    cin >> n;
    return n;
}

LL llnxt()
{
    LL l;
    cin >> l;
    return l;
}

LDB ldbnxt()
{
    LDB n;
    cin >> n;
    return n;
}

DB dbnxt()
{
    DB n;
    cin >> n;
    return n;
}

void bfs(VVI &graph, int start)
{
    int n = graph.size();
    Q<int> q;
    V<bool> visited(n);
    q.push(start);
    visited[start] = true;
    while (not q.empty())
    {
        auto curr = q.front();
        q.pop();
        for (auto i : graph[curr])
        {
            if (not visited[i])
            {
                q.push(i);
                visited[i] = true;
            }
        }
    }
}
int main()
{
    int n, m;
    cin >> n >> m;
    VI h(n);
    FOR(i, n)
    {
        cin >> h[i];
    }
    V<bool> b(n, true);
    FOR(i, m)
    {
        int u, v;
        cin >> u >> v;
        --u, --v;
        b[u] = b[u] & (h[u] > h[v]);
        b[v] = b[v] & (h[v] > h[u]);
    }
    int cnt = 0;
    for (auto i : b)
    {
        if (i)
            ++cnt;
    }
    cout << cnt;
}

Measured memory_bytes: 3788
import numpy as np
from collections import Counter

N = int(input())
A = [0] + list(map(int, input().split()))

cumsum = np.cumsum(A)
c = Counter(cumsum)
ans = 0
for k, v in c.items():
    if v > 1:
        ans += v * (v - 1) // 2

print(ans)


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

string S;
map<char, int> dic;

int main() {
    cin >> S;
    char now = 'a';
    REP(i, S.length()) { dic[S[i]]++; }
    string ans = "-1";
    REP(i, 27) {
        bool update = false;
        while(now <= 'z') {
            if(dic[now] == 0) {
                ans = S.substr(0, S.length() - i) + now;
                update = true;
                break;
            }
            now++;
        }
        if(update) break;
        now = S[S.length() - 1 - i] + 1;
        dic[S[S.length() - 1 - i]]--;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int d;
    
    scanf("%d",&d);
    
    if(d==25){
        printf("Christmas\n");
    }
    
    else if(d==24){
        printf("Christmas Eve\n");
    }
    
    else if(d==23){
        printf("Christmas Eve Eve\n");
    }
    
    else if(d==22){
        printf("Christmas Eve Eve Eve\n");
    }
    
    
    
    return 0;
}

Measured memory_bytes: 128
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

n=I()
s=input()
uu=u_alp*2
dict1=dict(zip(u_alp,range(0,26)))
#show(dict1)
a=[]
for i in s:
    a+=[uu[n+uu.index(i)]]
print(''.join(a))


Measured memory_bytes: 39020
object Scanner {
  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}

object Main extends App {
  val s = Scanner.next()
  val cArray = s.toCharArray

  val candidate1 = (0 until s.length).map(i=>{
    if (i%2==0){
      if (s(i)=='0'){
        0
      } else {
        1
      }
    } else {
      if (s(i)=='0') {
        1
      } else {
        0
      }
    }
  }).sum

  val candidate2 = (0 until s.length).map(i=>{
    if (i%2==0){
      if (s(i)=='0'){
        1
      } else {
        0
      }
    } else {
      if (s(i)=='0') {
        0
      } else {
        1
      }
    }
  }).sum

  println(Seq(candidate1,candidate2).min)

}

Measured memory_bytes: 37596
from itertools import permutations
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(M)]

graph = [[float('inf')] * N for _ in range(N)]
for i in range(N):
    graph[i][i] = 0

for u, v, l in edges:
    graph[u - 1][v - 1] = l
    graph[v - 1][u - 1] = l

for k in range(N):
    for i in range(N):
        if graph[i][k] == float('inf'):
            continue
        for j in range(N):
            if graph[k][j] == float('inf'):
                continue
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

ans = 10 ** 9 + 7
for l in permutations(r, R):
    ans = min(ans, sum(graph[l[i] - 1][l[i + 1] - 1] for i in range(R - 1)))
        
print(ans)


Measured memory_bytes: 122328
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

N = int(input())
A = list(map(int,input().split()))

# 負の数をカウントしつつ、絶対値が最小の数を求める & 0があるか
smallest = INF
minus = 0
is_zero = False
ans = 0
for a in A:
    smallest = min(smallest, abs(a))

    if a == 0:
        is_zero = True
    elif a < 0:
        minus += 1

    ans += abs(a)

if is_zero or minus % 2 == 0:
    print(ans)
else:
    ans -= smallest*2
    print(ans)


Measured memory_bytes: 14412
import kotlin.comparisons.compareBy

fun main(args: Array<String>) {
    abc000X()
}

fun abc000X() {
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map(String::toInt)

    var sortedList = list.sortedWith(compareBy { it })
    var ans = sortedList[n / 2] - sortedList[n / 2 - 1]
    println(ans)
}

Measured memory_bytes: 65964
#include<cstdio>
int main()
{
	int n,x,i,j,y;
	int a[1000];
	y=0;
	scanf("%d %d",&n,&x);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
			if(a[i]>a[j]){
				y=a[i];
				a[i]=a[j];
				a[j]=y;
			}
		}
	}
	y=0;
	// for(i=0;i<n;i++){
		// printf("a=%d\n",a[i]);
	// }
	for(i=0;i<x;i++) y+=a[i];
	printf("%d\n",y);
	return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N; cin >> N;
	int n = N;
	int f = 0;
	while (true) {
		f += N % 10;
		N /= 10;
		if (N == 0)break;
	}

	cout << ((n % f == 0) ? "Yes" : "No") << endl;

	return 0;
}

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

size_t solv(size_t N,
            std::string const& A,
            std::string const& B,
            std::string const& C) {
  size_t ret=0;

  for (size_t i=0; i<N; i++) {
    if (A[i] == B[i])
      if (B[i] == C[i])
        ret+=0;
      else
        ret+=1;
    else
      if (B[i] == C[i])
        ret+=1;
      else if (A[i] == C[i])
        ret+=1;
      else
        ret+=2;
  }


  return ret;
}

int main() {
  size_t N;
  std::string A, B, C;

  std::cin >> N;
  std::cin >> A >> B >> C;

  std::cout << solv(N, A, B, C) << std::endl;

  return 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let c: String = input();
    println!(
        "{}",
        if c == "a" || c == "e" || c == "i" || c == "o" || c == "u" {
            "vowel"
        } else {
            "consonant"
        }
    );
}


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

void Main() {
    // input
    int X, Y;
    cin >> X >> Y;


    // translate
    for (int x = 0; x <= X; x++) {
        int y = X - x;
        if (2 * x + 4 * y == Y) {
            cout << "Yes" << endl;
            return;
        }
    }

    cout << "No" << endl;
    return;


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h> 
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define ull unsigned long long
#define ll long long
void codeforces()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.in", "w", stdout);
    #endif
}

int32_t main()
{
    codeforces();
    // int t;cin>>t;
    // while(t--){
       
    // }

    int a,b,c,d;cin>>a>>b>>c>>d;
    int taka = c/b;
    int aoki = a/d;
    if(c>b && c%b!=0)taka++;
    if(a>d && a%d!=0)aoki++;
    if(taka<=aoki)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

#define N 200000

int main(){

  int i, j, n, key, maxv, minv, R[N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
  }
  minv = R[0];
  maxv = R[1]-R[0];

  for(j=1;j<=n-1;j++){
    if(R[j]-minv > maxv)maxv = R[j]-minv;
    if(R[j] < minv)minv = R[j];
  }
  printf("%d\n",maxv);
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rept(i, a, b) for(int i=a ; i<=b; i++)
    
int main(){
    string s; cin >> s;
    if(s=="SUN") cout << 7 << endl;
    else if(s=="MON") cout << 6 << endl;
    else if(s=="TUE") cout << 5 << endl;
    else if(s=="WED") cout << 4 << endl;
    else if(s=="THU") cout << 3 << endl;
    else if(s=="FRI") cout << 2 << endl;
    else if(s=="SAT") cout << 1 << endl;
}

                
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int s, w;
   cin >> s >> w;
   if(w>=s) {
       cout << "unsafe" << endl;
   } else {
       cout << "safe" << endl;
   }
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int w,n,a[30],b[30],result[30];
  for(int i=0;i<30;i++){
    result[i]=i+1;
  }
  
  cin >>w>>n;
  for(int i=0;i<n;i++){
    scanf("%d,%d",&a[i],&b[i]);
    swap(result[a[i]-1],result[b[i]-1]);
  }

  for(int i=0;i<w;i++) cout <<result[i]<<endl;
 
  return 0;
}
    
   

Measured memory_bytes: 1240
#define times(n) for(int m_=0;m_<n;m_++)
#include <iostream>
using namespace std;

int main(){
  int n;
  while (1){
    cin >> n;
    if (!n) break;
    bool map[21][21];
    for (int a = 0; a < 21; a++)
      for (int b = 0; b < 21; b++)
	map[a][b] = false;
    
    int x, y;
    times(n){
      cin >> x >> y;
      map[y][x] = true;
    }
    x = 10, y = 10;
    cin >> n;
    times(n){
      char c;
      int w;
      cin >> c >> w;
      times(w){
	switch(c){
	case 'N': y++; map[y][x] = false; break;
	case 'S': y--; map[y][x] = false; break;
	case 'W': x--; map[y][x] = false; break;
	case 'E': x++; map[y][x] = false; break;
	}
      }
    }
    bool flag = false;
    for (int a = 0; a < 21; a++){
      for (int b = 0; b < 21; b++){
	if (map[a][b]) flag = true;
      }
    }
    if (flag) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += 1
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

d = defaultdict(int)
for num in A:
    d[num] += 1

flag = 0
cnt = 0
for key, value in d.items():
    if value > 1:
        flag = (flag + value - 1) % 2
    cnt += 1

print(cnt-flag)

Measured memory_bytes: 18592
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
count_dic = defaultdict(int)
for x in A:
    count_dic[x] +=1
ans = 0
for v in count_dic.values():
    ans += v*(v-1)//2
for x in A:
    print(ans -(count_dic[x]-1))


Measured memory_bytes: 87884