akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}


int main(){
  ll H, N;
  cin >> H >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a.at(i);
  rep(i,N){
    H -= a.at(i);
  }
  string ans;
  if (H <=0){
    ans = "Yes";
  }else{
    ans = "No";
  }

  cout << ans << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long K;
    cin >> K;
    queue<string> q;
    if(K <= 9){
        cout << K << endl;
        return 0;
    }
    long long count = 0;
    for(int i = 1; i <= 9; i++){
        char c = '0' + i;
        string s;
        s += c;
        q.push(s);
        count++;
    }
    while(true){
        string t = q.front();
        char end = t[t.size() - 1];
        if(end - '0' - 1 >= 0) {
            string s = t;
            s += end - '0' - 1 + '0';
            q.push(s);
            count++;
            if(count == K){
                cout << s << endl;
                return 0;
            }
        }
        q.push(t + end);
        count++;
        if(count == K){
            cout << t + end << endl;
            return 0;
        }
        if(end - '0' + 1 <= 9){
            string s = t;
            s += end - '0' + 1 + '0';
            q.push(s);
            count++;
            if(count == K){
                cout << s << endl;
                return 0;
            }
        }
        q.pop();
    }
}

Measured memory_bytes: 4864
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int n, i, j, k, a[101]={0}, c1=0, c2=0;
    scanf("%d", &n);
    for(i=0;i<n;++i)
    {
        scanf("%d", &a[i]);
    }
    for(i=0;i<n;++i)
    {
        for(j=i;j<n;++j)
        {
            if(a[i]<a[j]) k = a[i], a[i] = a[j], a[j] = k;
        }
        if(i%2==0) c1+=a[i];
        else c2+=a[i];
    }
    printf("%d", c1-c2);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    do{
        scanf("%d %d",&a,&b);
        if(a==0 && b==0)
        break;
        for(int i=0;i<a;i++)
        {
            for(int j=0;j<b;j++)
            {
            	if(i==0||j==0||i==a-1||j==b-1){
                printf("#");}
                else
                printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }while(a!=0 && b!=0);
}


Measured memory_bytes: 2604
#include <iostream>

using namespace std;

template <class T>
T abs(T x) {
  if (x < 0) {
    return -x;
  } else {
    return x;
  }
}

int main(int ac, char **av) {
  int N, L;
  int k, minT;
  cin >> N >> L;
  k = 0;
  minT = 65536;
  for (int i = 0; i < N; i++) {
    int T = L - 1 + i + 1;
    if (abs(T) < abs(minT)) {
      minT = T;
      k = i;
    }
  }
  cout << N * (L-1) + (N * (N + 1)) / 2 - (L - 1 + k + 1) << endl;
  return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
A = [[] for i in range(H)]
B = [[] for i in range(H)]

for i in range(H):
	a = list(map(int,input().split()))
	A[i] = a
for i in range(H):
	b = list(map(int,input().split()))
	B[i] = b

D = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
R = 160*80
"""
dp = [[[False for k in range(R)] for j in range(W)] for i in range(H)]
dp[0][0][D[0][0]] = True
for i in range(H):
	for j in range(W):
		r = 80 * (i+j+2)
		for n in range(r):
			if not dp[i][j][n]:
				continue
			if j != W-1:
				d = D[i][j+1]
				dp[i][j+1][n+d] = True
				dp[i][j+1][abs(n-d)] = True
			if i != H-1:
				d = D[i+1][j]
				dp[i+1][j][n+d] = True
				dp[i+1][j][abs(n-d)] = True

"""
dp = [[0 for j in range(W)] for i in range(H)]
dp[0][0] = 2**(R + D[0][0]) | 2**(R - D[0][0])
for i in range(H):
	for j in range(W):
		if j != W-1:
			d = D[i][j+1]
			dp[i][j+1] |= (dp[i][j] << d | dp[i][j] >> d)
		if i != H-1:
			d = D[i+1][j]
			dp[i+1][j] |= (dp[i][j] << d | dp[i][j] >> d)
h,w = H-1, W-1
for i in range(R):
	mask = 2 ** (R+i) | 2 ** (R-i)
	if dp[h][w] & mask > 0:
		print(i)
		exit()

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

int code[8][3] = {
    {0, 0, 0},
    {0, 0, 255},
    {0, 255, 0},
    {0, 255, 255},
    {255, 0, 0},
    {255, 0, 255},
    {255, 255, 0},
    {255, 255, 255}
};
string name[8] = {"black",
                  "blue",
                  "lime",
                  "aqua",
                  "red",
                  "fuchsia",
                  "yellow",
                  "white"
};

int convert(string s){
    int d;
    sscanf(s.c_str(), "%x", &d);
    return d;
}

int main(){
    string line;
    while(cin >> line && line[0] != '0'){
        int r = convert(line.substr(1, 2));
        int g = convert(line.substr(3, 2));
        int b = convert(line.substr(5, 2));
        int ans_dist = 1e9;
        string ans = "--";
        rep(i,8){
            auto c = code[i];
            int d = 0;
            d += (r-c[0]) * (r-c[0]);
            d += (g-c[1]) * (g-c[1]);
            d += (b-c[2]) * (b-c[2]);
            if(d < ans_dist){
                ans_dist = d;
                ans = name[i];
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1248
N, C = map(int, input().split())
table = [[] for _ in range(C)]
for i in range(N):
    s, t, c = map(int, input().split())
    c -= 1
    table[c].append([s, t])

for i in range(C):
    table[i].sort()
    for j in range(len(table[i])-1):
        if table[i][j][1] == table[i][j+1][0]:
            table[i][j+1][0] = table[i][j][0]
            table[i][j] = [-1, -1]

imos = [0] * (10 ** 5 + 1000)
for channel in table:
    for s, t in channel:
        if s + t < 0:
            continue
        imos[s] += 1
        imos[t+1] -= 1

for i in range(10 ** 5 + 10):
    imos[i+1] += imos[i]

print(max(imos))


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

int main(){
	long long X,A1,A2,B,ans;
	cin>>X;
	A1 = X/500; A2 = X%500;
	B = A2/5;
	ans = A1*1000+B*5;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string s;
  cin >> s;
  int ct = 0;
  REP(i,N){
    if(s[i] == '('){
      ct++;
    }else{
      if(ct > 0) ct--;
      else if(ct == 0){
        cout << '(';
      }
    }
  }
  cout << s;
  if(ct > 0) cout << string(ct, ')');
  return 0;
}


Measured memory_bytes: 384
n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353

dp = [0 for i in range(s+1)]

ans = 0
tmp = [0]

for i, ai in enumerate(a):
    dpn = []
    dp[0] = i + 1
    for j in range(s+1):
        if j - ai >= 0 and dp[j-ai]:
            dpn.append((dp[j] + dp[j-ai]) % mod)
        else:
            dpn.append(dp[j])
    # print(dpn)
    ans = (ans + dpn[s]) % mod
    dp = dpn[:]
print(ans)


Measured memory_bytes: 46940
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def fi(): return float(input())
def mfi(): return map(float, input().rstrip().split())
def lmfi(): return list(map(float, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template


def main():
    S = input().rstrip()
    if S == "SAT":
        print(1)
    elif S == "MON":
        print(6)
    elif S == "TUE":
        print(5)
    elif S == "WED":
        print(4)
    elif S == "THU":
        print(3)
    elif S == "FRI":
        print(2)
    elif S == "SUN":
        print(7)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#include <numeric>
using namespace  std;

using ll = long long;
const ll mod = 998244353;
typedef pair<int , int> pairs;
typedef complex<ll> G;
const int N = 1e6+5;

const int INF = 1e9;

void done() {
    int n, m;
    cin >> n >> m;
    char a[n][m];
    set<int>q;
    set<int>p;
    vector<int>pos1, pos2;
    pairs ap = {INF, INF};
    int ok = 0;
    for(int i=0;i < n;i++) {
        for(int j = 0;j < m;j++) {
            cin >> a[i][j];
        }
    }
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < m;j++) {


            if(i < n-1 && i!=0 && j != 0 && j < m-1) {
                if(a[i][j] == '*' && a[i][j+1] == '*' && a[i+1][j] == '*' && a[i-1][j] == '*' && a[i][j-1] == '*') {
                    ap  = make_pair(i, j);
                    ok++;
                }
            }
        }
    }

    if(ok != 1) {
        cout << "NO\n";
        return;
    }
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < m;j++) {
            if(a[i][j] == '*') {
                if(i != ap.first && j!=ap.second) {
                    cout << "NO\n";
                    return;
                }
                if(j == ap.second)pos1.push_back(j);
                if(i == ap.first)pos2.push_back(i);
            }
        }
    }

    sort(pos1.begin(), pos1.end());
    sort(pos2.begin(), pos2.end());
    for(int i=0;i < pos1.size()-1;i++) {
        if(pos1[i+1]-pos1[i] > 1) {
            cout << "NO\n";
            return;
        }
    }
    for(int i=0;i < pos2.size()-1;i++) {
        if(pos2[i+1]-pos2[i] > 1) {
            cout << "NO\n";
            return;
        }
    }
    cout << "YES\n";



}

void solve(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i < n;i++) {
        cin >> a[i];
    }
    bool ok = 1;
    for(int i=0;i < n-1;i++) {
        if(a[i] > a[i+1]) {
            ok = 0;
            break;
        }
    }
    if(ok) {
        cout << 0 << '\n';
        return;
    }


}

void another() {
   int n;cin >> n;
    int ans = 0;
    for(int i =0;i < n;i++) {
        int p;cin >> p;
        if((i+1) & 1 && p & 1)ans++;
    }
    cout << ans << '\n';

}
void test_case() {
    int t;
    cin >> t;
    while(t--)solve();
}
int main() {

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    another();

}


Measured memory_bytes: 3664
fun main() {
    val (a, b, c, d) = readLine()!!.split(" ").map { it.toInt() }
    var counter = 0
    while (true) {
        if (c - b * counter <= 0) {
            println("Yes")
            return
        }
        if (a - d * counter <= 0) {
            println("No")
            return
        }
        counter += 1
    }
}

Measured memory_bytes: 36400
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, W;
  cin >> N >> W;
  long long w[N], v[N];
  for(int i = 0; i < N; i ++) cin >> w[i] >> v[i];
  long long ans = 0, dp[W + 1] = {0LL};
  for(int i = 0; i < N; i ++) {
    for(int j = W; j >= w[i]; j --) {
      dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
      ans = max(ans, dp[j]);
    }
  }
  cout << ans;
}

Measured memory_bytes: 1024
# A - Shiritori


def f(x):
    f_list = []
    for i in x:
        f_list.append(i)
    return f_list


# 標準入力 a b c
a, b, c = map(str, input().split(maxsplit=3))

word_list_a = f(a)
word_list_b = f(b)
word_list_c = f(c)

if word_list_a.pop() == word_list_b[0] and word_list_b.pop() == word_list_c[0]:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 9116
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
char t[ohara],d[ohara];

//-------------------------↓↓↓↓↓↓------------------------

bool check(ll iti){
    ll now=iti;
    bool ok=true;
    rep(i,q){
        if(s[now]!=t[i])continue;
        if(d[i]=='R')now++;
        else now--;
        if(now==-1){
            ok=false;
            break;
        }
    }
    return ok;
}

bool check2(ll iti){
    ll now=iti;
    bool ok=true;
    rep(i,q){
        if(s[now]!=t[i])continue;
        if(d[i]=='R')now++;
        else now--;
        if(now==n){
            ok=false;
            break;
        }
    }
    return ok;
}

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

    cin>>n>>q>>s;
    rep(i,q)cin>>t[i]>>d[i];
    ll le=0,ri=n-1,mid;
    while(ri-le>1){
        mid=(le+ri)/2;//falseで消滅
        if(check(mid))ri=mid;
        else le=mid;
    }
    ans=max(le-10,0LL);
    rrep(i,max(le-10,0LL),min(ri+10,n)){
        if(check(i)){
            break;
        }
        else{
            ans++;
        }
    }



    le=0,ri=n-1,mid;
    while(ri-le>1){
        mid=(le+ri)/2;//falseで消滅
        if(!check2(mid))ri=mid;
        else le=mid;
    }
    ans+=n-min(ri+10,n-1);
    ans--;
    rrrep(i,min(ri+10,n-1),max(le-10,0LL)){
        if(check2(i)){
            break;
        }
        else{
            ans++;
        }
    }
    //Cout(ans);
    Cout(max(n-ans,0LL));
    return 0;
}


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

ac = 0
wa = 0
tle = 0
re = 0

for _ in range(n):
    i = input()

    if i == "AC":
        ac += 1
    if i == "WA":
        wa += 1
    if i == "TLE":
        tle += 1
    if i == "RE":
        re += 1

print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))


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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int N;
	cin >> N;
	pair<pair<string, int>,int>sp[100];
	rep(i, N) {
		string s;
		int second;
		cin >> s >> second;
		sp[i] = make_pair(make_pair(s, -1 * second), i);
	}
	sort(sp,sp+N);
	rep(i, N) {
		println(sp[i].second + 1);
	}
}

