akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll K, X; cin >> K >> X;
  
  //main
  string ans = 500*K>=X ? "Yes" : "No";
  
  // output
  cout << ans << endl;

  return 0;
}

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

int main(void){
        char s[201],tmp[201];
        int h,i,m,j;
        while(1){
                scanf("%s",s);
                if(s[0]=='-')
                        break;
                scanf("%d",&m);
                for(i=0;i<m;i++){
                        scanf("%d",&h);
                        for(j=0;j<h;j++)
                                tmp[j]=s[j];
                        j=0;
                        while(s[h+j]){
                                s[j]=s[h+j];
                                j++;
                        }
                        s[j]='\0';
                        tmp[h]='\0';
                        strcat(s,tmp);
                }
                puts(s);
        }
        return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define per(i,n,k) for(int i=n;i>=k;i--)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define ll long long
using namespace std;
const int maxn=1005;
const ll modn=1e9+7;
const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int n,m;
ll f[maxn][maxn];
char a[maxn][maxn];
int main()
{
	scanf("%d%d",&n,&m);
	rep(i,0,n-1) scanf("%s",a[i]);
	rep(i,0,n-1) if(a[i][0]=='.') f[i][0]=1; else break;
	rep(i,0,m-1) if(a[0][i]=='.') f[0][i]=1; else break;
	rep(i,1,n-1) rep(j,1,m-1) if(a[i][j]=='.') f[i][j]=(f[i-1][j]+f[i][j-1])%modn;
	printf("%lld",f[n-1][m-1]);
	return 0;
}

Measured memory_bytes: 9088
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int cnt,len,i;
	char buf[1001],a[11];
	cnt=0;
	scanf("%s",a);
	len=strlen(a);
	for(i=0;i<len;i++)	{
		if(a[i]>='A' && a[i]<='Z')	a[i]+='a'-'A';
	}
	while(1)	{
		scanf("%s",buf);
		if(strcmp(buf,"END_OF_TEXT")==0)	break;
		len=strlen(buf);
		for(i=0;i<len;i++)	{
			if(buf[i]>='A' && buf[i]<='Z')	buf[i]+='a'-'A';
		}	
//		printf("%s\n",buf);
		if(strcmp(buf,a)==0)	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


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

long long N, a[300006], b[300006], ans;
int main(){
	scanf("%lld", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &a[i]);
		b[a[i]]++;
	}
	for (int i = 0; i <= N; i++) {
		ans += b[i]*(b[i] - 1)/2;
	}
	for (int i = 0; i < N; i++) {
		printf("%lld\n", ans - b[a[i]] + 1);
	}
	return 0;
}

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

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<tuple<ll, bool, ll>> events;
  for (int i = 0; i < N; ++i) {
    ll s, t, x;
    cin >> s >> t >> x;
    events.emplace_back(s - x, true, x);
    events.emplace_back(t - x, false, x);
  }
  sort(events.begin(), events.end());
  int j = 0;
  set<ll> xs;
  for (int i = 0; i < Q; ++i) {
    ll d;
    cin >> d;

    for (;; ++j) {
      if (j == events.size()) {
        cout << -1 << endl;
        break;
      }
      auto [t, to_add, x] = events[j];
      if (t > d) {
        if (xs.empty()) {
          cout << -1 << endl;
        } else {
          cout << *xs.begin() << endl;
        }
        break;
      }
      if (to_add) {
        xs.insert(x);
      } else {
        xs.erase(x);
      }
    }
  }
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main()
{
    int32 h,w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    REP(i,h)REP(j,w)cin >> a[i][j];
    REP(i,h){
        bool flg = true;
        REP(j,w){
            if(a[i][j] == '#'){
                flg = false;
                break;
            }
        }
        if(flg){
            a.erase(a.begin() + i);
            i--;
            h--;
        }
    }
    REP(j,w){
        bool flg = true;
        REP(i,h){
            if(a[i][j] == '#'){
                flg = false;
                break;
            }
        }
        if(flg){
            REP(i,h){
                a[i].erase(a[i].begin() + j);
            }
            j--;
            w--;
        }
    }
    REP(i,h){
        REP(j,w){
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let l: Vec<usize> = sc.vec(n);

    let mut two = vec![0; 10000];
    for i in 0..n {
        for j in (i + 1)..n {
            let x = l[i] + l[j];
            two[x] += 1;
        }
    }

    let mut ans = n * (n - 1) * (n - 2) / 6;
    for sum_length in 0..two.len() {
        let two_count = two[sum_length];
        if two_count == 0 {
            continue;
        }
        for &single in l.iter() {
            if sum_length <= single {
                ans -= two_count;
            }
        }
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

int main(void) {
  string n;
  cin >> n;

  for(int i = 0; i < n.length(); i++) {
    if(n[i] == '1') {
      n[i] = '9';
    }
    else {
      n[i] = '1';
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char *argv[])
{
    int num,i;
    char ch;
    int count[26];
    char s[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
                    'n','o','p','q','r','s','t','u','v','w','x','y','z'};
    
    for(i=0;i<26;i++){  //カウントの初期化
        count[i]=0;
    }
    
    while(scanf("%c",&ch) != EOF){
        
        
        if(ch == EOF)break;
        
        if('A' <= ch && ch <= 'Z'){  //大文字を小文字に変換
            ch = (ch + 'a') - 'A';
        }
        
        if('a'<= ch && ch <= 'z'){  //小文字を変数に当てはめ、カウント
            num = ch - 'a';
            count[num]++;
            
        }
        
    }
    for(i=0; i<26; i++){
        printf("%c : %d\n",s[i],count[i]);  //全てのアルファベットが入った配列とそのカウント数の表示
    }
    return 0;
}



Measured memory_bytes: 2024
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b=parseMap(split(readline()))
    if a+b==15
        println("+")
    elseif a*b==15
        println("*")
    else
        println("x")
    end
end
main()

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

int main(void) {
    int N,H;
    cin >> N >> H;

    vector<int> a(N);
    vector<int> b(N);
    for(int i=0;i<N;i++) {
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int cnt = 0;
    vector<int>::iterator it = upper_bound(b.begin(), b.end(), a[N-1]);
    int tmax = distance(it, b.end());
    for(int i=0;i<tmax;i++){
        H -= b[b.size()- i -1];
        cnt++;
        if(H <= 0) {
            cout << cnt << endl;
            return 0;
        }
    }

    cnt += (H/a[N-1]);
    if(H%a[N-1]) cnt++;
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

// struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visited[MAX]; // 訪問状況


int main() {
    // input
    int n, m;
    cin >> n >> m;
    vi x(m);
    rep(i, m) {
        cin >> x[i];
    }
    // solve
    sort(ALL(x));
    vi y(m-1);
    rep(i, m-1) {
        y[i] = x[i+1] - x[i];
    }
    sort(ALL(y));
    // output
    if (n >= m) {
        cout << 0 << "\n";
    } else {
        int sum = 0;
        rep(i, m-n) {
            sum += y[i];
        }
        cout << sum << "\n";
    }
}

Measured memory_bytes: 4052
#include <iostream>

using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;
    if(A==B){
        cout<<"Draw";
    }
    else if(A==1){
        cout<<"Alice";
    }
    else if (B==1){
        cout<<"Bob";
    }
    else if (A>B){
        cout<<"Alice";
    }
    else cout<<"Bob";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N,i,a1=0,a2=0,a4=0;
    cin>>N;
    int a[N];
    for(i=0;i<N;i++){
        cin>>a[i];
    }
    for(i=0;i<N;i++){
        if(a[i]%4==0){
            a4++;
        }else if(a[i]%2==0){
            a2++;
        }else{
            a1++;
        }
    }
//    cout<<a4<<" "<<a2<<" "<<a1<<endl;
    if(a2==0 && a1<=a4+1){
        cout<<"Yes";
    }else if(a2>0 && a1<=a4){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    int ans=0;
    for(int i=0;i<4;i++){
        if(s[i]=='+'){
            ans++;
        }
        else{
            ans--;
        }
    }
    cout<<ans<<endl;
}

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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int a, b;
  cin >> a >> b;
  if(a <= 5) cout << 0 << endl;
  else if(6 <= a && a <= 12) cout << b / 2 << endl;
  else cout << b << endl;
}

Measured memory_bytes: 256
use std::io;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let _w: String = read();
    let w = _w.to_lowercase();
    let mut count = 0;
    loop {
        let mut s: String = read();
        if s == "END_OF_TEXT" {
            break;
        }
        s = s.to_lowercase();
        count += s.split_whitespace().filter(|x| x == &w).count();
    }
    println!("{}", count);
}



Measured memory_bytes: 5052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int main(){
    string s;
    cin >> s;
    cout << (s.size() == 4 ? "ABD" : "ABC") << endl;
}


Measured memory_bytes: 256
import math
N, A, B = list(map(int, input().split()))


def sum_of_digits(n):
    res = 0
    while n > 0:
        res += n % 10
        n = math.floor(n / 10)
    return res


total = 0
for i in range(1, N+1):
    s = sum_of_digits(i)
    if s >= A and s <= B:
        total += i
print(total)


Measured memory_bytes: 9164
tick = list(map(int, list(input())))

for i in range(2**3):
  ans = tick[0]
  op = []
  for j in range(3):
    if (i >> j) & 1:
      op.append("+")
      ans += tick[j+1]
    else:
      op.append("-")
      ans -= tick[j+1]
  if ans == 7:
    print(tick[0], op[0], tick[1], op[1], tick[2], op[2], tick[3], "=7", sep="")
    exit()
    

Measured memory_bytes: 3064
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	/*if (N % 2 == 0)
	{
		writeln(N/2, " ", N, " ", N);
	}
	else*/
	{
		long h, n, w;
		(){
		foreach (i; 1..3501)
		{
			foreach (j; 1..3501)
			{
				auto y = (4*i*j - N*j - N*i);
				if (y <= 0.0) continue;
				auto z = cast(double)(N*i*j) / y;
				if (z < 1.0) continue;
				if (z == cast(double)cast(long)z)
				{
					h = i;
					n = j;
					w = cast(long)z;
					return;
				}
			}
		}}();
		writeln(h, " ", n, " ", w);
	}
	stdout.flush();
	debug readln();
}

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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int solve( vector<int>& a, int m, int i ) {
	if( m == 0 ) return 1;
	if( i >= a.size() ) return 0;
	int res = solve( a, m, i + 1 ) || solve( a, m - a[i], i + 1 );
}

int main() {
	int n; cin >> n;
	vector<int> a( n );
	REP( i, n ) cin >> a[i];
	
	int q, m; cin >> q;
	REP( i, q ) {
		cin >> m;
		if( solve( a, m, 0 ) ) cout << "yes" << endl;
		else				   cout << "no" << endl;
	}


}


Measured memory_bytes: 3104
# coding:utf-8

import sys

INF = 2 ** 31 - 1
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]


class SegmentTree:
    __slots__ = ['node', 'size']

    def __init__(self, n_):
        self.size = 2 ** n_.bit_length()
        self.node = [INF] * (2 * self.size)

    # k番目の値をaに変更
    def update(self, k, a):
        k += self.size - 1
        self.node[k] = a
        # 登りながら更新
        while k >= 0:
            k = (k - 1) // 2
            self.node[k] = min(self.node[k * 2 + 1], self.node[k * 2 + 2])

    # [a, b)の最小値を求める
    def query(self, a, b):
        l, r = a + self.size, b + self.size
        res = INF
        while l < r:
            if r & 1:
                r -= 1
                res = min(res, self.node[r - 1])

            if l & 1:
                res = min(res, self.node[l - 1])
                l += 1

            l >>= 1
            r >>= 1
        return res


n, q = LI()
sgt = SegmentTree(n)

for _ in range(q):
    c, x, y = LI()

    if c == 0:
        sgt.update(x, y)
    else:
        print(sgt.query(x, y + 1))



Measured memory_bytes: 9540
#include<bits/stdc++.h>
		#include <bitset>
		using namespace std;
		#define ll long long int 
		#define MOD 1000000007
		#define mod9 1000000009
		#define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
		#define mp make_pair
		#define pb push_back
		#define ct ll t;cin>>t;while(t--)
		#define bi begin()
		#define ei end()
		#define fi first 
		#define se second
	
bool isPrime(ll n) 
{ 
    // Corner case 
    if (n <= 1) 
        return false; 
  
    // Check from 2 to n-1 
    for (ll i = 2; i*i <= n; i++) 
        if (n % i == 0) 
            return false; 
  
    return true; 
}
  ll fact[1000007]={0};
  ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
    y=y>>1;x=(1ll*x*x)%MOD;} return res;}
void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%MOD;}
  ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
  
		 int main()
		 {
		 	fast
		 	
		 	// ct
			 {
				 ll s,w;
				 cin>>s>>w;
				 if(w>=s)
				 {
					 cout<<"unsafe\n";
				 }
				 else
				 {
					 cout<<"safe\n";
				 }
			 }			 
}	


Measured memory_bytes: 3640
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int n, k,x, dist = 0,adist,bdist;
    cin >> n >> k;
    rep(i, n) {
        cin >> x;
        adist = x * 2;
        bdist = abs(k - x) * 2;
        dist += min(adist, bdist);
    }
    cout << dist << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
 
int main()
{
    int x,y;
    cin>>x>>y;
 
    if(y%2==0 and y>=2*x and y<=4*x)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 
 
    return 0;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Pair> pairs = new ArrayList<Pair>();
		for(int i=0;i<N;i++) {
			Pair pair = new Pair();
			pair.title = sc.next();
			pair.length = sc.nextInt();
			pairs.add(pair);
		}
		String X = sc.next();
		boolean flag = false;
		int total = 0;
		for(Pair pair:pairs) {
			
			if(flag) {
				total+=pair.length;
			}
			if(pair.title.equals(X)) {
				flag = true;
			}
		}
		System.out.println(total);
	}

}
class Pair {
	public String title;
	public Integer length;
}


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

int n,pos;
vector<int> pre,in,post;

void rec(int l,int r){
  if(l>=r)return;
  int root=pre[pos++];
  int m=distance(in.begin(),find(in.begin(),in.end(),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}

void solve(){
  pos=0;
  rec(0,pre.size());
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<< post[i];
  }
  cout<<endl;
}

int main(){
  int op;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>op;
    pre.push_back(op);
  }
  for(int i=0;i<n;i++){
    cin>>op;
    in.push_back(op);
  }

  solve();
  return 0;
}



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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    rep2(i,N+1) cin >> x[i] >> y[i];
    double ans = 0.0;
    rep2(i, N+1) {
        for(int j = i + 1; j <= N; j++) ans += dist(i, j) * 2 / N;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return; 
}

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

Measured memory_bytes: 640
import numpy as np

N,M=input().split(' ')
N=int(N)
M=int(M)

x_arr=[]
y_arr=[]
z_arr=[]
for i in range(N):
	x,y,z=input().split(' ')
	x=int(x)
	y=int(y)
	z=int(z)
	x_arr.append(x)
	y_arr.append(y)
	z_arr.append(z)

x_arr=np.array(x_arr)
y_arr=np.array(y_arr)
z_arr=np.array(z_arr)

xyz1=x_arr+y_arr+z_arr
xyz1=np.sort(xyz1)[::-1]
xyz1_sum=np.sum(xyz1[:M:])

xyz2=x_arr+y_arr-z_arr
xyz2=np.sort(xyz2)[::-1]
xyz2_sum=np.sum(xyz2[:M:])

xyz3=x_arr-y_arr-z_arr
xyz3=np.sort(xyz3)[::-1]
xyz3_sum=np.sum(xyz3[:M:])

xyz4=x_arr-y_arr+z_arr
xyz4=np.sort(xyz4)[::-1]
xyz4_sum=np.sum(xyz4[:M:])

xyz5=-x_arr-y_arr+z_arr
xyz5=np.sort(xyz5)[::-1]
xyz5_sum=np.sum(xyz5[:M:])

xyz6=-x_arr+y_arr+z_arr
xyz6=np.sort(xyz6)[::-1]
xyz6_sum=np.sum(xyz6[:M:])

xyz7=-x_arr+y_arr-z_arr
xyz7=np.sort(xyz7)[::-1]
xyz7_sum=np.sum(xyz7[:M:])

xyz8=-x_arr-y_arr-z_arr
xyz8=np.sort(xyz8)[::-1]
xyz8_sum=np.sum(xyz8[:M:])

a=[xyz1_sum,xyz2_sum,xyz3_sum,xyz4_sum,xyz5_sum,xyz6_sum,xyz7_sum,xyz8_sum]
print(max(a))


Measured memory_bytes: 12436
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <deque>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) > (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n;
    cin>>n;
    int tmp;
    deque<int> dq;
    bool flag=0;
    REP(i,n){
        scanf("%d",&tmp);
        if(flag){
            dq.push_back(tmp);
        }else{
            dq.push_front(tmp);
        }
        flag=!flag;
    }
    if(flag){
        REP(i,n-1){
            printf("%d ", dq.front());
            dq.pop_front();
        }
        printf("%d\n", dq.front());
    }else{
        REP(i,n-1){
            printf("%d ", dq.back());
            dq.pop_back();
        }
        printf("%d\n", dq.back());
    }


    return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#define ll long long
using namespace std;
int pos(int n)
{
    if(n<0)
        return 0;
    else
        return n;
}
bool pali(ll n)
{
    char a[10000]= {0};
    int num=0,tn=n;
    for(int i=0; i<tn; i++)
    {
        a[i]=n%10;
        n/=10;
        num=i;
        if(n<=0)
            break;

    }
    for(int i=0; i<num/2; i++)
    {
        if(a[i]!=a[num-i])
        {
            return false;
        }
    }
    return true;
}
int main()
{
    string s;
    ll a,b;
    cin>>a>>b;
    int num=0;
    for(ll i=a; i<=b; i++)
    {
        if(pali(i)==true)
            num++;
    }
    cout<<num;
}


Measured memory_bytes: 256
/*
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

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

#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long int ll;

int main(){
    ll n, m, x, y, z, s[8][1000], sum, ans = 0;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> x >> y >> z;
        s[0][i] = x + y + z;
        s[1][i] = x + y - z;
        s[2][i] = x - y + z;
        s[3][i] = x - y - z;
        s[4][i] = -1 * x + y + z;
        s[5][i] = -1 * x + y - z;
        s[6][i] = -1 * x - y + z;
        s[7][i] = -1 * x - y - z;
    }
    for(int i = 0; i < 8 ; i++)
        sort(s[i], s[i] + n);
    for(int i = 0; i < 8; i++){
        sum = 0;
        for(int j = n - 1; j >= n - m; j--)
            sum += s[i][j];
        ans = max(ans,sum);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,x;
	float avr;
	scanf("%d %d", &a, &b);
	avr=((a*1.0)+(b*1.0))/2;
	x=ceil(avr);
	printf("%d", x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <math.h>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int d;
    if (a > b){
        d = a;
        a = b;
        b = d;
    }

    if (b > c){
        d = b;
        b = c;
        c = d;
    }
    if (a > b){
        d = a;
        a = b;
        b = d;
    }
    cout << a << " "<<b<<" " << c << endl;
    return 0;
}


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

int main() {
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    while (true) {
        c = c - b;

        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }

        a = a - d;

        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}


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

int solve(vector<int> cost)
{
  vector<int> memo(cost.size(), -1);
  function<int(int)> minimum = [&] (int i)
  {
    if (memo[i] != -1) return memo[i];
    if (i == n - 1) return memo[i] = 0;
    if (i == n - 2) return memo[i] = abs(cost[i] - cost[i + 1]);
    return memo[i] = min(
      minimum(i + 1) + abs(cost[i] - cost[i + 1]), minimum(i + 2) + abs(cost[i] - cost[i + 2])
    );
  };
  return minimum(0);
}
int main()
{
  scanf("%d", &n);
  vector<int> v(n);
  for (int i = 0; i < n; i++) scanf("%d", &v[i]);
  printf("%d\n", solve(v));
  return 0;
}
/* min(minimum(i + 1) + abs(cost[i] - cost[i + 1]), minimum(i + 2) + abs(cost[i] - cost[i + 2])) */

Measured memory_bytes: 5376
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n,a;
	cin>>n>>a;
	if((n%500)<=a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n,k=map(int,input().split())
a=Counter([int(i) for i in input().split()])
a=sorted(a.items(),key=lambda x:x[1])

li=[]
for i,j in a:
    li.append(j)

ans=0
if k>=len(a):
    ans=0
else:
    for i in range(len(a)-k):
        ans+=li[i]
print(ans)
        
    

Measured memory_bytes: 37784
//
// Created on 2020/07/16.
//


#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
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    double t,x;
    cin>>t>>x;
    double ans = t/x;
        printf("%.10f\n", ans);

    return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T>inline bool chmax(T& a,T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>inline bool chmin(T& a,T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

long long h[100010];
long long dp[100010];

int main() {
    int n,k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    for(int i = 0; i < 100010; i++) dp[i] = INF;
    dp[0] = 0;
    for(int i = 0;i < n;++i) {
        for(int j = 1; j <= k;++j) {
            chmin(dp[i+j],dp[i] + abs(h[i]-h[i+j]));
        }
    }

    cout << dp[n-1] << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {
  
  int N;
  cin >> N;

  vector<int> A(N + 1),B(N);
  for(int i = 0;i <= N;i++) {
      cin >> A.at(i);
  }

  for(int i = 0;i < N;i++) {
      cin >> B.at(i);
  }

  long long ans = 0;
  for(int i = 0;i < N;i++) {
      int t = A.at(i),nt = A.at(i + 1),y = B.at(i);
      if(t >= y) {
          ans += y;
      }else {
          ans += t;
          int rest = y - t;
          ans += min(rest,nt);
          A.at(i + 1) = max(0,nt - rest);
      }
  }

  cout << ans << endl;
 
 
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;

    constexpr int N = 55555;
    vector<int> prime;
    vector<bool> erato(N+5);
    FOR(i,2,N+1) {
        if (erato[i]) continue;
        prime.push_back(i);
        for(int j = 1; i * j <= N; j++) erato[i*j] = true;
    }
    
    vector<int> ans;
    REP(i,prime.size()) {
        if (prime[i] % 5 == 1) {
            ans.push_back(prime[i]);
            if (ans.size() == n) break;
        }
    }

    string str = "";
    REP(i,ans.size()-1) str += to_string(ans[i]) + " ";
    str += to_string(ans.back());
    cout << str << endl;

    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n,k;
cin>>n>>k;
vector<int> l(n);
for(int i=0;i<n;i++){
cin>>l[i];
}
sort(l.begin(),l.end());
int ans=0;
for(int i=0;i<k;i++){
ans+=l[n-1-i];
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<iterator>
#include<vector>
using namespace std;
typedef vector<int> vii;
#define ll long long
#define tt ll t;cin>>t;while(t--)
#define nl endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define vec vector<ll>
#define cinv(v) for(auto it:v)cin >> it;
#define coutv(v) for(auto it:v)cout << it <<' ';cout<<endl;
#define so ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
        so;

        string s;
        ll mx=0,ctr=0,i;
        cin>>s;

        for(i=0;i<s.size();i++){
          if(s[i]=='R'){
                    ctr++;
                    mx=max(mx,ctr);
          }
          else ctr=0;
        }
        cout<<mx<<nl;


        return 0;
}



Measured memory_bytes: 3648
def main():
    N, D = map(int, input().split())
    count = 0
    for i in range(N) :
        X, Y = map(int, input().split())
        if (X*X + Y*Y)**0.5 <= D :
            count += 1
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9628
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		Integer[] l = new Integer[n];
		
		for (int i=0; i<n; i++){
			l[i] = sc.nextInt();
		}
		Arrays.sort(l, Comparator.reverseOrder());
		
		int sum = 0;
		for (int j=0; j<k; j++){
			sum += l[j];
		}
		System.out.println(sum);
		
		sc.close();
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    string temp;
    cin>>temp;
    if((temp[0]==temp[1]&&temp[1]==temp[2])||(temp[1]==temp[2]&&temp[2]==temp[3]))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  int t;
  scanf("%d\n",&t);
  char data[t][4];
  int c0 = 0,c1 = 0,c2 = 0,c3 = 0;//AC,WA,TLE,RE
  for(int i = 0;i < t;i++){
    scanf("%s",data[t]);
    if(strcmp(data[t],"AC") == 0){
      ++c0;
    }else if(strcmp(data[t],"WA") == 0){
      ++c1;
    }else if(strcmp(data[t],"TLE") == 0){
      ++c2;
    }else if(strcmp(data[t],"RE") == 0){
      ++c3;
    }
  }
  printf("AC x %d\n",c0);
  printf("WA x %d\n",c1);
  printf("TLE x %d\n",c2);
  printf("RE x %d\n",c3);
  return 0;
}


Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll powmod(ll x, ll y){
    ll res = 1;
    for(ll i = 0;i < y; i++){
        res = res*x%mod;
    }

    return res;
}
int main(){
    ll n;
    cin>>n;
    ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define debug(x) cout<<#x<<": "<<x<<endl
map<int,int> e;	//<end,start>

bool insert(int x){
	auto itr = e.lower_bound(x);
	bool nextleft = (e.find(x-1)!=e.end());

	/* x??\?????????????????? */
	if(itr==e.end()){
		/* ?????????????????£??\ */
		if(nextleft){
			e[x]=e[x-1];
			e.erase(x-1);
		}/* ??¬??? */
		else e[x]=x;
		return true;
	}

	/* ??±??? */
	int left=itr->second,right=itr->first;
	if(left==1 && (x<right || (int)e.size()>1) ){
		return false;
	}

	/* ???????????? */
	if(x==right){
		e.erase(itr);
		return insert(left-1);
	}

	/* ????????? */
	if(left<=x){
		itr->second = x+1;
		return insert(left-1);
	}

	e[x]=x;

	/* ????????????????????£??\ */
	if(nextleft){
		e[x]=e[x-1];
		e.erase(x-1);
	}

	/* ????????????????????£??\ */
	if(itr->second==x+1){
		itr->second = e[x];
		e.erase(x);
	}
	return true;
}

int main(void){
	int n,x;
	cin>>n>>x;
	e[x]=x;
	cout<<"Yes"<<endl;
	while(--n){
		cin>>x;
		if(e.find(0)!=e.end()){
			cout<<"No"<<endl;
			continue;
		}
		if(insert(x))cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = s.split("/")
if int(t[1]) <= 4:
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 38256
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
suma=sum(a)
for i in range(n):
    if b[i]>a[i]:
        b[i]-=a[i]
        a[i]=0
    else:
        a[i]-=b[i]
        b[i]=0
    if b[i]>a[i+1]:
        b[i]-=a[i+1]
        a[i+1]=0
    else:
        a[i+1]-=b[i]
        b[i]=0
print(suma-sum(a))

Measured memory_bytes: 18476
# include <iostream>
using namespace std;
int n,m,p;
void work (void)
{
	int i,j,u,v,f;
	f=0;
	u=0;
	for (i=0;i<=n;i++)
	{
		v=u;
		for (j=0;j<=m;j++)
		{
			if (v==p)
			{
				f=1;
				break;
			}
			v+=n-i*2;
		}
		u+=m;
	}
	if (f==1)
	cout<<"Yes";
else cout<<"No";
} 
int main (void)
{
	cin>>n>>m>>p;
	work ();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<stack>
using namespace std;
const int N=1e5+50;
const int INF=0x3f3f3f;
long long dp[60][2600];
long long sum;
int main()
{
    int n,m,a,b;
    scanf("%d%d",&n,&m);
    dp[0][0]=1;
    sum=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&b);
        for(int j=i;j>=1;j--)
            {
                for(int k=m*n;k>=b;k--)
                {
                   dp[j][k]+=dp[j-1][k-b];
                }
            }
    }
    for(int i=1;i<=n;i++)
        sum+=dp[i][i*m];
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll N, M; cin >> N >> M;
  if(M<=2) {
    cout << "Yes" << endl;
    return 0;
  }
  vector<pair<pair<ll,ll>,ll>> LRD(M);
  rep(i,M) {
    cin >> LRD[i].first.first >> LRD[i].first.second >> LRD[i].second;
    LRD[i].first.first--;
    LRD[i].first.second--;
  }
  vector<vector<ll>> g(N);
  vector<vector<ll>> c(N);
  rep(i,M){
    ll l = LRD[i].first.first, r = LRD[i].first.second, d = LRD[i].second;
    g[l].pb(r);
    c[l].pb(d);
    g[r].pb(l);
    c[r].pb(-d);
  }
  vector<ll> pos(N,1e18);
  vector<bool> chk(N,false);
  queue<ll> q;
  rep(m,M){
    if(pos[LRD[m].first.first]==1e18){
      pos[LRD[m].first.first] = 0;
      q.push(LRD[m].first.first);
    }
    while(!q.empty()){
      ll l = q.front(); q.pop();
      if(chk[l]) continue;
      chk[l] = true;
      rep(i,sz(g[l])){
        ll r = g[l][i];
        if(pos[r]!=1e18){
          if(pos[r]-pos[l]!=c[l][i]){
            cout << "No" << endl;
            return 0;
          }
        }
        else{
          pos[r] = pos[l]+c[l][i];
          q.push(r);
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 23040
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main(){
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var N, M int
	fmt.Fscan(r, &N, &M)
	a := make([]int, M)
	ans := make([]int, N+5)
	for i:=0; i < N+5; i++{
		ans[i] = 0
	}
	for i:=0; i < M; i++{
		fmt.Fscan(r, &a[i])
		ans[a[i]] = -1
	}
	ans[0] = 1
	mod := int(1e9+7)
	for i:= 0; i < N; i++{
		if ans[i] == -1{
			continue
		}
		if ans[i+1] != -1{
			ans[i+1] += ans[i]
			ans[i+1] %= mod
		}
		if ans[i+2] != -1{
			ans[i+2] += ans[i]
			ans[i+2] %= mod
		}
	}
	fmt.Fprintln(w, ans[N])



}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a;
    char s[100];
    cin>>a;
    cin>>s;
    if(a>=3200)
        {
        cout<<s<<endl;
        //cout<<"a="<<a<<" is not less than 3200,so we print s="<<s<<"."<<endl;
        }
    else
    {
        cout<<"red"<<endl;
       // cout<<"a="<<a<<" is less than 3200,so we print red."<<endl;
    }


}


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

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

int main() {
    int Map[100][100];
    while(true)
    {
        int w, h;
        cin >> w >> h;
        if(w == 0 && h == 0) break;

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

        // 左上からラスタ走査
        int res = 0;
        for(int i = 0; i < h; ++i) {
            for(int j = 0; j < w; ++j) {
                if(Map[i][j] == 1) {
                    ++res;
                    queue<pair<int,int>> que;
                    que.push(make_pair(i,j));
                    Map[i][j] = 0;
                    while(!que.empty()){
                        int x = que.front().first;
                        int y = que.front().second;
                        que.pop();
                        for(int k = 0; k < 8; ++k) {
                            int nx = x + dx[k];
                            int ny = y + dy[k];
                            if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                            if(Map[nx][ny] == 1) {
                                que.push(make_pair(nx, ny));
                                Map[nx][ny] = 0;
                            }
                        }
                    }
                    
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
string n;
int main()
{
	//freopen("1273.in","r",stdin);
    //freopen("1273.out","w",stdout);  
	cin>>n; 
	for(int i=0;i<n.size();i++)
	{
	if(n[i]=='9')
	{
	cout<<"Yes"<<endl;
	return 0;
	} 
	} 
	cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------

ll calc_ptn(ll k) {
  ll ptn = 1;
  while (k >= 10) {
    k /= 10;
    ptn *= 2;
  }
  return ptn;
}

ll calc(ll n) {
  ll digit = 10;
  ll ans = n;
  while (n >= digit) {
    ans += n % digit * calc_ptn(n / digit) + calc(n / digit);
    digit *= 10;
  }
  return ans;
}

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

  ll N;
  cin >> N;
  cout << calc(N) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin>>V.at(i);
  }
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
  int sumA=0;
  int sumB=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      sumA+=V.at(i);
    }
    else{
      sumB+=V.at(i);
    }
  }
  cout<<sumA-sumB<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[666],i;
int main(){
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++){
		printf("node %d: key = %d, ",i,a[i]);
		if(i!=1)printf("parent key = %d, ",a[i/2]);
		if(i*2<=n)printf("left key = %d, ",a[i*2]);
		if(i*2+1<=n)printf("right key = %d, ",a[i*2+1]);
		puts("");
	}
	return 0;
}



Measured memory_bytes: 3196