akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define maxn 500100
#define lson root << 1
#define rson root << 1 | 1
#define lent (t[root].r - t[root].l + 1)
#define lenl (t[lson].r - t[lson].l + 1)
#define lenr (t[rson].r - t[rson].l + 1)
#define N 1111
#define eps 1e-6
#define pi acos(-1.0)
#define e exp(1.0)
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
char s[maxn];
int a[maxn];
int len;
bool check(int x)
{
    int sum = x * 9, cnt = 0;
    for (int i = 0; i < len; i++)
    {
        sum += a[i];
        cnt += sum % 10;
        sum /= 10;
    }
    while (sum > 0)
    {
        cnt += sum % 10;
        sum /= 10;
    }
    return cnt <= x * 9;
}
int main()
{
    while (~scanf("%s", s))
    {
        memset(a, 0, sizeof(a));
        len = strlen(s);
        reverse(s, s + len);
        for (int i = 0; i < len; i++)
            a[i] = (s[i] - '0') * 9;
        for (int i = 0; i < len; i++)
        {
            a[i + 1] += a[i] / 10;
            a[i] %= 10;
        }
        if (a[len])
            len++;
        int l = 0, r = len * 2, ans = -1;
        while (l < r)
        {
            int mid = l + r >> 1;
            if (check(mid))
            {
                ans = mid;
                r = mid;
            }
            else
                l = mid + 1;
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2688
n = gets.to_i
aryM = gets.split.map(&:to_i)
aryS = gets.split.map(&:to_i)

left = 0
ans  = 0

(n).times do |i|
  if aryS[i] >= aryM[i]
    ans += aryM[i]
    aryS[i] -= aryM[i]
    aryM[i] = 0
    if aryS[i] >= aryM[i + 1]
      ans += aryM[i + 1]
      aryM[i + 1] = 0
    else
      ans += aryS[i]
      aryM[i + 1] -= aryS[i]
    end
  else 
    ans += aryS[i]
  end
end

puts ans


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

typedef long long ll;
const int maxn=1e5+10;
int n,a[maxn];
ll sum;

int main(){
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=0;i<=n;++i)
		sum+=abs(a[i]-a[i+1]);
	for(int i=1;i<=n;++i)
		cout<<sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    double N,K; cin >> N >> K;
    double sum=0;
    double cnt=0;
    
    for (double i=1; i<=N; i++){
        int now=i;
        while(now<K){
            now=now*2;
            cnt++;
        }
        sum+=(1.0/N)*pow(0.5,cnt);
        cnt=0;
    }
    cout << fixed<<setprecision(12) <<sum<< endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		int an=Integer.parseInt(st.nextToken());
		int m=Integer.parseInt(st.nextToken());

		//配列作成
		//行列A
		int[][] Aary=new int[an][m];
		for(int y=0;y<an;y++) {
			for(int x=0;x<m;x++) {
				Aary[y][x]=0;
			}
		}
		//ベクトルb
		int[] Bary=new int[m];
		for(int x=0;x<m;x++) {
			Bary[x]=0;
		}

		//配列の数値入力
		//A
		for(int y=0;y<an;y++) {
			StringTokenizer sa=new StringTokenizer(br.readLine());
			for(int x=0;x<m;x++) {
				int a=Integer.parseInt(sa.nextToken());
				Aary[y][x]=a;
			}
		}
		//b
		for(int x=0;x<m;x++) {
			StringTokenizer sb=new StringTokenizer(br.readLine());
			int b=Integer.parseInt(sb.nextToken());
			Bary[x]=b;
		}

		//配列の加工
		int c=0;
		for(int y=0;y<an;y++) {
			for(int x=0;x<m;x++) {
				c=c+Aary[y][x]*Bary[x];
			}
			System.out.println(c);
			c=0;
		}

		//配列出力・デバッグ
		/*for(int y=0;y<an;y++) {
			for(int x=0;x<m;x++) {
				System.out.print(Aary[y][x]);
			}
			System.out.println("");
		}*/
	}

}



Measured memory_bytes: 27428
#include<stdio.h>
int main(void)
{
	int i,j,k;
	k=0;
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
	k=i*j;
	printf("%dx%d=%d\n",i,j,k);
	}
	}
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;


ll i;

struct UnionFind{
    vector<long long> par,height,size;
    UnionFind(ll N): par(N),height(N),size(N){
        for(ll i=0;i<N;i++){
            par.at(i)=i;
            height.at(i)=1;
            size.at(i)=1;
        }
    }

    ll root(ll x){
        if(par.at(x)==x)return x;
        return root(par.at(x));
    }