Measured memory_bytes: 256
/*---------------Go Code GO---------------*/

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

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
#define     PW2(a)          (long long)1<<a

map<string, long long> mp;

int main()
{
    long long i,j,k,l,m,n,o,p,q,r,tst,ans=0;
    cin>>n;
    string s;
    while(n--)
    {
        cin>>s;
        mp[s]++;
    }
    p=0;
    for(auto ch: mp)
    {
        p=max(p,ch.second);
    }
    for(auto ch: mp)
    {
        if(ch.second==p)
            cout<<ch.first<<endl;
    }


    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  bool isOK = false;
  vector<int> D(K);
  string strN;
  for(int i=0;i<K;i++){
    cin >> D[i];
  }

  // 1≦N<10000
  // 1≦K<10
  // 0≦D1<D2<…<DK≦9
  // {D1,D2,. ..,DK}≠{1,2,3,4,5,6,7,8,9}

  // 1000 8
  // 1 3 4 5 6 7 8 9

  string answer = "testtest";
  while(!isOK){
    isOK = true;
    strN = to_string(N);
    for(int j=0;j<D.size();j++){
      if(strN.find(to_string(D[j])) != string::npos){
          //  strNに指定した要素が存在しない場合(nposが取得された場合)
          isOK = false;
          break;
      }
    }

    if(isOK){
      answer = strN;
      break;
    } else {
      N++;
    }
  }

  cout << answer << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <cstring>
#define maxn 100005
#define maxm 
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
//#define DEBUG
using namespace std;

char s[maxn];
int main(){
	#ifdef DEBUG
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	scanf("%s", s);
	int n = strlen(s);
	int a = 0, b = 0;
	rep(i, 0, n - 1) {
		if ((s[i] - '0') != b) a++;
		b ^= 1;
	}
	int c = 0; b = 1;
	rep(i, 0, n - 1) {
		if ((s[i] - '0') != b) c++;
		b ^= 1;
	}
	printf("%d", min(a, c));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define         MAX         1000000
 
int main() {
  long long n, cnt=0, r=0, g=0,b=0;
  string s;
  cin>>n>>s;
  for(int i; i<n; i++){
    if(s[i]=='R')
      r++;
    else if(s[i]=='G')
      g++;
    else
      b++;
  }
  long long ans=r*g*b;
  
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      int k= j+(j-i);
      if(k>=n)
        break;
      if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])
        ans--;
    }
  }
  
  cout<<ans<<endl;
  
  return 0;
  
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a = 0,b=0,c=0,d=0,e;
  cin >> e;
  char tmp;
  rep(i,e){
    cin >> tmp;
    if(tmp=='P') a=1;
    if(tmp=='W') b=1;
    if(tmp=='G') c=1;
    if(tmp=='Y') d=1;
  }
  int f = a+b+c+d;
  if(f==3)cout << "Three";
  else cout << "Four";
}

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

