akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
string s;

ll cal(int t,ll sum,ll r){
	if(s.size()==t)
		return sum+r;
	if(r==0){
		return cal(t+1,sum,s[t]-'0');
	}else{
		return cal(t+1,sum+r,s[t]-'0')+cal(t+1,sum,r*10+s[t]-'0');
	}
}

int main(){
	cin>>s;
	cout<<cal(0,0,0)<<endl;
	return 0;
}

Measured memory_bytes: 256
N,A,B,C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = 10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1,a+l[cur],b,c) +10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long  int n;
     cin>>n;
    long long  int x=(n*(n-1))/2;
     cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("input.txt");ofstream coutt("output.txt");

int a[200005];
int pre[200005];
int dp[200005];

signed main(){
    FASTER;
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        pre[i]=a[i];
    }
    for(int i=3;i<=n;i+=2)pre[i]+=pre[i-2];
    
    for(int i=2;i<=n;i++){
        if(i&1){
            dp[i]=max(dp[i-2]+a[i],dp[i-1]);
        }else{
            dp[i]=max(dp[i-2]+a[i],pre[i-1]);
        }
    }
    cout<<dp[n];
    
}

Measured memory_bytes: 8336
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    s: String,
  }

  puts!("{}\n", if s == "AAA" || s == "BBB" {"No"} else {"Yes"});
}


Measured memory_bytes: 4352
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = gets.to_i
puts a[k - 1]

Measured memory_bytes: 1788
import numpy as np

# N:県, M:市
h, w, k = list(map(int, input().split()))

G = np.array([[[0] * w]* w]*h)

# print(G)

# print(G[0,0,:])

# 0番目の行列
def f(i):
  f_list = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
  return f_list[i]

for a in range(w):
  # a+1が「何本目」にあたる
  # print(G[0, a, a])
  G[0, a, a] = f(a) * f(w-a-1)
  if a <= w-2:
	  G[0, a, a+1] = f(a) * f(w-a-2)
  if a >= 1:
  	G[0, a, a-1] = f(a-1) * f(w-a-1)

for j in range(1, h):
  for a in range(w):
    for b in range(w):
      G[j, a, b] = G[j-1, a, b] * G[0, b, b]
      if b <= w-2:
        G[j, a, b] += G[j-1, a, b+1] * G[0, b+1, b] 
      if b >= 1:
        G[j, a, b] += G[j-1, a, b-1] * G[0, b-1, b]
      G[j, a, b] = G[j, a, b] % 1000000007


# print(G)

print(G[h-1, 0, k-1])


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

ll f[110][110],h[110][110];
ll bin[110][10010],fac[110],ifac[110];
ll n,m,K,mod;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll pls(const ll &x,const ll &y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll &x,const ll &y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }

