akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int x,n,c,b;
  cin>>x>>n;
  c=x;
  b=x;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int flag=0;
  for(int i=0;i<x;i++){
    for(int j=0;j<n;j++){
      if(x-i==a.at(j)){
        break;
      }
      if(j==n-1){
        c=i;
        flag=1;
      }
      if(flag==1){
        break;
      }
    }
  }
  flag=0;
  for(int i=0;i<x;i++){
    for(int j=0;j<n;j++){
      if(x+i==a.at(j)){
        break;
      }
      if(j==n-1){
        b=i;
        flag=1;
      }
      if(flag==1){
        break;
      }
    }
  }
  if(n==0){
    cout<<x;
  }else if(c<=b){
    cout<<x-c;
  }else{
    cout<<x+b;
  }
}

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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  if(s1!="AtCoder" || s2.at(0)<'A' || s2.at(0)>'Z' || s3!="Contest"){
    return 0;
  }
  for(int i=1; i<s2.size(); ++i){
    if(s2.at(i) < 'a' || s2.at(i) > 'z'){
      return 0;
    }
  }
  cout << s1.at(0) << s2.at(0) << s3.at(0) << endl;
  return 0; 
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, ans, sum, last, cnt = 25000;
Pll a[100000];
struct Edge { LL to,cost; };
vector<LL>v[50000];
string str[3];
bool f;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n)cin >> a[i].fir>>a[i].sec;
	sort(a, a + n);
	ans =max(ans,a[n-1].fir + a[n-1].sec);
	cout << ans << endl;
		return 0;
}


Measured memory_bytes: 2944
import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(),np.int64)
F = np.array(input().split(),np.int64)

# Aを昇順、Fを降順に並べ替える
# 消化コストの小さい人に食べにくい食べ物を食べてもらう
A.sort()
F.sort()
F=F[::-1]
sumA = A.sum()

def can_eat(x):
  # 全員がx秒以下で食べられるか調べる
  
  # 食べにくさfの食べ物をx秒以内に食べるための消化コストa'は、
  # a' * f <= x  ->  a' <= x / f
  # a'は整数とすると
  # a' = x // f
  
  # 各消化コストaのうち、a'(x秒以下に収めるための消化コスト)を
  # 超えているものについては、a'に収める
  # こうして、x秒以下に収まっている消化コストの配列を作る
  eat_cost_for_x = np.minimum(A, x // F)
  
  # 元の消化コストの合計と、
  # x秒以下に収まっている消化コスト（eat_cost_for_x）の合計を比較し、
  # 修行できる回数(K)以内の差であれば、全員x秒以下で食べられる
  return sumA - eat_cost_for_x.sum() <= K


# 不可能目標（最小でも0秒のため）
left = -1 
# 可能目標 (a <= 10^6, f <= 10^6 なので、a*f <= 10^12)
right = 10**12

# 二分探索でtest(x)がtrueとなるxの最小値を探索する
# left = rightとなるまで繰り返す
while left + 1 < right:
  mid = (left+right)//2
  
  # mid秒で食べられる場合は探索範囲の右端をmidにする
  if can_eat(mid):
    right = mid
  # mid秒で食べられない場合は探索範囲の左端をmidにする
  else:
    left = mid
 
answer = right
print(answer)



Measured memory_bytes: 37212
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <iomanip>

#include <algorithm>

#include <vector>

#include <stack>

#include <queue>

#include <cmath>

#include <set>

#include <map>

#include <string>

#include <numeric>

#include <cstdio>

#include <cstdlib>

#include <ctime>

#include <iterator>

#include <cstring>

using namespace std;


const int INF = 10000000;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for (int i = 0; i < (a); i++)

//char maze[100][101];

ll n, m;

int sx, sy;

int gx, gy;

int qqq;

//各座標までの最短距離

int d[100][100];


//移動方向のベクトル

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

int ans = 0;
pair<int, int> red[101], blue[101];
//ll a[200000], b[20000];

//ユークリッドの互除法
ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	if (y == 0) return x;
	return gcd(y, x%y);
}

int isPrime(int x) {
	int i;
	if (x < 2) return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0) return 0;
	return 1;
}

