akhauriyash/Code-Regression huggingface dataset:
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: f64,
    }

    println!("{}", (n / 111.0).ceil() as u64 * 111);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m,x;
  cin >> n >> m >> x;
  int l=0,r=0;
  rep(i,m){
    int a;
    cin >> a;
    if(a<x) ++l; else ++r;
  }
  cout << min(l,r) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n, x, max_num = -1000001, min_num=1000001;
    long long int sum(0);
    std::cin >> n;
    
    for(int i=0;i<n;i++){
        cin>>x;
        max_num=max(max_num,x);
        min_num=min(min_num,x);
        sum+=x;
    }
    
    cout<<min_num<<" "<<max_num<<" "<<sum<<endl;
}



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




int32_t main()
{ 
  IOS;
  //#ifndef ONLINE_JUDGE 
    //freopen("input.txt","r",stdin) ;
    //freopen("output.txt","w",stdout) ;
  //#endif  
  int  k;
  int a[5] ;
  
  for(int i = 0 ;  i < 5 ; i++ ) cin >> a[i] ;
    cin >> k ;
  if(a[4] - a[0] > k ) cout<<":("<<endl;
  else cout<<"Yay!"<<endl;
   
} 


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

void solve() {
  vector<int> vec;
  while(true) {
    int v; cin >> v;
    if(v == 0) break;
    vec.emplace_back(v);
  }

  int ptr = 1;
  vector< vector<int> > ans(1, vector<int>());
  vector<int> rec;
  vector<int> deg(1, 0), tar(1, 0);
  for(size_t i=0; i<vec.size(); i++) {
    if(vec[i] > 0) {
      int p = -1;
      if(rec.size()) p = rec.back();
      rec.emplace_back(ptr);

      // add new element
      tar.emplace_back(vec[i]);
      deg.emplace_back(0);
      ans.emplace_back(vector<int>());

      if(p > 0) {
        deg[ptr]++; deg[p]++;
        ans[ptr].emplace_back(p);
        ans[p  ].emplace_back(ptr);
      }
      ptr++;
    }
    else {
      int dist = -vec[i];
      int u = rec.back(), v = rec[rec.size() - 1 - dist];
      deg[u]++; deg[v]++;
      ans[u].emplace_back(v);
      ans[v].emplace_back(u);
    }

    // remove tails
    while(rec.size()) {
      int p = rec.back();
      if(deg[p] == tar[p]) rec.pop_back();
      else break;
    }
  }

  int N = ans.size();
  for(int i=1; i<N; i++) {
    sort(ans[i].begin(), ans[i].end());
    cout << i;
    for(auto e : ans[i]) cout << " " << e;
    cout << endl;
  }
}

int main() {
  int N; cin >> N;
  while(N--) solve();
}



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

int main () {
    int a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;

    if (k <= a) {
        ans = k;
    }
    else {
        ans = a;
        k -= a;
        if (b < k) {
            ans -= k-b;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int long long 
const int N=1e5+5;
const int INF=1e9+5;
vector<int> dp(N,INF);



int main(){
    int n,k;
    scanf("%d",&n);
    cin>>k;
    int a[n];
    for(int i=0;i<n;i++)
      cin>>a[i];
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
          if(j<n)
             dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
        }
    }

    printf("%d\n",dp[n-1]);  

return 0;
}

Measured memory_bytes: 1024
n = gets.chomp
s = n.size

ans = true
for i in 0..(s-3)/2
  ans = false if n[i] != n[-i-2]
end
ans = false if n[-1] == "1" || n[0] == "0"

if ans
  puts "1 2"
  l = 2
  for i in 1..(s-2)/2
    if n[i] == "0"
      puts "#{l} #{i+2}"
    else
      puts "#{l} #{i+2}"
      l = i+2
    end
  end
  for i in (s-2)/2+3..s
    puts "#{l} #{i}"
  end
else
  puts -1
end

Measured memory_bytes: 3196
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n; readV(n);
  string[] s; readA(n, s);

  writeln(s.canFind("Y") ? "Four" : "Three");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define debug(a) cerr << #a << ": " << a << endl
 
typedef long long ll;
typedef pair<int, int> ii;
 
#define x first
#define y second
 
const int N = 505;

void impossible() {
	cout << "No" << endl;
	exit(EXIT_SUCCESS);
}

int n;
ii x[N];
int a[N * N];

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
 
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> x[i].x;
		x[i].y = i;
	}

	sort(x + 1, x + n + 1);

	int at = 1, tot = n * n;
	for (int i = 1; i <= n; i++) {
		int ends = x[i].x;
		int num = x[i].y;

		for (int j = 1; j <= num - 1; j++) {
			while (at <= tot && a[at] != 0) at++;
			if (at > tot) impossible();
			a[at] = num;
			at++;
		}

		if (at > ends) impossible();
		a[ends] = num;
	}

	queue<int> q;
	x[n + 1].x = tot;

	for (int i = 0; i <= n; i++) {
		if (i > 0)
			for (int j = 1; j <= n - x[i].y; j++)
				q.push(x[i].y);

		for (int j = x[i].x + 1; j <= x[i + 1].x; j++) {
			if (a[j] == 0) {
				if (q.empty()) impossible();
				else {
					a[j] = q.front();
					q.pop();
				}
			}
		}
	}

	cout << "Yes" << endl;
	for (int i = 1; i <= tot; i++) cout << a[i] << " ";
 	
	return 0;
}

