akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define vsort(v) sort(all(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

ll N,K;
ll search(vector<data> a,vec maxc,ll st){
  ll i=1,ans=0,now=0;
  vec sta(N+1,0);
  while(st>0){
    sta[i++]=st%2; 
    st/=2;
  }
  rep1(i,N+1){
    if(sta[i]>0){
      now+=a[i].second;
      ans+=a[i].first;
    }
  }
  if(now>=K)return ans;
 
  for(i=N;i>0;i--){
    if(sta[i]>0)continue;
    if(K-now>maxc[i]){
      now+=a[i].second;
      ans+=a[i].first;
    }else{
      if(K>now){
        ans+=(K-now+i*100-1)/(i*100);
      }
      return ans;
    }
  }
  return 10000000000;
}
int main(){
  ll i,maxp=1,ans=1000000000;
  cin>>N>>K;
  vector<data> a(N+1);
  vec mxa(N+1,0);
  rep1(i,N+1){
    cin>>a[i].first>>a[i].second;
    mxa[i]=a[i].first*100*i;
    a[i].second+=mxa[i];
    maxp*=2;
  }
  //rep1(i,N+1)cout<<a[i].second<<" ";
  cout<<endl;
  ans=search(a,mxa,0);
  while(--maxp){
    ans=min(ans,search(a,mxa,maxp));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
const int mod=1000000007;
unsigned f[2][3010];
int calc(int m,int n){
	for(int i=1;i<=m;i++)f[0][i]=1;
	f[0][0]=f[0][m+1]=f[1][0]=f[1][m+1]=0;
	int c=0,s=0;
	for(int i=0;i<n;i++,c=!c)
		for(int j=1;j<=m;j++)
			f[!c][j]=(f[c][j-1]+f[c][j]*2+f[c][j+1])%mod;
	for(int i=1;i<=m;i++)(s+=f[c][i])%=mod;
	return s;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int s=4ll*(calc(n,m-1)+mod-calc(n-1,m-1))%mod;
	printf("%d\n",s);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<int,int>
#define ff first
#define ss second
#define mod 1000000007


int main() {
flash;

    
    string s;
    cin>>s;
    
    string str[8] = {"a","SAT","FRI","THU","WED","TUE","MON","SUN"};
    int ans;
    
    for(int i=1;i<=7;i++){
        if(str[i] == s){
            ans = i; break;
        }
    }
    cout<<ans;
    
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int n, x;
  int cnt;

  while(true){
    cin >> n >> x;

    cnt = 0;

    if(n == 0 && x == 0)
      break;

    for(int i = 1; i <= n; i++){
      for(int j = 1; j < i; j++){
	for(int k = 1; k < j; k++){
	  if(i + j + k == x)
	    cnt++;
	} // k
      } // j
    } // i

    cout << cnt << endl;

  }

  return 0;
}

Measured memory_bytes: 1160
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T = 1;
	for(int t = 1; t <= T; t++){
		int n,d;
		cin >> n >> d;
		int count = 0;
		for(int i = 1;i <= n; i++){
			int x,y;
			cin >> x >> y;
			if((int) ceil(sqrt(pow(x,2) + pow(y,2))) <= d){
				count += 1;
			}
		}
		cout << count;
	}
}



Measured memory_bytes: 3692
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int assume(int h, pair<int,int>c, pair<int,int>at){
	return max(0,h-abs(c.F-at.F)-abs(c.S-at.S));
}
int main(){
	int n;
	pair<pair<int,int>,int>ans;
	cin >>n;
	int down=INF;
	bool can=true;
	pair<int,int>at=mp(0,0);
	vector<pair<pair<int,int>,int>>data(n);
	int x,y,h;
	rep(i,n){
		cin>>x>>y>>h;
		data[i]=mp(mp(x,y),h);
		chmin(down,h);
	}
	for(h=down;h<=down+200;h++){
		for(at.F=0;at.F<=100;at.F++){
			for(at.S=0;at.S<=100;at.S++){
				can=true;
				rep(i,n){
					if(assume(h,at,data[i].F)!=data[i].S){
						can=false;
					}
				}
				if(can){
					printf("%d %d %d\n",at.F,at.S,h);
					return 0;
				}
			}
		}
	}
	//cout<<ans<<endl;
}

Measured memory_bytes: 3696
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int n, m;
    cin >> n >> m;
    int a[n+1];
    fill(a, a+n+1, 1);
    rep(i, 0, m) {
        int x; cin >> x;
        a[x] = 0;
    }

    rep(i, 2, n+1) {
        if (a[i] != 0) a[i] = a[i-1] + a[i-2];
        a[i] %= MOD;
    }

    cout << a[n] << endl;
   
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int NUM = 2e5 + 5;
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        int n,a,b; cin>>n>>a>>b;
        cout<<min(n*a,b);
    }
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $N, $K);
$x = explode(" ", trim(fgets(STDIN)));

$answer = PHP_INT_MAX;

for ($i = 0; $i <= $N - $K; $i++) {
	$w = $x[$i + $K - 1] - $x[$i];
	$w += min(abs($x[$i + $K - 1]), abs($x[$i]));
	$answer = min($answer, $w);
}
echo $answer;


Measured memory_bytes: 12792
#include<cstdio>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>

#define ll long long
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug(Head head,Tail... tail){
    cerr<<" "<<to_string(head);
    debug(tail...);
}

int main(){
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    double max_c=0;
    int max_water;
    int max_sugar;
    for(int water=0;water<=F;water+=100*A){
        for(int water2=water;water2<=F;water2+=100*B){
            int capacity_sugar=water2*E/100;
            for(int sugar=0;sugar<=capacity_sugar&&water2+sugar<=F;sugar+=C){
                for(int sugar2=sugar;sugar2<=capacity_sugar&&water2+sugar2<=F;sugar2+=D){
                    if(max_c<=sugar2/(double)(water2+sugar2)){
                        max_c=sugar2/(double)(water2+sugar2);
                        max_water=water2;
                        max_sugar=sugar2;
                    }
                }
            }
        }
    }
    cout<<max_water+max_sugar<<" "<<max_sugar<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  ll min = (ll)pow(10, 13);

  for(int i = 1; i <= sqrt(N); ++i) {
    if(!(N % i)) {
      ll j = N / i;
      min = (min < (i - 1) + (j - 1))? min : (i - 1) + (j - 1);
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;
 
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    //string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n>>m)
    {
        string str[n];
        for(i=0;i<n;i++)  cin>>str[i];
        int sum[5][n][m];
        memset(sum,0,sizeof sum);
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
               if(j==0) {
                   if(str[i][j]=='.') sum[1][i][j]=1;
                   if(i>0 && str[i][j]=='.') sum[2][i][j]=sum[2][i-1][j]+1;
                   else if(i==0 && str[i][j]=='.') sum[2][i][j]=1;
                }
                else if(i==0) {
                    if(str[i][j]=='.') sum[2][i][j]=1;
                    if(str[i][j]=='.') sum[1][i][j]=sum[1][i][j-1]+1;
                }
                else{
                    if(str[i][j]=='.') sum[1][i][j]=sum[1][i][j-1]+1,sum[2][i][j]=sum[2][i-1][j]+1;
                }
            }
        }

        for(i=n-1;i>=0;i--){
            for(j=m-1;j>=0;j--){
                    if(j==m-1) {
                        if(str[i][j]=='.') sum[3][i][j]=1;
                        if(i<n-1 && str[i][j]=='.') sum[4][i][j]=sum[4][i+1][j]+1;
                        else if(i==n-1 && str[i][j]=='.') sum[4][i][j]=1;
                    }
                    else if(i==n-1) {
                        if(str[i][j]=='.')  sum[4][i][j]=1;
                        if(str[i][j]=='.') sum[3][i][j]=sum[3][i][j+1]+1;
                    }
                else{
                    if(str[i][j]=='.') sum[3][i][j]=sum[3][i][j+1]+1,sum[4][i][j]=sum[4][i+1][j]+1;
                }
            }
        }


        mx=0;
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                if(str[i][j]=='.') p=sum[1][i][j]+sum[2][i][j]+sum[3][i][j]+sum[4][i][j];
                mx=max(mx,p-3);
            }
        }

        cout<<mx<<endl;
    }





}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, k;
vector<int> g[2000];

