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

int main() {
    vector<vector<int>> a(3, vector<int>(3));
    for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];
    vector<int> x(3), y(3);
    for (int k = 0; k < 3; ++k) y[k] = a[0][k] - x[0];
    for (int l = 0; l < 3; ++l) x[l] = a[l][0] - y[0];
    for (int m = 0; m < 3; ++m) {
        for (int i = 0; i < 3; ++i) {
            if (x[m] + y[i] != a[m][i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mm=1000000007;
int t1,t2,i,j,k,n,m,a[210001],b[210001],c[210001],fac[210001],c1[210001];
ll pw(ll b,ll p){
	ll res=1;
	for (;p;p>>=1,b=b*b%mm)
	 if (p&1) res=res*b%mm;
	return res;
}
int main(){
	scanf("%d",&n);memset(b,0,sizeof(b));fac[0]=1;n++;
	for (i=1;i<=n;i++){
		scanf("%d",&a[i]);fac[i]=(ll)fac[i-1]*(ll)i%mm;
		if (!b[a[i]]) b[a[i]]=i;else t1=b[a[i]],t2=i;
	}
	for (i=0;i<=n;i++) c[i]=(ll)fac[n]*pw((ll)fac[i]*(ll)fac[n-i]%mm,mm-2)%mm;
	for (i=0,k=t1-1+(n-t2);i<=k;i++) c1[i]=(ll)fac[k]*pw((ll)fac[i]*(ll)fac[k-i]%mm,mm-2)%mm;
	for (i=1;i<=n;i++){
		k=c[i];
		if (t1-1+(n-t2)>=i-1) k=(k-c1[i-1]+mm)%mm;
		printf("%d\n",k);
	}
	return 0;
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
int nya[10010010];
int main(){
	int N;
	scanf("%d",&N);
	for(int i=1; i<=N; i++){
		for(int j=1; i*j <= N; j++){
			nya[i*j]++;
		}
	}
	long long ans = 0;
	for(long long i=1; i<=N; i++){
		ans += i * nya[i];
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  std::string s;
  std::cin >> s;
  int count = 0;
  for (const auto i : s) {
    if (i == 'o') {
      count++;
    }
  }

  std::cout << 700 + 100 * count << std::endl;
  return 0;
}


Measured memory_bytes: 256
const MOD: usize = 1e9 as usize + 7;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let l: u64 = sc.read();
    let r: u64 = sc.read();
    let mut dp = vec![vec![vec![0; 2]; 2]; 2];
    dp[0][0][0] = 1;
    for i in (0..63).rev() {
        let l = (l >> i) & 1;
        let r = (r >> i) & 1;
        let mut next = vec![vec![vec![0; 2]; 2]; 2];
        for lower_r in 0..2 {
            for upper_l in 0..2 {
                for same_highest in 0..2 {
                    for (x, y) in vec![(0, 1), (0, 0), (1, 1)].into_iter() {
                        if lower_r == 0 && r < y {
                            continue;
                        }
                        if upper_l == 0 && l > x {
                            continue;
                        }
                        if same_highest == 0 && x != y {
                            continue;
                        }
                        let next_lower_r = if lower_r == 1 || r > y { 1 } else { 0 };
                        let next_upper_l = if upper_l == 1 || l < x { 1 } else { 0 };
                        let next_same_highest = if same_highest == 1 || x == 1 && y == 1 {
                            1
                        } else {
                            0
                        };
                        next[next_lower_r][next_upper_l][next_same_highest] +=
                            dp[lower_r][upper_l][same_highest];
                        next[next_lower_r][next_upper_l][next_same_highest] %= MOD;
                    }
                }
            }
        }
        dp = next;
    }

    let mut ans = 0;
    for i in 0..2 {
        for j in 0..2 {
            for k in 0..2 {
                ans += dp[i][j][k];
            }
        }
    }
    println!("{}", ans % MOD);
}

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: 4476
#include<stdio.h>

int main(void)
{
	int a, b, c;
	int tmp;

	scanf("%d %d %d", &a, &b, &c);

	if (a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if (a > c){
		tmp = a;
		a = c;
		c = tmp;
	}
	if (b > c){
		tmp = b;
		b = c;
		c = tmp;
	}


	printf("%d %d %d\n", a, b, c);

	return 0;

}


Measured memory_bytes: 2700
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N; cin >> N;
	vector<ll> p(N + 1);
	vector<ll> loc;
	for (int i = 1; i <= N;i++) {
		cin >> p[i];
		if (p[i] == i) {
			loc.push_back(i);
		}
	}
	ll cnt1 = 0;
	auto temp = p;
	for (int i = 0; i < loc.size();i++) {
		ll at = loc[i];
		if (temp[at] != at) continue;
		if (at != 1) {
			if (temp[at - 1] != at) {
				swap(temp[at - 1], temp[at]);
				cnt1++;
				continue;
			}
		}
		if (at != N) {
			if (temp[at + 1] != at) {
				swap(temp[at + 1], temp[at]);
				cnt1++;
				continue;
			}
		}
	}
	temp = p;
	ll cnt2 = 0;
	for (int i = 0; i < loc.size();i++) {
		ll at = loc[i];
		if (temp[at] != at) continue;
		if (at != N) {
			if (temp[at + 1] != at) {
				swap(temp[at + 1], temp[at]);
				cnt2++;
				continue;
			}
		}
		if (at != 1) {
			if (temp[at - 1] != at) {
				swap(temp[at - 1], temp[at]);
				cnt2++;
				continue;
			}
		}
	}
	cout << min(cnt1,cnt2) << endl;
	return 0;
}

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

const int mod = 1e9+7;
const int INF = 1000000000;

int n,A[20];

bool solve(int p, int m, int sum){
    if(p == n) {
        if(sum == m) return true;
        return false;
    }
    return solve(p+1, m, sum+A[p]) || solve(p+1, m, sum);
}

int main() {
    cin >> n;
    rep(i,n) cin >> A[i];
    int q,m;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> m;
        if(solve(0,m,0)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}



Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<queue>
#include<unordered_set>
#include<cmath>
#include<string>
typedef long long ll;


using namespace std;


int main(){
    int N, M;
    cin >> N >> M;
    unordered_set<int> solved;
    map<int, int> pen;
    for(int i=0;i<M;i++){
        int p;
        string s;
        cin >> p;
        cin >> s;
        if(s == "WA" && solved.count(p) == 0){
            if(pen.count(p) == 0){
                pen[p] = 0;
            }
            pen[p]++;
        }
        if(s == "AC" && solved.count(p) == 0){
            solved.insert(p);
        }
    }
    int penalty=0;
    for(auto sol:solved){
        if(pen.count(sol) > 0){
            penalty += pen[sol];
        }
    }

    cout << solved.size() << " " << penalty << endl;

    return 0;
}


Measured memory_bytes: 4388
#include <iostream>

#include <string.h>

using namespace std;

typedef long long ll;

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(void) {
    int N;
    cin >> N;
    char s[10010];
    cin >> s;
    int len = strlen(s);

    for (int i = 0; i < len; i++) {
        s[i] = ((s[i] - 'A' + N) % 26) + 'A';
    }

    cout << s << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
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 N, A, B, C;
vi L;

int dfs(int i, int a, int b, int c)
{
    if (i == N)
    {
        if (a == 0 || b == 0 || c == 0)
        {
            return 1000000000;
        }

        return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }

    auto ans = dfs(i + 1, a, b, c);
    chmin(ans, dfs(i + 1, a + L[i], b, c) + 10);
    chmin(ans, dfs(i + 1, a, b + L[i], c) + 10);
    chmin(ans, dfs(i + 1, a, b, c + L[i]) + 10);

    return ans;
}

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    cin >> N >> A >> B >> C;

    L.resize(N);
    inN(L, N);

    outl(dfs(0, 0, 0, 0));

    return 0;
}

Measured memory_bytes: 3644
#include<iostream>

using namespace std;

#define MAX 1000

struct S{
	int i,j,k,r;
};

int main(){

	int a,b,c,N;
	S check[MAX];
	int res[100+100+100+1];
	int cnt;

	while(1){

		cin>>a>>b>>c;
		if(a==0&&b==0&&c==0) break;

		for(int i=1;i<=a+b+c;i++){
			res[i]=-1;
		}

		cin>>N;
		for(int i=0;i<N;i++){
			cin>>check[i].i>>check[i].j>>check[i].k>>check[i].r;
			if(check[i].r==1){
				res[check[i].i]=1;
				res[check[i].j]=1;
				res[check[i].k]=1;
			}
		}

		for(int i=0;i<N;i++){
			cnt=0;
			if(check[i].r==0){
				if(res[check[i].i]!=1) cnt++;
				if(res[check[i].j]!=1) cnt++;
				if(res[check[i].k]!=1) cnt++;
				if(cnt==1){
					if(res[check[i].i]!=1) res[check[i].i]=0;
					if(res[check[i].j]!=1) res[check[i].j]=0;
					if(res[check[i].k]!=1) res[check[i].k]=0;
				}
				else{
					if(res[check[i].i]==-1) res[check[i].i]=2;
					if(res[check[i].j]==-1) res[check[i].j]=2;
					if(res[check[i].k]==-1) res[check[i].k]=2;
				}
			}
		}

		for(int i=1;i<=a+b+c;i++){
			if(res[i]!=-1) cout<<res[i]<<endl;
			else cout<<"2"<<endl;
		}

	}

	return 0;
}

Measured memory_bytes: 1176
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    if n%10==2 or n%10==4 or n%10==5 or n%10==7 or n%10==9:
        print("hon")
    elif n%10==0 or n%10==1 or n%10==6 or n%10==8:
        print("pon")
    else:
        print("bon")
if __name__=='__main__':
    main()

Measured memory_bytes: 61876
#include <stdio.h>

int main() {
	char s[100];
	int n,bcnt = 0;

	scanf("%d", &n);
	scanf("%s", &s);

	for (int i = 0;i < n;i++) {
		if (s[i] == 'B') bcnt++;
	}
	n = n - bcnt;
	if (n > bcnt) printf("Yes\n");
	else printf("No\n");

	return 0;
}

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

using namespace std;

int main(void){

    vector<int> dish(5);
    int end = 10, index, tmp, ans = 0;

    for(int i = 0;i < 5;i++){
        cin >> dish[i];
        if(end > dish[i] % 10 && dish[i] % 10 != 0){
            index = i;
            end = dish[i] % 10;
        }
    }

    for(int i = 0;i < 5;i++){
        if(dish[i] % 10 != 0 && i != index){
            dish[i] += 10;
            dish[i] = (dish[i]/10)*10;
        }
    }

    for(int i = 0;i < 5;i++){
        ans += dish[i];
    }

    cout << ans << endl;

    return 0;
}

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

int n;

double m1(vector<int> x, vector<int> y)
{
  double ans = 0;
  for (int i = 0; i < n; i++)
  {
    ans += abs(x.at(i) - y.at(i));
  }
  return ans;
}

double m2(vector<int> x, vector<int> y)
{
  double square_sum = 0;
  for (int i = 0; i < n; i++)
  {
    square_sum += pow(x.at(i) - y.at(i), 2);
  }
  return sqrt(square_sum);
}

double m3(vector<int> x, vector<int> y)
{
  double cube_sum = 0;
  for (int i = 0; i < n; i++)
  {
    cube_sum += pow(abs(x.at(i) - y.at(i)), 3);
  }
  return pow(cube_sum, 1 / 3.0);
}

double minf(vector<int> x, vector<int> y)
{
  double M = -1;
  for (int i = 0; i < n; i++)
  {
    double tmp;
    tmp = abs(x.at(i) - y.at(i));
    M = max(M, tmp);
  }
  return M;
}

int main()
{
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++)
  {
    cin >> x.at(i);
  }
  for (int i = 0; i < n; i++)
  {
    cin >> y.at(i);
  }
  printf("%.8f\n%.8f\n%.8f\n%.8f\n", m1(x, y), m2(x, y), m3(x, y), minf(x, y));
}


Measured memory_bytes: 3404
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<bits/stdc++.h>
#define Foru(i,a,b) for(int i=(a);i<=(b);++i)
#define File ifstream fin("G:\\QtCode\\data\\in.txt")
using namespace std;
void slove(int num_question)
{
    while (num_question--)
    {
        string s;
        int n;cin>>n;
        cin>>s;
        for(unsigned int i=0;i<s.size();i++)
        {
            s[i]=(s[i]-65+n)%26;
            s[i]+=65;
        }
        cout<<s<<endl;
    }
    return;
}
int main()
{
    //int n;cin>>n;
    slove(1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

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

int used[100010];

int main ()
{

    int N,M;
    cin >> N >> M;
    vector < int > P(M),Y(M);
    REP(i,M) cin >> P[i] >> Y[i];

    vector < vector < int > > ord;
    REP(i,M) ord.push_back({Y[i], P[i], i});

    sort(ord.begin(), ord.end());

    vector < pair < int, string > > ans;
    REP(i,M) {
        used[ord[i][1]]++;
        string a = to_string(ord[i][1]);
        string b = to_string(used[ord[i][1]]);
        while (a.size() < 6) a = "0" + a;
        while (b.size() < 6) b = "0" + b;
        ans.push_back(make_pair(ord[i][2], a + b));
    }

    sort(ans.begin(), ans.end());
    REP(i,ans.size()) {
        cout << ans[i].second << endl;
    }

    return 0;
}



Measured memory_bytes: 15024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, modinv, bitSearch, bitList, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color; vll path; vl D; ll C = 0;
//***********//
void bfs(ll now) {
	queue<ll> Q;
	Q.push(now);
	ll u;
	while (!Q.empty()) {
		u = Q.front();
		Q.pop();
		if(u!=-1) C++;
		if (C == K) {
			cout << u;
			exit(0);
		}
		ll p = u % 10;
		ll z = 0;
		ll n = 9;
		if (u != -1) {
			for (ll v = max(z, p - 1); v <= min(n, p + 1); v++) {
				Q.push(u * 10 + v);
			}
		}
		else {
			for (ll v = 1; v <= 9; v++) {
				Q.push(v);
			}
		}
	}
}
int main() {
	cin >> K;
	bfs(-1);
}

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

int main(){
  int a, b, c = 0;
  cin >> a >> b;
  for(int i = 0; i < 20; i++){
    a = a - 2*b - 1;
    c++;
    if(a <= 0){
      break;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
import Control.Monad
 
import Data.Ord
import Data.List
import Data.Function
import Data.Maybe
 
import qualified Data.ByteString.Char8 as BS
 
import Debug.Trace
 
tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x, y)
tuplify2 _ = undefined
 
readInt = read :: String -> Integer
readIntTuple = tuplify2 . map readInt . words
readIntList = map readInt . words
 
getInt = readInt <$> getLine
getIntList = readIntList <$> getLine
getIntMatrix = map readIntList . lines <$> getContents
getIntTuple = readIntTuple <$> getLine
getIntTuples = map readIntTuple . lines <$> getContents
 
main = do
  s <- getLine
  putStr $ f s

f s@(c1:c2:c3:c4:_)
  | c1 == c2 = "Bad"
  | c2 == c3 = "Bad"
  | c3 == c4 = "Bad"
  | otherwise = "Good"


Measured memory_bytes: 380
n = int(input())
a = list(map(int, input().split()))

if n <= 2:
  print(1)
  exit()

dec, inc = False, False
cnt = 1

for i in range(n-1):

  if a[i+1] - a[i] < 0:
    dec = True
  elif a[i+1] - a[i] > 0:
    inc = True

  if dec and inc:
    cnt += 1
    dec, inc = False, False

print(cnt)

Measured memory_bytes: 14252
#include <iostream>
#include <cstring>
using namespace std;
char s[200010];
int l,c[26];
int main()
{
    int r=0;
    long long sum=0;
    char z[26];
    cin>>s;
    l=strlen(s);
    memset(c,0,sizeof(c));
    for(int i=0;i<l;i++)
    {
        int j,x=s[i]-'a';
        for(j=0;j<26;++j)
		{
			if(j==x) continue;
			sum+=c[j];
		}
        c[x]++;
    }

    cout<<sum+1<<endl;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
typedef long long ll;
using namespace std;

int main(){
  int N,M = 1000000007;
  ll ans = 1;
  scanf("%d",&N);
  REP(i,1,N + 1){
    ans = ans * i % M;
  }

  printf("%lld",ans); 
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX 100

int main()
{
  int X, Y;
  int flag = 0;
  scanf("%d%d", &X, &Y);

  int tmp = Y / 2;
  if (Y % 2 != 1 && 2 * X >= tmp && tmp >= X)
    flag = 1;

  printf(flag ? "Yes\n" : "No\n");
  return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#define nmax 5005
using std::cin;
using std::cout;
long long min(long long x, long long y)
{
    return (y < x) ? y : x;
}
int n, x[nmax+1], p[nmax+1];
long long dp[nmax+1][nmax*2+1], a, b;
int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> a >> b;
    for(int i = 1; i <= n; ++i)
      cin >> p[i];
    for(int i = 1; i <= n; ++i)
      x[p[i]] = (i << 1) - 1;
    for(int i = 1; i <= n; ++i){
      dp[i][0] = dp[i - 1][0] + b;
      for(int j = 1; j <= n << 1; ++j)
        dp[i][j] = min(dp[i][j - 1], ((j < x[i]) ? b : ((j > x[i]) ? a : 0)) + ((j & 1) ? dp[i - 1][j - 1] : dp[i - 1][j]));
    }
    cout << dp[n][n * 2];
    return 0;
}


Measured memory_bytes: 391552
n = int(input())
abc = ['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']
G = [99 for i in range(26)]#こっちが答えのリスト
for i in range(n):
  A = [0 for i in range(26)]
  S = list(input())
  for s in S:
    A[abc.index(s)] += 1
  for j in range(26):
    G[j] = min(G[j], A[j])
L = ""
for i in range(26):
  L += abc[i]*G[i]
print(L)

Measured memory_bytes: 3064
#include <cstdio>

int main(){
    int a, b, d, r;
    scanf("%d %d", &a, &b);
    d = a/b;
    r = a % b;
    double f = (double)a/(double)b;
    printf("%d %d %f\n", d, r, f);
    return 0;

}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/


ll MOD = 1e9+7;
ll times(ll x,ll n){
  if(n==1) return x;
  if(n==0) return 1;
  ll ans = (n%2==0)?1:x;
  ll ret = times(x,n/2);
  ans *= ret;
  ans %= MOD;
  ans *= ret;
  ans %= MOD;
  return ans;
}
ll modinv(ll x){
  return times(x,MOD-2);
}

vl mdinv(2001);

int main() {
  ll N,K;
  cin >> N >> K;
  FOR(i,1,2001){
    if(i==1) mdinv[i] = 1;
    else mdinv[i] = ((MOD-MOD/i) * mdinv[MOD%i])%MOD;
  }
  FOR(k,1,K+1){
    ll blue = 1;
    FOR(i,1,k){
      blue *= K-k+i;
      blue %= MOD;
      blue *= mdinv[i];
      blue %= MOD;
    }
    ll t = N - K - (k-1);
    ll red = 1;
    FOR(i,1,k+1){
      red *= t+i;
      red %= MOD;
      //red *= modinv(i);
      red *= mdinv[i];
      red %= MOD;
    }
    cout << red*blue%MOD << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define repr(i, n, a) for (int i = (n)-1; i >= (a); i--)
#define each(it, v) for (auto(it) = (v).begin(); (it) != (v).end(); (it)++)
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vi>
#define vd vector<double>
#define vvd vector<vd>
#define co(x) cout << (x)
#define con(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define out(x) rep(i, 0, x.size()) cout << x[i] << ((i != x.size() - 1) ? " " : "\n")
const double PI = 3.14159265;
const int MAXN = 1 << 15;
const ll LINF = 1LL << 60;
const int INF = 1 << 30;
#define Pr(a) (#a) << "=" << (a) << " "
#define pr(a) cout << Pr(a) << '\n'
///////////////////////////////////////////////////////
int main() {
  int n, q;
  cin >> n;
  vi A(n);
  rep(i, 0, n) cin >> A[i];
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    reverse(A.begin() + a, A.begin() + b);
  }
  out(A);
  return 0;
}


Measured memory_bytes: 3076
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count = 0

for i in range(n-1, -1, -1):
    if A[i+1] >= B[i]:
        count += B[i]
        continue
    else:
        count += A[i+1]
        power = B[i] - A[i+1]

        if power >= A[i]:
            count += A[i]
            A[i] = 0
        else:
            count += power
            A[i] -= power

print(count)


Measured memory_bytes: 18476
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var s = Str;
		var K = F;
		var min = new SortedSet<string>();
		for (var i = 0; i < s.Length; i++)
		{
			for (var l = 1; l <= 5 && i + l <= s.Length; l++)
			{
				var t = s.Substring(i, l);
				if (min.Count < 5) min.Add(t);
				else
				{
					var M = min.Max;
					if (t.CompareTo(M) < 0 && !min.Contains(t))
					{
						min.Remove(M);
						min.Add(t);
					}
				}
			}
		}
		WriteLine(min.ToList()[K - 1]);
	}
}


Measured memory_bytes: 17884
package main

import "fmt"

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)
	var x, ans int
	for i := 0; i < N; i++ {
		switch S[i] {
		case 'I':
			x++
			ans = max(x, ans)
		case 'D':
			x--
		}
	}
	fmt.Println(ans)
}

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


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atCoder161
{
    class ClassB
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            int N = int.Parse(str[0]);
            int M = int.Parse(str[1]);

            string[] ary = Console.ReadLine().Split(' ');

            decimal[] A = ary.Select(decimal.Parse).ToArray();

            List<decimal> listA = new List<decimal>(A);

            decimal sum = listA.Sum();

            decimal limit = sum / 4 / M;

            List<decimal> sorted = listA.OrderByDescending(v => v).ToList();
            
            if (sorted[M-1] < limit)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }

        }
    }
}


Measured memory_bytes: 13524
def main():
    n =int(input())
    h = list(map(int,input().split(' ')))
    h[0] -= 1
    for i in range(n-1):
        if h[i] <h[i+1]:
            h[i+1] -=1
        elif h[i] > h[i+1]:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()

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

int main()
{
  int n;
  int sum = 0, sum2 = 0;
  cin >> n;

  vector<int> w(n);
  rep(i, n)
  {
    cin >> w.at(i);
    sum += w.at(i);
  }

  int ans = 100000000;
  int now = 0;

  for (int i = 0; i < n; i++)
  {
    sum -= w.at(i);
    sum2 += w.at(i);
    int tmp = abs(sum - sum2);
    ans = min(ans, tmp);
  }
  cout << ans;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    int n;
    cin>>n;
    int h[n],ans=0,val=0;
    for(int i=0;i<n;i++)cin>>h[i];
    for(int i=0;i<n-1;i++)
    {
        if(h[i]>=h[i+1])
        {
            val++;
        }
        else
        {
            ans=max(ans,val);
            val=0;
        }
        //cout<<val<<" "<<ans<<endl;
    }
    ans=max(ans,val);
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


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

int main(){
    int n, a, b;

    cin >> n >> a >> b;

    int p1 = n * a;
    int ans;
    if(p1 < b) ans = p1;
    else ans = b;

    cout << ans << endl;

}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAC solver = new AAC();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAC {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            if (s.next().equals("ABC"))
                w.println("ARC");
            else
                w.println("ABC");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return nextString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

using namespace std;

bool vis[310][310][310];
double dp[310][310][310];

double go(int c1, int c2, int c3, int n) {
    if(c1 + c2 + c3 == 0) return 0;

    if(vis[c1][c2][c3]) return dp[c1][c2][c3];

    int c0 = n - (c1 + c2 + c3);
    double w1 = 0.0, w2 = 0.0, w3 = 0.0;

    if(c1 > 0) w1 = (1.0 * c1 / n) * (1 + go(c1 - 1, c2, c3, n));
    if(c2 > 0) w2 = (1.0 * c2 / n) * (1 + go(c1 + 1, c2 - 1, c3, n));
    if(c3 > 0) w3 = (1.0 * c3 / n) * (1 + go(c1, c2 + 1, c3 - 1, n));

    double p0 = (1.0 * c0 / n);

    vis[c1][c2][c3] = true;

    return dp[c1][c2][c3] = (p0 + w1 + w2 + w3) / (1 - p0);
}

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<int> f(4);

    for(int i = 0; i < n; i++) {
        int v;
        cin >> v;

        f[v]++;
    }

    double ans = go(f[1], f[2], f[3], n);

    printf("%.14f\n", ans);
}

/*
 * J
**/


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

using namespace std;

typedef long long int64;

int N, V[45];
bool G[45][45];
int64 NG[45];
int sum[45];
int beet;

void dfs(int64 idx, int64 bit, int fake)
{
  beet = max(beet, fake);
  if(idx == N) return;
  if(fake + sum[idx] <= beet) return;
  dfs(idx + 1, bit, fake);
  if((NG[idx] & bit) == 0) dfs(idx + 1, bit | (1LL << idx), fake + V[idx]);
}

int main()
{
  while(cin >> N, N) {
    memset(G, false, sizeof(G));
    map< string, int > conv;

    vector< vector< string > > gg(N);
    for(int i = 0; i < N; i++) {
      string A;
      cin >> A;
      conv[A] = i;
      int sz;
      cin >> V[i];
      cin >> sz;
      for(int j = 0; j < sz; j++) {
        string D;
        cin >> D;
        gg[i].push_back(D);
      }
    }
    for(int i = 0; i < N; i++) {
      for(auto &s : gg[i]) {
        G[i][conv[s]] = true;
      }
    }

    memset(sum, 0, sizeof(sum));
    for(int i = N - 1; i >= 0; i--) {
      sum[i] = sum[i + 1] + V[i];
    }

    for(int i = 0; i < N; i++) {
      NG[i] = 0;
      for(int j = 0; j < N; j++) {
        if(G[i][j]) NG[i] |= 1LL << j;
      }
    }
    beet = 0;
    dfs(1, 1, V[0]);
    cout << beet << endl;
  }
}

Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){

    int x, a, b;
    cin >> x >> a >> b;

    if(abs(x-a) >= abs(x-b)){
        cout << "B" << endl;
    }else{
        cout << "A" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import numpy as np
from functools import reduce
import fractions

def main():
    N, X = map(int, input().split())
    x = np.absolute(np.asarray([int(i) for i in input().split()]) - X)
    if N == 1:
        print(x[0])
    else:
        print(reduce(fractions.gcd, x))


if __name__ == '__main__':
    main()

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

using namespace std;

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

int abs(int x){
    if (x > 0) return x;
    else return -x;
}

int main(){ 
    int n;
    cin >> n;
    int w[n];
    rep(i, n) cin >> w[i];
    int sm1 = 0, sm2 = 0;
    rep(i, n) sm1 += w[i];
    int ans = 100000;
    for(int i = 0; i < n - 1; i++){
        sm1 -= w[i];
        sm2 += w[i];
        if (abs(sm1 - sm2) < ans) ans = abs(sm1 - sm2);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String n = scanner.nextLine();
    String[] h = scanner.nextLine().split(" ");
    
    int max = Integer.parseInt(h[0]);
    int lookAble = 1;
    
    for(int i = 1; i < Integer.parseInt(n); i++) {
      if(max <= Integer.parseInt(h[i])) {
        lookAble ++;
        max = Integer.parseInt(h[i]);
      }
    }
 
    System.out.print(lookAble);
  }
}

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


#define N 50000

int main(){
    int n;

    bool is_prime[N];
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<N;i++){
      is_prime[i] = true;
    }
    for(int i=2; i*i<N; i++){
      if(is_prime[i]){
        for(int j=i*i;j<N; j+=i){
          is_prime[j] = false;
        }
      }
    }


    while(1){
      int counter = 0;
      cin >> n;
      if(n == 0)
        break;
      if(cin.eof())
        break;
      int i=0;
      while(i <= n/2){
        if(is_prime[n-i] && is_prime[i])
          counter++;
        i++;
      }
        cout << counter << endl;
      }

    return 0;
}



Measured memory_bytes: 3044
s = input()
zero = 0
one = 0
for i , j in enumerate(s):
    if i % 2 == 0:
        if j == '1':
            zero += 1
        if j == '0':
            one += 1
    if i % 2 == 1:
        if j == '1':
            one += 1
        if j == '0':
            zero += 1
print(min(zero, one))

Measured memory_bytes: 3188
import logging

logging.basicConfig(level=logging.INFO)
logging.info('info')


def main():
    N, M, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    B_list = list(map(int, input().split()))
    logging.info("hello")

    a = [0]
    b = [0]

    for i in range(N):
        a.append(a[i] + A_list[i])

    for i in range(M):
        b.append(b[i] + B_list[i])

    ans = 0
    j = M
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i + j)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 49164
def main():
	n, m = map(int, input().split())

	total = m//n
	answer = 1
	for i in range(1, total+1):
		if i * i > m:
			break

		if m % i == 0:
			answer = max(i, answer)
			if i >= n:
				answer = max(m//i, answer)

	print(answer)


if __name__ == '__main__':
    main()

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

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  x--; y--;
  vector<int> ans(n-1, 0);
  
  for (int i; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      int a = min(j-i, abs(x-i)+abs(y-j)+1);
      ans[a-1]++;
    }
  }
  
  for (auto n : ans) {
    cout << n << endl;
  }
}

Measured memory_bytes: 256
#include<cstdint>
#include<cstdio>
#include<cstring>

static const unsigned long long MOD = 1000000007LL;

int n;
char s[100005];
uint64_t dp[100005][13];

int main () {
    int i, j, ki;
    uint64_t res = 0;

    scanf("%s", s);
    n = strlen(s);

    dp[0][0] = 1;
    for (i = 0; i < n; i++) {
        int c;
        if (s[i] == '?') c = -1;
        else c = s[i] - '0';

        for(j = 0; j < 10; j++) {
            if (c != -1 && c != j) continue;
            for (ki = 0; ki < 13; ki++) {
                dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
            }
        }
        for (j = 0; j < 13; j++) dp[i + 1][j] %= MOD;
    }
    res = dp[n][5];

    printf("%llu\n", res);
    return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 998244353
#define endl "\n"
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;


ll int power(ll int x, ll int y, ll int p)  
{  
   ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

ll int modInverse(ll int a,ll int m) 
{ 
    ll int g = __gcd(a, m); 
   
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
        
       return      power(a, m-2, m); 
   
} 


int main()
{
  fastio();
ll int T;
T=1;

while(T--)
{
  ll int n;
  cin>>n;
  ll int i,j,k;
  map<ll int,ll int> mp;
  for(i=1;i<=100;i++)
  {
    for(j=1;j<=100;j++)
    {
      for(k=1;k<=100;k++)
      {
      
          mp[i*i+j*j+k*k+i*j+j*k+k*i]++;
      }
    }
  }
  for(i=1;i<=n;i++)
  {
    cout<<mp[i]<<endl;
  }

  }
    return 0;
}

Measured memory_bytes: 6004
function Main(input) {

input = input.split('\n');
var args = input[1].split(' ');
var ans = 0;

while (true) {
  var isEven = args.every(function (data) {
    return data % 2 == 0;
  });

  if (isEven) {
    var tmp = [];
    args.map;
    args = args.map(function (data) {
      return Number(data) / 2;
    });
    ans++;
  } else {
    console.log(ans);
    break;
  }
}
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7500
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

typedef struct hoge {
  int64_t A;
  int64_t B;
} t_list;

int list_sort( const void * a , const void * b ) {
  return (((t_list*)a)->A - ((t_list*)b)->A);
}

int main(void) {
  int64_t N, M;
  scanf("%ld%ld", &N, &M);

  t_list L[100000];
  for(int i = 0; i < N; i++) {
    scanf("%ld%ld", &L[i].A, &L[i].B);
  }
  qsort((void*)L, N, sizeof(t_list), list_sort);

  //for(int i = 0; i < N; i++) {
  //printf("L[%d].A=%d .B=%d\n", i, L[i].A, L[i].B);
  //}

  int64_t Num = 0;
  int64_t Yen = 0;
  for(int i = 0; i < N; i++) {
    if((Num + L[i].B) >= M) {
      Yen += (M - Num) * L[i].A;
      Num = M;
      break;
    } else {
      Yen += L[i].B * L[i].A;
      Num += L[i].B;
    }
  }

  printf("%ld\n", Yen);
  return 0;
}


Measured memory_bytes: 3324
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int GCD(int a, int b){
	int large, small, surplus;
	large = max(a, b);
	small = min(a, b);
	surplus = large % small;
	if(surplus == 0){
		return small;
	}else{
		return GCD(small, surplus);
	}
}

int main(){
	
	int a, b;
	
	while(scanf("%d %d", &a, &b) != EOF){
		int ans;
		ans = GCD(a, b);
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    int n, m;
    cin >> n >> m;
    int p[100002];
    int a[100002] {0};
    ll ans[100002];
    for(int i = 0; i < m; i++){
        cin >> p[i];
        a[p[i]] = 1;
    }
    ans[0] = ans[1] = 1;
    if(a[1]) ans[1] = 0;
    for(int i = 2; i <= n; i++){
        ans[i] = (ans[i - 2] + ans[i - 1]) % MOD;
        if(a[i]) ans[i] = 0;
    }
    cout << ans[n] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,k;
int arr[100004],dp[100006];

int dp_na_pari(int ind)
{
    if(ind==n-1) return 0;
    if(ind>=n) return INT_MAX;

    int ans=INT_MAX;
    if(dp[ind]!=-1)
        return dp[ind];

    for(int i=1;i<=k;i++)
    {
        if(ind+i<n)
          ans=min(ans,abs(arr[ind]-arr[ind+i])+ dp_na_pari(ind+i));
    }
    return dp[ind]=ans;

}

int main()
{

    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)cin>>arr[i];
    cout<<dp_na_pari(0)<<endl;

}


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

map<long, long> prime;

void prime_factorize(long n)
{
    if (n <= 1)
        return;
    long l = sqrt(n);
    for (long i = 2; i < l; i++)
    {
        if (n % i == 0)
        {
            prime_factorize(i);
            prime_factorize(long(n / i));
            return;
        }
    }
    prime[n]++;
    return;
}
int main()
{
    long X;
    cin >> X;
    if (X == 1)
    {
        cout << "0 -1" << endl;
        return 0;
    }
    prime_factorize(X);
    for (int i = -1000; i < 1000; i++) {
        for (int j = -1000; j < 1000; j++) {
            if(pow(i, 5) - pow(j, 5)==X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;
    cin  >> n;
    vector<int> a(n+1);
    a[0] = 0;
    FOR(i,1,n) cin >> a[i];
    int counter = 0;
    int cur = 0;
    FOR(i,1,n) {
            if (counter+1 == a[i] and i > cur){
                counter++;
                cur = i;
            }
    }
    if (counter == 0) cout << -1 << endl;
    else cout << n - counter << endl;
}

Measured memory_bytes: 1024
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(n: usize, sp: [(String, usize); n]);
    let mut spn: Vec<(String, usize, usize)> = sp
        .iter()
        .cloned()
        .zip(1..)
        .map(|x| ((x.0).0, (x.0).1, x.1))
        .collect();

    spn.sort_by(|x, y| {
        if x.0 == y.0 {
            y.1.cmp(&x.1)
        } else {
            x.0.cmp(&y.0)
        }
    });

    for s in spn.iter() {
        println!("{}", s.2);
    }
}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(100000)


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


elements = set()


def decomposition(used_set, last_used, rest):
    global elements

    if rest == 0:
        if len(used_set) > len(elements):
            elements = used_set
    i = last_used + 1
    while rest - i >= 0:
        if i in used_set:
            continue
        decomposition(used_set | {i}, i, rest - i)
        i += 1


N = int(input())
if N == 1:
    print(0)
    exit()
factors = factorization(N)
ans = 0
for p, e in factors:
    if e == 2:
        ans += 1
    else:
        elements = set()
        decomposition({1}, 1, e - 1)
        ans += len(elements)
print(ans)


Measured memory_bytes: 68068