int v_find(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	if (itr != vec.end()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

int ok = 1000; //解が存在する値
int ng = -1;   //解が存在しない値

ll BIG = 10000000000;

ll POW(ll a, ll b) {
	if (b == 0) return 1;
	return (a*POW(a, b - 1)) % BIG;
}

int Kaijou(int a) {
	if (a < 2) return 1;
	return a * Kaijou(a - 1);
}


ll aa[51];

int main() {
	char s[27] = { "" };
	cin >> s;
	if (strcmp(s,"zyxwvutsrqponmlkjihgfedcba")==0) {
		cout << -1 << endl;
		return 0;
	}
	if (strlen(s) == 26) {
		vector<int> v(26);
		iota(v.begin(), v.end(), 0);
		for (int i = 0; i < 26; ++i) {
			v[i] = (int)s[i] - 97;
		}
		int f = 0;
		do {
			if (f) break;
			f = 1;
		} while (next_permutation(v.begin(), v.end()));
		char c[26] = { "" };
		for (int i = 0; i < 26; ++i) {
			c[i] = (char)(v[i] + 97);
			cout << c[i];
			if (c[i] != s[i]) break;
		}
		cout << endl;
		return 0;
	}
	int aa[26] = { 0 };
	for (int i = 0; i < strlen(s); ++i) {
		aa[(int)s[i] - 97] = 1;
	}
	cout << s;
	for (int i = 0; i < 26; ++i)
		if (aa[i] == 0) {
			cout << char(i+ 97) << endl;
			break;
		}
	return 0;
}


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

using namespace std;

struct B {
    int v;
    bool t;
};

B b[100005];

bool comp(B a1, B a2) {
    return a1.v < a2.v;
}

int main() {
    int N;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> b[i].v;
        b[i].t = i%2;
    }
    sort(b, b+N, comp);
    int ans =0;
    for(int i = 0; i < N; i += 2) {
        if(b[i].t) {
            ans++;
        }

    }
    cout << ans << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, m;
    cin>>n>>m;

    vl cs(n, 1);
    vector<bool> ps(n);
    ps[0] = true;
    rep(i, m) {
        ll x, y;
        cin>>x>>y; x--; y--;
        if (ps[x]) {
            if (cs[x] == 1) {
                ps[x] = false;
                ps[y] = true;
            }
            else ps[y] = true;
        }
        cs[x]--;
        cs[y]++;
    }
    ll ans = 0;
    rep(i, n) if (ps[i]) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
use std::io::{stdin, Read};
use std::collections::HashMap;

fn main() {
    let mut buffer = String::new();
    let mut stdin = stdin();

    stdin.read_to_string(&mut buffer).unwrap();
    let rows: Vec<&str> = buffer.split('\n').collect();
    let row1: Vec<&str> = rows[0].split(' ').collect();

    let n: u64 = row1[0].parse().unwrap();
    let mut map = HashMap::new();
    for i in 1..=n {
        map.insert(i.to_string(), false);
    }
    let mut k: u64 = row1[1].parse().unwrap();

    k = 2 * k;
    let mut j: usize = 1;
    while j <= k as usize {
        if (j - 1) % 2 == 0 {
            j += 1;
            continue;
        } else {
            let row: Vec<&str> = rows[j].split(' ').collect();
            for x in row {
                map.insert(x.to_string(), true);
            }
        }
        j += 1;
    }
    let mut res = 0;
    for (k, v) in map {
      if v == false {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2212
#include <iostream>
#include <vector>

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(1<<n);
	for (long long int i = 0; i < (1<<n); i++) {
		cin >> a[i];
	}
	while (a.size() > 1) {
		vector<long long int> b;
		for (long long int i = 0; i < a.size(); i += 2) {
			if (a[i] > a[i+1]) {
				b.push_back(a[i]-a[i+1]);
			} else if (a[i] < a[i+1]) {
				b.push_back(a[i+1]-a[i]);
			} else {
				b.push_back(a[i]);
			}
		}
		a = b;
	}
	cout << a[0] << endl;
	return 0;
}

Measured memory_bytes: 3448
// https://atcoder.jp/contests/agc028/tasks/agc028_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int c, int d) { return c / gcd(c, d) * d; }

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    int lc = lcm(n, m);
    int gc = gcd(n, m);
    REP(i, gc) {
        if (s[i * n / gc] != t[i * m / gc]) {
            cout << "-1\n";
            return 0;
        }
    }
    cout << lc << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.TreeSet;


public class Main {
	public static void main(String[] args) {
		Scanner sn = new Scanner(System.in);
		int N = 4;
		boolean ad[][] = new boolean[N][N];
		for (int i = 0; i < 3; i++) {
			int a = sn.nextInt()-1;
			int b = sn.nextInt()-1;
			ad[a][b] = ad[b][a] = true;
		}
		boolean can = false;
		for (int i = 0; i < N; i++) 
			for (int j = 0; j < N; j++) 
				for (int k = 0; k < N; k++) 
					for (int p = 0; p < N; p++) 
						if( ad[i][j] && ad[j][k] && ad[k][p])
						{
							TreeSet<Integer> s = new TreeSet<Integer>();
							s.add(i);
							s.add(j);
							s.add(k);
							s.add(p);
							if( s.size() == 4 )
								can = true;
							
						}
		System.out.println(can?"YES":"NO");
		
		sn.close();
	}
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll H;
    ll W;

    cin >> H >>  W;
    vector<vector<char>> table(H, vector<char>(W));
    vector<vector<int>>   ans(H, vector<int>(W));

    REP(i, H){
        REP(j, W){
            cin >> table[i][j];
        }
    }

    if( table[0][0] == '.' ){
        ans[0][0] = 0;
    }else{
        ans[0][0] = 1;
    }

    for( int i = 1 ; i < H; i++ ){
        if( table[i][0] == '.' ){
            ans[i][0] = ans[i-1][0];
        }else{
            if( table[i-1][0] == '#' ){
                ans[i][0] = ans[i-1][0];
            }else{
                ans[i][0] = ans[i-1][0]+1;
            }
        }
    }

    for( int j = 1 ; j < W; j++ ){
        if( table[0][j] == '.' ){
            ans[0][j] = ans[0][j-1];
        }else{
            if( table[0][j-1] == '#' ){
                ans[0][j] = ans[0][j-1];
            }else{
                ans[0][j] = ans[0][j-1]+1;
            }
        }
    }

    for( int i = 1 ; i < H; i++ ){
        for( int j = 1 ; j < W; j++ ){
            if( table[i][j] == '.' ){
                ans[i][j] = min(ans[i][j-1], ans[i-1][j]);
            }else{
                int tmp = INT_MAX;
                if( table[i-1][j] == '#' ){
                    tmp= min(tmp, ans[i-1][j]);
                }else{
                    tmp= min(tmp, ans[i-1][j]+1);
                }
                if( table[i][j-1] == '#' ){
                    tmp = min(tmp, ans[i][j-1]);
                }else{
                    tmp = min(tmp, ans[i][j-1]+1);
                }
                ans[i][j] = tmp;
            }
        }
    }

    cout << ans[H-1][W-1] << endl;
}


Measured memory_bytes: 256
import bisect
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

#和がx以上になる組み合わせの総数を求める関数
def pattern_num_ge_x(x):
    p=0
    for a in A:
        p+=(N-bisect.bisect_right(A, x-1-a))
    return(p)

#pattern_num_ge_x(x)がM未満になる最小のxを探す(=r)
#lはM以上になる最大のx
l=-1
r=10**10+1
while r-l>1:
    m=(r+l)//2
    if pattern_num_ge_x(m)<M:
        r=m
    else:
        l=m

#和がr以上になる組み合わせの総和を求める(累積和を使用)
S=[0]+list(reversed(A[:]))
for i in range(1,N+1):
    S[i]+=S[i-1]
ans=0
for a in A:
    idx=bisect.bisect_right(A,r-a-1)
    ans+=a*(N-idx) + S[N-idx]
    M-=(N-idx)

#回数のあまり分lを足す
ans+=l*M

print(ans)

Measured memory_bytes: 56708
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
typedef long long ld;


int main() {
	// violinista forever xd
	ios::sync_with_stdio(0),cin.tie(0);
	ll n;
	cin>>n;
	ll tmp,may=0,rta=0;
	for(ll i=0;i<n;i++){
		cin>>tmp;
		if(tmp>=may) may=tmp;
		else rta+=may-tmp;
	}
	cout<<rta<<endl;
	
	return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);
    ll ans = 0;
    Repe(i,N+1,1){
        if( i%3 && i%5 ){
            ans+=i;
        }
    }
    printf ("%lld\n", ans );

    return 0;
}



Measured memory_bytes: 3828
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
	int u, minv;
	int d[MAX], p[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while (1) {
		minv = INFTY;
		u = -1;
		for (int i = 0; i < n; i++) {
			if (minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}
		if (u == -1) break;
		color[u] = BLACK;
		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > M[u][v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != -1) sum += M[i][p[i]];
	}

	return sum;
}




int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int e; cin >> e;
			M[i][j] = ((e == -1) ? INFTY : e);
		}
	}

	cout << prim() << endl;

	return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

	int count = 0;
	for (size_t i = 0; i < N - 2; i++)
	{
		if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
		{
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3176
#include <iostream>

using namespace std;

int main() {
  int n;
  int numbers[100];
  cin >> n;
  for(int i=0; i < n; ++i){
    cin >> numbers[i];
  }
  for(int i=0; i < n; ++i){
    if(i)cout << " ";
    cout << numbers[n-1-i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3100
#include <iostream>
    #include <math.h>
    #include <vector>
    #include <string>
    using namespace std;
    int main() {
        double bit= 380000.0 ;
        double sum=0;
        int n;cin>>n;
        for(int i=0;i<n;i++){
            double x=0; string u;
            cin >>x >>u;
            //cout<<x<<u<<endl;
            sum += (u=="BTC") ? x*bit : x;
        }
        cout << sum<< endl;
        return 0;
    }

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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() {
  int a, b, t;
  cin >> a >> b >> t;
  P((t / a) * b);


  return 0;

}

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

int main () {
  vector<int> line(3) ;
  for ( int i = 0 ; i < 3 ; i++ ){
    cin >> line.at(i) ;
  }
  
  sort ( line.begin() , line.end() ) ;
  
  if ( line.at(0) == line.at(1) && line.at(1) == line.at(2) ) {
    cout << 1 << endl ;
  } else if (  line.at(0) != line.at(1) && line.at(1) != line.at(2) ){
    cout << 3 << endl ;
  } else {
    cout << 2 << endl ;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define rep(i,n) for (int i = 0 ;i < (int)(n); i++)
typedef long long ll;
using namespace std;
int main() {
	int a[9];
	rep(i, 9) {
		cin >> a[i];
	}
	int n;
	cin >> n;
	int b[10];
	rep(i, n) {
		cin >> b[i];
	}
	int ans = 0;
	rep(i, n) {
		rep(j, n) {
			rep(l, n) {
				if ((b[i] == a[0] && b[j] == a[1] && b[l] == a[2]) || (b[i] == a[3] && b[j] == a[4] && b[l] == a[5]) || (b[i] == a[6] && b[j] == a[7] && b[l] == a[8]) || (b[i] == a[0] && b[j] == a[4] && b[l] == a[8])|| (b[i] == a[2] && b[j] == a[5] && b[l] == a[8])|| (b[i] == a[0] && b[j] == a[3] && b[l] == a[6])|| (b[i] == a[1] && b[j] == a[4] && b[l] == a[7])|| (b[i] == a[2] && b[j] == a[4] && b[l] == a[6])) {
					ans = 1;
				}

			}
		}
	}
	if (ans == 0) {
		cout << "No" << endl;
	}
	else if (ans == 1) {
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
from itertools import combinations_with_replacement

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, Q = lr()
ABCD = [lr() for _ in range(Q)]
answer = 0
for x in combinations_with_replacement(range(1, M+1), N):
    temp = 0
    for a, b, c, d in ABCD:
        if x[b-1] - x[a-1] == c:
            temp += d
    if temp > answer:
        answer = temp

print(answer)
#05

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int a = 1;

  for (int i = 0; i < N; i++) {
	if (a <= K) {
      a *= 2;
    } else {
      a += K;
    }
  }
  
  cout << a << endl;
  
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n = I()
print(ceil(n/2))

Measured memory_bytes: 63468
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S; cin >> S;
  vector<char> MY(4);
  for (int i=0;i<4;i++){
    MY.at(i)=S.at(i);
  }
  sort(MY.begin(), MY.end());
  if(MY.at(0)==MY.at(1) && MY.at(1)!=MY.at(2) && MY.at(2)==MY.at(3)){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static int n;
    private static int m;
    private static int q;
    private static int[] a;
    private static int[] b;
    private static int[] c;
    private static int[] d;
    private static int ans;

    private static void dfs(List<Integer> A) {
        if (A.size() == n + 1) {
            int now = 0;
            for (int i = 0; i < q; i++) {
                if (A.get(b[i]) - A.get(a[i]) == c[i]) {
                    now += d[i];
                }
            }
            ans = Math.max(ans, now);
            return;
        }
        int start = A.get(A.size() - 1);
        for (int i = start; i <= m; i++) {
            A.add(i);
            dfs(A);
            A.remove(A.size() - 1);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        q = sc.nextInt();
        a = new int[q];
        b = new int[q];
        c = new int[q];
        d = new int[q];
        for (int i = 0; i < q; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        List<Integer> list = new ArrayList<>();
        list.add(1);
        dfs(list);
        System.out.println(ans);
    }

}


Measured memory_bytes: 39240
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int a,b;cin>>a>>b;
	cout << max({a+b,a-b,a*b}) << endl;
}

Measured memory_bytes: 256
import sys
import  math
import bisect
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c = na()
if a == b:
    print(c)
elif b == c:
    print(a)
else:
    print(b)

Measured memory_bytes: 6040
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int dp[] = new int[n+1];
        Arrays.fill(dp,Integer.MAX_VALUE-1);
        dp[0] = 0;
        HashSet<Integer> set = new HashSet<>();
        set.add(1);
        int num = 1;
        while(num <= n){
            num *= 6;
            set.add(num);
        }
        num = 1;
        while(num <= n){
            num *= 9;
            set.add(num);
        }

        for(Integer val : set){
            for(int i = val; i < dp.length ; i++){
                dp[i] = Math.min(dp[i],1+dp[i-val]);
            }
        }
        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 23636
#!/usr/bin/env ruby

n = gets.chomp.to_i

dict = {}
n.times do
  action, str = gets.chomp.split

  case action
  when 'insert'
    dict[str.to_sym] = 1
  when 'find'
    puts dict[str.to_sym] ? 'yes' : 'no'
  end
end

Measured memory_bytes: 86504
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int num[2000]={},co=n;
        for(int i=0;i<n;i++)cin>>num[i];
        bool NA=0;
        for(int i=0;!NA&&i<10000;i++){
            bool kawa=1;
            for(int j=0;j<co&&kawa;j++)if(num[j]!=j+1)kawa=0;
            if(kawa){
                NA=1;
                cout<<i<<endl;
            }
            num[co]=co+1;
            for(int j=0;j<=co;j++){
                if(num[j]==1)for(int k=j+1;k<=co&&num[j]==1;k++)if(num[k]!=1)swap(num[j],num[k]);
                num[j]--;
            }
            for(int j=co+1;j>=0;j--){
                if(num[j]!=0){
                    co=j+1;
                    break;
                }
            }
        }
        if(!NA)cout<<-1<<endl;
    }
}

Measured memory_bytes: 1168
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	ll k, ans;
	cin >> k;
	vector<ll> v = {1, 2, 3, 4, 5, 6, 7, 8, 9};

	for (int i = 0; i < k; i++) {
		ans = v[i];
		if (v.size() <= k) {
			if (ans % 10 != 0)
				v.pb(ans * 10 + ans % 10 - 1);
			v.pb(ans * 10 + ans % 10);
			if (ans % 10 < 9)
				v.pb(ans * 10 + ans % 10 + 1);
		}
	}

	cout << ans;
}

Measured memory_bytes: 1592
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List

solve :: Int -> Int -> [[Int]] -> (Int, [[Int]])
solve h w ass = (length coms, coms)
  where
    coms = rowop Nothing 1 [] ass

rowop _ _ res [] = res
rowop pos y res (as:ass)
  = rowop thisPos (y+1) (res ++ vert pos ++ thisRes) ass
  where
    (thisPos, thisRes) = colop Nothing 1 [] as

    vert Nothing = []
    vert (Just x) = [[y-1, x, y, x]]

    colop start x res [] = (start, res)
    colop start x res (a:as)
      | a' `mod` 2 == 0 = colop start (x+1) res as
      | otherwise = case start of
          Nothing -> colop (Just x) (x+1) res as
          Just x' -> colop Nothing (x+1) (res ++ coms x' x) as
      where a' | pos == Just x = a + 1
               | otherwise     = a
            coms x1 x2 = [[y,t,y,t+1] | t <- [x1..x2-1]]

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

main = do
  cont <- B.getContents
  let [h, w] : ass = map bsReadInts (B.lines cont)
      (n, yss) = solve h w ass
  B.putStr $ B.unlines $ map (B.unwords . map (B.pack . show)) ([n] : yss)


Measured memory_bytes: 65276
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define LL long long
#define SZ(X) X.size()
#define pii pair<int,int>
#define ALL(X) X.begin(),X.end()
 
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;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 2e5 + 11;
int a[N];
int main() {
	ios::sync_with_stdio(false);
	int h,n,x=0;
	cin>>n>>h;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	LL ans=0;
	for(int i=1;i<=n-h;i++){
		ans+=a[i];
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
Stringlist=[input() for i in range(n)]


ResList=[0,0,0,0]

for i in Stringlist:
  if i=='AC':
    ResList[0]+=1
  elif i=='WA':
    ResList[1]+=1
  elif i=='TLE':
    ResList[2]+=1
  else:
    ResList[3]+=1
    
print("AC x "+str(ResList[0]))
print("WA x "+str(ResList[1]))
print("TLE x "+str(ResList[2]))
print("RE x "+str(ResList[3]))

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=1e5+5;

int a[N],pref[N],odd[N],even[N];
int n,q;

int check(int idx,int x)
{
     int have=n-idx+1;
     idx--;
     if(idx<1)
          return true;
     int st=(lower_bound(a+1,a+1+n,x-(a[idx]-x))-a);
     st=min(st,idx);
     int chances=idx-st+1;
     if(chances>have)
          return false;
     return true;     
}

int binsearch(int x)
{
     int low=lower_bound(a+1,a+1+n,x)-a;
     int high=n;
     while(low<high)
     {
          int mid=(low+high+1)/2;
          if(check(mid,x))
               low=mid;
          else
               high=mid-1;
     }
     return low;
}

int32_t main()
{
     cin>>n>>q;
     for(int i=1;i<=n;i++)
          cin>>a[i];
     for(int i=1;i<=n;i++)
     {
          odd[i]=odd[i-1];
          even[i]=even[i-1];
          pref[i]=pref[i-1]+a[i];
          if(i%2)
               odd[i]+=a[i];
          else
               even[i]+=a[i];
     }
     while(q--)
     {
          int x;
          cin>>x;
          if(x>=a[n])
          {
               cout<<(n%2?odd[n]:even[n])<<endl;
               continue;
          }
          int idx=binsearch(x);
          int ans=pref[n]-pref[idx-1];
          int st=n-2*(n-(idx)+1);
          ans+=(st%2?odd[st]:even[st]);
          cout<<ans<<endl;     
     }
}

Measured memory_bytes: 4864
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a )% 2 == 0) {
		ll hoge = b - a - 1;
		if (hoge == 1) {
			hoge = (b - a) / 2;
		}
		else {
			hoge = ((b - a - 2) / 2) + 1;
		}
		hoge = min(hoge, min(n - a, b - 1));
		cout << hoge << endl;
	}
	else {
		cout << min(min((a - 1) + 1 + ((b - a - 1) - 1) / 2 + 1, (n - b) + 1 + ((b - a - 1) - 1) / 2 + 1), min(n - a, b - 1)) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(s) for s in input().split()]
count = 0
max = a[0]
for i in range(1, len(a)):
    if max >  a[i]:
        if a[i - 1] > max:
            max = a[i - 1]
        count += max - a[i]
    else:
        max = a[i]
print(count)

Measured memory_bytes: 32088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = nk[0];
            int k = nk[1];
            int[] l = new int[26];
            for (int i = 0; i < n; i++)
            {
                l[(Console.ReadLine()[0] - 'A')]++;
            }
            PriorityQueue<int> pq = new PriorityQueue<int>(CompareAccount);
            for (int i = 0; i < 26; i++)
            {
                if (l[i] > 0) pq.Enqueue(l[i]);
            }
            int ans = 0;
            while (pq.Count >= k)
            {
                List<int> ls = new List<int>();
                for (int i = 0; i < k; i++)
                {
                    ls.Add(pq.Dequeue() - 1);
                }
                for (int i = 0; i < ls.Count; i++)
                {
                    if (ls[i] > 0) pq.Enqueue(ls[i]);
                }
                ans++;
            }
            Console.WriteLine(ans);
        }
        static int CompareAccount(int x, int y)
        {
            if (x > y)
                return -1; // xがyより大きい
            else if (x < y)
                return 1; // xがyより小さい
            else // if (x == y)
                return 0; // xとyが等しい
        }

    }
    class PriorityQueue<T>
    {
        private readonly List<T> heap;
        private readonly Comparison<T> compare;
        private int size;
        public PriorityQueue() : this(Comparer<T>.Default) { }
        public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) { }
        public PriorityQueue(Comparison<T> comparison) : this(16, comparison) { }
        public PriorityQueue(int capacity, Comparison<T> comparison)
        {
            this.heap = new List<T>(capacity);
            this.compare = comparison;
        }
        public void Enqueue(T item)
        {
            this.heap.Add(item);
            var i = size++;
            while (i > 0)
            {
                var p = (i - 1) >> 1;
                if (compare(this.heap[p], item) <= 0)
                    break;
                this.heap[i] = heap[p];
                i = p;
            }
            this.heap[i] = item;

        }
        public T Dequeue()
        {
            var ret = this.heap[0];
            var x = this.heap[--size];
            var i = 0;
            while ((i << 1) + 1 < size)
            {
                var a = (i << 1) + 1;
                var b = (i << 1) + 2;
                if (b < size && compare(heap[b], heap[a]) < 0) a = b;
                if (compare(heap[a], x) >= 0)
                    break;
                heap[i] = heap[a];
                i = a;
            }
            heap[i] = x;
            heap.RemoveAt(size);
            return ret;
        }
        public T Peek() { return heap[0]; }
        public int Count { get { return size; } }
        public bool Any() { return size > 0; }
    }

}


Measured memory_bytes: 4184
import math

def append_factor(f, p):
    if p not in f:
        f[p] = 0
    f[p] += 1

def append_factors(n, f, p):
    num_factors = 0
    while n % p == 0:
        num_factors += 1
        n //= p
    if num_factors != 0:
        f[p] = num_factors
    return n

def factors(n):
    l = int(math.sqrt(n)) + 1
    ret = {}
    n = append_factors(n, ret, 2)
    n = append_factors(n, ret, 3)
    i = 6
    while i*i <= n + 1:
        p1, p2 = i - 1, i + 1
        n = append_factors(n, ret, i - 1)
        n = append_factors(n, ret, i + 1)
        i += 6
    if n != 1:
        append_factor(ret, n)

    return ret

def minimum_sum(x):
    # find the minimum integer n where n(n+1)/2 <= x
    # n^2 < n(n+1) <= 2x < (n+1)(n+2) < (n+2)^2

    n = int(math.sqrt(x))
    while (n + 1)*(n + 2) <= 2*x:
        n += 1

    return n

def main():
    N = int(input())
    fs = factors(N)
    # print(fs)
    ans = 0
    for f in fs:
        ans += minimum_sum(fs[f])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
import math
n,k=map(int,input().split())
i=1
sum=0.0
for i in range(1,n+1):
    cnt=k/i
    temp=1/n
    # cznt=i
    #
    # while cnt < k:
    #     cnt*=2
    #     m+=1
    # m=math.ceil(math.log2(cnt))
    m=-(-math.log2(cnt)//1)
    if i < k:
        sum+=temp * (1/2)**m
    else:
        sum+=temp
    # print(1/n * (1/2)**m)
print(sum)


Measured memory_bytes: 3060
class CountingSort:
    def countingSort(self, a, b, k):
        n = len(a)
        c = [0] * (k + 1)
        for j in a:
            c[j] += 1
         
        for i in range(1, k + 1):
            c[i] = c[i] + c[i-1]
             
        for j in a[::-1]:
            b[c[j]] = j
            c[j] -= 1
        return b[1:]
 
if __name__ == '__main__':
    n = int(input().rstrip())
    a = [int(i) for i in input().rstrip().split(" ")]
    b = [0] * (n + 1)
    k = max(a)
    x = CountingSort()
    print(" ".join([str(i) for i in x.countingSort(a, b, k)]))

Measured memory_bytes: 252240
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

ll Pow_mod(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

vl fact(10000);

ll Fact(ll n){
	if(fact[n]) return fact[n];
	if(!n) return fact[n]=1;
	return fact[n]=Fact(n-1)*n%mod;
}

ll Division_mod(ll n,ll m){
	return n*Pow_mod(m,mod-2)%mod;
}

ll Permutation(ll n,ll k){
	return Division_mod(Fact(n),Fact(n-k));
}

int n,a,b,c,d;

int main(){
	cin>>n>>a>>b>>c>>d;
	vvi dp(b-a+2,vi(n+1));
	for(int i=0;i<b-a+2;i++) dp[i][0]++;
	for(int i=1;i<b-a+2;i++) for(int j=1;j<=n;j++){
		for(int k=c;k<=d&&j-(i+a-1)*k>=0;k++) (dp[i][j]+=Division_mod(dp[i-1][j-(i+a-1)*k]*Permutation(n-j+(i+a-1)*k,(i+a-1)*k)%mod,Pow_mod(Fact(i+a-1),k)*Fact(k)%mod))%=mod;
		(dp[i][j]+=dp[i-1][j])%=mod;
	}
	cout<<dp[b-a+1][n]<<endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    map<int, int> m;
    int s;
    cin >> s;
    m[s] = 1;
    for (int i = 1; i < 1000000; ++i) {
        if(s%2) s = 3*s+1;
        else s = s/2;
        if(m[s]){
            cout << i+1 << "\n";
            break;
        }
        m[s] = i+1;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <set>
const int maxlongint=2147483647;
const int mo=1e9+7; 
const int N=105;
using namespace std;
short f[N][N][N][N],n,m,a[N][N],ans,sx,sy,v[N][N],v1[N][N];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {
            char c=getchar();
            while(c!='.' && c!='o' && c!='E') c=getchar();
            v[i][j]=v1[i][j]=a[i][j]=(c=='o');
            v[i][j]+=v[i][j-1];
            v1[i][j]+=v1[i-1][j];
            if(c=='E') sx=i,sy=j;
        }
    for(short i=sx;i>=1;i--)
        for(short j=sy;j>=1;j--)
            for(short i1=sx;i1<=n;i1++)
                for(short j1=sy;j1<=m;j1++)
                {
                    if(1<i && i1+1<sx+i)
                        f[i-1][j][i1][j1]=max((int)f[i-1][j][i1][j1],(int)f[i][j][i1][j1]+v[i-1][min((int)j1,m-sy+j)]-v[i-1][max((int)j-1,j1-sy)]);
                    if(i1<n && sx+i1<n+i)
                        f[i][j][i1+1][j1]=max((int)f[i][j][i1+1][j1],(int)f[i][j][i1][j1]+v[i1+1][min((int)j1,m-sy+j)]-v[i1+1][max((int)j-1,j1-sy)]);
                    if(1<j && j1+1<sy+j)
                        f[i][j-1][i1][j1]=max((int)f[i][j-1][i1][j1],(int)f[i][j][i1][j1]+v1[min((int)i1,n-sx+i)][j-1]-v1[max((int)i-1,i1-sx)][j-1]);
                    if(j1<m && sy+j1<m+j)
                        f[i][j][i1][j1+1]=max((int)f[i][j][i1][j1+1],(int)f[i][j][i1][j1]+v1[min((int)i1,n-sx+i)][j1+1]-v1[max((int)i-1,i1-sx)][j1+1]);
                }
for(short i=sx;i>=1;i--)
        for(short j=sy;j>=1;j--)
            for(short i1=sx;i1<=n;i1++)
                for(short j1=sy;j1<=m;j1++) ans=max(f[i][j][i1][j1],ans);
    cout<<ans<<endl;
}

Measured memory_bytes: 227584
def main():
    from collections import Counter
    n, *a = map(int, open(0).read().split())
    b = Counter(a)
    for i in range(1, n + 1):
        m = b.get(i)
        if m is None:
            m = 0
        print(m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 36380
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;

int N,M,d,p;
pair<int,int> prin[20000];
int main(){
	cin >> N >> M;
	while((N!=0)||(M!=0)) {
		for(int i=0; i<N; ++i) {
			cin >> d >> p;
			prin[i] = make_pair(-p,d);
		}
		sort(prin,prin+N);
		int money=prin[0].second;
		int k = 0;
		while(money <= M) {
			++k;
			if(k>N-1) break;
			money += prin[k].second;
		}
		if(money<=M) cout << 0 << endl;
		else {
			int ex = -prin[k].first * (money - M);
			for(int l=k+1; l<N; ++l) {
				ex += -prin[l].first * prin[l].second;
			}
			cout << ex << endl;
		}
		cin >> N >> M;
	}
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int w,h,n,a,b,c,count=0;
 cin >> w >> h >> n;
 int maps[h][w];
 
 for(int i=0;i<h;i++){
  for(int j=0;j<w;j++){
   maps[i][j]=0;
  }
 }

 for(int cas=0;cas<n;cas++){
  cin >> a >> b >> c;
  if(c == 1){
   for(int i=0;i<a;i++){
    for(int j=0;j<h;j++){
     maps[j][i]=1;
    }
   }
  } else if( c == 2){
   for(int i=a;i<w;i++){
    for(int j=0;j<h;j++){
     maps[j][i]=1;
    }
   }
  } else if( c == 3){
   for(int i=0;i<b;i++){
    for(int j=0;j<w;j++){
     maps[i][j]=1;
    }
   }
  } else if(c == 4){
   for(int i=b;i<h;i++){
    for(int j=0;j<w;j++){
     maps[i][j]=1;
    }
   }
  }
 }

 for(int i=0;i<h;i++){
  for(int j=0;j<w;j++){
   if( maps[i][j] == 0){
     count++;
   }
  }
 }

 cout << count << endl;
 return 0;
}

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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int v[n], c[n];
  rep(i, n) cin >> v[i];
  rep(i, n) cin >> c[i];

  vector<int> r(n);
  rep(i, n) r[i] = v[i] - c[i];
  sort(r.rbegin(), r.rend());
  int ans = 0;
  rep(i, n) {
    if (r[i] > 0)
      ans += r[i];
    else
      break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

H, W = MAP()
N = INT()
a = LIST()

cnt = 0
ans = [[-1]*W for _ in range(H)]
tmp = a.pop(0)
color = 1
flg = 0

for i in range(H):
	for j in range(W):
		if i%2==0:
			j = -j-1
		ans[i][j] = color
		tmp -= 1
		if tmp == 0:
			if not a:
				break
			tmp = a.pop(0)
			color += 1



for i in ans:
	print(" ".join([str(x) for x in i]))


Measured memory_bytes: 10632
#include <bits/stdc++.h>
using namespace std;
 
ifstream in ("test.in" );
ofstream out("test.out");
 
const int DIM = 2e5 + 5;
const int INF = 0x3f3f3f3f;
 
map<int, bool> mmp[DIM];
 
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(); cout.tie();
    
    int n, m;
    cin >> n >> m;
    
    for (int i = 1; i <= m; ++i) {
        int x, y;
        cin >> x >> y;
        
        mmp[x][y] = true;
    }
    
    bool ok = false;
    for (int i = 2; i < n; ++i)
        ok |= (mmp[1][i] & mmp[i][n]);
    
    cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << "\n";
    return 0;
}

Measured memory_bytes: 37760
#include <stdio.h>

int main() {
	int h[110], n, a[110], cnt = 0, ans = 0, temp;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		a[i] = 0;
	}
	while (cnt < n) {
		if (a[cnt] < h[cnt]) {
			temp = cnt;
			ans++;
			while ((a[temp] < h[temp]) && (temp < n)) {
				a[temp]++;
				temp++;
			}
		}
		else
			cnt++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
require 'bigdecimal'
require 'bigdecimal/util'

inputs = Array.new
while line = $stdin.gets
  inputs << line.chomp
end

a, b = inputs[0].split(" ")
a_i = a.to_i
b_d = b.to_d

b_i = (b_d * 100).floor

ans = a_i * b_i / 100
puts ans


Measured memory_bytes: 14488