inline void pre_gao()
{
	fac[0]=1;
	for (int i=1;i<=100;i++) fac[i]=fac[i-1]*i%mod;
	ifac[100]=ksm(fac[100],mod-2);
	for (int i=99;~i;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
	for (int i=1;i<=K;i++)
	{
		bin[i][0]=1;
		for (int j=1;j<=10000;j++) bin[i][j]=bin[i][j-1]*i%mod;
	}
}

int main()
{
	n=rd();m=rd();K=rd();mod=rd();pre_gao();
	f[0][0]=1;
	for (int k=1;k<=K;k++)
	{
		for (int l=1;l<=n;l++) for (int j=0;j<=m;j++) h[l][j]=ifac[l]*bin[K-k+1][l*j]%mod*bin[k][l*(m-j)]%mod;
		for (int i=n;i;i--) for (int j=0;j<=m;j++) for (int l=1;l<=i;l++) f[i][j]=(f[i][j]+f[i-l][j]*h[l][j])%mod;
		for (int l=1;l<=m;l++) for (int i=0;i<=n;i++) h[l][i]=ifac[l]*bin[K-k+1][l*i]%mod*bin[k][l*(n-i)]%mod;
		for (int i=0;i<=n;i++) for (int j=m;j;j--) for (int l=1;l<=j;l++) f[i][j]=(f[i][j]+f[i][j-l]*h[l][i])%mod;
		for (int l=1;l<=n;l++) for (int j=0;j<=m;j++) h[l][j]=ifac[l]*bin[K-k][l*j]%mod*bin[k][l*(m-j)]%mod*((l&1)?(mod-1):1)%mod;
		for (int i=n;i;i--) for (int j=0;j<=m;j++) for (int l=1;l<=i;l++) f[i][j]=(f[i][j]+f[i-l][j]*h[l][j])%mod;
		for (int l=1;l<=m;l++) for (int i=0;i<=n;i++) h[l][i]=ifac[l]*bin[K-k][l*i]%mod*bin[k][l*(n-i)]%mod*((l&1)?(mod-1):1)%mod;
		for (int i=0;i<=n;i++) for (int j=m;j;j--) for (int l=1;l<=j;l++) f[i][j]=(f[i][j]+f[i][j-l]*h[l][i])%mod;
	}
	printf("%lld\n",f[n][m]*fac[n]%mod*fac[m]%mod);
	return 0;
}

Measured memory_bytes: 8576
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush
import collections

n,k=list(map(int,stdin.readline().split()))
a=list(map(int,stdin.readline().split()))


for i in range(min(k,100)):
    #nw=[0]*n
    pr=[0]*n
    for x,d in enumerate(a):
        if d==0:
            pr[x]+=1
            if x!=n-1:
                pr[x+1]-=1
            continue
        l=math.floor(x-d)
        r=math.floor(x+d)
        l=max(0,l)
        r=min(n-1,r)
        pr[l]+=1
        if r!=n-1:
            pr[r+1]-=1
    
    for m in range(1,n):
        pr[m]+=pr[m-1]
    
    a[:]=pr


        

for i in a:
    print(i,end=" ")

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

int n, m, q;
int dp[100000];
vector<int> v[100000];

void f(int p, int idx) {
	if (dp[p] < 0) {
		dp[p] = idx;
		for (int i = 0; i < v[p].size(); i++) {
			f(v[p][i], idx);
		}
	}
}

void f2() {
	int idx = 0;
	for (int i = 0; i < n; i++) {
		if (dp[i] < 0) {
			f(i, idx++);
		}
	}
}


int main(){
	int s, t;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> s >> t;
		v[s].push_back(t);
		v[t].push_back(s);
	}
	cin >> q;
	fill(dp, dp + n, -1);
	f2();
	for (int I = 0; I < q; I++) {
		cin >> s >> t;
		if (dp[s] == dp[t]) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 12120
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  string s;
  cin>>n>>s;
  
  int ma=0;
  for(int i=1;i<n;i++){
    vector<int> A(26),B(26);
    for(int j=0;j<i;j++){
      A[s[j]-'a']++;
    }
    for(int j=i;j<n;j++){
      B[s[j]-'a']++;
    }
    int cnt=0;
    for(int j=0;j<26;j++){
      if(A[j]>0 && B[j]>0) cnt++;
    }
    ma=max(ma,cnt);
  }
  cout<<ma<<endl;

  return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<int> a(3 * n, 0);
	for (int i = 0; i < a.size(); i++) {
		cin >> a[i];
	}

	sort(a.begin(), a.end(), greater<int>());

	long long sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[2 * i + 1];
	}

	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> v;

  for (ll i = 1; i <= N; i++) {
    if (i >= K) {
      v.PB(0);
      continue;
    }
    ll t = i, cnt = 0;
    while (t < K) t *= 2, cnt++;
    v.PB(cnt);
  }

  ll ma = *max_element(ALL(v));
  for (auto& e : v) e = ma - e;
  ll sum = 0;
  for (auto& e : v) sum += 1LL << e;
  cout << Decimal << (double)sum/N/(1LL << ma) << endl;

  return 0;
}