bool vis[2000];
int dfs(int v, int d) {
	if(exchange(vis[v], true)) { return 0; }
	int x = (d > k / 2 ? 1 : 0);
	for(auto && w: g[v]) { x += dfs(w, d + 1); }
	return x;
}

int dfs_v(int v) {
	inc(i, n) { vis[i] = false; }
	return dfs(v, 0);
}

int dfs_e(int v1, int v2) {
	inc(i, n) { vis[i] = false; }
	int x = 0;
	
	vis[v2] = true;
	x += dfs(v1, 0);
	vis[v2] = false;
	x += dfs(v2, 0);
	
	return x;
}

int main() {
	cin >> n >> k;
	inc(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	
	int ans = n;
	if(k % 2 == 0) {
		inc(i, n) { setmin(ans, dfs_v(i)); }
	} else {
		inc(i, n) {
		for(auto && j: g[i]) {
			setmin(ans, dfs_e(i, j));
		}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
import sys
from itertools import accumulate

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60

N, M, Q = map(int, readline().split())
G = [[0] * N for _ in range(N)]
for _ in range(M):
    l, r = map(int, readline().split())
    G[l - 1][r - 1] += 1

csum = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(N):
    for j in range(N):
        csum[i + 1][j + 1] = csum[i + 1][j] + csum[i][j + 1] - csum[i][j] + G[i][j]

ans = []
for _ in range(Q):
    p, q = map(int, readline().split())
    ans.append(csum[q][q] - csum[q][p - 1] - csum[p - 1][q] + csum[p - 1][p - 1])

print(*ans, sep='\n')


Measured memory_bytes: 54236
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

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

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

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

func main() {
	sc.Split(bufio.ScanWords)

	R := float64(getInt())
	fmt.Printf("%12.12f\n", R*math.Pi*2)
}


Measured memory_bytes: 1760
use std::io::{stdin, Read};
use std::str::FromStr;

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

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let aa = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();
    let mut t = vec![0; n];
    t[0] = aa[0];

    for i in 1..n {
        t[i] = gcd(t[i - 1], aa[i])
    }

    println!("{}", t[n - 1]);

    fn gcd(a: usize, b: usize) -> usize {
        if b == 0 {
            a
        } else {
            gcd(b, a % b)
        }
    }
}


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

using vi = vector<int>;

int main(){
int n;
cin >> n;
vi a(n + 2 , 0);
for(int i = 1; i <=n; i++){
cin >> a[i];
a[i] += a[i- 1];
}
vi b(n + 2, 0);
for(int i = 1; i <=n; i++){
    cin >> b[i];
}
for(int i = n; i >= 1; --i){
    b[i] += b[i + 1];
}

for(int i = 1; i <=n; i++){
    cerr << a[i] << " \n"[i==n];
}
for(int i = 1; i <=n; i++){
    cerr << b[i] << " ";
}

int ans = 0;
for(int i = 1; i <= n; i++){
    ans = max(ans , a[i] + b[i] );
}
cout << ans << '\n';

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<vector<int> > A(3, vector<int>(3, 0));
  vector<vector<bool> > AA(3, vector<bool>(3, false));
  REP(i, 3) REP(j, 3){
    cin >> A[i][j];
  }
  int N; cin >> N;
  REP(i, N){
    int tmp; cin >> tmp;
    REP(j, 3) REP(k, 3){
      if(A[j][k] == tmp) AA[j][k] = true;
    }
  }
  bool flag = false;
  REP(i, 3){
    if(AA[i][0] && AA[i][1] && AA[i][2]) flag = true;
    if(AA[0][i] && AA[1][i] && AA[2][i]) flag = true;
  }
  if(AA[0][0] && AA[1][1] && AA[2][2]) flag = true;
  if(AA[2][0] && AA[1][1] && AA[0][2]) flag = true;
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int x,a,b,da,db;
  scanf("%d%d%d",&x,&a,&b);
  da=(x>a)? x-a:a-x;
  db=(x>b)? x-b:b-x;
  printf("%c\n",(da<db)? 'A':'B');
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>

#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define pb push_back
#define mp make_pair

inline int LSB(int x)
{
    return x & (-x);
}

class BIT {

public:
    BIT() {
        memset(c, 0, sizeof(c));
        n = 200;
    }

    int value(int poz)
    {
        int i, s;
        s = 0;
        for (i = poz + 100; i >= 1; i = i - LSB(i))
            s = s + c[i];
        return s;
    }

    void insert(int i)
    {
        i = i + 100;
        for (; i <= n; i = i + LSB(i))
            c[i]++;
    }

private:
    int n;
    int c[201];
};

std::tuple<int, int, bool> process_input(const string& in) {
    size_t index = in.find('.');
    string decimal, base;
    int ten = 0;
    if (index != string::npos) {
        base = in.substr(0, index);
        decimal = in.substr(index + 1);
        ten = in.size() - index - 1;
    }
    else {
        base = in;
    }
    long long number = std::stoull(base + decimal);
    int two = 0, five = 0;
    while (number % 2 == 0) {
        two++;
        number = number / 2;
    }
    while (number % 5 == 0) {
        five++;
        number = number / 5;
    }
    int common = min(two, five);
    ten -= common;
    two -= common;
    five -= common;
    return std::tuple(max(two, five), ten, (two == 0));
}

long long process(const vector < std::tuple<int, int, bool> >& data, const bool cls) {
    const int N = (int)data.size();
    if (N <= 1) {
        return 0;
    }
    BIT bit;
    long long sol = 0;
    for (int i = 0; i < N; i++) {
        int value, ten;
        bool my_cls;
        std::tie(value, ten, my_cls) = data[i];
        if (cls != my_cls) {
            bit.insert(-(value - ten));
        }
        else {
            sol = sol + bit.value(-ten);
            bit.insert(ten);
        }
    }
    return sol;
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    // cout.setf(ios::fixed), cout.precision(20);

#ifdef LOCAL
    ifstream cin("input.txt");
#endif

    int N;
    cin >> N;
    vector < std::tuple<int, int, bool> > data;
    for (int i = 1; i <= N; i++) {
        string in;
        cin >> in;
        data.push_back(process_input(in));
    }
    sort(data.begin(), data.end());
    long long sol = process(data, false) + process(data, true);
    cout << sol << '\n';
    return 0;
}

Measured memory_bytes: 5924
use proconio::{input, fastout};
use std::cmp::*;

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

    let mut ans = 0;
    let mut mas = 0;
    for i in 0..n {
        a[i] -= 1;
        if a[i]==mas {
            mas += 1;
        } else {
            ans += 1;
        }
    }
    if ans==n {
        println!("-1");
        return;
    } else {
        println!("{}", ans);
    }

}


Measured memory_bytes: 4768
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10e+6
#define DEKA 1000000007

using namespace std;

int main(){
    string s;
    cin >> s;
    bool ans=false;
    for(int i=1;i<4;i++){
        if(s.at(i-1)==s.at(i)) ans=true;
    }
    if(ans) cout << "Bad" << endl;
    else cout << "Good" << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;

int main()
{
    int n, s, t; cin>>n>>s>>t;
    ll ds[334], dt[334];
    for(int i=1; i<=n; i++){
        cout<<"? "<<i<<" "<<s<<endl;
        cin>>ds[i];
        cout<<"? "<<i<<" "<<t<<endl;
        cin>>dt[i];
    }
    vector<P> v;
    for(int i=1; i<=n; i++){
        if(ds[i]+dt[i]==ds[t]){
            v.push_back({ds[i], i});
        }
    }
    sort(v.begin(), v.end());
    vector<int> ans;
    ans.push_back(s);
    int p=v[1].second;
    ans.push_back(p);
    int k=2;
    while(p!=t){
        int q=v[k].second;
        cout<<"? "<<p<<" "<<q<<endl;
        ll d; cin>>d;
        if(ds[p]+d==ds[q]){
            p=q;
            ans.push_back(q);
        }
        k++; 
    }
    cout<<"!";
    for(auto x:ans) cout<<" "<<x;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4660
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	long long int n, a[11000],ta=-1000005,ti=1000005;
	long long int sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 0; i < n; i++){
		if (ti>a[i])ti = a[i];
		if (ta < a[i])ta = a[i];
	}
	printf("%lld %lld %lld\n",ti,ta,sum);
	return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int a[3]={0};
for (int i=0;i<3;i++)cin>>a[i];
sort(a,a+3);
for (int i=0;i<2;i++)cout<<a[i]<<" ";

cout<<a[2]<<endl;

return 0;
}





Measured memory_bytes: 3152
#include<cstdio>
#include<cctype>
#include<algorithm>
namespace fast_IO
{
	const int IN_LEN=1000000,OUT_LEN=1000000;
	char ibuf[IN_LEN],obuf[OUT_LEN],*ih=ibuf+IN_LEN,*oh=obuf,*lastin=ibuf+IN_LEN,*lastout=obuf+OUT_LEN-1;
	inline char getchar_(){return (ih==lastin)&&(lastin=(ih=ibuf)+fread(ibuf,1,IN_LEN,stdin),ih==lastin)?EOF:*ih++;}
	inline void putchar_(const char x){if(oh==lastout)fwrite(obuf,1,oh-obuf,stdout),oh=obuf;*oh++=x;}
	inline void flush(){fwrite(obuf,1,oh-obuf,stdout);}
}
using namespace fast_IO;
//#define getchar() getchar_()
//#define putchar(x) putchar_((x))
//#include<ctime>
#define rg register
typedef long long ll;
template <typename T> inline T max(const T a,const T b){return a>b?a:b;}
template <typename T> inline T min(const T a,const T b){return a<b?a:b;}
template <typename T> inline void mind(T&a,const T b){a=a<b?a:b;}
template <typename T> inline void maxd(T&a,const T b){a=a>b?a:b;}
template <typename T> inline T abs(const T a){return a>0?a:-a;}
template <typename T> inline void swap(T&a,T&b){T c=a;a=b;b=c;}
//template <typename T> inline void swap(T*a,T*b){T c=a;a=b;b=c;}
template <typename T> inline T gcd(const T a,const T b){if(!b)return a;return gcd(b,a%b);}
template <typename T> inline T lcm(const T a,const T b){return a/gcd(a,b)*b;}
template <typename T> inline T square(const T x){return x*x;};
template <typename T> inline void read(T&x)
{
	char cu=getchar();x=0;bool fla=0;
	while(!isdigit(cu)){if(cu=='-')fla=1;cu=getchar();}
	while(isdigit(cu))x=x*10+cu-'0',cu=getchar();
	if(fla)x=-x;
}
template <typename T> inline void printe(const T x)
{
	if(x>=10)printe(x/10);
	putchar(x%10+'0');
}
template <typename T> inline void print(const T x)
{
	if(x<0)putchar('-'),printe(-x);
	else printe(x);
}
const int mod=1000000007,MAX=524289;
int n,a[200001];
ll away,last,val,tj[200001]; 
int main()
{
	read(n);
	for(rg int i=1;i<=n;i++)read(a[i]);
	away=1;
	for(rg int i=1;i<=n;i++)
	{
		if(last&&last!=a[i])tj[last]+=val;
		last=a[i],val=away+tj[a[i]];
		away=(away+tj[a[i]])%mod;
		tj[a[i]]=0;
	}
	print(away);
	return flush(),0;
}

Measured memory_bytes: 4224
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int h, w;
	cin >> h >> w;

	vector<string> field;

	field.resize(h);

	for(int i = 0; i < h; i++){
		cin >> field[i]; 
	}

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			int ok = false;
			if(field[i][j] == '.')continue;
			for(int k = 0; k < 4; k++){
				if(i + dy4[k] < 0 || i + dy4[k] >= h ||
				j + dx4[k] < 0 || j + dx4[k] >= w){
					continue;
				}
				if(field[i + dy4[k]][j + dx4[k]] == '#'){
					ok = true;
					continue;
				}
			}
			if(!ok){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

}



Measured memory_bytes: 256
/*
 
 Author : Bisma
 
 */
#include<algorithm>
#include <assert.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define ll long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <long long, long long >
#define plp pair <int, pll >
#define pb push_back
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define ll long long 
#define sum(a,b) a=a+b
#define repn(a,b,c) for(int a = b ; a>=c ; a--)
#define mem(a, b) memset(a, (b), sizeof(a))



ll max(ll a , ll b){
  if(a>b) return a;
  return b;
}

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
}

ll a[7];

int main(){
  
  fast();    

  ll n = 5;

  ll num;
  cin>>num;

  ll mini = (ll)1e16;
 
  rep(i,1,n){
    cin>>a[i];
    mini = min(mini , a[i]);
  }

  ll ans = 4;

  ll bil = num / mini;

  if(num % mini != 0) bil++;

  ans += bil;

  cout<<ans<<endl;

    return 0;

}


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

void solve(long long int n) 
{
	long long int ans = 0;
	for(long long int i = 1; i <=n; i++) {
		//if(n % 3 == 0 and n % 5 == 0) continue;
		if(i % 5 == 0 or i % 3 == 0) continue;
		
		ans += i;
	}
	cout << ans << endl;
		
}

int main() 
{
	long long int T = 0;
	cin >> T;
	
	solve(T);
	
	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

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

	/* 入力 */
	String sa = scan.next();
	String sb = scan.next();
	String sc = scan.next();

	/* 前準備 */
	char turn = sa.charAt(0);
	sa = sa.substring(1,sa.length());

	while(true){
	    /* 次のターンを決める */
	    if(turn == 'a'){
		if(sa.length() == 0){
		    System.out.println("A");
		    break;
		}else{
		    turn = sa.charAt(0);
		    sa = sa.substring(1,sa.length());
		}
	    }else if(turn == 'b'){
		if(sb.length() == 0){
		    System.out.println("B");
		    break;
		}else{
		    turn = sb.charAt(0);
		    sb = sb.substring(1,sb.length());
		}
	    }else{
		if(sc.length() == 0){
		    System.out.println("C");
		    break;
		}else{
		    turn = sc.charAt(0);
		    sc = sc.substring(1,sc.length());
		}
	    }
	}
    }
}


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

int main () {
  int N, K, x = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    if ( x * 2 <= x + K) 
      x *= 2;
    
    else {
      x += K;
    }
  }
  
  cout << x << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }
  ll maxi = LLONG_MAX;
  ll cur = 0;
  rep(i,n-1) {
    cur += a[i];
    maxi = min(maxi,llabs(cur-(sum-cur)));
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio> 
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
typedef long long ll;
const ll mod=1e9+7;
const ll INF=0x3f3f3f3f;
const ll maxn=1e6+5;
const double pi = acos(-1.0);
using namespace std;
ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
int main(){
	ll n,m;
	cin>>n>>m;
	ll x=n*m;
	ll y=gcd(m,n);
	cout<<x/y<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Mod=1e9+7;
char s[10010];
int d,l,f[10010][110];
void upd(int &x,int v)
{
	x=(x+v)%Mod;
}
int main()
{
	scanf("%s",s+1);
	l=strlen(s+1);
	scanf("%d",&d);
	int sum=0;
	for (int i=1;i<=l;i++)
	{
		for (int j=0;j<s[i]-'0';j++)
		{
			upd(f[i][(sum+j)%d],1);
		}
		sum=(sum+s[i]-'0')%d;
		for (int j=0;j<d;j++)
		{
			for (int k=0;k<10;k++)
			{
				upd(f[i][(j+k)%d],f[i-1][j]);
			}
		}
		/*
		for (int j=0;j<d;j++)
		{
			cerr<<f[i][j]<<" ";
		}
		cerr<<endl;
		*/
	}
	int res=f[l][0];
	if (sum)
	{
		upd(res,Mod-1);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
    int a[3],d;
    cin>>a[0]>>a[1]>>a[2]>>d;
    int x=a[0]-a[2];
    if(x<0){
        x*=-1;
    }
    sort(a,a+3);
    if(a[2]-a[1]<=d&&a[1]-a[2]<=d||x<=d){
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <utility>
#include <set>
#include <numeric>
#include <queue>
#include <sstream>
#include <map>
#include <cmath>
using namespace std;
using LLI = long long int;

#define Rep(i, N) for (int i = 0; i < N; i++)

const int M = 1000000007;

int bitof(int a, int k) {
    return (a >> k) & 1;
}


// 端点を共有する横棒の存在しない横棒配置パターン
// 左からi番目に横棒が存在 -> 下からibit目が1
const vector<int> valid_k(int W) {
    vector<int> v;
    for (int k=0; k<(1<<(W-1)); k++) {
        bool valid = true;
        for (int l=0; l<W-1; l++) {
            if (bitof(k, l) & bitof(k, l+1)) {
                valid = false;
                break;
            }
        }
        if (valid) {
            v.push_back(k);
        }
    }
    
    return v;
}

int main(int argc, char *argv[])
{
    int H, W, K;
    cin >> H >> W >> K;

    vector<vector<int>> dp(H+1, vector<int>(W));

    dp[0][0] = 1;
    for (int i=1; i<=H; i++) {
        for (int j=0; j<W; j++) {
            for (const auto k : valid_k(W)) {
                if (j >= 1 && bitof(k, j-1)) {
                    // 左へ移動
                    dp[i][j-1] = (dp[i][j-1] + dp[i-1][j]) % M;
                } else if (j < W-1 && bitof(k, j)) {
                    // 右へ移動
                    dp[i][j+1] = (dp[i][j+1] + dp[i-1][j]) % M;
                } else {
                    // 左右へ移動なし
                    dp[i][j] = (dp[i][j] + dp[i-1][j]) % M;
                }
            }
        }
    }

    cout << dp[H][K-1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll a[500000];
signed main(){
	int n;cin>>n;
	rep(i,n)scanf("%lld",&a[i]);
	map<int,int>mp;
	ll ans=0;
	int d=0;
	rep(i,n){
		rep(j,30){
			if(a[i]>>j&1){
				if(mp.count(j))d=max(d,mp[j]+1);
				mp[j]=i;
			}
		}
		ans+=i-d+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;


int main(){
	long int H,W;
	
	cin >> H >> W;
	
	int i,j;
	int input_num;
	int** arr = new int*[H];
	int no_even_conter=0;
	
	for(i=0;i<H;++i){
		arr[i] = new int[W];
		for(j=0;j<W;++j){
			cin >> arr[i][j];
			if(arr[i][j]%2==1)++no_even_conter;
		}
	}
	no_even_conter=no_even_conter/2;
	//cout << "no_even_conter" << no_even_conter << endl;
	//奇数と奇数の間の数を数える
	int counter_flag=0;
	int counter_sousa=0;
	int buff_no_even_count=0;
	for(i=0;i<H;++i){
		if(i%2==0){ //iが偶数行かどうか
			for(j=0;j<W;++j){
				if(arr[i][j]%2==1){
					if(counter_flag){
						counter_flag=0;
					}else{
						counter_flag=1;
						++buff_no_even_count;
						
						if(no_even_conter<buff_no_even_count){
							counter_flag=0;
						}
					}
				}
				
				if(counter_flag){
					++counter_sousa;
					//cout << i << " " << j << endl;
				}
			}
		}else{
			for(j=W-1;j>-1;--j){
				if(arr[i][j]%2==1){
					if(counter_flag){
						counter_flag=0;
					}else{
						counter_flag=1;
						++buff_no_even_count;
						if(no_even_conter<buff_no_even_count){
							counter_flag=0;
						}
					}
				}
				
				if(counter_flag){
					++counter_sousa;
					//cout << i << " " << j << endl;
				}
			}
		}
	}
	cout << counter_sousa << endl;
	
	
	// 操作する
	int flag=0;
	for(i=0;i<H;++i){
		if(i%2==0){ //iが偶数行かどうか
			for(j=0;j<W;++j){
				if(flag==1){
					cout << i+1 << " " << j+1 << endl;
					++arr[i][j];
					flag=0;
				}
				
				if(arr[i][j]%2==1){
					
					--counter_sousa;
					if(counter_sousa==-1){
						return 0;
					}
					
					cout << i+1 << " " << j+1 << " ";
					flag=1;
				}
			}
		}else{
			for(j=W-1;j>-1;--j){
				if(flag==1){
					cout << i+1 << " " << j+1 << endl;
					++arr[i][j];
					flag=0;
				}
				
				if(arr[i][j]%2==1){
					
					--counter_sousa;
					if(counter_sousa==-1){
						return 0;
					}
					
					cout << i+1 << " " << j+1 << " ";
					flag=1;
				}
			}
		}
	}
	
	
	
	
	return 0;
}




Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi a(n); cin >> a;
	int mn = *min_element(ALL(a));
	int mx = *max_element(ALL(a));
	vector<pii> ans;
	if (abs(mn) < abs(mx))
	{
		int p = max_element(ALL(a)) - a.begin();
		REP(i, n)
		{
			if (a[i] < 0)
			{
				a[i] += mx;
				ans.emplace_back(p, i);
			}
		}
		REP(i, n - 1)
		{
			if (a[i] > a[i + 1])
			{
				a[i + 1] += a[i];
				ans.emplace_back(i, i + 1);
			}
		}
	}
	else
	{
		int p = min_element(ALL(a)) - a.begin();
		REP(i, n)
		{
			if (a[i] > 0)
			{
				a[i] += mn;
				ans.emplace_back(p, i);
			}
		}
		for(int i = n - 1; i > 0; i--)
		{
			if (a[i] < a[i - 1])
			{
				a[i - 1] += a[i];
				ans.emplace_back(i, i - 1);
			}
		}
	}
	cout << ans.size() << endl;
	for (auto p : ans) cout << p.first + 1 << " " << p.second + 1 << endl;
	return 0;
}

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

int main(void){
    long long n;
    cin >> n;
    vector<long long> a(n+10), b(n+10);
    long long asum = 0, bsum = 0;
    for(long long i=0;i<n;++i){
        cin >> a[i];
        asum += a[i];
    }
    for(long long i=0;i<n;++i){
        cin >> b[i];
        bsum += b[i];
    }
    long long cnt = 0;
    if(asum > bsum){
        cout << "No\n";
        return 0;
    }else{
        cnt = bsum - asum;
    }
    long long tmp = 0;
    for(long long i=0;i<n;++i){
        if(a[i]==b[i]) continue;
        if(a[i]<b[i]){
            tmp += (b[i]-a[i])/2;
        }else{
            tmp -= (a[i]-b[i]);
        }
    }
    if(tmp >= 0) cout << "Yes\n";
    else cout << "No\n";
}

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

public class Main{

	public static class Pair implements Comparable<Pair> {
		int id, val;

		public Pair(int id, int val) {
			this.id = id;
			this.val = val;
		}

		@Override
		public int compareTo(Pair o) {
			return Integer.compare(this.val, o.val);
		}
	}

	public static void main(String[] args) throws IOException {
		int N = readInt(), M = readInt(); ArrayList<Pair> graph[] = new ArrayList[N+1];
		for(int i = 1; i<=N; i++) graph[i] = new ArrayList<Pair>();
		for(int i = 1; i<=M; i++) {
			int l = readInt(), r = readInt(), d = readInt(); graph[l].add(new Pair(r, d)); graph[r].add(new Pair(l, -d));
		}
		int dist[] = new int[N+1]; boolean vis[] = new boolean[N+1];
		LinkedList<Integer> list = new LinkedList<Integer>(); 
		for(int i = 1; i<=N; i++) {
			if(!vis[i]) {
				list.add(i); vis[i] = true;
				while(!list.isEmpty()) {
					int n = list.pop(); 
					for(Pair e : graph[n]) {
						if(!vis[e.id]) {vis[e.id] = true; dist[e.id] = dist[n] + e.val; list.add(e.id);}
						if(vis[e.id] && dist[e.id] != dist[n] + e.val) {println("No"); exit();} 
					}
				}
			}
		}

		println("Yes");
		exit();
	}

	public static int find(int par[], int n) {
		if(par[n] == n) return par[n];
		else return par[n] = find(par, n);
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong() throws IOException {
		return Long.parseLong(next());
	}

	static float readFloat() throws IOException {
		return Float.parseFloat(next());
	}

	static boolean readBool() throws IOException {
		return Boolean.parseBoolean(next());
	}

	static short readShort() throws IOException {
		return Short.parseShort(next());
	}

	static byte readByte() throws IOException {
		return Byte.parseByte(next());
	}

	static int readInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static char readChar() throws IOException {
		return next().charAt(0);
	}

	static String readLine() throws IOException {
		return br.readLine().trim();
	}

	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		br.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 76796
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		long[][] array_A = new long[n][m];
		long[][] array_B = new long[m][l];
		long[][] array_C = new long[n][l];

		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				array_A[i][j] = scan.nextInt(); 
			}
		}

		for(int i=0; i<m; i++){
			for(int j=0; j<l; j++){
				array_B[i][j] = scan.nextInt();
			}
		}

		for(int i = 0; i<n; i++){
			for(int j=0; j<l; j++){
				for(int k = 0; k<m; k++){
					array_C[i][j] += array_A[i][k]*array_B[k][j];
				}
			}
		}

		for(int i = 0; i<n; i++){
            System.out.print(array_C[i][0]);
            for(int j=1;j<l;j++){
                System.out.print(" "+array_C[i][j]);  
        }
        System.out.println();
    	}

	}
}

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

int main()
{
    int n,x,t;
    scanf("%d %d %d",&n,&x,&t);
    int m;
    if(n%x==0)
    {
        m=(n/x);
        printf("%d",m*t);
    }
    else
    {
         m=(n/x)+1;
        printf("%d",m*t);
    }
    return 0;
}


Measured memory_bytes: 2136
#include<stdio.h>
#include<string.h>
#define LEN 100005
  
typedef struct pp{
  char name[100];
  int t;
}
  
P;
  
P Q[LEN];
int head,tail,n;
  
void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}
  
P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}
  
int min(int a,int b){return a<b?a:b;}
  
int main(){
  int elaps=0,c;
  int i,q;
  P u;
  scanf("%d%d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head=1;tail=n+1;
  
  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u);
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  return 0;
}

Measured memory_bytes: 12840
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define mp make_pair
#define pb push_back
#define forn(i, n) for(int i = 0; i < (int)(n); ++i)
#define for1(i, n) for(int i = 1; i < (int)(n); ++i)
#define nfor(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define correct(x, y, n, m) (0 <= x && x < n && 0 <= y && y < m)
#define all(x) (x).begin(), (x).end()
#define fst first
#define snd second
#define endl "\n"

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef tuple<int,int,int> iii;

template<typename T> inline T abs(T a){ return ((a < 0) ? -a : a); }
template<typename T> inline T sqr(T a){ return a * a; }
template<class T> T gcd(T a, T b) { return a ? gcd (b % a, a) : b; }
template<class T> T lcm(T a, T b) { return a / gcd (a, b) * b; }
template<class T> T sign(T a) { return a > 0 ? 1 : (a < 0 ? -1 : 0); }

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}

template<typename T>
vector<T> make_unique(vector<T> v) {
    sort(all(v));
    return v.resize(unique(all(v)) - v.begin());
}

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

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int dxKn[8] = {-2, -1, 1, 2,  2,  1, -1, -2};
const int dyKn[8] = { 1,  2, 2, 1, -1, -2, -2, -1};
const int dxK[8] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dyK[8] = {1, -1, 0, 0, 1, -1, 1, -1};

const int MOD = int(1e9) + 7;
const int INF = int(1e9) + 100;
const ll INF64 = 2e18;
const ld PI = ld(3.1415926535897932384626433832795);
const ld e = ld(2.7182818284590452353602874713527);
const ld EPS = 1e-9;

//#############################
const int MAXN = 1000005;

int main() {
    fastIO();
    char x = getchar();

    cout << (isupper(x)? 'A' : 'a') << endl;
    return 0;
}

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

using namespace std;
const double pi=acos(-1.0);
const double eps=1e-9;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define re return
#define vi vector <int> 
#define pii pair <int,int>
#define pll pair <long long , long long>
typedef long long ll;

string s;
int k;

int main()
{
	ios:: sync_with_stdio(false);
	cin >> s;
	cin >> k;
	for(int i=0;i<s.size();i++)
	{
		if(k>=((26-(int)s[i]+'a')%26))
		{
			//cout << "Hi";
			
			k-=(26-(int)s[i]+'a')%26;
			s[i]='a';
		}
		//cout << k << endl;
	}
	k%=26;
	for(int i=0;i<k;i++)
		s[s.size()-1]++;
	if(s[s.size()-1]>'z')s[s.size()-1]-=26;
	cout << s;
	return 0;
}

Measured memory_bytes: 592
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n,q=map(int,input().split())
c=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  c[a].append(b)
  c[b].append(a)
px=[0]*n
for I in range(q):
    p,x=map(int,input().split())
    px[p-1]+=x 
ans=[0]*n
def dfs(g,h=-1):
  ans[g]=ans[h]+px[g]
  for i in c[g]:
    if i==h:continue
    dfs(i,g)
dfs(0)
print(*ans)


Measured memory_bytes: 274440