akhauriyash/Code-Regression huggingface dataset:
<?php  
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $cnt=[];
  for($i=0;$i<$n;$i++){
    if(!isset($cnt[$a[$i]])) $cnt[$a[$i]]=0;
    $cnt[$a[$i]]++;
  }
  $ans = 0;
  foreach($cnt as $key => $value){
    if($value >= $key){
      $ans += $value-$key;
    }else{
      $ans += $value;
    }
  }
  echo $ans;

Measured memory_bytes: 28612
#include <stdio.h>
#include <queue>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
using namespace std;
char s[505][15];
struct edge{
    int v,next;
}e[10000];
int head[30];
int en;
void add(int u,int v)
{
    e[en].v=v;
    e[en].next=head[u];
    head[u]=en++;
}
bool vis[30];
bool dfs(int u)
{
    vis[u]=true;
    for(int i=head[u];i!=-1;i=e[i].next)
    {
        int v = e[i].v;
        if(vis[v])return true;
        if(dfs(v))return true;
    }
    vis[u]=false;
    return false;
}
bool has[30][30];
int main()
{
    //freopen("a.txt","r",stdin);
    int n;
    while(~scanf("%d",&n)&&n)
    {
        if(n==1)
        {
            char ss[15];
            scanf("%s",ss);
            printf("yes\n");
            continue;
        }
        int len=0;
        memset(s,0,sizeof(s));
        memset(head,-1,sizeof(head));
        en=0;
        for(int i=0;i<n;++i){
            scanf("%s",s[i]);
            len=max(len,(int)strlen(s[i]));
        }
        int same[2][505];
        bool flag = true;
        memset(has,false,sizeof(has));
        memset(same,0,sizeof(same));
        for(int i=0;i<len;++i)
        {
            int q=i&1;
            int now = 0;
            for(int j=1;j<n;++j)
            {
                if(same[q^1][j-1]==same[q^1][j])
                {
                    int a = s[j-1][i] - 'a';
                    int b = s[j][i] - 'a';

                    if(b<0&&a>=0){
                        flag=false;
                        same[q][j]=++now;
                    }
                    else if(a<0&&b<0){
                        same[q][j]=same[q][j-1];
                    }
                    else if(a<0&&b>=0)
                    {
                        same[q][j]=++now;
                    }
                    else if(a==b){
                        same[q][j]=same[q][j-1];
                    }
                    else{
                        if(!has[a][b])
                        {
                            has[a][b]=true;
                            add(a,b);
                        }
                        same[q][j]=++now;
                    }
                }
                else same[q][j]=++now;
            }
        }
        for(int i=0;i<26;++i){
            memset(vis,false,sizeof(vis));
            if(dfs(i))
            {
                flag=false;
                break;
            }
        }
        if(!flag)printf("no\n");
        else printf("yes\n");
    }
    return 0;
}

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

int main() {
  string a;
  cin>>a;
  
  if(a.at(0)==a.at(1)&&a.at(0)==a.at(2)){
    cout<<"Yes"<<endl;
  }
  else if(a.at(1)==a.at(2)&&a.at(2)==a.at(3)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl; //NO→No 条件の大文字小文字に注意。
  }
    
}





Measured memory_bytes: 256
#17:31
n = int(input())
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b,c = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append([b,c])
  peer[b].append([a,c])
q,k = map(int,input().split())
k -= 1
now = [k]
seen = [0 for _ in range(n)]
way = [0 for _ in range(n)]
seen[k] = 1
while now:
  last = now
  now = []
  for x in last:
    for yc in peer[x]:
      y,c = yc
      if seen[y] == 0:
        seen[y] = 1
        way[y] = way[x] + c
        now.append(y)
#print(way)
for _ in range(q):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  print(way[a]+way[b])

Measured memory_bytes: 92576
#include <stdio.h>

int main(void){
	int i;
	int num[12];
	double total, rate, sum;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
			 &num[0],&num[1], &num[2], &num[3], &num[4], &num[5],
			 &num[6], &num[7], &num[8], &num[9], &num[10], &num[11]) != EOF){
		sum = 0;
		for(i = 0; i < 10; i++)
			sum += num[i];
		rate = num[10]/(double)(num[10] + num[11]);
		total = sum * rate;
		sum = 0;
		for(i = 0; i < 10; i++){
			if( sum < total && total < sum + num[i]){
				printf("%d\n", i + 1);
			}else if(sum == total){
				printf("%d\n", i);
			}
			sum += num[i];
		}
	}
	return (0);
}

Measured memory_bytes: 596
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::vec::Vec;