    void unite(ll x,ll y){
        ll rx=root(x);
        ll ry=root(y);
        if(rx!=ry){
            if(height.at(rx)<height.at(ry)) swap(rx,ry);
            size.at(rx)+=size.at(ry);
            height.at(rx)=max(height.at(ry)+1,height.at(rx));
            par.at(ry)=rx;
        }
    }

    bool same(ll x,ll y){
        if(root(x)==root(y))return true;
        else return false;
    }
    
};



int main(){
    ll N,M;
    cin>>N>>M;
    V X(M),Y(M),Z(M);
    rep(i,M)cin>>X.at(i)>>Y.at(i)>>Z.at(i);

    UnionFind tree(N);
    rep(i,M)tree.unite(X.at(i)-1,Y.at(i)-1);
    ll ans=0;
    vector<bool> jud(N,true);
    for(ll j=0;j<N;j++){
        if(jud.at(tree.root(j))){
            jud.at(tree.root(j))=false;
            ans++;
        }
    }
    cout<<ans<<endl;




}


Measured memory_bytes: 4992
package main
import (
  "fmt"
)

func main() {
  var n int
  fmt.Scan(&n)
  a := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&a[i])
  }

  res := 0
  loop := true
  for {
    for i := 0; i < len(a); i++ {
      if a[i] == 0 || a[i] % 2 == 1 {
      	loop = false
        break
      } else {
      	a[i] = a[i] / 2
      }
    }
    if !loop {
      break
    }
    res++
  }

  fmt.Printf("%v", res)
}

Measured memory_bytes: 512
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    use std::cmp::max;

    input! {
        N: usize,
        W: usize,
        item: [(usize, i64); N],
    }

    let mut dp: Vec<Vec<i64>> = vec![vec![0; (W + 1)]; (N + 1)];

    for i in 1..N + 1 {
        let (w, v) = item[i - 1];

        for j in 0..W + 1 {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if w <= j {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w] + v);
            }
        }
    }


    println!("{:?}", dp[N].iter().max().unwrap());
}