Measured memory_bytes: 1400
<?php
list($n, $k) = ints();
if ($k > ($n - 1) * ($n - 2) / 2) exit('-1');
// 1と他の点を繋ぐ、この時が最短距離2の点の組み合わせは最大となり n-1C2 通り
for ($i = 2; $i <= $n; ++$i) $ans[] =  implode(' ', [1, $i]);
// 減らしたい数だけ直接繋ぐ
$r = ($n - 1) * ($n - 2) / 2 - $k;
for ($i = 2; $i <= $n - 1; ++$i) {
    for ($j = $i + 1; $j <= $n; ++$j) {
        if ($r === 0) break 2;
        $ans[] = implode(' ', [$i, $j]);
        --$r;
    }
}
echo count($ans) . PHP_EOL;
echo implode(PHP_EOL, $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main(){
    int d;
    cin >> d;
    if(d == 25){
        cout << "Christmas" << endl;
    }
    else if(d == 24){
        cout << "Christmas Eve" << endl;
    }
    else if(d == 23){
        cout << "Christmas Eve Eve" << endl;
    }
    else{
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int t[100005];

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	cin>>n;
	a=0;
	for(i=0;i<n;i++){
		cin>>t[i+1];
		a+=abs(t[i+1]-t[i]);
	}
	a+=abs(t[n]);
	for(i=1;i<=n;i++){
		b=a;
		b-=abs(t[i]-t[i-1])+abs(t[i+1]-t[i]);
		b+=abs(t[i+1]-t[i-1]);
		cout<<b<<endl;
	}
	
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int lcm(int a, int b) {
  return a / __gcd(a, b) * b;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;
  vint a(n);
  //int LCM = 1;
  rep(i, n) {
    cin >> a[i];
    //LCM = lcm(LCM, a[i]);
  }
  //cout << LCM << endl;
  int sum = 0;
  rep(i, n) sum += a[i]-1;//sum += (LCM-1)%a[i];
  cout << sum << endl;

  return 0;
}


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

int main(void) {
	double x1, y1, x2, y2,x,y,distance;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	x = x1 - x2;
	y = y1 - y2;

	distance = sqrt(pow(x, 2) + pow(y, 2));

	printf("%f\n", distance);

	return 0;
}


Measured memory_bytes: 2704
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
ll n,m,x;
cin >>n>>m>>x;
ll a[m];
for(ll i=0;i<m;i++){
cin >>a[i];
}
ll sum=0;
ll count1=0;
ll count2=0;
for(ll i=0;i<m;i++){
if(a[i]<x)
count1++;
else
count2++;
}
if(count1<count2)
cout <<count1;
else
cout <<count2;


return 0;

}

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

int n, m;

int main() {
  std::cin >> n >> m;
  if (n < m) {
    for (int i = 1; i <= m; ++i) {
      std::cout << n;
    }
  } else {
    for (int i = 1; i <= n; ++i) {
      std::cout << m;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N, M = map(long, raw_input().split())
A = list()
for i in xrange(N):
    a, b = map(long, raw_input().split())
    A.append((a,b))

A.sort()

count = 0L
cost = 0L

for (a, b) in A:
    if count + b >= M:
        cost += a * (M - count) 
        print str(cost)
        break
    else:
        count += b
        cost += a * b




Measured memory_bytes: 17316
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

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

  char d = 'a' - 'A';

S.at(K-1) = S.at(K-1) + d;

  cout << S << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int s, h, m;
	scanf("%d", &s);
	h = (int)s / 3600;
	m = (int)(s - 3600 * h) / 60;
	s = s- (int)(3600 * h + 60 * m);
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 2624
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	lint mod = 1000000007,ans=1;
	cin>>n;
	rep1(i,n){
		ans=(ans*i)%mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
k = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[k-1])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}

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

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


int main(void){

    //Inputの値
    int n;//商品の種類
    int m;//選択する人気商品の個数
    
    //作業用変数
    int sum;//総得票数
    int counter;//選択した人気商品の数
    
    //初期値
    sum = 0;
    counter = 0;
    
    //値を獲得する。
    cin >> n >> m;
    
    //各商品の票数
    int A[n];
    
    //for分で得票数を取得する。併せて総得票数を計算する
    rep(i,n) cin >> A[i], sum += A[i];
    
    //人気商品か否かを確認し、人気商品の数を数える
    rep(i,n) if( A[i] * 4 * m  >= sum ) counter += 1;
    
    //人気商品がN個獲得できたかどうか確認する。
    if( n >= counter && counter >= m) cout << "Yes" << endl;
    else cout << "No" <<endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <stack>
#include <vector>//子のセットを記録
#include <string>//ノードのタイプ(root、internal node、leafのいずれか)を記録
#include <algorithm>
#include <iterator>//back_inserter
#define N_MAX 100000
#define MAX_DEPTH
#define NIL -1//親や子などが存在しない場合に用いる
using namespace std;
//常に心してかかれ
//簡単なことを簡単にできるように練習する
//びっくりするくらいつまらないことで詰まってることも多い
//それでも不具合の可能性は常にある

int n;//num of input (=num of nodes)



class node{
	/*今回の場合，その節点の親，一番左の子，すぐ右の兄弟からその節点
	 *を特徴づけることができる
	 */
public:
	int parent;
	int leftest_child;
	int nearest_right_slimbs;
	int depth;

};

node list[N_MAX+1];
int setDepth(int u){
	int d = 0;//whileは先判定なのでNILではまずい
	while(list[u].parent != NIL){
		u = list[u].parent;//uは値渡しなのでこれで問題ない
		d++;
	}
	return d;
}

void print(int u){
	int c;
	cout <<"node " <<u <<": ";
	cout <<"parent = " <<list[u].parent <<", ";
	cout <<"depth = " <<list[u].depth <<", ";

	if(list[u].parent == NIL) cout <<"root, ";
	else if(list[u].leftest_child == NIL) cout <<"leaf, ";
	else cout <<"internal node, ";

	cout <<"[";

	c=list[u].leftest_child;
	for(int i=0;c != NIL;i++){
		if(i>0)cout <<", ";
		cout <<c;
		c = list[c].nearest_right_slimbs;
	}
	cout <<"]" <<endl;
}

int main(){
	int root_id;
	int id_tmp;
	int numchld_tmp;
	int chldid_tmp;
	int prvs_chldid;

	

	for(int i=0;i<N_MAX;i++){//初期化
		list[i].leftest_child = list[i].nearest_right_slimbs = list[i].parent = list[i].depth = NIL;
	}

	scanf("%d",&n);

	for(int i=0;i<n;i++){
		scanf("%d",&id_tmp);
		scanf("%d",&numchld_tmp);

		
		//numchld_tmp == 0のときはこのループは回らないが初期化が適切なので問題ない
		for(int j=0;j<numchld_tmp;j++){
			scanf("%d",&chldid_tmp);
			if(j == 0){//一番左の子
				list[id_tmp].leftest_child = chldid_tmp;
			}else{//j>0
				list[prvs_chldid].nearest_right_slimbs = chldid_tmp;//ひとつ前の子のすぐ右の子
			}
			prvs_chldid = chldid_tmp;
			list[chldid_tmp].parent = id_tmp;
		}
	}

	//親の探索
	for(int i=0;i<n;i++){
		if(list[i].parent == -1){
			root_id = i;
		}
	}

	for(int i=0;i<n;i++){
		list[i].depth = setDepth(i);
	}

	for(int i=0;i<n;i++){
		print(i);
	}

	return 0;
}
/*雑記
class node{
public:
	int node_id;
	int parent;
	int depth;
	string type;
	vector<int> list_of_children;/*vector<int> list_of_children();だとエラーになるなんで？
								  *これだとvector<int>型の返り値をもつ引数なしのlist_of_children
								  *という名前のメンバ関数のプロトタイプ宣言をしてしまってる．
								  *引数なしのコンストラクタを用いるときは後ろに()を付けないこと！
								  *//*
	node(){
	}

	node(int NODE_ID){
		node_id = NODE_ID;
	}

	void setListOfChildren(int num){
		int tmp;

		for(int i=0;i<num;i++){
			scanf("%d",&tmp);
			list_of_children.push_back(tmp);
		}
	}

};
*/

Measured memory_bytes: 2768
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

void count(int idx, map<int,vector<int> > &m, set<int> &s, set<int> &f){
  if(f.count(idx) != 0) return;
  f.insert(idx);
  if(m.count(idx) == 0) s.insert(idx);
  else{
    vector<int> &v = m[idx];
    FOR(it, v) count(*it, m, s,f);
  }
}

inline int n2i(const string &str, map<string,int> &m){
  if(m.count(str) == 0){
    int next = m.size();
    return m[str] = next;
  }else
    return m[str];
}

int main(){
  int n;
  char table[128];
  REP(i,128) table[i] = i;
  table[':'] = table[','] = table['.'] = ' ';
  
  while(cin>>n, n){
    string str;
    int start;
    map<string,int> m;
    map<int,vector<int> > vv;
    REP(i,n){
      cin>>str;
      FOR(it,str) *it = table[*it];

      stringstream ss(str);
      string tmp;
      int idx;

      ss>>tmp;
      if(i == 0) start = idx = n2i(tmp,m);
      else idx = n2i(tmp,m);

      vector<int> &v = vv[idx];

      while(ss>>tmp) v.push_back(n2i(tmp,m));
    }

    set<int> s,f;
    count(start, vv, s, f);
    cout << s.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1068
// [[ABC134C] Exception Handling] https://www.luogu.com.cn/problem/AT4843
#include <algorithm>
#include <iostream>
#include <map>
#include <cstdio>
using namespace std;
int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);

  if (a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12) {
    printf("%d\n", b == 31 ? 1 : 0);
  } else if (a == 4 || a == 6 || a == 9 || a == 11) {
    printf("%d\n", b == 30 ? 1 : 0);
  } else {
    printf("%d\n", b == 28 ? 1 : 0);
  }
  return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> v(m);
    REP (i, 0, m) cin >> v[i];
    vector<lli> w(n + 1, 0), e(n + 1, 0);
    REP (i, 0, m) REP (j, 0, n) {
        if (v[i][j] == 'W') w[j]++;
        else e[j + 1]++;
    }
    REP (i, 0, n) {
        e[i + 1] += e[i];
        w[n - i - 1] += w[n - i];
    }
    int idx = 0;
    lli error = 1 << 30;
    REP (i, 0, n + 1) {
        lli er = w[i] + e[i];
        if (er < error) {
            error = er;
            idx = i;
        }
    }
    cout << idx << ' ' << idx + 1 << endl;
    return 0;
}


Measured memory_bytes: 4800
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>; //pop_back pop_front push_back push_front front back clear empty
using L = vector<long long>;
using M = map<int,long long>;  //erase  (でキーごと削除) 追加削除検索O(log(N))
using A = vector<vector<long long>>;
using U = unordered_map<int,long long>; //map  (との違いはkeyの順番を保持していない)
using PQL = priority_queue<long long>; //erase  (でキーごと削除) push pop top 
using PQG = priority_queue<long long,L,greater<long long>>; //erase  (でキーごと削除) push pop top 

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vdel(vector,a) vector.erase(vector.begin()+a)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define max max<unsigned long>
#define min min<unsigned long>
#define inf 1000000000000000000+10
#define setans long long ans=0;

long long MOD=1000000007;

template <typename PQ>
long long pqsum(PQ pq){long long tmp=0;while(!pq.empty()){tmp+=pq.top();pq.pop();};return tmp;};

template <typename T>
void print(T a){for (auto b:a){cout<<b<<" ";};cout<<endl;}
template <>
void print(unsigned long a){cout<<a<<endl;}
template <>
void print(char a){cout<<a<<endl;}
template <>
void print(bool a){cout<<a<<endl;}
template <>
void print(long long a){cout<<a<<endl;}
template <>
void print(A a){for (auto b:a){for (auto c:b){cout<<c<<" ";}cout<<endl;};cout<<endl;}
template <>
void print(string a){cout<<a<<endl;}



//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ
//printf("%.16f", ans); 誤差落ち対応君



int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    long long k,x;
    cin>>k>>x;
    for(long long i=x-k+1  ;i<x  ;i++){
        cout<<i<<" ";
    }
    for(long long i=x  ;i<x+k  ;i++){
        cout<<i<<" ";
    }
}


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

template<class T>
ostream& operator<<(ostream& os,vector<T> const& v){for(auto itr=v.begin();itr!=v.end();++itr){if(itr!=v.begin())os<<' ';os<<*itr;}return os;}

signed main(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  int q;
  cin>>q;
  while(q--){
    int k;
    cin>>k;
    cout<< binary_search(a.begin(),a.end(),k) <<endl;
  }

}


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(void){
    string S;
    cin >> S;
    
    if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<class T>inline void read(T &res)
{
    char c;
    T flag=1;
    while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
    res=c-'0';
    while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';
    res*=flag;
}
void gcd(ll a,ll b,ll &d,ll &x,ll &y)
{
    if(!b)
    {
        d=a;
        x=1;
        y=0;
    }
    else
    {
        gcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}
ll in(ll a,ll mod)
{
    ll d,x,y;
    gcd(a,mod,d,x,y);
    return d==1?(x+mod)%mod:-1;
}

ll qp(ll a,ll x,ll mod)
{
    ll ans=1;
    while(x)
    {
        if(x%2==1)
            ans=(ans*a)%mod;
        a=(a*a)%mod;
        x/=2;
    }
    return ans;
}
int cmp(ll a,ll b)
{
    return a<b;
}
ll a[3005][3005],v,ans;
ll dp[3005][3005][4];
int main()
{
    int n,m,k,x,y;
    cin>>n>>m>>k;
    for(int i=0;i<k;i++)
	{
		read(x);read(y);read(v);
		a[x][y]=v;
	}
	dp[1][1][0]=0;
	dp[1][1][1]=a[1][1];
	dp[1][1][2]=a[1][1];
	dp[1][1][3]=a[1][1];
	for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        {/*
            if(i==1&&j==1)
                continue;
            if(i==1)
            {
                dp[i][j][0]=max(dp[i][j][0],dp[i][j-1][0]);
                dp[i][j][1]=max(dp[i][j][1],max(dp[i][j-1][0]+a[i][j],dp[i][j-1][1]));
                dp[i][j][2]=max(dp[i][j][2],max(dp[i][j-1][1]+a[i][j],dp[i][j-1][2]));
                dp[i][j][3]=max(dp[i][j][3],max(dp[i][j-1][2]+a[i][j],dp[i][j-1][3]));
                continue;
            }
            if(j==1)
            {
                dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][3]);
                dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][3]);
                dp[i][j][2]=max(dp[i][j][2],dp[i-1][j][3]);
                dp[i][j][3]=max(dp[i][j][3],dp[i-1][j][3]);
                continue;
            }*/
            dp[i][j][0]=max(dp[i][j][0],max(dp[i-1][j][3],dp[i][j-1][0]));
            dp[i][j][1]=max(dp[i][j][1],max(dp[i-1][j][3]+a[i][j],max(dp[i][j-1][0]+a[i][j],dp[i][j-1][1])));
            dp[i][j][2]=max(dp[i][j][2],max(dp[i-1][j][3]+a[i][j],max(dp[i][j-1][1]+a[i][j],dp[i][j-1][2])));
            dp[i][j][3]=max(dp[i][j][3],max(dp[i-1][j][3]+a[i][j],max(dp[i][j-1][2]+a[i][j],dp[i][j-1][3])));

        }
    cout<<max(dp[n][m][0],max(dp[n][m][1],max(dp[n][m][2],dp[n][m][3])))<<endl;
    return 0;

}

/*



5 5 23
1 2 2
1 3 1
1 4 3
1 5 1
2 1 1
2 2 2
2 3 1
2 4 3
2 5 1
3 1 1
3 2 4
3 3 1
3 4 2
3 5 1
4 1 1
4 2 1
4 3 1
4 4 1
4 5 1
5 1 1
5 2 1
5 3 1
5 4 1

*/

Measured memory_bytes: 355388
D,G = map(int,input().split())
PC = [list(map(int,input().split())) for i in range(D)]

ans = float("inf")
bi = [0,1]
import itertools

for i in list(itertools.product(bi, repeat=D)):
    tmp = 0
    p = 0
    for j in range(D):
        if i[j] == 1:
            p += PC[j][1]
            p += PC[j][0]*100*(j+1)
            tmp += PC[j][0]
    for j in range(D):
        k = D-1-j
        if p >= G:
            break
        if i[k] == 0:
            tmp += min(PC[k][0]-1,-(-(G-p)//(100*(k+1))))
            p += min(PC[k][0]-1,-(-(G-p)//(100*(k+1)))) * (100*(k+1))
            
    if ans > tmp and p>=G:
        ans = tmp


print(ans)

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

int main() {
  ll x;
  cin >> x;
  
  ll deposit = 100.0;
  ll ans = 0;
  
  while (deposit < x) {
    ans++;
    deposit *= 1.01;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<pair<ll, ll>> VPI;
typedef pair<ll, ll> PLL;
typedef map<ll, ll> MLL;
#define EPS 1e-9
#define pb push_back
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    int dp[s.length() + 1][t.length() + 1];
    FOR(i, 0, s.length() + 1)
    {
        FOR(j, 0, t.length() + 1)
        {
            if (i == 0 || j == 0)
            {
                dp[i][j] = 0;
            }
            else if (s[i - 1] == t[j - 1])
            {
                dp[i][j] = 1 + dp[i - 1][j - 1];
            }
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    int index = dp[s.length()][t.length()];
    int i = s.length(), j = t.length();
    char output[index + 1];
    output[index] = '\0';
    while (i > 0 && j > 0)
    {
        if (s[i - 1] == t[j - 1])
        {
            output[index - 1] = s[i - 1];
            i--;
            index--;
            j--;
        }
        else if (dp[i][j - 1] > dp[i - 1][j])
        {
            j--;
        }
        else
            i--;
    }
    cout << output;
    return 0;
}


Measured memory_bytes: 35456
//12252024832524
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; 

typedef long long LL;
const int MAXN = 100005;

LL Read()
{
	LL x = 0,f = 1;char c = getchar();
	while(c > '9' || c < '0'){if(c == '-')f = -1;c = getchar();}
	while(c >= '0' && c <= '9'){x = (x*10) + (c^48);c = getchar();}
	return x * f;
}
void Put1(LL x)
{
	if(x > 9) Put1(x/10);
	putchar(x%10^48);
}
void Put(LL x,char c = -1)
{
	if(x < 0) putchar('-'),x = -x;
	Put1(x);
	if(c >= 0) putchar(c);
}
template <typename T>T Max(T x,T y){return x > y ? x : y;}
template <typename T>T Min(T x,T y){return x < y ? x : y;}
template <typename T>T Abs(T x){return x < 0 ? -x : x;}

LL wu(LL x)
{
	return x * x * x * x * x;
}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	LL n = Read();
	for(LL i = -500;i <= 500;++ i)
		for(LL j = -500;j <= 500;++ j)
			if(wu(i) - wu(j) == n)
			{
				Put(i,' ');
				Put(j);
				return 0;
			}
	return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n, m;
    cin >> n >> m;
    map<int, int> h;
    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        h[i] = tmp;
    }
    vector<int>check(n, 1);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        if (h[a-1] < h[b-1]) check[a-1]--;
        else if (h[a-1] > h[b-1]) check[b-1]--;
        else {
            check[a-1]--;
            check[b-1]--;
        }
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        if (check[i] > 0) ++res;
    } 
    cout << res << endl;
    return 0;
}

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

int main(){
  int P;
  int D;
  cin >> P >> D;
  vector<vector<int>> points(P, vector<int> (D));
  for (int i = 0; i < P; i++){
    for (int j = 0; j < D; j++){
      cin >> points[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < P; i++){
    for (int j = 0; j < i; j++){
      int dist = 0;
      for (int k = 0; k < D; k++){
        dist += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]);
      }
      for (int k = 0; k <= dist; k++){
        if (k * k == dist){
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int A,B;
    cin>>A>>B;
    cout<<max(max(2*A-1,A+B),2*B-1)<<endl;
}

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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        char[] data = S.toCharArray();
        int count = 0;
        for (int i = 0; i < N - 2; i++) {
            if (data[i] == 'A' && data[i+1] == 'B' && data[i+2] == 'C') {
                count += 1;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21716
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define debug(x)			{ cerr << #x << " = " << x << endl; }
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define vi					vector<int>
#define vii					vector<vi>
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n,d;
	cin>>n>>d;
	int x[11][11];
	for(int i=0; i<n; i++){
		for(int j=0; j<d; j++) {
			cin>>x[i][j];
		}
	}
	int ans = 0;
	for(int i=0; i<n; i++) {
		for(int j=i+1;j<n; j++) {
			double dis = 0;
			for(int k=0; k<d; k++) {
				dis += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			
			}	
			if(sqrt(dis) == (int)sqrt(dis)) {
				ans++;
			}
		}
	
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 892
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    a, b = sc.intarr()
    print(gcd(a, b))


def gcd(a, b):
    a, b = b, a % b
    if b == 0:
        return a
    else:
        return gcd(a, b)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


main()



Measured memory_bytes: 5668
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;
int main(){
  double N, T, A;
  cin >> N >> T >> A;
  double min = 1000;
  int ans;

  for(int i=0;i<N;i++){
  	double a;
  	cin >> a;
  	double error = abs(A - T + 0.006*a);
  	if(error < min){
  		ans = i+1;
  		min = error;
  	}  	
  }
  cout << ans <<endl;
  return 0;
}

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

int main() {
    int n, h = 0, m = 0, s = 0;
    cin >> n;
    if(n / 3600 > 0) h = n / 3600;
    n = n % 3600;
    if(n / 60 > 0) m = n / 60;
    s = n % 60;
    cout << h << ':' << m << ':' << s << endl;
}


Measured memory_bytes: 3096
def f():
    a = list(map(int, input().split()))+list(map(int, input().split()))+list(map(int, input().split()))
    b = []
    for i in range(4):
        b.append(sum(x==i+1 for x in a))
    for i in b:
        if i > 2:
            print('NO')
            return
    print('YES')
f()

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
	if(a<b){
	cout<<"a < b"<<endl;
	}else if(a>b){
	cout<<"a > b"<<endl;
	}else{
	cout<<"a == b"<<endl;
	}
return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    vi vec(n);
    REP(i,n)cin>>vec[i];
    REP(i,n-1){
        ans+=min(b,a*(vec[i+1]-vec[i]));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int a, b, k;
    cin >> k >> a >> b;
    forn (i, a, b + 1)
        if (i % k == 0)
            return cout << "OK", 0;
    cout << "NG";
    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());

        var ans = N < 1000 ? "ABC" : "ABD";

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 27508
#include <iostream>
#include<cmath>
using namespace std;
int min(int x,int y)
{
    if(x>y)return y;
    else return x;
}
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
    return 0;
}

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

int main() {
	int q;
	std::cin >> q;
	
	for (int i = 0; i < q; i++) {
		std::string s1, s2;
		std::cin >> s1 >> s2;
		std::vector<int> ref(s2.size(), 0);
		for (int j = 0; j < s1.size(); j++) {
			std::vector<int> vec = ref;
			for (int k = 0; k < s2.size(); k++) {
				if (s1[j] == s2[k]) {
					int al = k == 0 ? 0 : ref[k - 1];
					int a = ref[k];
					vec[k] = std::max(al + 1, a);
				}
				else {
					int l = k == 0 ? ref[0] : vec[k - 1];
					int a = ref[k];
					vec[k] = std::max(l, a);
				}
			}
			ref = vec;
		}
		std::cout << ref[s2.size() - 1] << std::endl;
	}
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
const int MAXN = 4096;
const int mod = 998244353;
using bs = bitset<MAXN>;

int len(bs &x){
	for(int i=MAXN-1; i>=0; i--){
		if(x[i]) return i + 1;
	}
	return 0;
}

bs MOD(bs a, bs b){
	int d = len(a) - len(b);
	if(d < 0) return a;
	return a ^ (b << d);
}

bs gcd(bs a, bs b){
	if(len(b) == 0) return a;
	return gcd(b, MOD(a, b));
}

bs input(){
	string s;
	cin >> s;
	bs ret = 0;
	reverse(s.begin(), s.end());
	for(int i=0; i<s.size(); i++){
		if(s[i] == '1') ret.set(i);
	}
	return ret;
}

int pwr(int x){
	int ret = 1;
	for(int i=0; i<x; i++) ret = ret * 2 % mod;
	return ret;
}

int main(){
	int n;
	cin >> n;
	bs x = input();
	bs g = 0;
	for(int i=0; i<n; i++){
		g = gcd(g, input());
	}
	n = len(x);
	int m = len(g);
	int ret = 1;
	bs cur = 0;
	for(int i=n-1; i>=m-1; i--){
		if(x[i] == 0){
			if(cur[i] == 1){
				cur ^= (g << (i - m + 1));
			}
		}
		else{
			if(cur[i] == 0){
				ret += pwr(i - m + 1);
				ret %= mod;
				cur ^= (g << (i - m + 1));
			}
			else{
				ret += pwr(i - m + 1);
				ret %= mod;
			}
		}
	}
	for(int i=m-2; i>=0; i--){
		if(cur[i] < x[i]) break;
		if(cur[i] > x[i]){
			ret += mod - 1;
			ret %= mod;
			break;
		}
	}
	cout << ret << endl;
}



Measured memory_bytes: 12416
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

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

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

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N, M;
	cin >> N >> M;

	vll x(M + 1), y(M + 1);
	repn(i, M) cin >> x[i] >> y[i];

	vvll set(N + 1, vll(N + 1, 0));
	vll live(N + 1, 1);
	repn(i, N)set[i][i] = 1;

	for (ll i = M; i >= 1; i--) {
		repn(j, N) {
			if (set[j][x[i]] == 1 && set[j][y[i]] == 1) { live[j] = 0; }
			if (live[j] == 0) { continue; }

			if (set[j][x[i]] == 1) { set[j][y[i]] = 1; }
			if (set[j][y[i]] == 1) { set[j][x[i]] = 1; }
		}
	}

	ll ans = 0;
	repn(i, N)for(ll j=i+1;j<=N;j++) {
		if (live[i] == 0 || live[j] == 0) { continue; }

		bool b = 1;
		repn(k, N)if (set[i][k] == 1 && set[j][k] == 1) { b = 0; }

		if (b) { ans++; }
	}

	cout << ans << endl;
}

Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int ans=0;
  int now=0;
  rep(i,n){
    if(s[i]=='I')now++;
    else now--;
    chmax(ans,now);
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256