using namespace std;

int main(){
        int a, b;
        int p=1;
        cin>>a>>b;
        while((b/p)>0){
                p*=10;
        }
        b+=a*p;
        bool res=false;
        //cout<<b<<endl;
        for(int i=0;i<1e4;i++){
                if(i*i==b){
                        res=true;
                        break;
                }
                if(i*i>b){
                        break;
                }
        }
        if(res){
                cout<<"Yes"<<endl;
        }
        else{
                cout<<"No"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
n,w=map(int,input().split())
wv=[tuple(map(int,input().split())) for i in range(n)]
wv.sort(key=itemgetter(1),reverse=True)#reverse
wv.sort(key=itemgetter(0))
#print(wv)
w0=wv[0][0]
x=[[0],[0],[0],[0]]
for i in range(n):
    z=wv[i][0]-w0
    k=wv[i][1]+x[z][-1]
    l=len(x[z])
    if l*wv[i][0]<=w:
        x[z].append(k)
ma=0
l3=len(x[3])
l2=len(x[2])
l1=len(x[1])
l0=len(x[0])
for i in range(l3):
    for j in range(l2):
        d=w-i*(w0+3)-j*(w0+2)
        if d>=0:
            for k in range(l1):
                d=w-i*(w0+3)-j*(w0+2)-k*(w0+1)
                if d>=0:
                    ma_sub=x[3][i]+x[2][j]+x[1][k]+x[0][min(d//w0,l0-1)]
                    ma=max(ma,ma_sub)
                else:
                    break
        else:
            break

print(ma)


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

int main(){

  int a[110],n;
  cin >> n;
  for(int i = 0; i < n ; i++){
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    int min = i;
    for(int j = i; j < n; j++){
      if(a[j] < a[min]) min = j;
    }
    if(i != min){
      int tmp = a[i];
      a[i] = a[min];
      a[min] = tmp;
      ans++;
    }
  }
  for(int i = 0; i < n; i++){
    if(i != n-1) cout << a[i] << " ";
    else cout << a[i] <<endl;
  } 
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define maxx 100010
#define mp make_pair
typedef pair<int,int> ii;
int dp[maxx];
vector <int> peso;

int x;
int main() {
	cin >> x;
	int n;
	for(int i = 0; i < x; i++){
		cin >> n;
		peso.push_back(n);
	}
	
	dp[0] = 0;
	dp[1] = dp[0] + abs(peso[0]-peso[1]);
	for(int i = 2; i < x; i++)	dp[i] = min(dp[i-1] + abs(peso[i-1] - peso[i]),dp[i-2] + abs(peso[i-2] - peso[i]));
	
	cout << dp[x-1] << endl;
	return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  rep(i,n)cin >> a[i];
  int o=0;
  rep(i,n)o+=a[i];
  int ans=0;
  int v[n];
  rep(i,100000){
    if(i==0)continue;
    if(o%i!=0)continue;
    int u=i;
    rep(i,n)v[i]=a[i]%u;
    sort(v,v+n);
    int m=0;
    rep(i,n)m+=v[i];
    int c=m;
    rep(i,c/u)m-=v[n-1-i];
    if(m<=k)ans=max(ans,u);
    u=o/i;
    rep(i,n)v[i]=a[i]%u;
    sort(v,v+n);
    m=0;
    rep(i,n)m+=v[i];
    //cout << m << " " << u << " " << m/u << endl;
    int b=m;
    rep(i,b/u){
      m-=v[n-1-i];
      //if(u==40000)cout << i << " " << m << endl;
    }
    if(m<=k)ans=max(ans,u);
    //if(u==40000)cout << m << endl;
  }
  cout << ans << endl;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;

  vector<ll> p(a);
  for (ll i = 0; i < a; ++i) {
    cin >> p[i];
  }
  vector<ll> q(b);
  for (ll i = 0; i < b; ++i) {
    cin >> q[i];
  }
  vector<ll> r(c);
  for (ll i = 0; i < c; ++i) {
    cin >> r[i];
  }

  sort(p.begin(), p.end(), greater<ll>());
  sort(q.begin(), q.end(), greater<ll>());
  sort(r.begin(), r.end(), greater<ll>());

  vector<ll> v(x+y);
  for (ll i = 0; i < x; ++i) {
    v[i] = p[i];
  }
  for (ll i = 0; i < y; ++i) {
    v[x+i] = q[i];
  }
  for (ll i = 0; i < r.size(); ++i) {
    v.push_back(r[i]);
  }
  sort(v.begin(), v.end(), greater<ll>());

  ll ans = 0;
  for (ll i = 0; i < x+y; ++i) {
    ans += v[i];
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int cnt(int x){
    int sum = 0;
    int time = 1;
    while(sum +time <= x){
        sum += time;
        time++;
    }
    return time-1;
}

int main(){
    ll n; cin >> n;
    ll N = n;
    map<ll,int> mp;
    for(ll i = 2;i*i <= N;++i){
        while(n%i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n]++;
    int ans = 0;
    for(auto x : mp){
        ans += cnt(x.second);
    }
    cout << ans << endl;
}

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

#define N 100000

int n, X;
int x[N];

long long gcd(int u, int v)
{
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

int main() {
	int n;

	cin >> n >> X;
	for( int i = 0; i < n; i++ ) {
		cin >> x[i];
	}

	long long ans = abs(x[0] - X);
	if( n > 1 ) {
		for( int i = 1; i < n; i++ ) {
			ans = gcd( ans, abs(x[i] - X) );
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int n, k; cin >> n >> k;
  vector<int> a(n + 1, 0);
  int sum = 0;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    a[x]++;
    if(a[x] == 1) sum++;
  }
  sort(a.begin(), a.end(), greater<int>());
  //for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
  int ans = 0;
  for(int i = k; i <= sum - 1; i++){
    ans += a[i];
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 1024
/*
AOJ 0189 Convenient Location

?¢????????±???????????????¬??? ??°??¶??????????????¬?????? ???????????????  ?????¬?????° ????¶????10

?????\??????????????\??????????¬¬?????????n (1 ??? n ??? 45)?????\?????\n?????? (x, y, d)???x??°y????????????d
??????????????¬?????? ??? ????????????
 */
#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include <algorithm>
#include <complex>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define SZ(a) (int)(a).size()
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define REP(i,n) for (int i=0; i<(n); ++i)
#define ALL(c) c.begin(), c.end()
#define CLR(c,n) memset(c, n, sizeof(c))
#define TR(it, c) for(typeof(c.begin()) it = c.begin();it != c.end(); ++it)
#define CONTAIN(it, c) (c.find(it) != c.end())
typedef vector<int> VI;
typedef pair<int, int> PII;
template <class T> void checkmin(T &a, T b) { if (b<a) a=b; }
template <class T> void checkmax(T &a, T b) { if (b>a) a=b; }

const int N = 10;
const int INF = 0x3F3F3F3F;
int dist[N][N];
int n, e, name[N];
map<int, int> name_map;

int getid(int x) {
  map<int, int>::iterator it = name_map.find(x);
  if (it == name_map.end()) {
    name_map[x] = n;
    name[n] = x;
    return n++;
  } else {
    return it->second;
  }
}

int main(int argc, char *argv[]) {
  int x, y, d;
  while (scanf("%d", &e) == 1 && e > 0) {
    n = 0;
    name_map.clear();
    CLR(dist, INF);
    while (e--) {
      scanf("%d %d %d", &x, &y, &d);
      x = getid(x); y = getid(y);
      checkmin(dist[x][y], d);
      checkmin(dist[y][x], d);
    }
    REP(i, n) dist[i][i] = 0;
    REP(k, n) REP(i, n) REP(j, n) {
      checkmin(dist[i][j], dist[i][k] + dist[k][j]);
    }
    int ans = INF, best = -1;
    REP(i, n) {
      int current = accumulate(dist[i], dist[i] + n, 0);
      if (current < ans) {
        ans = current;
        best = name[i];
      }
    }
    printf("%d %d\n", best, ans);
  }
}

Measured memory_bytes: 1192
w, h, n = map(int, input().split())
xya = [[0] * 3 for i in range(n)]
for i in range(n):
    x, y, a = map(int, input().split())
    xya[i][0], xya[i][1], xya[i][2] = x, y, a

area = [[False] * w for i in range(h)]
for i in xya:
    if i[2] == 1:
        for row in range(h):
            for col in range(0, i[0]):
                area[row][col] = True
    elif i[2] == 2:
        for row in range(h):
            for col in range(i[0], w):
                area[row][col] = True
    elif i[2] == 3:
        for row in range(0, i[1]):
            for col in range(w):
                area[row][col] = True
    else:
        for row in range(i[1], h):
            for col in range(w):
                area[row][col] = True

ans = 0
for row in range(h):
    for col in range(w):
        if not area[row][col]:
            ans += 1
print(ans)

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

int a,b,ans=1000000000;

void rec(int x,int y) {
	if(x>a) { 
		ans=min(ans,y);
		return;
	} else {
		rec(x+1,y*2);
		rec(x+1,y+b);
	}
}

int main() {
	cin>>a>>b;
	rec(1,1);
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi matmul(vi dp,vvi mt,int n){
    vi res(n);
    rep(i,n)rep(j,n){
        res[i]+=mt[i][j]*dp[j];
        res[i]%=mod;
    }
    return res;
}
vvi update(vvi mt,int n){
    vvi res(n,vi(n));
    rep(i,n)rep(j,n)rep(k,n){
        res[i][j]+=mt[i][k]*mt[k][j];
        res[i][j]%=mod;
    }
    return res;
}
void matpow(vi &dp,vvi mt,ll k,int n){
    while(k){
        if(k&1)dp=matmul(dp,mt,n);
        mt=update(mt,n);
        k>>=1;
    }
}
int main(){
    ll n,k;cin>>n>>k;
    vvi v(n,vi(n));
    rep(i,n)rep(j,n)cin>>v[i][j];
    vi dp(n,1);
    matpow(dp,v,k,n);
    ll sum=0;
    rep(i,n)sum=(sum+dp[i])%mod;
    out(sum);
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main() {
    std::string S, T;
    std::cin >> S >> T;

    int cnt = 0;
    for (std::size_t i = 0; i < S.size(); ++i) {
        if (S[i] == T[i]) {
            ++cnt;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<int, int, int> tp;
///-------------------------

int main()
{
    Phuong_; /// <3333
    int n;
    cin >> n;
    n%=10;
    if (n==1 || n==0 || n==6 || n==8) cout << "pon"; else
    if (n==3) cout << "bon"; else cout << "hon";
    return 0;
}


Measured memory_bytes: 3608
str = input().split(" ")
n = int(str[0])
l = int(str[1])
aji = []
for i in range(1, n+1):
    aji.append(l+ i-1)
    #print("aji: ", aji)
sa = sum(aji)
mina = 1000
min_index = None
for i in range(0, n):
    tmp = aji.copy()
    tmp.pop(i)
    dif = abs(sa - sum(tmp))
    if mina > dif:
        mina = dif
        min_index = i
        #print('mina: ',mina, "index: ", i)

#aji = sorted(aji)
aji.pop(min_index)
#print(aji)
print(sum(aji))

Measured memory_bytes: 3064
N  = input()
line = raw_input()
cost = line.split(' ')

for i in range(0,N):
	cost[i] = int(cost[i])

dp = [0]*(N)

dp[0] = 0
dp[1] = abs(cost[1] - cost[0])

for n in range(2,N):
	dp[n] = min(abs(cost[n] - cost[n-1]) + dp[n-1], abs(cost[n] - cost[n-2]) + dp[n-2])

print(dp[N-1])

Measured memory_bytes: 12536
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main() {
    char A[100];
    cin>>A;

    string C;

    int B;

    B=strlen(A);

    for(int i=0;i<B;i++){

        C+="x";

    }

    cout<<C<<endl;

}



Measured memory_bytes: 256
"""
B - Toll Gates
"""

n, m, x = map(int, input().split())

value = []
for part in input().split():
    value.append(int(part))

left = 0
right = 0
for i in value:
    if 1 <= i and i < x:
        left += 1
    if x < i and i <= n:
        right += 1

print(min(left, right)) 

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


ll N;
ll D[100010];
ll cnt[100010];
ll key = 0;
int main() {
	cin >> N;
	REP(i, N) {
		cin >> D[i];
		if (i != 0 && D[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
		cnt[D[i]]++;
		key = max(key, D[i]);
	}
	if (cnt[0] != 1) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	for (ll i = 2; i <=key; ++i) {
		if (i != key && cnt[i] == 0)ans = 0;
		else {
			ll x = cnt[i];
			while (x != 0) {
				ans *= cnt[i - 1];
				ans %= 998244353;
				x--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long[] a = new long[n + 1];


        for (int i = 0; i < n + 1; i++) {
            a[i] = sc.nextInt();
        }

        Arrays.sort(a);
//        for(int i = 0;i<n+1;i++){
//            System.out.print(a[i]+" ");
//            if(i == n)
//                System.out.println("");
//        }

        for (int i = n; i > 0; i--) {
            a[i] -= a[i - 1];
        }
//        for(int i = 0;i<n+1;i++){
//            System.out.print(a[i]+" ");
//            if(i == n)
//                System.out.println("");
//        }
        if (a.length > 2) {
            long temp = gcd(a[1], a[2]);
            for (int i = 2; i < n; i++) {
                temp = gcd(temp, a[i + 1]);
            }
            System.out.println(temp);
        } else {
            System.out.println(a[1]);
        }
    }

    static long gcd(long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }
}

Measured memory_bytes: 49672
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i = a; i <= b; ++i)
#define ff(i, a, b) for(ll i = a; i < b; ++i)
#define F(i, a, b) for(ll i = a; i >= b; --i)
#define FF(i, a, b) for(ll i = a; i > b; --i)
#define x first
#define y second
#define X real()
#define Y imag()
using namespace std;
typedef complex<ll> P;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;

string s;
ll l, r;
vector<ll> ans;
vector<ii> arr;

signed main(){
//	freopen("PERFECT1.inp","r",stdin);
//	freopen("PERFECT1.out","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s;
	if(s.back() != '0') cout <<"-1";
	else{
		l = 0; r = s.size()-2;
		while(l <= r){
			if(s[l] != s[r] || (l == 0 && r == s.size()-2 && (s[l] == '0' || s[r] == '0'))){
				cout <<"-1";
				return 0;
			}
			if(s[l] == '1' && s[r] == '1') ans.push_back(l+1);
			l++, r--;
		}
		ll dist, prev = 1, node = 1;
		for(auto i : ans){
			dist = i-prev; prev = i;
			ff(j,0,dist) arr.push_back({node+j, node+dist});
			node += dist;
		}
		arr.push_back({node, node+1});
		node++;
		f(i,node+1,s.size()){
			arr.push_back({node, i});
		}
		for(auto i : arr) cout << i.x <<" "<<i.y<<"\n";
	}
}



Measured memory_bytes: 3648
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);





void solve()
{
    
    string s;
    cin>>s;
    int a=0,b=0;
    rep(i,s.size()){
        if(s[i]=='0') a++;
        else b++;
    }
    cout<<min(a,b)*2<<endl;
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve();
}

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


const int inf = 1e18L;

signed main(){
	int n,w;
	cin>>n>>w;
	vector<pair<int,int>> a(n);
	int s=0;
	for(int i=0;i<n;i++){
		cin>>a[i].first>>a[i].second;
	}

	vector<int> dp(w+1,0);
	// dp[i]-represents the minimum weight using values atleast i
	
	dp[0]=0;
	for(int item=0;item<n;item++){
		for(int weight=w-a[item].first;weight>=0;weight--){
			dp[weight+a[item].first]=max(dp[weight+a[item].first],dp[weight]+a[item].second);
		}
	}

	int ans=0;
	for(int i=0;i<=w;i++){
		if(1){
			ans=max(ans,dp[i]);
		}
	}

	cout<<ans<<endl;

}

Measured memory_bytes: 1024
import math
 
def factorial(n):
    if n == 0:
        return 1.0
    else:
        return n*factorial(n-1)
 
 
n = int(raw_input())
k = n
arr = []
while(k > 0):
    x, y = map(int, raw_input().split())
    arr.append((x, y))
    k -= 1
 
total = 0.0
for i in range(n):
    x1 = arr[i][0]
    x2 = arr[i][1]
    for j in range(i+1, n, 1):
        y1 = arr[j][0]
        y2 = arr[j][1]
        dist = (x1-y1)*(x1-y1) + (x2-y2)*(x2-y2)
        dist = float(math.sqrt(dist))
        dist = dist * float((factorial(n-1)*2))
        total += dist * float(1/factorial(n))
 
print total

Measured memory_bytes: 2696
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

namespace {
#define VERA(i,a,b) for(ll i=(a);i<(b);++i)
#define ANDY(i,a,b) for(ll i=(a);i>(b);--i)
#define SIZE(x) (ll)(x.size())

typedef long long ll;
typedef double dd;

const string TAR = "AKIHABARA";
string str;

void Solve() {
  ll i =0;
  bool res=true;
  for (auto c : TAR) {
    if (i >= SIZE(str) || str[i] != c) {
      if (c != 'A') {
        res = false;
        break;
      }
      continue;
    }
    if (i == SIZE(str)) {
      res=false;
      break;
    }
    ++i;
  }
  if (i != SIZE(str))
    res=false;
  if (res)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

bool Input() {
  if (cin >> str)
    return true;
  return false;
}

}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  while (Input()) {
    Solve();
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int Limit = 21, Sentry = 10;
int main(){
	long work[2*Limit+4*Sentry]={};
	long *list = work+Sentry, *list_tmp = work+Limit+3*Sentry;
	int N,num;
	cin >> N >> num;
	list[num]=1;
	for (int n = 1; n < N - 1; n++) {
		cin >> num;
		for (int i = 0; i < Limit; i++)list_tmp[i] = list[i - num] + list[i + num];
		swap(list_tmp, list);
	}
	cin>>num;
	cout<< list[num]<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    int d[10][10];
    rep(i, 10) {
        rep(j, 10) {
            int tmp;
            cin >> tmp;
            d[i][j] = tmp;
        }
    }
    rep(k, 10) {
        rep(i, 10) {
            rep(j, 10) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    /*
    rep(i, 10) {
        rep(j, 10) {
            cout << d[i][j];
        }
        cout << endl;
    }
    */
    int A[H][W];
    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            cin >> A[i][j];
            if (A[i][j] != -1) {
            ans += d[A[i][j]][1];
    }
        }
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        const int big = 1000000;
        var n = long.Parse(Console.ReadLine());
        decimal count = 0;
        long last = Math.Min(big, n);
        // n / m = n % m = k とすると
        // m = (n - k) / k
        for (long k = 1; k < last; k++)
        {
            var m = (n - k) / k;
            if (m <= 0)
            {
                continue;
            }

            if (n / m == n % m)
            {
                count += m;
            }
        }

        if (last != n)
        {
            for (long m = (n - last) / last; m > 0; m--)
            {
                if (n / m == n % m)
                {
                    count += m;
                }
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 11220
s = input()
n = len(s)
ans = 0
for bit in range(1 << (n - 1)):
    f = s[0]
    for i in range(n - 1):
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]
    ans += sum(map(int, f.split("+")))
print(ans)

Measured memory_bytes: 9104
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;



int main() {
	int N, R;
	cin >> N >> R;
	if (N >= 10) {
		cout << R << endl;
	}
	else {
		cout << R + 100 * (10 - N) << endl;
	}
}


Measured memory_bytes: 256