Measured memory_bytes: 106748
#include<stdio.h>
#include<iostream>
using namespace std;
int swap(int *a,int *b){
	int w=*a;
	*a=*b;
	*b=w;
}
int main(){
	int w,n;
	cin>>w;
	int array[w];
	for(int i=1;i<=w;i++){
		array[i-1]=i;
//		cout<<array[i-1]<<endl;
	}
		
	cin>>n;
	for(int i=0;i<n;i++){
		int a,b;
		char c;
		cin>>a>>c>>b;
		swap(&array[a-1],&array[b-1]);
	}
	for(int i=1;i<=w;i++)cout<<array[i-1]<<endl;
	
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(){
	int a, b, c;
	int k;
	scanf("%d %d %d", &a, &b, &c);
	scanf("%d", &k);
	if(a>b && a>c) printf("%d\n", (a<<k)+b+c);
	else if(b>a && b>c) printf("%d\n", a+(b<<k)+c);
	else printf("%d\n", a+b+(c<<k));
	return 0;
}

Measured memory_bytes: 128
from math import factorial
X, Y = map(int, input().split())
MOD = 10**9 + 7

def comb(n, r, p):
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

    if r < 0 or n < r:
        return 0
    r = min(r, n-r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def solve():
    a = (2*Y-X) / 3
    b = (2*X-Y) / 3
    if a.is_integer() and b.is_integer() and a >= 0 and b >= 0:
        ans = comb(int(a+b), int(min(a, b)), MOD)
        print(ans)
    else:
        print(0)

if __name__ == '__main__':
    solve()

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {

    int n;
    cin>>n;
    vector<int> d(n);
    rep(i,n)    cin>>d.at(i);

    sort(all(d));
    int ans=d[n/2]-d[n/2-1];

    cout<<ans<<endl;

 return 0;
}

Measured memory_bytes: 640
// author: Saman Mahdanian
#include <bits/stdc++.h>

using namespace std;
const int N = 600;
const int MOD = 1e9 + 7;

void _psum (int &, int);
int _sum (int, int);
int _mul (int, int);
int _pow (int, int);
int gcd (int, int);

int n, m, k, inv[N], f[N], res[N];
vector <int> X;

int x[] = {0, 0, -1, +1};
int y[] = {-1, +1, 0, 0};
string s[N];
int t[N][N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int q;
	cin >> q;
	while (q--) {
		long long p1,p2; 
		cin >> p1 >> p2;
		if (p1 > p2) 
			swap(p1, p2);
		long long p3 = p1 * p2; 
		long long root = sqrt(p3);
		if (root * (root + 1) < p3) 
			cout << 2 * root - 1 << endl;
		else if (root * root == p3) {
			if (p1 == p2) 
				cout << 2 * root - 2 << endl;
			else 
				cout << 2 * root - 3 <<endl;
		} else
			cout << 2 * root - 2 << endl;
 	}
}

int gcd (int a, int b) {
	return !b? a : gcd (b, a % b);
}

// int choose (int r, int k) {
// 	return _mul (f[k], _mul(inv[r], inv[k - r]));
// }

void _psum (int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int _sum (int a, int b) {
	return a + b - (a + b >= MOD? MOD : 0);
}

int _mul (int a, int b) {
	return 1LL * a * b % MOD;
}

int _pow (int a, int b) {
	if (!b) 
		return 1;
	int res = _pow (a, b >> 1);
	res = _mul (res, res);
	if (b & 1)
		res = _mul (res, a);
	return res;
}

// SamMHD :: Jun27-2019 :: Another Day with Shayan...

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

int main() {
    int n, m;
    cin >> n >> m;
    if (n > m) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> x(m);
    for (auto& x_i : x) 
        cin >> x_i;
    sort(x.begin(), x.end());

    vector<pair<int, int>> diff;
    for (int i = 0; i < x.size() - 1; ++i) 
        diff.push_back(make_pair(i, x[i + 1] - x[i]));
    sort(diff.begin(), diff.end(), [] (const pair<int, int>& p1, const pair<int, int>& p2) {return p1.second > p2.second;});
    vector<int> first;
    first.push_back(0);
    for (auto itr = diff.begin(); itr != diff.begin() + n - 1; ++itr)
        first.push_back(itr->first + 1);
    sort(first.begin(), first.end());
    int sum = 0;
    for (auto itr = first.begin(); itr != first.end() - 1; ++itr) 
        sum += x[*(itr + 1) - 1] - x[*itr];
    sum += *(x.end()-1) - x[*(first.end() - 1)];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2292
import sys
h, w = map(int, input().split())
f = [list(map(str, input().rstrip())) for _ in range(h)]

for i in range(h - 1):
    for j in range(w - 1):
        if (f[i][j] == "#" and f[i][j + 1] == "#" and f[i + 1][j] == '#') or (f[i][j + 1] == "#" and f[i + 1][j] == "#" and f[i + 1][j + 1] == "#"):
            print("Impossible")
            sys.exit()

print("Possible")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
int main(){cout<<fixed<<setprecision(10);int a,b,c;cin>>a>>b>>c;Yes(2*max(a,max(b,c))==a+b+c);}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
  io;
  ll a,b,c,d;
  ll max=INT_MIN;
  cin>>a>>b>>c>>d;
  set <ll> s;
  s.insert(a*c);
  s.insert(a*d);
  s.insert(b*c);
  s.insert(b*d);

  auto it =s.end();
  it--;
  cout<<*it<<endl;

  // cout<<max<<endl;
  return 0;
}


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

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);  
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < n; ++i) 
    	ans += (s[i] == 'R');
    int t = ans;
    for (int i = 0; i < t; ++i) 
    	ans -= (s[i] == 'R');
    cout << ans;
    return 0;
}

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

int main(){
  int N,X;
  cin >> N >> X;
  
  vector<int> amount(N);
  for(int i=0; i < N; i++){
    cin >> amount.at(i);
  }
  
  int min = 1000;
  int sum = 0;
  for(int i = 0; i < N ; i++){
    if(min > amount.at(i)){
      min = amount.at(i);
    }
    sum += amount.at(i);
  }
  
  int dounats = (X-sum)/min + N;
  
  cout << dounats << endl;
  
}

Measured memory_bytes: 3600
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
        rec: [usize; n],
    }

    let mut turn = vec![0; n];

    for (i,r) in rec.iter().enumerate() {
        turn[*r-1] = i+1;
    }

    for t in &turn {
        print!("{} ", t);
    }
}


Measured memory_bytes: 6908
#include<iostream>

using namespace std;