Measured memory_bytes: 2688
import math

k = int(input())

s = 0
x = []
for a in range(1,k+1):
    for b in range(1,k+1):
        x.append(math.gcd(a,b))
for y in x:
    for c in range(1,k+1):
        s+=math.gcd(y,c)
print(s)

Measured memory_bytes: 9352
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/



int main() {
string S;
cin>>S;
map<char,int> map;
rep(i,S.size()){
    map[S[i]]++;
}
int N=S.size();
if((map['a']>=N/3)&&(map['a']<=N/3+1)&&(map['b']>=N/3)&&(map['b']<=N/3+1)&&(map['c']<=N/3+1)&&(map['c']>=N/3)){
    cout<<"YES"<<endl;
}
else{
    cout<<"NO"<<endl;
}

return 0;
}


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

int main() {
  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 << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,m; cin >> n >> m;
  int ans=0;
  for(int i=1;i<=sqrt(m);i++){
    if(m%i==0){
      if(i>=n) chmax(ans,m/i);
      else if(m/i>=n) chmax(ans,i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<int> w(n);
    for (int i = 0; i < n; i++){
      cin >> w[i];
    }
    vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
    for (int d = 1; d <= n; d++){
      for (int i = 0; i <= n - d; i++){
        int j = i + d;
        if (d % 2 == 1){
          for (int k = i; k <= j; k++){
            dp[i][j] = max(dp[i][j], dp[i][k] + dp[k][j]);
          }
        } else {
          for (int k = i; k <= j; k++){
            dp[i][j] = max(dp[i][j], dp[i][k] + dp[k][j]);
          }
          if (abs(w[j - 1] - w[i]) <= 1 && dp[i + 1][j - 1] == j - i - 2){
            dp[i][j] = max(dp[i][j], dp[i + 1][j - 1] + 2);
          }
        }
      }
    }
    cout << dp[0][n] << endl;
  }
}


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

using namespace std;

int main() {
	string O, E;
	cin >> O >> E;

	if (O.size() == E.size()) {
		for (int i = 0;i < O.size();i++) {
			cout << O[i] << E[i];
		}
	}
	else {
		int counter = 0;
		for (int i = 0;i < E.size();i++ ){
			cout << O[i] << E[i];
			counter++;
		}
		cout << O[counter];
	}
	cout << endl;
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let a = scan.readn::<i64>(n);
    let mut b = scan.readn::<i64>(n);
    let mut ret = 0;
    let mut mask = 0;
    for k in 0..29 {
        mask |= 1 << k;
        let mut p = 0;
        b.sort_by_key(|&x| x & mask);
        let t = 1 << k;
        for i in 0..n {
            let ai = a[i] & mask;
            p += binary_search(&b, |&b| ai + (b & mask) >= 2*t) as i64 - binary_search(&b, |&b| ai + (b & mask) >= t) as i64;
            p += n as i64 - binary_search(&b, |&b| ai + (b & mask) >= 3*t) as i64;
            p %= 2;
        }
        ret += p * t;
    }
    println!("{}", ret);
}

#[allow(dead_code)]
fn binary_search<T, F>(arr: &[T], f: F) -> usize where F: Fn(&T) -> bool {
    let mut ok = arr.len() as i64;
    let mut ng = -1i64;
    while (ok - ng).abs() > 1 {
        let mid = (ok + ng) / 2;
        if f(&arr[mid as usize]) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    ok as usize
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(a[0] < 9 && a[1] < 9 ? "Yay!" : ":(");
        }
    }
}



Measured memory_bytes: 13268
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MN 2000
#define INF 0x7fffffff
#define sort std::sort
#define min std::min
#define max std::max
int n,k,q,ans=INF,st,ed,l;
int a[MN+5],b[MN+5],bc,c[MN+5],p[MN+5];
bool e[MN+5],f=false;
bool cmp1(int x,int y){return a[x]<a[y];}
int main(){
	memset(e,true,sizeof(e));
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		p[i]=i;
	}
	sort(p+1,p+1+n,cmp1);
	ans=a[p[q]]-a[p[1]];
	for(int i=1;i<=n;i++){
		e[p[i]]=false;
		st=1; bc=0;
		for(int j=1;j<=n;j++){
			if(!e[j]){
				ed=j-1; l=ed-st+1;
				if(l>=k){
					for(int i=st;i<=ed;i++)
						c[i-st+1]=a[i];
					sort(c+1,c+1+l);
					for(int i=1;i<=l-k+1;i++)
						b[++bc]=c[i];
				}
				st=j+1;
			}
		}
		ed=n; l=ed-st+1;
		if(l>=k){
			for(int i=st;i<=ed;i++)
				c[i-st+1]=a[i];
			sort(c+1,c+1+l);
			for(int i=1;i<=l-k+1;i++)
				b[++bc]=c[i];
		}
		if(bc<q)break;
		sort(b+1,b+1+bc);
		ans=min(ans,b[q]-b[1]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str1,str2;
  
  cin >> str1 >> str2;
  
  int counter = 0;
  
  for(int i=0;i<3;i++){
    if(str1.at(i) == str2.at(i)) counter++;
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define MOD 1000000007
#define LL long long int

int N, dp[MAXN + 3][2], answer;
vector<int> adj[MAXN + 3];

int color(int parent, int u, int c) {
    if (dp[u][c] != -1)
        return dp[u][c];

    LL result = 1;
    for (int i = 0; i < adj[u].size(); i++) {
        int v = adj[u][i];

        if (v == parent)
            continue;

        if (c == 0)
            result = (result * (color(u, v, 0) + color(u, v, 1)))%MOD;
        else
            result = (result * color(u, v, 0))%MOD;
    }

    return dp[u][c] = result;
}

int main() {
    cin >> N;
    for (int i = 1; i < N; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    memset(dp, -1, sizeof(dp));

    answer = (color(1, 1, 0) + color(1, 1, 1))%MOD;

    cout << answer << endl;
}


Measured memory_bytes: 14848
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N,x = map(int, input().split())
    vec =list(map(int, input().split())) 
    vec.sort()
    SUM = 0
    i = 0
    for p in range(N):
        SUM += vec[p]


        # print(SUM)
        if(SUM > x):
            break
        
        i += 1

    if(x > sum(vec)):
        i -= 1
    print(i)
        
if __name__ == '__main__':
    solve()


Measured memory_bytes: 3940
n=int(input())
a=list(map(int,input().split()))
a.sort()
if sum(a)==0:
    print('Yes')
    exit()
x=[0]*3
x[0] = a.count(a[0])
x[1] = a.count(a[n//2])
x[2] = a.count(a[-1])
x.sort()

if a[0]^a[n//2] == a[-1] and x[0] == x[1] == x[2] == n//3:
    print('Yes')
elif a[0] == 0 and x[0] == n//3 and x[1] == x[2] == n*2//3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 60784
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b>=c)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
 } 

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

N, K = map(int, input().split())
L = [v for v in input().split()]

for n in range(N, 200000):
    s = list(str(n))
    
    f = False
    for c in s:
        if c in L:
            f = True
    if f:
        continue
            
    print("".join(s))
    exit()

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
main() {
    vector<pair<int, int>> xss;
    for(int i=1; i<=5; ++i) {
        int dish; cin>>dish;
        int wait= (10-dish%10)%10;
        xss.push_back({wait, dish});
    }
    sort(xss.begin(), xss.end());
    int time=0;
    for(auto xs:xss) {
        time= (time+9) /10*10;
        int dish= xs.second;
        time+= dish;
    }
    cout<<time<<endl;
}

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

using namespace std;

const int maxx = 2e5 + 20;

int n, x, w[maxx];
set<int> s;

int main()
{
	fill(w, w + maxx, -1);
	cin >> n >> x;
	for(int i = 1; i < n + n; i++) s.insert(i);
	if (x == 1 || x == n + n - 1) return cout << "No" << endl, 0;
	cout << "Yes" << endl;
	if (n == 2) return cout << 1 << endl << 2 << endl << 3 << endl, 0;
	if (x == 2)
	{
		w[n-1] = x; s.erase(x);
		w[n-2] = x+1; s.erase(x+1);
		w[n] = x-1; s.erase(x-1);
		w[n+1] = x+2; s.erase(x+2);
	}
	else
	{
		w[n-1] = x; s.erase(x);
		w[n-2] = x-1; s.erase(x-1);
		w[n] = x+1; s.erase(x+1);
		w[n+1] = x-2; s.erase(x-2);	
	}
	for(int i = 0; i < n + n - 1; i++)
	{
		if (w[i] != -1) continue;
		w[i] = *s.begin();
		s.erase(s.begin());
	}
	for(int i = 0; i < n + n - 1; i++)
		cout << w[i] << endl;
	return 0;
}

Measured memory_bytes: 11648
from collections import deque

def main():
    n, q = list(map(int, input().split(" ")))
    v_list = [[] for i in range(n)]
    for _ in range(n-1):
        a, b = list(map(int, input().split(" ")))
        v_list[a-1].append(b-1)
        v_list[b-1].append(a-1)

    p_x_list = [0]*n
    for _ in range(q):
        p, x = list(map(int, input().split(" ")))
        p_x_list[p-1]+=x

    point_list = [0]*n
    checked_list = [0]*n
    stack = deque([0]) 
    while stack:
        cur = stack.pop()
        checked_list[cur] = 1
        point_list[cur]+=p_x_list[cur]
        for next_i in v_list[cur]:
            if checked_list[next_i]:
                continue
            stack.append(next_i)
            point_list[next_i]+=point_list[cur]
   
    print(*point_list)

if __name__=="__main__":
    main()


Measured memory_bytes: 62864
#include<bits/stdc++.h>
using namespace std;
#define itn int

int main(void){
    int n;
    cin >> n;
    int a[n],b[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    
    sort(b,b+n,greater<itn>());
    for(int i = 0;i < n;i++){
        if(b[0] == a[i])cout << b[1] << endl;
        else cout << b[0] << endl;
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std; 
#define loop for(int i=0;i<n;i++)
const int N=100020;
vector<int> adj[N];
int visited[N];
int n;
vector<int> ans[N];
int32_t  main()
{
	int n;
	cin>>n;
	set<string> st;
	while(n--)
	{
		string k;
		cin>>k;
		st.insert(k);
	}
	cout<<st.size();
}



	


Measured memory_bytes: 23952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m);
    for(int i = 0; i < m; i++) {
        cin >> k[i];
        s[i].resize(k[i]);
        for(int j = 0; j < k[i]; j++){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    vector<int> p(m);
    for(int i = 0; i < m; i++) cin >> p[i];
    ll ans = 0;
    for(int bit = 0; bit < (1<<n); bit++) {
        bool f = true;
        for(int i = 0; i < m; i++) {
            int cnt = 0;
            for(int j = 0; j < k[i]; j++) {
                if(bit & (1<<s[i][j])) cnt++;
            }
            if(cnt % 2 != p[i]) f = false; 
        }
        if(f) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll S[1<<18];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,1<<N) cin>>S[i];
	sort(S,S+(1<<N));
	int M=(1<<N)-1;
	multiset<int> T;
	FOR(i,M) T.insert(S[i]);
	
	vector<int> V;
	V.push_back(S[M]);
	FOR(i,N) {
		vector<int> W=V;
		
		FORR(v,V) {
			auto it=T.lower_bound(v);
			if(it==T.begin()) return _P("No\n");
			it--;
			W.push_back(*it);
			T.erase(it);
		}
		
		sort(ALL(W));
		reverse(ALL(W));
		swap(V,W);
	}
	_P("Yes\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	bool a = false;
	for (int i = 0; i < s.size(); ++i) {
		if (s == t) {
			a = true;
		}
		s.insert(s.begin(), s.back());
		s.pop_back();
	}
		if (a == true) {
			cout << "Yes" << endl;
			
		}
		else{
			cout << "No" << endl;
		}
	return 0;
}

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

using namespace std;

int INF=1e9;

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

    int a,b,c;
    cin>>a>>b>>c;

    int ans=0;

    if(a%2==1 || b%2==1 || c%2==1)ans=0;
    else if(a==b&&b==c)ans=-1;
    else{
        while(a%2!=1 && b%2!=1 && c%2!= 1){
            long long na=(b+c)/2,nb=(a+c)/2,nc=(a+b)/2;
            a=na;b=nb;c=nc;
            ans++;
        }
    }

    cout<<ans<<endl;

}

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

#define rep(i, n) for(int i = 0; i < n; ++i)
const int max_v = 10100;
const int max_e = 505000;
const int inf = 0x3fffffff;

typedef pair<int, int> P;

typedef struct edge {
    int to, dist;
    edge():to(0),dist(0) {}
    edge(int _to, int _dist):to(_to),dist(_dist) {}
    bool operator < (const edge & o) const {
	return dist > o.dist;
    }
}edge;

struct graph {
    int V, E;
    int d[max_v], prev[max_v];
    bool vis[max_v];
    vector<edge> G[max_v];
    graph():V(0),E(0) {}

    graph(int _V):V(_V),E(0) {}

    graph(int _V, int _E, int ed[][3], bool bidirect):V(_V),E(_E) {
	rep(i, E) {
	    int u = ed[i][0], v = ed[i][1], dist = ed[i][2];
	    G[u].push_back(edge(v, dist));
	    if (bidirect) G[v].push_back(edge(v, dist));
	}
    }
    graph(int _V, int g[][max_v]) {
	V = _V; E = 0;
	rep(i, V) rep(j, V)
	    if (g[i][j] != inf) {
		G[i].push_back(edge(j, g[i][j]));
		++E;
	    }
    }

    void add_edge(int u, int v, int c) {
	G[u].push_back(edge(v, c));
    }

    void output() {
	rep(i, V) {
	    printf("[%d] ", i);
	    rep(j, G[i].size()) {
		printf("(%d %d) ", G[i][j].to, G[i][j].dist);
	    }
	    putchar('\n');
	}
    }

    void dijkstra(int g[][max_v], int s) {
	rep(i, V) d[i] = inf;
	rep(i, V) prev[i] = -1;
	rep(i, V) vis[i] = false;

	d[s] = 0;
	rep(i, V) {
	    int tmp = inf;
	    int u = -1;
	    rep(j, V) {
		if(!vis[j] && d[j] < tmp) {
		    tmp = d[j];
		    u = j;
		}
	    }
	    vis[u] = true;
	    rep(j, V) {
		if(!vis[j] && d[u] + g[u][j] < d[j]) {
		    d[j] = d[u] + g[u][j];
		    prev[j] = u;
		}
	    }
	}
    }

    void dijkstra(int s) {
	rep(i, V) d[i] = inf;
	rep(i, V) prev[i] = -1;
	rep(i, V) vis[i] = false;
	
	priority_queue<edge> pq;
	pq.push(edge(s, 0));
	d[s] = 0;

	while(! pq.empty()) {
	    edge e = pq.top(); pq.pop();
	    if(e.dist > d[e.to]) continue;
	    d[e.to] = e.dist;
	    vis[e.to] = true;
	    
	    rep(j, G[e.to].size()) {
		int v = G[e.to][j].to;
		int dist = G[e.to][j].dist;

		if(!vis[v] && d[e.to] + dist < d[v]) {
		    d[v] = d[e.to] + dist;
		    prev[v] = e.to;
		    pq.push(edge(v, d[v]));
		}
	    }
	}
    }
};

int N, M;

void solve() {
    int u, k, v, c;
    scanf("%d", &N);
    graph g = graph(N);
    rep(i, N) {
	scanf("%d%d", &u, &k);
	rep(j, k) {
	    scanf("%d%d", &v, &c);
	    g.add_edge(u, v, c);
	}
    }
    g.dijkstra(0);
    rep(i, N) {
	printf("%d %d\n", i, g.d[i]);
    }
}

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

Measured memory_bytes: 1504
#include <queue>
#include <vector>
#include <iostream>

#define INF (1 << 25)

using namespace std;

vector<vector<vector<vector<int> > > > dp;

vector<vector<int> > M;

int H, W, sx1, sy1, sx2, sy2;

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

int bfs()
{
	dp = vector<vector<vector<vector<int> > > >(H, vector<vector<vector<int> > >(W, vector<vector<int> >(H, vector<int>(W, INF)))); dp[sy1][sx1][sy2][sx2] = 0;

	queue<pair<pair<pair<int, int>, pair<int, int> >, int> > que; que.push(make_pair(make_pair(make_pair(sx1, sy1), make_pair(sx2, sy2)), 0));

 	while (!que.empty())
	{
		int x1 = que.front().first.first.first;
		int y1 = que.front().first.first.second;
		int x2 = que.front().first.second.first;
		int y2 = que.front().first.second.second;

		int turn = que.front().second;

		que.pop();

		for (int dir = 0; dir < 4; dir++)
		{
			int tx1 = x1 + dx[dir]; if (tx1 < 0 || tx1 >= W) { tx1 -= dx[dir]; }
			int ty1 = y1 + dy[dir]; if (ty1 < 0 || ty1 >= H) { ty1 -= dy[dir]; }
			int tx2 = x2 - dx[dir]; if (tx2 < 0 || tx2 >= W) { tx2 += dx[dir]; }
			int ty2 = y2 - dy[dir]; if (ty2 < 0 || ty2 >= H) { ty2 += dy[dir]; }

			if (M[ty1][tx1] == 1) { tx1 -= dx[dir]; ty1 -= dy[dir]; }
			if (M[ty2][tx2] == 1) { tx2 += dx[dir]; ty2 += dy[dir]; }

			if (tx1 == tx2 && ty1 == ty2) { return turn + 1; }

			if (dp[ty1][tx1][ty2][tx2] == INF)
			{
				dp[ty1][tx1][ty2][tx2] = turn + 1;

				que.push(make_pair(make_pair(make_pair(tx1, ty1), make_pair(tx2, ty2)), turn + 1));
			}
		}
	}

	return -1;
}

int main()
{
	while (true)
	{
		cin >> W >> H;

		if (H == 0 && W == 0) { break; }

		M = vector<vector<int> >(H, vector<int>(W));

		cin >> sx1 >> sy1 >> sx2 >> sy2;

		sx1--; sy1--; sx2--; sy2--;

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> M[i][j];
			}
		}

		int Ans = bfs();

		if (Ans == -1)
		{
			cout << "NA" << endl;
		}
		else
		{
			cout << Ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 60400
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

  long long N, K;
  cin >> N >> K;
  vector<long long> cnt(1e5 + 1, 0);
  for(int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    cnt[a] += b;
  }

  for(int i = 1; i <= 1e5; i++) {
    if(K <= cnt[i]) {
      cout << i << endl;
      break;
    }
    K -= cnt[i];
  }

  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

vll buglevel(50);
vll patty(50);

ll bug(ll level,ll down){
    if(level==0 && down==1)return 1;
    else if(down<=1)return 0;
    else if(1<down && down<=1+buglevel[level-1])return bug(level-1,down-1);
    else if(down==2+buglevel[level-1])return patty[level-1]+1;
    else if(2+buglevel[level-1]<down && down<=2+2*buglevel[level-1]){
        return 1+patty[level-1]+bug(level-1,down-2-buglevel[level-1]);
    }
    else return 2*patty[level-1]+1;
}

int main(){
    ll n,x;
    cin>>n>>x;
    buglevel[0]=1;patty[0]=1;
    rep(i,n)buglevel[i+1]=2*buglevel[i]+3;
    rep(i,n)patty[i+1]=2*patty[i]+1;
    cout<<bug(n,x)<<endl;
    return 0;
}

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

double per(double n){
    if(n == 1) return n;
    return n*per(n-1);
}

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>>p(n);
    for(int i=0;i<n;i++){
        int x, y;
        cin >> x >> y;
        p[i] = {x, y};
    }
    double ans = 0;

    sort(p.begin(), p.end());

    do{
        for(int i=0;i<n;i++){
            if(i){
                ans += sqrt((p[i].first-p[i-1].first)*(p[i].first-p[i-1].first)+(p[i].second-p[i-1].second)*(p[i].second-p[i-1].second));
            }
        }
    }while(next_permutation(p.begin(), p.end()));

    ans /= per((double)n);
    printf("%.9lf\n", ans);

}

Measured memory_bytes: 3760
//B - Iroha Loves Strings (ABC Edition) 
#include<bits/stdc++.h>
using namespace std;


int main()
{
    multiset<string> m;
    int n,l;
    string s;
    cin>>n>>l;
    for(int i=0;i<n;i++)
    {
	cin>>s;
	m.insert(s);
    }

    for(auto x : m)
	cout<<x;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = list(str(input()))

point = {}
point["r"] = p
point["s"] = r
point["p"] = s

ans = 0
for i in range(k):
    j = 1
    count = 1
    letter = t[0+i]
    # print(letter)
    while(1):
        if j*k+i >= len(t):
            break

        letter_next = t[j*k+i]
        if letter == letter_next:
            count += 1
        else:
            # print((count+1//2)*point[letter])
            # print(count)
            ans += ((count+1)//2)*point[letter]
            count = 1
        letter = letter_next
        # print(letter)
        j += 1
    # print((count+1//2)*point[letter])
    # print(count)
    # print()
    ans += ((count+1)//2)*point[letter]

print(ans)


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int MX = 2005;
bool d[3][3][MX];
 
int main() {
  vector<string> s(3);
  rep(i,3) cin >> s[i];
  sort(s.begin(),s.end());
  int ans = MX*3;
  do {
    rep(i,3)rep(j,3)rep(k,s[i].size()) {
      if (i >= j) continue;
      bool ok = true;
      for (int ni = k; ni < s[i].size(); ni++) {
        int nj = ni-k;
        if (nj >= s[j].size()) break;
        if (s[i][ni] == '?' || s[j][nj] == '?') continue;
        if (s[i][ni] != s[j][nj]) ok = false;
      }
      d[i][j][k] = ok;
    }
 
    auto f = [&](int i, int j, int k) {
      if (k >= s[i].size()) return true;
      return d[i][j][k];
    };
 
    rep(x,MX)rep(y,MX) {
      if (!f(0,1,x)) continue;
      if (!f(1,2,y)) continue;
      if (!f(0,2,x+y)) continue;
      int now = 0;
      now = max<int>(now, s[0].size());
      now = max<int>(now, x+s[1].size());
      now = max<int>(now, x+y+s[2].size());
      ans = min(ans, now);
    }
  } while (next_permutation(s.begin(), s.end()));
  cout << ans << endl;
  return 0;
}

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


float calc_sum (int num){
    if (num%2 == 0) {
        return (num+1)*(num/2);
    } else {
        return (num+1)*(num/2)+num/2+1;
    }
}

int main() {

    int n,k;

    cin >> n >> k;

    vector<long double> p(n);

    int tmp;

    for (int i =0;i<n;i++){
        cin >> tmp;

        long double s = calc_sum(tmp);

        p.at(i) = s/tmp;
    }
  	
    
    long double now_max = 0;
    long double now = 0;
    int index =0;

    for (int i=0;i<(n-k);i++){
        now += p.at(i+k);
        now -= p.at(i);
        if (now > now_max){
            now_max = now;
            index = i+1;
        }
    }

    long double ans = 0;
    for (int j=0;j<k;j++){
        ans += p.at(index+j);
    }


    cout <<setprecision(10)<< ans << endl;
    //printf("%.10f", ans);

}

Measured memory_bytes: 3328
<?php
$N = trim(fgets(STDIN));
$a = array_map('intval', explode(" ", trim(fgets(STDIN))));
$alice = 0;
$bob = 0;
$cnt = 0;

rsort($a);
foreach ($a as $i) {
    if ($cnt%2 == 0) {
        $alice += $i;
    }else {
        $bob +=$i;
    }
    $cnt ++;
}
echo $alice-$bob;

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

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

int main(){
    ll x,y;
    cin >> x >> y;
    
    cout << return_gcd(x, y) << endl;
}




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

int main()
{
    int P,Q,R,t[5];
    scanf("%d%d%d",&t[0],&t[1],&t[2]);
    sort(t,t+3);
    printf("%d\n",t[0]+t[1]);
return 0;
}

Measured memory_bytes: 256
#include<cstdio>

const int MAX_N = 200000;
int x[MAX_N];
long long sum_x[MAX_N+1];

int main() {
	long long N, X;
	scanf("%lld %lld", &N, &X);
	sum_x[0] = 0;
	for(int i=0;i<N;i++) {
		scanf("%d", &x[i]);
		sum_x[i+1] = sum_x[i] + x[i];
	}
	unsigned long long m = sum_x[N] * 5 + 2 * N * X;
	for(int k=1;k<=(N+1)/2;k++) {
		unsigned long long t = sum_x[N] + (k + N) * X;
		for(int i=0;i<=N/k;i++) {
			t += 2 * sum_x[N%k + i * k];
		}
		t += 2 * (sum_x[N] - sum_x[N - k]);
		if(m > t) m = t;
	}
	printf("%lld\n", m);
	return 0;
}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    string s;
    string key = "keyence";
    cin >> s;
    int n = (int) s.size();

    bool pos = false;
    string part1, part2;
    int atp1 = 0, atp2 = 0;

    while ( atp1 < 7 and s[atp1] == key[atp1] ) {
        atp1++;
    }
    while ( atp2 < 7 and s[n - 1 - atp2] == key[7 - 1 - atp2] ) {
        atp2++;
    }
    if ( atp1 + atp2 >= 7 ) pos = true;

    cout << (pos ? "YES\n" : "NO\n");

    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if(a > 0) cout << "Positive" << endl;
    else if(b >= 0) cout << "Zero" << endl;
    else if((b - a) % 2 == 1) cout << "Positive" << endl;
    else cout << "Negative" << endl;
}

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

int main(){
  int N;
  cin>>N;
  for (int i=0;i<N;i++){
    string x;
    cin>>x;
    if (x=="Y"){
      cout<<"Four"<<endl;
      break;
    }
    if (i==N-1){
      cout<<"Three"<<endl;
    }
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

int gcd3(int A, int B) {
	if (B == 0) return A;
	else return gcd3(B, A % B);
}
ll gcd2(ll A, ll B) {
	if (B == 0) return A;
	ll k = A - ll(double(A) / B) * B;
	if (B < 2e9) return gcd3(B, k);
	else return gcd2(B, k);
}
ll gcd(ll A, ll B) {
	if (B == 0) return A;
	if (B < 2e9) return gcd3(B, A % B);
	if (B < 2e15) return gcd2(B, A % B);
	else return gcd(B, A % B);
}

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


	int N;
	cin >> N;
	pair<ll, ll> AB[200200], BA[200200];
	int a0 = 0, b0 = 0;
	int ab00 = 0;
	int ka = 0, kb = 0;
	rep(i, N) {
		ll a, b;
		cin >> a >> b;

		if (a == 0 && b == 0) {
			ab00++;
			continue;
		}
		if (a == 0) {
			a0++;
			continue;
		}
		if (b == 0) {
			b0++;
			continue;
		}

		ll G = gcd(abs(a), abs(b));
		a /= G;
		b /= G;
		if (a < 0) {
			a = -a;
			b = -b;
		}
		if (b > 0) AB[ka++] = { a,b };
		else BA[kb++] = { -b,a };
	}

	ll kotae = 1;
	sort(AB, AB + ka);
	sort(BA, BA + kb);
	BA[kb] = { 2e18, 2e18 };

	pair<ll, ll> mae = AB[0];
	int p = 0;
	int kA = 0;
	rep(i, ka) {
		ll a = AB[i].first;
		ll b = AB[i].second;
		if (mae != AB[i]) {
			int tmp = 0;

			pair<ll, ll> mae2 = BA[p];
			int kB = 0;
			while (p < kb && BA[p] <= mae) {
				if (mae2 != BA[p]) {
					kotae = kotae * modpow(2, kB) % mod;
					mae2 = BA[p];
					kB = 1;
				}
				else kB++;
				p++;
			}

			if (mae == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}

			if (tmp) {
				kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
			}
			else {
				kotae = kotae * modpow(2, kA) % mod;
			}

			mae = AB[i];
			kA = 1;
		}
		else kA++;
	}

	int tmp = 0;
	pair<ll, ll> mae2 = BA[p];
	int kB = 0;
	while (p < kb) {
		if (mae2 != BA[p]) {
			if (AB[ka - 1] == mae2) {
				tmp = kB;
			}
			else {
				kotae = kotae * modpow(2, kB) % mod;
			}
			mae2 = BA[p];
			kB = 1;
		}
		else kB++;
		p++;
	}

	if (AB[ka - 1] == mae2) {
		tmp = kB;
	}
	else {
		kotae = kotae * modpow(2, kB) % mod;
	}

	if (tmp) {
		kotae = kotae * (modpow(2, kA) + modpow(2, kB) - 1) % mod;
	}
	else {
		kotae = kotae * modpow(2, kA) % mod;
	}

	kotae = kotae * (modpow(2, a0) + modpow(2, b0) - 1) % mod;

	co((kotae - 1 + ab00 + 2 * mod) % mod);

	Would you please return 0;
}

Measured memory_bytes: 9912
#include <bits/stdc++.h>
#include <string>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define vi std::vector<int>
#define pi std::pair<int, int>
#define mp std::make_pair
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
#define Yes std::cout << "Yes" << std::endl
#define No std::cout << "No" << std::endl
#define YES std::cout << "YES" << std::endl
#define NO std::cout << "NO" << std::endl
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy8[8] = {0, 1, 0, -1, 1, -1, 1, -1};
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
unsigned long long modpow(int x__, int n__, long long mod__);
template <typename T> void debug(const T& t);
constexpr ll mod10_9p7 = 1000000000 + 7;

/**************************************************************/
int main()
{
    stat();
    int a,b,c;
    cin>>a>>b>>c;
    rep(i,10000){
	    if((a*i)%b==c){
YES;return 0;
	    }
    }
    NO;
    return 0;
}
/**************************************************************/
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

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

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}

unsigned long long modpow(int x__, int n__, long long mod__)
{
    long long ret__ = 1;
    for (long long i__ = 0; i__ < n__; ++i__) {
        ret__ = ret__ * x__ % mod__;
    }
    return ret__;
}

template <typename T> void debug(const T& t)
{
#ifdef local
    dbg(t);
#endif
}


Measured memory_bytes: 3628
N, x = map(int,input().split())
A = sorted(list(map(int, input().split())))
ans = 0
su = 0
for i, A_i in enumerate(A):
	if su + A_i <= x:
		ans = i + 1
		su += A_i
	else:
		break
if sum(A) < x:
	ans -= 1
print(max(0, ans))

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

int main(){
  double a,d;
  ll b,c,i,ans;
  ans=2;
  cin >> a;
  b=floor(a/1.08);
  for(i=0;i<=1;i++){
    c=b+i;
    d=floor(c*1.08);
    if(d==a)ans=i;
  }
  if(ans==2)cout << ":(";
  else cout << ans+b;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main () {
    int n;
    cin >> n;
    vector <int> x(n);
    vector <int> y(n);
    rep(i,0,n) {
        cin >> x[i] >> y[i];
    }
    double sum = 0;
    rep (i, 0,n) {
        rep(j, 0, n) {
            if (i ==j) continue;
            int b= pow(x[i]-x[j],2)+ pow(y[i]-y[j],2);
            sum += sqrt(b);
        }
    }
    int c= 1;
    rep (i,1,n+1){
        c *=i;
    };
    cout << setprecision(14) << (sum / n) << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define WHITE 0
#define BLACK 1
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

const int INF = 1 << 30;

vector<int> graph[222];

template <class T>
class WarshallFloyd {
    private:
        T identity;
        vector<vector<T> > dist;
    public:
        WarshallFloyd(int node_num, T _identity):
        identity(_identity), dist(vector<vector<T> >(node_num, vector<T>(node_num, _identity))) {}
        void add_edge(int from, int to, T cost) {
            dist[from][to] = cost;
        }
        void calc_shortest_path() {
            int n = (int)dist.size();
            for (int k = 0; k < n; k++) {
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        if (dist[i][k] == identity || dist[k][j] == identity) continue;
                        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                    }
                }
            }
        }
        T get_dist(int from, int to) {
            return dist[from][to];
        }
};

bool dfs(int node, int color, vector<int>& colors) {
    colors[node] = color;
    bool res = true;
    rep(i, 0, graph[node].size()) {
        int next_node = graph[node][i];
        if (colors[next_node] < 0) {
            res &= dfs(next_node, color ^ 1, colors);
        }
        else {
            if (colors[next_node] != (color ^ 1)) {
                return false;
            }
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, 0, N) cin >> S[i];
    WarshallFloyd<int> warshall(N, INF);
    rep(i, 0, N) rep(j, i + 1, N) {
        if (S[i][j] == '1') {
            graph[i].push_back(j);
            graph[j].push_back(i);
            warshall.add_edge(i, j, 1);
            warshall.add_edge(j, i, 1);
        }
    }
    vector<int> color(N, -1);
    if (!dfs(0, WHITE, color)) {
        cout << -1 << endl;
        return 0;
    }
    warshall.calc_shortest_path();
    int max_dist = -INF;
    rep(i, 0, N) rep(j, i + 1, N) {
        max_dist = max(max_dist, warshall.get_dist(i, j));
    }
    cout << max_dist + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void) {
	int E, Y;
	scanf("%d %d", &E, &Y);
	switch (E) {
	case 0:
			if (1868 <= Y&&Y <= 1911) {
				printf("M%d\n", Y - 1867);
			}
			else if (1912 <= Y&&Y <= 1925) {
				printf("T%d\n", Y - 1911);
			}
			else if (1926 <= Y&&Y <= 1988) {
				printf("S%d\n", Y - 1925);
			}
			else {
				printf("H%d\n", Y - 1988);
			}
			break;
	case 1:
		if (1 <= Y&&Y <= 44) {
			printf("%d\n", Y + 1867);
		}
			break;
	case 2:
		if (1 <= Y&&Y <= 14) {
			printf("%d\n", Y + 1911);
		}
		break;
	case 3:
		if (1 <= Y&&Y <= 63) {
			printf("%d\n", Y + 1925);
		}
			break;
	case 4:
		if (1 <= Y) {
			printf("%d\n", Y + 1988);
		}
		break;
	}
	return 0;
}


Measured memory_bytes: 2104
import sys
N,Y=map(int,input().split())
for i in range(N+1):
  for j in range(N+1-i):
    if i+j>N:
      continue
    if i*10000+j*5000+(N-i-j)*1000==Y:
      print(i,j,N-i-j)
      sys.exit()
print(-1,-1,-1)


Measured memory_bytes: 9088
#include <stdio.h>

int main(void){

	int n,a[100],i;

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

	for(i=n-1; i!=-1; i--){
		printf("%d",a[i]);
		if(i != 0){
			printf(" ");
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 1028