fn main() {
    let stdin = stdin();
    let mut scan = InputScanner::new(stdin.lock(),256);

    let n:usize = scan.next();

    let ab:Vec<(usize,usize)> = (0..n).map(|_| (scan.next(),scan.next())).collect::<Vec<(usize,usize)>>();
    let mut cd:Vec<(usize,usize)> = (0..n).map(|_| (scan.next(),scan.next())).collect::<Vec<(usize,usize)>>();

	let mut m:Vec<bool> = (0..n).map(|_| false).collect::<Vec<bool>>();

	let mut count = 0;

	cd.sort_by(|a,b| a.0.cmp(&b.0));

	let cd = cd;

	for &(c,d) in &cd {
		let mut max = 0;
		let mut index = None;

		for (i,&(a,b)) in ab.iter().enumerate() {
			if !m[i] && a < c && b < d && max <= b {
				max = b;
				index = Some(i);
			}
		}

		if let Some(i) = index {
			count += 1;
			m[i] = true;
		}
	}

    println!("{}",count);
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define vecin(x,n); vi x;int hool; for(int o=0;o<n;o++) {cin>>hool; x.pb(hool);}
#define vecout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
#define IO freopen("input.txt", "r", stdin); freopen("output.txt", "w+", stdout)
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1)
		{res=(res*a);
		res%=MOD;
		b--;}
        a=(a*a);
        a%=MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	cin>>n;
	cout<<((power(10,n)%MOD-power(9,n)%MOD-power(9,n)%MOD+power(8,n)%MOD)+2*MOD)%MOD;
	
	
	
	
	
	 
}
int32_t main() {
    fast
    //IO;
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

Measured memory_bytes: 3640
import numpy as np

N, W = map(int, input().split())
dp = np.zeros(W+1, int)

for i in range(N):
    w, v = map(int, input().split())
    dp = np.concatenate([dp[:w], np.fmax(dp[w:], dp[:W+1-w]+v)])
    #print(dp)
    
print(dp[-1])
    

Measured memory_bytes: 18264
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = 100100100100;
const int MOD = 1000000007;
const ld EPS = 1e-10;

int main(){
  int N; string S; cin >> N >> S;
  int ans = 0;
  rep(i, N-2) {
    if(S.substr(i, 3) == "ABC") ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ull = unsigned long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vull = vector<ull>;
using vpii = vector<pii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    int N,X;
    cin >>N>>X;
    vi m(N);
    FOR(i,0,N-1) {
        cin >>m[i];
        X-=m[i];
    }
    
    SORT(m);
    cout <<(N+(int)(X/m[0]));

    return 0;
}

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

#define ll long long

using namespace std;

int main(void){
    int N;
    cin >> N;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        int D, E;
        cin >> D >> E;
        if(D == E) cnt++;
        else cnt = 0;
        if(cnt >= 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = n; i <= 1111; ++i){
        if(i%111 == 0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, X;
	cin >> N >> X;
	int least = INF32;
	int ans = N;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		least = min(least, tmp);
		X -= tmp;
	}

	ans += X / least;

	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
// devesha1459 L:cpp
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    
	ll t;
	string str;
	cin>>str;
	int flag=0;
	for(int i=0;i<str.length()/2;i++)
	{
		if(str[i]!=str[str.length()-i-1])
		{
			flag=1;
			break;
		}
	}
	if(flag==0)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
def arr_max(arr)
    max = arr[0]
    arr.each do |a|
        if max < a
            max = a
        end
    end
    max
end

N = gets.to_i
A = Array.new(N , Array.new(3))
N.times do |i|
    A[i] = gets.split.map{|n| n.to_i}
end

dp = Array.new(N + 1).map{Array.new(3)}
dp[0] = [0 , 0 , 0]

N.times do |i|

    dp[i + 1][0] = A[i][0] + ((dp[i][1] > dp[i][2]) ? dp[i][1] : dp[i][2])
    dp[i + 1][1] = A[i][1] + ((dp[i][0] > dp[i][2]) ? dp[i][0] : dp[i][2])
    dp[i + 1][2] = A[i][2] + ((dp[i][0] > dp[i][1]) ? dp[i][0] : dp[i][1])
    
end

puts arr_max(dp[N])

Measured memory_bytes: 14844
n = gets.to_i
ary = []
n.times do
  ary.push(gets.split.map(&:to_i))
end
ary.sort_by!{|a|a[2]}.reverse!

(0..100).each do |i|
  (0..100).each do |j|
    h = (i - ary[0][0]).abs + (j - ary[0][1]).abs + ary[0][2]
    ary.size.times do |k|
      break if !([h - (i - ary[k][0]).abs - (j - ary[k][1]).abs,0].max == ary[k][2])
      puts "#{i} #{j} #{h}"if k == n-1
    end
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    string s;
    cin >> s;

    string t = s;
    int n = s.size();
    bool ok = true;
    rep(i, n){
        if(s[i] != t[n-1-i]){
            ok = false;
        }
    }

    rep(i, n/2){
        if(s[i] != s[n/2-1-i]){
            ok = false;
        }
    }

    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
	string S, P, S_twice;
	bool y_n = false;
	getline(cin,S);
	getline(cin,P);
	S_twice = S + S;
	int lenS, lenP, i;
	lenS = S.length();
	lenP = P.length();
	for(i=0;i<lenS;i++){
		if(strncmp(P.c_str(), S_twice.c_str(), lenP) == 0){
			y_n = true;
		}
		S_twice.erase(0, 1);
	}
	if(y_n == true){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 1200
n = gets.to_i
ws = gets.split.map(&:to_i)
w_ave = ws.inject(&:+)/2
sum = 0
index = 0
ws.each_with_index do |w,i|
	sum += w
	if sum > w_ave
		index = i
		break
	end
end
ans = ws[index..-1].inject(&:+) - ws[0...index].inject(&:+)
if ws[index] < ans
	ans = ws[index]*2 - ans
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using  namespace std;
#define PI 3.1416
int main()
{
	int n;
	cin>>n;
	float area1,area2;
	area1=PI*(n*n);
	area2=PI*(1*1);
	int com=area1/area2;
	cout<<com<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
typedef long long ll;

using namespace std;

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

    if ((a == b) && (b == c)) {
        cout << "No" << endl;
    } else if((a == b) || (a == c) || (b == c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 7+1e18
#define lld long double
#define eps 0.000001
#define endl '\n'
using namespace std ;

lli spf[100000+1];
lli const MAXN = 100001;
lli modex(lli x,lli y,lli p);
void getZarr(string str, lli Z[]);
void sieve();
vector<lli> getFactorization(lli x); 

int main()
{
    ////////////////////
    
    
    lli n,a,b;
    cin>>n;
    if(n==1) cout<<"Hello World"<<endl;
    else { cin>>a>>b; cout<<a+b<<endl;}

}


void getZarr(string str, lli Z[]){
    Z[0]=0;
    lli n = str.length();
    lli L, R, k;
    L = R = 0;
    loopl(i,1,n){
        if (i > R){
            L = R = i;
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        } else {
            k = i-L;
            if (Z[k] < R-i+1)
                Z[i] = Z[k];
            else {
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}

lli modex(lli x,lli y,lli p) 
{ 
    lli res = 1; 
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
  
        y = y>>1;  
        x = (x*x) % p;   
    } 
    return res; 
}

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
    spf[i] = i; 
  
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (int j=i*i; j<MAXN; j+=i) 
  
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
vector<lli> getFactorization(lli x) 
{ 
    vector<lli> ret; 
    while (x != 1) 
    { 
        ret.pb(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

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

using i64 = int64_t;

i64 calc(i64 n){
    i64 bit = 1, res = 0, i = 1;
    while((n>>(bit-1)) > 0){
        i64 ones = (n+1) / (2*i) * i;
        ones += max((i64)0, (n+1) % (2*i) - i);
        ones &= 1;
        res |= (ones << (bit-1));
        bit++;
        i *= 2;
    }
    return res;
}

int main(){
    i64 a, b;
    cin >> a >> b;
    cout << (calc(a-1) ^ calc(b)) << endl;

    return 0;
}


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

int main() {
  long long N,D;
  cin >> N >> D ;
  long long X[N];
  long long Y[N];
  for (int i=0;i<N;i++) cin >> X[i] >> Y[i];
  int ans=0;
  for (int i=0 ; i<N ; i++) {
    int64_t XX=X[i]*X[i];
    int64_t YY=Y[i]*Y[i];
    int64_t DD=D*D;
    if (XX+YY<=DD) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6756
def S(x) :
    mod = 1000000007
    return(x % mod)
    
def A(a, b, mod) :
    if b == 1 :
        return a
    elif b%2 == 0 :
        a_2 = S(a**2)
        b_2 = b // 2
        return S(A(a_2, b_2, mod))
    else :
        a_2 = S(a**2)
        b_2 = (b-1) // 2
        return S(A(a_2, b_2, mod)*a)
        
mod = 1000000007
m, n = map(int, input().split())

print(A(m, n, mod))


Measured memory_bytes: 5600
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let a = i.read_line().as_bytes().to_vec();
    let b = i.read_line().as_bytes().to_vec();
    let c = i.read_line().as_bytes().to_vec();

    let mut result = 0;

    for i in 0..n {
        result += if a[i] == b[i] && b[i] == c[i] {
            0
        } else if a[i] == b[i] || b[i] == c[i] || c[i] == a[i] {
            1
        } else {
            2
        };
    }
    writeln!(o, "{}", result).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
use proconio::{input, fastout};

const MAX: usize = 100_000;

#[fastout]
fn main() {
    input! {
        q: usize,
        lr: [(usize, usize); q],
    }

    let is_prime = sieve(MAX);

    let mut cumsum = vec![0; MAX+1];

    for i in 1..=MAX {
        cumsum[i] = cumsum[i-1];
        if is_prime[i] && is_prime[(i+1)/2] {
            cumsum[i] += 1;
        }
    }

    for &(l, r) in lr.iter() {
        let ans = cumsum[r] - cumsum[l-1];
        println!("{}", ans);
    }
}

fn sieve(n: usize) -> Vec<bool> {
    let mut is_prime = vec![true; n + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..=n {
        if !is_prime[i] {
            continue;
        }
        for j in 2..=n/i {
            is_prime[i * j] = false;
        }
    }
    is_prime
}


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

int main(){
  int n,t;cin>>n>>t;
  for(int x=0;x<=n;x++){
    for(int y=0;y<=n-x;y++){
      if(x*10000+y*5000+(n-x-y)*1000==t){
        cout<<x<<" "<<y<<" "<<n-x-y;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1";
}

Measured memory_bytes: 256
H, W, K = gets.split.map(&:to_i)

num = Array.new(W){Array.new(W, 0)}

(2**(W-1)).times do |bits|
    if (W-2).times.all?{|i| bits[i] == 0 || bits[i+1] == 0}
        arr = W.times.to_a
        (W-1).times do |i|
            if bits[i] == 1
                arr[i], arr[i+1] = arr[i+1], arr[i]
            end
        end
        W.times do |i|
            num[i][arr[i]] += 1
        end
    end
end

dp = Array.new(H+1){Array.new(W, 0)}
dp[0][0] = 1
MOD = 10**9+7

H.times do |i|
    W.times do |j|
        W.times do |k|
            dp[i+1][k] = (dp[i+1][k] + dp[i][j] * num[j][k]) % MOD
        end
    end
end

puts dp[H][K-1]

Measured memory_bytes: 1788
n,m=map(int,input().split())
listl=[]
listr=[]
for i in range(m):
  l,r=map(int,input().split())
  listl.append(l)
  listr.append(r)
maxl=max(listl)
minr=min(listr)
if minr-maxl+1>=1:
  print(minr-maxl+1)
else:
  print(0)

Measured memory_bytes: 10996
import math

#入力
a,b,x = map(int, input().split())

if a*b*a/2 < x:
    c = 2*x/(a*a) - b
    if b == c:
        print(0)
    else:
        d = a*b/(b-c)
        print(90-math.degrees(math.atan(d/b)))
else:
    c = (2*x)/(a*b)
    print(90 - math.degrees(math.atan(c/b)))

Measured memory_bytes: 3064
N, M = map(int, input().split())
PYlist = [tuple(map(int, input().split())) for _ in range(M)]


def ume0(num):
    return "0" * (6 - len(str(num))) + str(num)


now_city = -1
simo = 0
ans = {}
for P, Y in sorted(PYlist):
    if P != now_city:
        now_city = P
        simo = 0
    simo += 1
    ans[(P, Y)] = ume0(now_city) + ume0(simo)

for PY in PYlist:
    print(ans[PY])


Measured memory_bytes: 37740
#include <stdio.h>
int main(void)
{
	int h,w,i,j,a=0;
	char s[51][51];
	scanf("%d%d",&h,&w);
	for(i=0; i<h; i++){
		scanf("%s",s[i]);
	}
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			if(s[i][j]=='.'){
				if(s[i-1][j-1]=='#'){
					a=a+1;
				}if(s[i-1][j]=='#'){
					a=a+1;
				}if(s[i-1][j+1]=='#'){
					a=a+1;
				}if(s[i][j-1]=='#'){
					a=a+1;
				}if(s[i][j+1]=='#'){
					a=a+1;
				}if(s[i+1][j-1]=='#'){
					a=a+1;
				}if(s[i+1][j]=='#'){
					a=a+1;
				}if(s[i+1][j+1]=='#'){
					a=a+1;
				}
				s[i][j]='0'+a;
				a=0;
			}
		}
	}
	for(i=0; i<h; i++){
		printf("%s\n",s[i]);
	}
	return 0;
}

Measured memory_bytes: 128
n=[int(i) for i in input()]
p1=[1 if i%2==0 else 0 for i in range(len(n))]
p2=[0 if i%2==0 else 1 for i in range(len(n))]
p1_n=[p1[i]-n[i] for i in range(len(n))]
ans1=sum(x==0 for x in p1_n)
p2_n=[p2[i]-n[i] for i in range(len(n))]
ans2=sum(x==0 for x in p2_n)
print(min(ans1, ans2))

Measured memory_bytes: 7068
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))
P, Y = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(M)]))

nums = defaultdict(int)
ans = [''] * M
for i in np.lexsort((Y, P)):
    nums[P[i]] += 1
    ans[i] = '{:06d}{:06d}'.format(P[i], nums[P[i]])
print('\n'.join(map(str, ans)))


Measured memory_bytes: 69056
import java.util.*;
import java.math.*;

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

        int[][] dp = new int[s.length() + 1][t.length() + 1];
        int[][] dir = new int[s.length() + 1][t.length() + 1];

        for (int i = 1; i <= s.length(); i++) {
            for (int j = 1; j <= t.length(); j++) {
                if (s.charAt(i - 1) == t.charAt(j - 1)) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    dir[i][j] = 1; // to left-up
                } else {
                    if (dp[i - 1][j] >= dp[i][j - 1]) {
                        dp[i][j] = dp[i - 1][j];
                        dir[i][j] = 2; //to up;
                    } else {
                        dp[i][j] = dp[i][j - 1];
                        dir[i][j] = 3; //to left
                    }
                }
            }
        }

        StringBuilder res = new StringBuilder();

        int row = s.length();
        int col = t.length();

        while (row >= 0 && col >= 0) {
            if (dir[row][col] == 1) {
                res.insert(0, s.charAt(row - 1));
                row--;
                col--;
            } else if (dir[row][col] == 2) {
                row--;
            } else {
                col--;
            }
        }

        System.out.println(res);


    }
}


Measured memory_bytes: 129100
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    x = int(readline())
    v = 100
    for i in range(10 ** 6):
        if v >= x:
            print(i)
            break
        v += v // 100


if __name__ == '__main__':
    main()


Measured memory_bytes: 62756
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);

    int i;
    long long ans = 0;
    for (i = 1; i <= n; i++)
    {
        if(i % 3 != 0 && i % 5 != 0)
        {
            ans += i;
        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 1728
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = 10**20

    for i in range(-100, 101):
        total = 0
        for j in a:
            total += (j-i)**2
        res = min(res, total)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include <string>
#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(){
    string name;
    int count= 0;
    int c1 = 0;
    int c2 = 0;
    bool ok = 0;
    cin >> name;
    //cout << name.size() << endl;
    for(int i=0 ; i < name.size() ; i++){
        if(name[i] == name[name.size()-1-i])count++;
    }
    if(count == name.size())ok = 1;
    
    string S1 = name.substr(0,(name.size()-1)/2);
    string S2 = name.substr((name.size()+3)/2-1,name.size());

    //cout << S2 << endl;
    for(int i=0; i < S1.size() ; i++){
        if(S1[i] == S1[S1.size()-1-i])c1++;
    }
    if(c1 != S1.size())ok = 0;
    //cout << ok << endl;
    for(int i=0; i < S2.size() ; i++){
        if(S2[i] == S2[S2.size()-1-i])c2++;
    }
    if(c2 != S2.size())ok = 0;
    //cout << ok << endl;
    if(ok){
        cout << "Yes" <<endl;
        return 0;
    }
    cout <<"No"<<endl;
    return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;
  while(cin>>s,s!="#"){
    bool f=1;
    for(int i=0;i<(1<<19);i++){
      bitset<19> b(i);
      int x[7],y;
      x[0]=s[((((((((((((b[ 0]<<1)+b[ 1])<<1)+b[ 2])<<1)+b[ 4])<<1)+b[ 6])<<1)+b[ 7])<<1)+b[ 9])]-'0';
      x[1]=s[((((((((((((b[ 1]<<1)+b[ 3])<<1)+b[ 4])<<1)+b[ 6])<<1)+b[ 8])<<1)+b[ 9])<<1)+b[11])]-'0';
      x[2]=s[((((((((((((b[ 2]<<1)+b[ 4])<<1)+b[ 5])<<1)+b[ 7])<<1)+b[ 9])<<1)+b[10])<<1)+b[12])]-'0';
      x[3]=s[((((((((((((b[ 4]<<1)+b[ 6])<<1)+b[ 7])<<1)+b[ 9])<<1)+b[11])<<1)+b[12])<<1)+b[14])]-'0';
      x[4]=s[((((((((((((b[ 6]<<1)+b[ 8])<<1)+b[ 9])<<1)+b[11])<<1)+b[13])<<1)+b[14])<<1)+b[16])]-'0';
      x[5]=s[((((((((((((b[ 7]<<1)+b[ 9])<<1)+b[10])<<1)+b[12])<<1)+b[14])<<1)+b[15])<<1)+b[17])]-'0';
      x[6]=s[((((((((((((b[ 9]<<1)+b[11])<<1)+b[12])<<1)+b[14])<<1)+b[16])<<1)+b[17])<<1)+b[18])]-'0';
      y   =s[((((((((((((x[ 0]<<1)+x[ 1])<<1)+x[ 2])<<1)+x[ 3])<<1)+x[ 4])<<1)+x[ 5])<<1)+x[ 6])]-'0';
      f&=(x[3]==y);
    }
    cout<<(f?"yes":"no")<<endl;
  }
  return 0;
}

Measured memory_bytes: 3084
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, m = na()
p = [[] for i in range(n)]
for i in range(m):
    pp, y = na()
    pp -= 1
    p[pp].append((y, i))

for i in range(n):
    if len(p[i]) <= 0:
        continue
    p[i].sort()

w = [0 for i in range(m)]
for i in range(n):
    if len(p[i]) <= 0:
        continue
    for j in range(len(p[i])):
        w[p[i][j][1]] = (i + 1, j + 1)

for i in range(m):
    print('{:0>6}{:0>6}'.format(w[i][0], w[i][1]))

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

int P[10010];
void init(int N);
int root(int a);
bool is_same_set(int a,int b);
void unite(int a,int b);

int main() {
  int N,Q;
  cin >> N >> Q;
  init(N);
  for (int i=0;i<Q;++i) {
    int com,x,y;
    cin >> com >> x >> y;
    if (com==0)
      unite(x,y);
    else {
      if (is_same_set(x,y)==true)
	cout << 1 << endl;
      else
	cout << 0 << endl;
    }
  }
}

void init(int N) {
  for (int i=0;i<=N;++i) P[i] = i;
}

int root(int a) {
  if (P[a] == a) return a;
  return (P[a] = root(P[a]));
}

bool is_same_set(int a,int b) {
  return root(a)==root(b);
}

void unite(int a,int b) {
  P[root(a)] = root(b);
}

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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
   int x,a[200000],b[1000001],i,j,k,n,m;

   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%d",&a[i]);
   qsort(a,n,sizeof(int),asc);
   m=a[n-1];
   for (i=1;i<=m;i++) b[i]=1;
   for (i=0;i<n;i++)
      if (b[a[i]]) 
         for (j=a[i]*2;j<=m;j+=a[i]) b[j]=0;
   for (i=0;i<n-1;i++)
      if (a[i]==a[i+1]) b[a[i]]=0;
   for (m=i=0;i<n;i++)
      if (b[a[i]]) m++;
   printf("%d\n",m);
   return 0;
}


Measured memory_bytes: 6420
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char[] s = sc.next().toCharArray();
		int cnt = 0;
		int max = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
				cnt++;
				max = Math.max(max, cnt);
			} else {
				cnt = 0;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 23124
s = input()

MOD = 10**9 + 7

a, ab, abc, q = 0, 0, 0, 1

for x in s:
    # Aなら状態数を足す
    if x == "A":
        a += q
        a %= MOD
    # BならこれまでAだった状態数を足す
    elif x == "B":
        ab += a
        ab %= MOD
    # CならAB→ABCが完成する
    elif x == "C":
        abc += ab
        abc %= MOD
    # ?なら色々変化する
    else:
        # 状態数が3倍になり、?がC, Bのケースも足される
        abc = (abc * 3 + ab) % MOD
        ab = (ab * 3 + a) % MOD
        a = (a * 3 + q) % MOD
        q = q * 3 % MOD

print(abc % MOD)

Measured memory_bytes: 9256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int i,j;
	bool d[10]={};
	for(i=0;i<k;i++){
		cin>>j;
		d[j]=true;
	}
	string s;
	bool f;
	char c[10];
	for(i=0;i<10;i++) c[i]='0'+i;
	for(i=n;i<n*100;i++){
		stringstream ss;
		ss<<i;
		s=ss.str();
		f=true;
		for(j=0;j<10;j++){
			if(d[j]&&s.find(c[j])!=-1){
				f=false;
				break;
			}
		}
		if(f){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

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

const int INF = 1e9;

int main() {
  long long x;
  cin>>x;
  if ((x - 1) % 11 <= 5) {
    cout<<((x - 1) / 11 + 1) * 2 - 1<<endl;
  } else {
    cout<<((x - 1) / 11 + 1) * 2<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    Scanner sc = new Scanner(System.in);

   int A = sc.nextInt();
   String x = sc.next();
   int B = sc.nextInt();

   if(x.contains("+")){
    System.out.println(A + B);
   }else if(x.contains("-")){
    System.out.println(A - B);
   }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> A >> B;
  C=A^B;
  Out(C);
}

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

int main(void)
{
	char	comp[4];	//[S] Company!

	//STDinput S. 3 chars.
	scanf("%s", comp);

	if( (strcmp(comp, "AAA") == 0) || (strcmp(comp, "BBB") == 0) )
		printf("No");
	else
		printf("Yes");

	return (0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		int p[n];
		int q[n];
		int a[n];
		for (int i = 0; i < n; i++)
		{
			cin>>p[i];
			a[i]=i+1;
		}
		for (int i = 0; i < n; i++)
		{
			cin>>q[i];
		}
		int i=1,c,b;
		do{
			int f=0,g=0;
			for(int i=0;i<n;i++){
				if(a[i]!=p[i])
					f=1;
			}
			for(int i=0;i<n;i++){
				if(a[i]!=q[i])
					g=1;
			}
			if(!f)
				c=i;
			if(!g)
				b=i;
			i++;
		}while (next_permutation(a,a+n));
		cout<<abs(c-b)<<endl; 
	}
}



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

using namespace std;

string s,t, res = "";
int dp[3010][3010];

int f(int i, int j) {
    if(i == (int)s.size() or j == (int)t.size()) return 0;
    int &ans = dp[i][j];
    if(ans != -1) return ans;
    ans = 0;
    if(s[i] == t[j]) ans = max(ans, f(i + 1, j + 1) + 1);
    ans = max(ans, f(i + 1, j));
    ans = max(ans, f(i, j + 1));
    return ans;
}

void r(int i, int j) {
    if(i == (int)s.size() or j == (int)t.size()) return;
    int ans = 0;
    int id = -1;
    if(s[i] == t[j]) {
        if(f(i + 1, j + 1) + 1 > ans) {
            ans = f(i + 1, j + 1) + 1;
            id = 0;
        }
    }
    
    if(f(i + 1, j) > ans) {
        ans = f(i + 1, j);
        id = 1;
    }

    if(f(i, j + 1) > ans) {
        ans = f(i, j + 1);
        id = 2;
    }
    
    if(id == 0) {
        res += s[i];
        r(i + 1, j + 1);
        return;
    }

    if(id == 1) r(i + 1, j);
    if(id == 2) r(i, j + 1);
    
}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> s >> t;
    
    f(0, 0);
    r(0, 0);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 35968
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 14 Jun 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine(), " ");
        int a;
        int j = 1;
        while (st.hasMoreTokens()) {
            a = Integer.parseInt(st.nextToken());
            if (a == 0) {
                System.out.println(j);
                break;
            }
            j++;
        }
        br.close();
    }
}


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

bool field[100][100];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		memset(field, 0, sizeof(field));
		int w, h; scanf("%d%d", &w, &h);
		rep(i, n) {
			int x, y; scanf("%d%d", &x, &y);
			x--; y--;
			field[x][y] = true;
		}
		int s, t; scanf("%d%d", &s, &t);
		int Max = 0;
		rep(i, w - s + 1)rep(j, h - t + 1) {
			int cnt = 0;
			rep(k, s)rep(l, t)cnt += field[i + k][j + l];
			Max = max(Max, cnt);
		}
		printf("%d\n", Max);
	}
}

Measured memory_bytes: 3148
#include <stdio.h>


int main(int argc, char ** argv){
    int a, b, c;
    bool flag = 0;
    scanf("%d %d %d", &a, &b, &c);
    for (int i=1; i<=b; i++){
        if (a*i % b == c){
            flag = 1;
        }
    }
    if(flag){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int a, b;
    cin >> a >> b;
    printf("%d %d %.15f\n", a/b, a%b, (double)a/b);
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  while (true) {
    ll t, d, l;
    cin >> t >> d >> l;
    if (t == 0)
      break;
    vector<ll> x(t);
    for (int i = 0; i < t; i++)
      cin >> x[i];
    ll ans = 0;
    ll turn = 0;
    for (int i = 0; i < t; i++) {
      if (turn > 0) {
        turn--;
        ans++;
      }
      if (l <= x[i]) {
        turn = d;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  int n, k; cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(),h.end());
  ll ans = INF;
  rep(i,n-k+1){
    ans = min(ans,h[i+k-1]-h[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3936
import scala.io.StdIn.readLine

object Main {
  def getSubArea(hd:Int,stack2:List[(Int,Int)],subarea:Int):List[(Int,Int)] = {
    if(stack2.length==0) (hd,subarea)::stack2
    else {
      stack2 match {
        case hd2::tl2 =>
          if(hd2._1<=hd) (hd,subarea)::stack2
          else {
            getSubArea (hd,tl2,subarea+hd2._2)
          }
        case _ => throw new Exception("unexpected")
      }
    }
  }

  def getArea(stack:List[Int],stack2:List[(Int,Int)],area:Int,s:String,i:Int):(Int,List[(Int,Int)]) = {
    if(i==s.length) (area,stack2)
    else {
      if(s(i) == '\\') getArea(i::stack,stack2,area,s,i+1)
      else if(s(i) == '/' && stack.length!=0) {
        stack match {
          case hd::tl =>
            getArea(tl,getSubArea(hd,stack2,i-hd),area+i-hd,s,i+1)
          case _ => throw new Exception("unexpected")
        }
      } else getArea(stack,stack2,area,s,i+1)
    }
  }

  def main(args:Array[String]) = {
    val s = readLine
    val n = getArea(Nil,Nil,0,s,0)
    println(n._1)
    print(n._2.length)
    if(n._2.length>0) println(" " + n._2.reverse.map(_._2).mkString(" "))
    else println
  }
}

Measured memory_bytes: 44908
n,m=map(int,input().split())
a=[[int(i) for i in input().split()]for i in range(n)]
a.sort()
q=0
t=0
for i in range(n):
    q+=a[i][1]
    if q>=m:
        t=i
        break
ans=0
z=0
for i in range(t):
    ans+=a[i][0]*a[i][1]
    z+=a[i][1]
ans+=a[t][0]*(m-z)
print(ans)


Measured memory_bytes: 21604
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
using namespace std;
const int MAXN = 1e5;
int n, m, k;
int p[MAXN+10], s[MAXN+10];

VI g[MAXN+10];

int find(int x){
	if(p[x] == x) return x;
	return p[x] = find(p[x]);
}
void join(int x, int y){
	int xr = find(x), yr = find(y);
	if(xr != yr){
		s[yr] += s[xr];
		p[xr] = yr;
	}
}
int main(){
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1; i <= n; i++){
		p[i] = i;
		s[i] = 1;
	}
	for(int i = 0; i < m; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		g[x].pb(y);
		g[y].pb(x);
		join(x, y);
	}
	for(int i = 0; i < k; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		if(find(x) == find(y)){
			g[x].pb(y);
			g[y].pb(x);
		}
	}

	for(int i = 1; i <= n; i++) sort(g[i].begin(), g[i].end());

	for(int i = 1; i <= n; i++){
		int sz = s[find(i)]-1;
		for(int j = 0; j < g[i].size(); j++){
			if(j == 0) sz--;
			else sz -= g[i][j] != g[i][j-1];
		}
		printf("%s%d", (i == 1) ? "" : " ", sz);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 8696
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
int n;
char a[10001];
int main(){
	scanf("%s",a+1);
	n=strlen(a+1);
	printf("%s",a+1);
	if(a[n]=='s') printf("es");
	else printf("s");
}

Measured memory_bytes: 3752
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    lint n,x,ans=0,sum=0,mod=1000000007;
    cin>>n;
    vector<lint> vec(n);
    for(int i=0;i<n;i++){
        cin>>x;
        sum+=x;sum%=mod;
        vec[i]=x;
    }
    for(int i=0;i<n;i++){
        sum-=vec[i];
        if(sum<0)sum+=mod;
        ans+=vec[i]*sum%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 long double d,s,t;
 cin>>d>>t>>s;
 long double time=d/s;
 if(time<=t)
 {
     cout<<"Yes"<<endl;
 }
 else
 {
     cout<<"No"<<endl;
 }

return 0;
}



Measured memory_bytes: 3756