int main(){
    
    long long n,a;
    long long min=1000000;
    long long max=-1000000;
    long long sum=0;
    cin>>n;
    
    for(int i=0;i<n;i++){
        cin>>a;
        if(a<min)min=a;
        if(a>max)max=a;
        sum+=a;
        
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int n; cin>>n;
	int g; cin>>g;
  for (int i=1; i<n; i++) {
    int x; cin>>x;
    g = __gcd(x,g);
  }
  out(g);
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5+5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


int n,m,u,v; vector <int> adj[N];
bool vis[N];

void dfs(int s) {
    vis[s]=true;
    for (auto u : adj[s]) if (!vis[u]) dfs(u);
}

void solve()
{
    cin >> n >> m;
    fill(vis,vis+n+2,false); int ans=0;
    for (int i=0; i<m; ++i) {
        cin >> u >> v;
        adj[u].pb(v); adj[v].pb(u);
    }
    for (int i=1; i<=n; ++i) {
        if (!vis[i]) {
            dfs(i); ans++;
        }
    }

    nout(ans-1);
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 9700
#define _LIBCPP_DEBUG 0

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  vector<int>b(n);
  vector<ll>ans(100001);
  priority_queue<int>pq;
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  vector<vector<int>>data(100001);
  for(int i=0;i<n;i++){
    data[a[i]].push_back(b[i]);
  }
  ll sum=0;
  ans[0]=0;
  for(int i=1;i<=100000;i++){
    for(int j=0;j<data[i].size();j++){
      pq.push(data[i][j]);
    }
    if(pq.size()>0){
      sum+=pq.top();
      pq.pop();
    }
    ans[i]=sum;
  }
  cout<<ans[m]<<endl;
}
      
  
  


Measured memory_bytes: 7168
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (a, b, x) = listOfLong()

    if (a == 0L) {
        println(b / x + 1)
    } else {
        println((b / x) - ((a-1) / x))
    }
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 38024
#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 yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll w[101],u[101];
ll dp[101][100001]={};
P1 d[100001]={};
int main() {

	int n,W;

	cin>>n>>W;
	rep(i,n){
		cin>>w[i+1]>>u[i+1];
		d[i+1].first=w[i+1];
		d[i+1].second=u[i+1];
	}
	sort(d,d+n);
	for(int i=1; i<W+1; i++){
		for(int j=1; j<n+1; j++){
			if(d[j].first<=i){
				dp[j][i]=max(dp[j][i],dp[j-1][i-d[j].first]+d[j].second);
			}
			dp[j][i]=max(dp[j][i],dp[j-1][i]);
		}
	}
	cout<<dp[n][W]<<endl;
	return 0;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define db double 
#define LL long long 
const int N = 1e5 + 11;
db x[N];
int m, a[N], n;
int stk[N], tp, to[N], res[N];
bool mark[N];
LL K;
int main(){
    cin>>n;
    for(int i = 1;i <= n; i++){
        scanf("%lf", &x[i]);
    }
    for(int i = n;i >= 1; i--)x[i] -= x[i-1], to[i] = i;
    cin>>m>>K;
    for(int i = 1;i <= m; i++){
        scanf("%d", &a[i]);
        swap(to[a[i]], to[a[i]+1]);
    }
    for(int i = 1;i <= n; i++){
        if(mark[i])continue;
        mark[i] = tp = 1; stk[1] = i; 
        int now = to[i];
        while(now != i)mark[now] = 1, stk[++tp] = now, now = to[now];
        for(int j = 1;j <= tp; j++)res[stk[j]] = stk[(j-1+K)%tp+1];
    }
    db t = 0;
    for(int i = 1;i <= n; i++){
        t += x[res[i]];
        printf("%.1lf\n", t);
    }
    return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> toshi(N);
  rep(i,M){
  	int a,b;
    cin >> a >> b;
    toshi.at(a-1)++;
    toshi.at(b-1)++;
  }
  rep(i,N){
    cout << toshi.at(i) << endl;
  }
}







Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
t, i, j = 0, 0, 1

a.sort()
while True:
    if i >= len(a):
        break

    if len(a) > 1:
        while a[i] == a[j]:
            j += 1

            if j == len(a):
                break

    if a[i] > j - i:
        t += j - i
    elif a[i] < j - i:
        t += j - i - a[i]

    i = j

print(t)


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

using namespace std;

int main(){
    int a, b, v1, v2 ,v3, ans1, ans2;
    cin >>a >>b;
    v1 = a + b;
    v2 = a - b;
    v3 = a * b;
    ans1 = max(v1,v2);
    ans2 = max(ans1, v3);
    cout << ans2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define abs(a) ((a)>(0)?(a):-(a))
#define MOD 1000000007
#define ll long long
ll inv(ll a){
  ll t=1;
  while (a>1){
    t=t*(MOD-MOD/a)%MOD;
    a=MOD%a;
  }
  return t;
}
ll comb(ll n,ll k){
  if (k>n-k) k=n-k;
  ll nu=1,de=1,i;
  rep(i,1,k+1){
    nu=nu*(n+1-i)%MOD;
    de=de*i%MOD;
  }
  return nu*inv(de)%MOD;
}
int main(){
    long long n,m,k,ans=0,i;
    scanf("%lld%lld%lld",&n,&m,&k);
    rep(i,1,n) ans+=i*abs(n-i)*(m*m);
    ans%=MOD;
    rep(i,1,m) ans+=i*abs(m-i)*(n*n);
    ans%=MOD;
    ans*=comb(n*m-2,k-2);
    printf("%lld",ans%MOD);
}

Measured memory_bytes: 128
n = int(input())
x = list(map(int, input().split()))

sortedx = x[:]
sortedx.sort()

for i in range(n):
    #ix = sortedx.index(x[i])
    #print(sortedx)
    #print(ix)
    if x[i] <= sortedx[n//2-1]:
        print(sortedx[n//2])
    else:
        print(sortedx[n//2-1])

Measured memory_bytes: 26016
s = input()
n = len(s)

def dfs(i , f):
    if i == n-1:
        return sum(list(map(int , f.split("+"))))
    
    return dfs(i+1 , f + s[i+1]) + dfs(i + 1 , f + "+" + s[i+1])

print(dfs(0 , s[0]))

Measured memory_bytes: 38896
N = gets.to_i
X = 0
Y = 1
CITIES = N.times.map { gets.split.map!(&:to_i) }

dist = 0
CITIES.permutation(N) do |cities|
  cities.each_cons(2) do |a, b|
    dist += Math.sqrt((a[X] - b[X])**2 + (a[Y] - b[Y])**2)
  end
end

puts dist / 2.upto(N).inject(:*)

Measured memory_bytes: 1916
from collections import Counter
N, X, Y = map(int, input().split())
X -= 1
Y -= 1
dis = []
for i in range(N-1):
    for j in range(i, N):
        dis.append(min(abs(i-j), abs(i-X)+abs(j-Y)+1,  abs(i-Y)+abs(j-X)+1))
cnt = Counter(dis)
for k in range(1, N):
    print(cnt[k])


Measured memory_bytes: 67804
import sys
import collections as col
import numpy as np
MOD = 1000000007


def input():
    return sys.stdin.readline().rstrip()


def main():
    n, k = [int(e) for e in input().split()]
    adj = [[] for _ in range(n+1)]
    for _ in range(n-1):
        u, v = [int(e) for e in input().split()]
        adj[u].append(v)
        adj[v].append(u)

    ans = 1
    queue = col.deque([(1, 0, k)])
    while len(queue) > 0:
        u, p, k_ = queue.popleft()
        ans = (ans * k_) % MOD
        if p == 0:
            k_next = k - 1
        else:
            k_next = k - 2
        for v in adj[u]:
            if v == p:
                continue
            queue.append((v, u, k_next))
            k_next -= 1
    print(ans)


main()


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

int main(void){
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
n,a,b=map(int,input().split())
X=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if (X[i+1]-X[i])*a>b:
        ans+=b
    else:
        ans+=(X[i+1]-X[i])*a

print(ans)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
const int N=2*1e5+100,M=4100;
int n;
int a[N],b[N],MAX;
ll fac[M*2],inv[M*2],dp[M][M];
inline ll m_pow(ll a,int b)
{
	ll ans=1;
	while (b)
	{
		if (b&1) ans=(ans*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return ans;
}
inline void add(ll &a,ll b){a=(a+b)%mod;}
inline void mul(ll &a,ll b){a=(a*b)%mod;}
inline void sep(ll &a,ll b){a=(a*m_pow(b,mod-2))%mod;}
inline void del(ll &a,ll b){a=(a-b+mod)%mod;}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		dp[2000-a[i]][2000-b[i]]++;
		MAX=max(MAX,a[i]+b[i]);
	}
	fac[0]=1;
	for (int i=1;i<=2*MAX;i++) fac[i]=(fac[i-1]*i)%mod;
	inv[2*MAX]=m_pow(fac[2*MAX],mod-2);
	for (int i=2*MAX-1;i>=1;i--) inv[i]=(inv[i+1]*(i+1))%mod;
	for (int i=0;i<=4000;i++)
	{
		for (int j=0;j<=4000;j++)
		{
			if (i!=0) add(dp[i][j],dp[i-1][j]);
			if (j!=0) add(dp[i][j],dp[i][j-1]);
		}
	}
	ll ans=0,num;
	for (int i=1;i<=n;i++)
	{
		add(ans,dp[a[i]+2000][b[i]+2000]);
		num=fac[a[i]*2+b[i]*2];
		mul(num,inv[a[i]*2]);mul(num,inv[b[i]*2]);
		del(ans,num);
	}
	sep(ans,2);
	printf("%lld\n",ans);
}

Measured memory_bytes: 133584
#include "bits/stdc++.h"
using namespace std;

int main(int argc, char const *argv[])
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int ans = 0;
	ans += (a[2] - a[1]) >> 1;
	ans += (a[2] - a[0]) >> 1;

	if((a[2] % 2) != (a[1] % 2) && (a[2] % 2) != (a[0] % 2)) {
		++ans;
	} else if ((a[2] % 2) != (a[1] % 2) || (a[2] % 2) != (a[0] % 2)) {
		ans += 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(a>0&&c>0){
    a-=d;
    c-=b;
    if(c<=0){
      cout<< "Yes" << endl;
      return 0;}
    if(a<=0){
      cout<< "No" << endl;
      return 0;}
  }
}


Measured memory_bytes: 3624
nab = list(map(lambda word: int(word), input().split(' ')))
s = input()

count = 0
foreign = 0
for student in s:
    if student == 'a' and count < nab[1] + nab[2]:
        print('Yes')
        count += 1
    elif student == 'b' and count < nab[1] + nab[2] and foreign + 1 <= nab[2]:
        print('Yes')
        count += 1
        foreign += 1
    else:
        print('No')


Measured memory_bytes: 4016
N = int(input())
A_s = list(map(int, input().split()))
B_s = list(map(int, input().split()))
C_s = list(map(int, input().split()))
pa = -1
answer = 0
for a in A_s:
    if pa+1 == a:
        answer += C_s[pa-1]
    answer += B_s[a-1]
    pa = a
print(answer)

Measured memory_bytes: 38536
n = int(input())

d = {"M":0,"R":0,"A":0,"C":0,"H":0}
S = []
num = 0

for i in range(n):
    S.append(input())


for s in S:
    #キーの中にs[0]の文字があるときのみ
    if s[0] in list(d.keys()):
        d[s[0]] += 1



for al1 in list(d.keys()):
    for al2 in list(d.keys()):
        for al3 in list(d.keys()):
            if al1 != al2 and al1 != al3 and al2 != al3:
                num += d[al1]*d[al2]*d[al3]

print(int(num/6))
        

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  int ans=0;
  for(int i=0;i<n;i++) ans+=a[i]-1;
  cout<<ans<<endl;
}


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

int main() {
  char B,D;
  int A,C,E;
  cin >> A >> B >> C >> D >> E;
  
  if(C>4){
    cout<< "TBD" << endl;
  }
  else{
    cout << "Heisei" << endl;
  }
}


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

class Node:
    def __init__(self,index,height):
        self.index = index
        self.height = height
        self.refs = []
        self.isGood = True

    def append(self,target):
        if target.height >= self.height:
            self.isGood = False
        if self.height >= target.height:
            target.isGood = False
        self.refs.append(target)
        target.refs.append(self)

def solve(N: int, M: int, H: "List[int]", A: "List[int]", B: "List[int]"):
    nodes = [Node(i,H[i]) for i in range(N)]
    for i in range(M):
        nodes[A[i]-1].append(nodes[B[i]-1])
    def isGood(node):
        return node.isGood

    print(len(list(filter(isGood,nodes))))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, H, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 100144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int res = 0;
		
		for (int i = 1; i <= n; i++) {
			int sum = getDigitSum(i);
			
			if ((sum >= a) && (sum <= b)) {
				res += i;
			}
		}
			
		System.out.println(res);
	}
	
	private static int getDigitSum(int num) {
		int res = 0;
		while (num > 0) {
			res += (num % 10);
			num /= 10;
		}
		return res;
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


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

int main() {
  int n,m; cin >> n >> m;
  vector<int> a(n); for(int i=0; i<n; i++) cin >> a[i];
  vector<pair<int,int>> data(m);
  for(int i=0; i<m; i++) cin >> data[i].first >> data[i].second;
  
  sort(a.begin(), a.end());
  sort(data.begin(), data.end(), [](pair<int,int> a, pair<int,int> b) {
    if(a.second != b.second) return a.second > b.second;
    else return a.first > b.first;
  });
  
  vector<int> d(n);
  int x=0;
  for(int i=0; i<n; i++) {
    for(int j=0; j<data[i].first; j++) {
      if(x==n) break;
      d[x]=data[i].second;
      ++x;
    }
    if(x==n) break;
  }
  
  for(int i=0; i<n; i++) {
    if(a[i]>=d[i]) break;
    a[i]=d[i];
  }
  
  long ans=0;
  for(int i: a) ans+=i;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll mygcd(long long a,long long b){if(b==0) return a ; return mygcd(b,a%b) ;}
//ll mylcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

ll modpow(ll a,ll b){
	if(a==0){
		return (b==0) ;
	}
	if(a==1) return 1 ;
	ll res = 1 ;
	while(b>0){
		if(b&1) res = res*a%mod ;
		b /= 2 ;
		a = a*a%mod ;
	}
	return res ;
}

int main(){
	ll n,k ;
	cin >> n >> k ;
	ll ans = 0 ;
	vector<ll> num(k+1,-1) ;
	vector<ll> used(k+1,0) ;
	for(ll i=k;i>=2;i--){
		ll sub = 0 ;
		if(num.at(k/i)==-1) num.at(k/i) = modpow(k/i,n) ;
		sub = num.at(k/i) ;
		(sub = sub-used.at(i)+mod) %= mod ;
		(ans += sub*i%mod) %= mod ;
		for(ll j=1;j*j<=i;j++){
			if(i%j==0){
				used.at(j) += sub ;
				used.at(j) %= mod ;
				if(j!=i/j){
					used.at(i/j) += sub ;
					used.at(i/j) %= mod ;
				}
			}
		}
//		cout << ans << endl ;
	}
//	for(int i=1;i<=k;i++) cout << used.at(i) << (i==k?'\n':' ') ;
	ans += (modpow(k,n)-used.at(1)+mod) ;
	ans %= mod ;
	cout << ans << endl ;
}


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

#define fastio {\
    ios::sync_with_stdio(0);\
    cin.tie(0);\
}

#define file {\
    freopen("io\\in.txt", "r", stdin);\
    freopen("io\\out.txt", "w", stdout);\
    freopen("io\\err.txt", "w", stderr);\
}

#ifdef LOCAL
#define debug(args...) {\
    string _s(#args);\
    replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s);\
    istream_iterator<string> _it(_ss);\
    debug1(_it, args);\
}

#pragma GCC diagnostic ignored "-Wunused-parameter"
void debug1(istream_iterator<string> it) {
    cerr << endl;
}
#pragma GCC diagnostic pop

template<class T, class... Args>
void debug1(istream_iterator<string> it, T a, Args... args) {
    cerr << '>' << *it << " = " << a << "; ";
    debug1(++it, args...);
}
#else
#define debug(args...)
#define cerr if (false) cerr
#endif

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n)   for (int i = 0; i < n; i++)
#define dotc()      int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)       (int)x.size()
#define eb          emplace_back
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define all(x)      x.begin(), x.end()
#define rall(x)     x.rbegin(), x.rend()
#define fi          first
#define se          second

const int inf(0x3fffffff);
const int mod(1000000007);
const double pi(acos(-1.0));

signed main() {
    fastio;
#ifdef LOCAL
    file;
#endif

    string s;
    cin >> s;
    cout << (count(all(s), '7') ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main()
{
string s1,s2;
cin>>s1>>s2;
int l=s1.length();
int c=0;
for(int i=0;i<l;i++)
{

if(s1.at(i)!=s2.at(i))
{
	c++;
}
}

cout<<c<<endl;
}

	
	
	
	
	
	
	
	
	


Measured memory_bytes: 3924
#include<stdio.h>

int main(){
	char A;
	int B;
	while(!feof(stdin)){
		A=fgetc(stdin);
		if(A=='0')
			break;
		B=0;
		B+=A-'0';
		while((A=fgetc(stdin))!='\n'){
			B+=A-'0';
		}
		printf("%d\n",B);
	}
	return 0;
}

Measured memory_bytes: 524
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    questionnaire = [0] * m
    for _ in range(n):
        questionnaire = map(lambda x, y: x+y, questionnaire, map(int, input().split()))
    d = {m-k: v for k, v in enumerate(questionnaire)}
    result = sorted(d.items(), key=lambda x: (x[1], x[0]), reverse=True)
    print(*[m-r[0]+1 for r in result])

Measured memory_bytes: 8956
package main

import "fmt"

func main() {
	var x int
	var i int
	var y int
	y = 100
	fmt.Scan(&x)
	for i = 1; true; i++ {
		y = int(float64(y) * 1.01)
		if x <= y {
			break
		}
	}
	fmt.Println(i)
}


Measured memory_bytes: 1752
using System;

namespace ABC155
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            int i;

            bool flag = false;


            int[] num = new int[N];


            for (i = 0; i < N; i++)
            {
                num[i] = int.Parse(str[i]);

                if(num[i] % 2 == 0)
                {
                    if(num[i] % 3 ==0 || num[i] % 5 == 0)
                    {

                    }
                    else
                    {
                        flag = true;
                    }
                }

            }


            if (flag)
            {
                Console.WriteLine("DENIED");
            }
            else
            {
                Console.WriteLine("APPROVED");
            }



        }
    }
}



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

using str = string;
using ss = stringstream;

int p,q;

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

    int n,a,b;
    cin>>n>>a>>b;

    str s;
    cin>>s;

    for(int i=0;i<n;i++)
    {
        if(s[i]=='a')
        {
            p++;
            puts(p<=a+b?"Yes":"No");
        }
        else if(s[i]=='b')
        {
            q++;
            if(q<=b)p++;
            puts(p<=a+b&&q<=b?"Yes":"No");
        }
        else if(s[i]=='c')
        {
            printf("No\n");
        }
    }

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll sum = 0;
    vector<ll> A;
    cin >> N;
    A.resize(N);
    rep(i, N) {
        cin >> A[i];
        sum += abs(A[i] - (i == 0 ? 0 : A[i - 1]));
    }
    sum += abs(A.back());
    rep(i, N) {
        ll left = (i == 0 ? 0 : A[i - 1]);
        ll right = (i == N - 1 ? 0 : A[i + 1]);
        cout << sum - abs(A[i] - left) - abs(right - A[i]) + abs(right - left) << endl;
    }
    return 0;
}


Measured memory_bytes: 2048
x = int(input())

if x >= 1800:
    print(1)
elif x >= 1600:
    print(2)
elif x >= 1400:
    print(3)
elif x >= 1200:
    print(4)
elif x >= 1000:
    print(5)
elif x >= 800:
    print(6)
elif x >= 600:
    print(7)
else:
    print(8)

Measured memory_bytes: 9016
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
  string K;
  int D;
  cin >> K >> D;
  int N = K.size();
  ll dp[N + 10][D][2];
  rep(i, N + 1)rep(j, D)rep(k, 2) dp[i][j][k] = 0;
  dp[0][0][1] = 1;
  rep(i, N) {
    int now = K[i] - '0';
    rep(j, D) {
      // 1 to 1
      dp[i + 1][(j + now) % D][1] += dp[i][j][1];
      dp[i + 1][(j + now) % D][1] %= MOD;

      // 1 to 0
      if(now != 0) {
	rep(k, now) {
	  dp[i + 1][(j + k) % D][0] += dp[i][j][1];
	  dp[i + 1][(j + k) % D][0] %= MOD;
	}
      }

      // 0 to 0
      rep(k, 10) {
	dp[i + 1][(j + k) % D][0] += dp[i][j][0];
	dp[i + 1][(j + k) % D][0] %= MOD;
      } 
    }
  }
  cout << (dp[N][0][0] + dp[N][0][1] - 1  + MOD) % MOD << endl;
}

Measured memory_bytes: 19216
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int N, M;
void solve() {
    cin >> N >> M;
    long long ans = 0;
    vector<pair<long, long>> Ener;
    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B;
        Ener.push_back(make_pair(A, B));
    }
    sort(Ener.begin(), Ener.end());
    long long rest = M;
    int idx = 0;
    //for (int i = 0; i < N; i++) {
    //    if (M <= Ener[i].second) {
    //        cout << ans + Ener[i].first * M << endl;
    //        return;
    //    }
    //    ans += Ener[i].first * Ener[i].second;
    //    M -= Ener[i].second;
    //}
    while (rest - Ener[idx].second > 0) {
        rest = rest - Ener[idx].second;
        ans = ans + (Ener[idx].first * Ener[idx].second);
        idx++;
    } 
    ans = ans + (Ener[idx].first * rest);
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 2420
#define REP(i, n) for (int (i) = 0;(i)<(int)(n);(i)++)
#define rep(i, n) REP(i, n)
#define REPI(i, a, n) for(int i=int(a);i<int(b);i++)
#define repi(i, a, n) REPI(i, a, n)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define putn(x, n) cout<<fixed<<setprecision(n)<<x<<endl
#define PB push_back

typedef long long ll;

#include <bits/stdc++.h>

using namespace std;


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

    char c;
    int n=0,s=0;
    while(cin>>c){
        int x=c-'0';
        s+=x;
        n=n*10+x;
    }
    if(n%s==0)cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[105][2];
int main()
{
    dp[0][0]=1;
    dp[0][1]=0;
    int n,m,x;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)
    {
    	scanf("%d",&x);
    	if(x%2==0)
    	{
    		dp[i][0]=dp[i-1][0]*2;
    		dp[i][1]=dp[i-1][1]*2;
		}
		else
		{
			dp[i][0]=dp[i-1][1]+dp[i-1][0];
    		dp[i][1]=dp[i-1][0]+dp[i-1][1];
		}
	}
	printf("%lld",dp[n][m]);
}

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

int main(){ 
    int n,x;
    int a=0;
    int b=0;
    cin>>n>>x;
    vector<int> vec(n);
for (int i = 0; i < n; i++) {
  cin >> vec.at(i);
}
for(int i=0;i<n;i++){
if(a>x){
break;
}
a+=vec.at(i);
b++;
}
if(x>=a){
    b+=1;
}
cout<<b;
    return 0;
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    string s;
    cin >> s;
    if ( s == "ABC" ) {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3660