akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    int count = 0;

    for(int i = 1; i < n + 1; i++){

        if(String.valueOf( i ).length() % 2 == 1){
            count++;
        }
    }

    System.out.println(count);


    
  

    


    


    

    
    
    



    





}
}

Measured memory_bytes: 41460
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  ll N;
  cin >> N;
  vector<ll> a;
  rep(i, N) {
    ll ai;
    cin >> ai;
    a.pb(ai);
  }

  ll changeCount = 0;
  ll sum = 0;
  bool nextSumPositive = true;

  rep(i, N) {
    // DEBUG("---");
    // DEBUG(i);
    // DEBUG(nextSumPositive);
    // DEBUG(a[i]);

    sum += a[i];

    if (nextSumPositive) { // 合計が正である必要がある
      if(sum <= 0) { // だけど合計は負または0
        ll change = - sum + 1;  // sum を正にして + 1を変化させる
        // DEBUG(change);
        changeCount += abs(change); // 変更分をカウント
        sum += change; // 変化を sum に適用
      }
    } else { // 合計が負である必要がある
      if(sum >= 0) {// だけど合計は正または0
      ll change = - sum - 1; // sum を負 にして - 1を変化させる
      // DEBUG(change);
      changeCount += abs(change); // 変更分をカウント
      sum += change; // 変化を sum に適用
      }
    }
    // DEBUG(changeCount);
    // DEBUG(sum);

    nextSumPositive = !nextSumPositive;
  }


  // 最初が正、負で2パターン調べてみる 
  ll firstAns = changeCount;

  changeCount = 0;
  sum = 0;
  nextSumPositive = false;
  rep(i, N) {
    // DEBUG("---");
    // DEBUG(i);
    // DEBUG(nextSumPositive);
    // DEBUG(a[i]);

    sum += a[i];

    if (nextSumPositive) { // 合計が正である必要がある
      if(sum <= 0) { // だけど合計は負または0
        ll change = - sum + 1;  // sum を正にして + 1を変化させる
        // DEBUG(change);
        changeCount += abs(change); // 変更分をカウント
        sum += change; // 変化を sum に適用
      }
    } else { // 合計が負である必要がある
      if(sum >= 0) {// だけど合計は正または0
      ll change = - sum - 1; // sum を負 にして - 1を変化させる
      // DEBUG(change);
      changeCount += abs(change); // 変更分をカウント
      sum += change; // 変化を sum に適用
      }
    }
    // DEBUG(changeCount);
    // DEBUG(sum);

    nextSumPositive = !nextSumPositive;
  }



  cout << min(firstAns, changeCount) << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int n;
P p[100005];
ll a[100005],b[100005],c[100005];

int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&a[i],&b[i]);
        c[i]=a[i]+b[i];
        p[i]=P(c[i],a[i]);
    }
    sort(p,p+n);
    ll ans=0;
    int l=0,r=n;
    int s=0;
    while(l<r){
        //printf("%lld\n",ans);
        if(s==0){
            ll pl=p[r-1].second;
            ans+=pl;
            r--;
        }else{
            ll pl=p[r-1].first-p[r-1].second;
            ans-=pl;
            r--;
        }
        s=1-s;
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if((a+b)%2 != 0){
    cout << (a+b)/2 + 1 << endl;
  }
  else{
    cout << (a+b)/2 << endl;
  }
}

Measured memory_bytes: 3544
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
W = LIST()

ans = 1000
for i in range(N):
	W1 = W[0:i]
	W2 = W[i:]
	ans = min(ans, abs(sum(W1)-sum(W2)))
print(ans)

Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    int ans = inf;
    rep(bit, 0, 1 << n) {
        // bit=上げるビルの番号
        int sum = 0;
        int mx = a[0], cnt = 1;
        rep(i, 1, n) {
            if (mx < a[i]) {
                mx = a[i];
                cnt++;
            } else if (bit & 1 << i) {
                sum += ++mx - a[i];
                cnt++;
            }
        }
        if (cnt == k) ans = min(ans, sum);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3632
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, M] = string_to_int(inputs[0])
    if N == 1 and M == 1:
        return 1
    if N == 1 or M == 1:
        return (N * M) - 2
    # if N == 2 and M == 2:
    #     return 0
    if N == 2 or M == 2:
        return 0

    return (N*M) - (N * 2 + M * 2 - 4)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3812
n, k = map(int, input().split())
n_list = [0] * n
for i in range(k):
  _ = int(input())
  d = list(map(int, input().split()))
  for _ in d:
    n_list[_-1] += 1
result = 0
for _ in n_list:
  if _ == 0:
    result += 1
print(result)

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

typedef long long ll;

const int N = 105;
int a[N];

ll sum(string s)
{
    ll sum = 0, temp = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == '+')
        {
            sum += temp;
            temp = 0;
        }
        else
            temp = temp * 10 + s[i] - '0';
    }
    return sum + temp;
}

int main()
{
    string s;
    cin >> s;

    ll res = 0;

    while(1)
    {
        string temp;

        for(int i = 0; i < s.size() - 1; i++)
        {
            a[i + 1] += a[i] / 2;
            a[i] %= 2;
        }

        if(a[s.size() - 1])
            break;

        for(int i = 0; i < s.size() - 1; i++)
        {
            temp += s[i];

            if(a[i])
                temp += "+";
        }

        temp += s[s.size() - 1];

        res += sum(temp);
        a[0]++;
    }

    cout << res << '\n';

    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int w,h,n;
    cin >> w >> h >> n;
    int x[n],y[n],a[n];
    int X=0,Y=0;
    rep(i,n){
        cin >> x[i] >> y[i] >> a[i];
    }

    rep(i,n){
        if(a[i]==1){
            X=max(X,x[i]);
        }
        if(a[i]==2){
            w=min(w,x[i]);
        }
        if(a[i]==3){
            Y=max(Y,y[i]);
        }
        if(a[i]==4){
            h=min(h,y[i]);
        }
    }

    if(w-X>0&&h-Y>0){
        cout << (w-X)*(h-Y) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  if(a+b-1>n || a*b<n){ cout << -1 << endl; return 0; }

  vector<int> lisdl;
  rep(i,b){
    int d = 1;
    if(a>1){
      if(i<(n-b)/(a-1)) d=a;
      if(i==(n-b)/(a-1)) d=1+(n-b)%(a-1);
    }
    int st = n+1-lisdl.size()-d;
    rep(j,d) lisdl.emplace_back(st+j);
  }

  for(auto ans:lisdl){
    cout << ans << " ";
  }
  cout << endl;

  return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int sum = a1 + a2 + a3;
    if(sum >= 22){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;

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

    if (N >= 10) cout << R << endl;
    else cout << R + 100 * (10 - N) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef int ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i <= b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 2e5 + 1, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, m, i, j, ans;
long long k, a[MAXN], b[MAXN];

//<<-----Implement Functions Here---->>//
inline void solve()
{
	in(n >> m >> k)
	FOR(i, 1, n)
	{
		in(a[i])
		a[i] += a[i-1];
	}
	FOR(i, 1, m)
	{
		in(b[i])
		b[i] += b[i-1];
	}
	i = 0, j = m;
	while (i <= n && a[i] <= k)
	{
		while (b[j] > k - a[i])
			--j;
		ans = max(ans, i + j), ++i;
	}
	out(ans)
}

//<<----------Start of Main---------->>//
int main()
{
	fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 6748
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		int y = scan.nextInt();
		
		int b = (y - 2*x) / 2;
		int a = x - b;
		
		if((a+b) == x && (2*a + 4*b) == y && x != 0 && y != 0 && a >= 0 && b >= 0) {
			System.out.print("Yes");
		}
		else {
			System.out.print("No");
		}
		
	}

}


Measured memory_bytes: 35760
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

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

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

int main() {
    int x, y;
    cin >> x >> y;
    cout << x + y/2 << "\n";
    return 0;
}


Measured memory_bytes: 764
from collections import Counter

N = int(input())
a = list(map(int,input().split()))

d = Counter(a)
l = []
flag = False
for k,v in list(sorted(d.items()))[::-1]:
  if v >= 4:
    l.append(k)
    l.append(k)
  elif v >= 2:
    l.append(k)
  if len(l) >= 2:
    flag = True
    break

ans = 0
if flag:
  ans = l[0]*l[1]


print(ans)

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

struct Dice {
  int s1, s2, s3, s4, s5, s6;
  void turnN() {
    int tmp = s1;
    s1 = s2; s2 = s6; s6 = s5; s5 = tmp;
  }
  void turnS() {
    int tmp = s1;
    s1 = s5; s5 = s6; s6 = s2; s2 = tmp;
  }
  void turnW() {
    int tmp = s1;
    s1 = s3; s3 = s6; s6 = s4; s4 = tmp;
  }
  void turnE() {
    int tmp = s1;
    s1 = s4; s4 = s6; s6 = s3; s3 = tmp;
  }
};

int main() {
  
  int S1, S2, S3, S4, S5, S6, q;
  
  cin >> S1 >> S2 >> S3 >> S4 >> S5 >> S6 >> q;
  
  Dice d = {S1, S2, S3, S4, S5, S6};
  
  for (int i = 0; i < q; i++) {
    
    int top, front; cin >> top >> front;
    
    while (true) {
      
      int r = rand();
      
      if (r % 4 == 0) d.turnN();
      if (r % 4 == 1) d.turnS();
      if (r % 4 == 2) d.turnW();
      if (r % 4 == 3) d.turnE();
      
      if (d.s1 == top && d.s2 == front) {
        cout << d.s3 << endl;
        break;
      }
      
    }
    
  }
  
}


Measured memory_bytes: 3092
#include <iostream> 
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main() {
	vector<int> N(4);
	int N1, N2, N3, N4;
	cin >> N1 >> N2 >> N3 >> N4;
	N[0] = N1; N[1] = N2; N[2] = N3; N[3] = N4;
 	sort(N.begin(), N.end());
	if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

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

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	int n; cin >> n;
	vector<int> v(n), c(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int maxx = v[0];
	int cnt = 1;
	for (int i = 1; i < n; i++) {
		if (v[i] >= maxx) {
			cnt++;
			maxx = max(maxx, v[i]);
		}
	}
	cout << cnt;
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

class C
{
	static long[] Read() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    static void Main()
    {
        long[] n = Read(), a = Read(), b = Read(), c = new long[n[0] + 1], d = new long[n[1] + 1];
        long s = 0, j = n[1];
        for (int i = 1; i <= n[0]; i++) c[i] = c[i - 1] + a[i - 1];
        for (int i = 1; i <= n[1]; i++) d[i] = d[i - 1] + b[i - 1];
        for (int i = 0; i <= n[0]; i++)
        {
            if (c[i] > n[2]) break;
			while (d[j] > n[2] - c[i]) j--;
            s = Math.Max(s, i + j);
        }
        Console.WriteLine(s);
    }
}


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

int n, m, sum, t;

int main() {
	cin >> n >> m;
	while (m--) {
		cin >> t;
		sum += t;
	}
	if (sum > n)
		printf("-1");
	else
		printf("%d", n - sum);
	return 0;
}

Measured memory_bytes: 3760
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



int main() {
	
	int n;
	cin >> n;
	vector<int> c(n), s(n), f(n);
	for(int i = 1; i < n; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	ll ans = 0;
	bool is_last = false;
	for (int i = 1; i < n; ++i) {
		int t = 0;
		//if (i + 1 == n) ans += c[i];
		for (int j = i; j < n; j++) {
			int k = max(0.0, ceil((double)(t - s[j]) / f[j]));
			t = s[j] + k * f[j];
			t += c[j];
		}
		cout << t << endl;
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
s = input().split('T')
s = [len(_s) for _s in s]
x, y = map(int, input().split())
dx = s[::2]
dy = [0]+s[1::2]

def check(dz, z, base=8001, first_fixed=True):
  a = dz[0]
  if first_fixed:
    state = 1 << base + a
  else:
    state = 1 << (base + a) | 1 << (base - a) 
  for a in dz[1:]:
    state = (state<<a | state>>a)
  return (state>>(base+z)) & 1

if check(dx, x) and check(dy, y, first_fixed=False):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3188
using System;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            if (a[0] < 6)
            {
                Console.WriteLine(0);
                return;
            }
            if (a[0] < 13)
            {
                Console.WriteLine(a[1] / 2);
                return;
            }
            Console.WriteLine(a[1]);

        }
    }
}


Measured memory_bytes: 13396
import java.util.*;
import java.util.Scanner;
class Main{
    public static void main(String[] args)
    {
        int contestNumberOfTimes;
        int rating;
        int ratingResult;
        
        Main main = new Main();
        Scanner scanner = new Scanner(System.in);
        contestNumberOfTimes = scanner.nextInt();
        rating = scanner.nextInt();
        ratingResult = rating + main.Calculation(contestNumberOfTimes);

        System.out.println(ratingResult);
    }
    public int Calculation(int contentsNumber){
        int result;
        if(contentsNumber < 10){
            result = 100 * (10 - contentsNumber);
        }else{
            result = 0;
        }
        return result;
    }
}

Measured memory_bytes: 21844
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int x, y, s;
	while(1){
		int ans = 0;
		cin >> x >> y >> s;
		if (x == 0 && y == 0 && s == 0) break;
		int price = (100.0 * s) / (100 + x) + 0.5;
		REP(i, 1, price + 1){
			REP(j, 1, price + 1){
				int a_sx = (100.0 + x) * i / 100.0;
				int b_sx = (100.0 + x) * j / 100.0;
				if(a_sx + b_sx == s){
					int a_sy = (100.0 + y) * i / 100.0;
					int b_sy = (100.0 + y) * j / 100.0;
					ans = max(a_sy + b_sy, ans);
				}				
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
 int N,A = 0;
 cin >> N;
 for(int i=1; i<=N; i++){
   if (i>0 && i<10 ){
     A++;
   }
   else if (i>99 && i<1000){
     A++;
   }
   else if (i>9999 && i<100000){
     A++;
   }
 }
   cout << A << endl;
}


Measured memory_bytes: 3604
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC160D
int main(void) {
  int n, x, y, k, i, cou=0, tmp;
  scanf("%d %d %d", &n, &x, &y);
  int len[n];
  for(i=0; i<n; i++)
    len[i]=0;

  for(k=1; k<n; k++){
    for(i=0; i<k; i++){
      tmp=k-i<abs(x-1-i)+1+abs(y-1-k) ? k-i : abs(x-1-i)+1+abs(y-1-k);
      //printf("k=%d i=%d tmp=%d\n", k, i, tmp);
      len[tmp]++;
    }
  }
  for(k=1; k<n; k++)
    printf("%d\n", len[k]);
}

Measured memory_bytes: 128
//AtCoder ABC052 B - Sum of Three Integers
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
    int K,S;
    cin>>K>>S;
    int ans=0;
    for(int x=0;x<=K;++x){
        for(int y=0;y<=K;++y){
            int z=S-x-y;
            if(z>=0&&z<=K) ++ans;
			// for(int z = 0; z <= K; ++z) {
            //     if(x+y+z==S)++ans;
			// }
		}
	}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*---------------------------------------------*/
/*
    ABC174 C
 */
/*---------------------------------------------*/

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

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;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

int main() {
    int64_t n;
    cin >> n;
    if ( n%2 != 0 ) {
        int64_t L;
        if ( n%7 == 0 ) {
            L = 9*n/7;
        } else {
            L = 9*n;
        }

        int64_t num = 10;
        rep2(i, L) {
            if ( num%L == 1 ) {
                cout << i << endl;
                return 0;
            }
            num = (num%L)*10;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

ll GetDigit(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    //cout << digit << endl;
    return digit;
}

int main()
{
    ll n, ans = 0;
    cin >> n;
    if (n %2) {
        cout << 0 << endl;
        return 0;
    }
    n /= 2;
    while (n) {
        ans += n/5;
        n /= 5;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<cstring>
#include<stack>
#include<deque>
using namespace std;

int main(){

    char str[20000] = {'0'};
    scanf("%s", str);

    int time = 0;
    stack<int> depth, depth2;
    stack<int> Lake;
    deque<int> Lake2;

    int lake_menseki = 0;

    int counter = 0;
    int sum = 0;

    for(int i=20000-1; i>=0; i--){
        time++;
        if(str[i]=='0') continue;

        if(i==0){
            if(str[0]=='\\'){
            if(!depth.empty()){
            int tmp = depth.top();
            lake_menseki += time - tmp; 
            sum += time - tmp;
            depth.pop();
            if(depth.empty()){
                Lake.push(lake_menseki);
                counter++;
                }
            }
            }
            if(!depth.empty()){

                int height = 0;
                int height_max = 0;
                int time2 = 0;
                int lake_menseki2 = 0;

                for(int i=0; i<strlen(str); i++){   //頂上を調べる
                    if(str[i]=='\\') height--;
                    else if(str[i]=='/') height++;

                    if(height > height_max) height_max = height;
                }

                height = 0;
                for(int j=0; j<strlen(str); j++){
                    if(height == height_max) break;
                    time2++;
                    if(str[j]=='\\'){
                        height--;
                        depth2.push(time2);
                    }
                    else if(str[j]=='/'){ 
                        height++;
                        if(!depth2.empty()){
                            int tmp = depth2.top();
                            lake_menseki2 += time2 - tmp; 
                            depth2.pop();
                            if(depth2.empty()){
                                Lake2.push_back(lake_menseki2);
                                counter++;
                                lake_menseki2=0;
                            }
                        }
                    }else if(str[j]=='_'){
                        continue;
                    }
                }

            }
        }else{

        if(str[i]=='/'){
            depth.push(time);
        }else if(str[i]=='\\'){
            if(!depth.empty()){
            int tmp = depth.top();
            lake_menseki += time - tmp; 
            sum += time - tmp;
            depth.pop();
            if(depth.empty()){
                Lake.push(lake_menseki);
                counter++;
                lake_menseki=0;
            }
            }
        }else if(str[i]=='_'){
            continue;
        }
        }
    
    }

    printf("%d\n", sum);
    printf("%d", counter);
    while(!Lake2.empty()){
        printf(" ");
        printf("%d", Lake2.front());
        Lake2.pop_front();
    }
    while(!Lake.empty()){
        printf(" ");
        printf("%d", Lake.top());
        Lake.pop();
    }
    printf("\n");

    return 0;
}


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

int main() {
  vector<int> time(5);
  for(int i = 0; i < 5; i++) {
    cin >> time.at(i);
  }
  int ans = 1000;
  for(int i = 0; i < 5; i++) {
    int total = 0;
    total += time.at(i);
    for(int j = 0; j < 5; j++) {
      if(j == i) {
        continue;
      }
      total += ((time.at(j) - 1) / 10) * 10 + 10;
    }
    if(total < ans) {
      ans = total;
    }
  }
  cout << ans << endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w;
	cin >>h >>w;
	
	vector<string> ba(h, string(w, ' '));
	vector<VI> dp(h, VI(w));
	auto usd = dp;
	rep(i,h) rep(j,w) cin >>ba[i][j];
	
	dp[0][0] =1;
	queue<pii> q;
	q.emplace(0,0);
	
	while(!q.empty()){
		auto v = q.front(); q.pop();
		int cy=v.first, cx=v.second;
		rep(j, 2){
			int ny = cy +(j==0), nx = cx +(j==1);
			if(ny >=h || nx >=w || ba[ny][nx] !='.') continue;
			if(usd[ny][nx] >>j & 1) continue;
			(dp[ny][nx] += dp[cy][cx]) %=mod;
			q.emplace(ny, nx);
			usd[ny][nx] = 1<<j;
			//dbg(j,cy,cx,ny,nx, ba[ny][nx],dp[cy][cx]);
		}
	}
	
	cout << dp[h-1][w-1] <<"\n";
	//for(auto xl: dp){for(auto x :xl) printf("%d ",x); puts("");}

	return 0;
}



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

int main() {
  int A,B,C,X;
  cin>>A>>B>>C>>X;
  int count=0;
  for(int i=0;i<A+1;i++){
    for(int j=0;j<B+1;j++){
      for(int k=0;k<C+1;k++){
        int total=500*i+100*j+50*k;
        if(total==X){
          count++;
        }
      }
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.*;

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

    int n = sc.nextInt();
    int m = sc.nextInt();
    int l = sc.nextInt();

    long[][] a = new long[n][m];
    long[][] b = new long[m][l];
    long[][] ans = new long[n][l];

    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
        a[i][j] = sc.nextLong();
      }
    }

    for(int i = 0; i < m; i++){
      for(int j = 0; j < l; j++){
        b[i][j] = sc.nextLong();
      }
    }

    for(int i = 0; i < n; i++){
      for(int j = 0; j < l; j++){
        for(int k = 0; k < m; k++){
          ans[i][j] += a[i][k] * b[k][j];
        }
      }
    }

    for(int i = 0; i < n; i++){
      for(int j = 0; j < l; j++){
        System.out.print(ans[i][j]);
        if(j != l - 1){
          System.out.print(" ");
        }
      }
      System.out.println();
    }
  }
}



Measured memory_bytes: 53884
#import <stdio.h>
#import <limits.h>
#define ABS(a) ((a)>0?(a):(-(a)))
#define MIN(a,b) ((a)<(b)?(a):(b))
typedef long long INT;
int main(){
    INT N;
    INT S[200002] = {0};
    scanf("%lld",&N);
    for(INT i=0;i<N;i++){
        INT a;
        scanf("%lld",&a);
        S[i] = a + ((i==0) ? 0 : S[i-1]);
    }
    INT min = LLONG_MAX;
    for(INT i=0;i<N-1;i++) {
        min = MIN(min, ABS(S[i] * 2 - S[N-1]));
    }
    printf("%lld", min);
}


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

using namespace std;

const int TMAX = 1e5+1;

int main(){
    int N,C; cin >> N >> C;
    vector<vector<int> > TV(C, vector<int>(TMAX*2,0));

    for(int i=0;i<N;i++){
        int s,t,c;
        cin >> s >> t >> c;
        c--;
        TV[c][2*s-1]++;
        TV[c][2*t+1]--;
    }

    for(int c=0;c<C;c++){
        for(int t=1;t<2*TMAX;t++){
            TV[c][t] += TV[c][t-1];
        }
    }
    int ans = 0;

    for(int t=0;t<2*TMAX;t++){
        int cnt = 0;
        for(int c=0;c<C;c++){
            if(TV[c][t] >= 1){
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 24576
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int answer = 0;
    
    if (a == b) {
        answer = a + b;
    } else if (a > b) {
        answer = a + a - 1;
    } else if (a < b) {
        answer = b + b - 1;
    }
    
    System.out.println(answer);
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,l;
string s[125];

int main(){

scanf("%d%d",&n,&l);
REP(i,n){
  char _s[125];
  scanf("%s", _s);
  s[i] = string(_s);
}
sort(s,s+n);
REP(i,n)printf("%s",s[i].c_str());
printf("\n");

  return 0;
}


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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n, m, k;
  cin >> n >> m >> k;
  vl a(n), b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  
  //ーーーー累積和ーーーー//
  
  vl A(n), B(m);
  A[0] = a[0], B[0] = b[0];
  ll ans = 0;
  rep(i,n-1) A[i+1] = A[i] + a[i+1];
  rep(i,m-1) B[i+1] = B[i] + b[i+1];
  
  rep(i,m) if (B[i] <= k) ans = max(ans,i+1);
  
  //ーーーー二分探索ーーーー//
  
  rep(i,n) {
    ll key = k - A[i];
    ll l = -1, r = m;
    if (key < 0) continue;
    if (key < A[0]) {
      ans = max(ans,i+1);
      continue;
    }
    
    ll it = upper_bound(B.begin(), B.end(), key) - B.begin();
    ans = max(i+1+it,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9544
N = int(input())

def dfs(n):
    if N < int(n):
        return 0

    ansB = True
    for i in '753':
        if n.count(i) == 0:
            ansB = False
            break
    ans = 0
    if ansB:
        ans = 1

    for i in '753':
        ans += dfs(n + i)
    return ans

print(dfs('0'))

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

int main(){
    int n, m;
    cin >> n >> m;
    int a[n][m] = {};
    int b[m] = {};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < m; i++) cin >> b[i];

    int c[n] = {};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            c[i] += a[i][j] * b[j];
        }
    }

    for(int i = 0; i < n; i++){
        cout << c[i] << endl;
    }

    return 0;
}



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

void apply(int *a, int *b)
{
	(*a)++;
	(*b)--;
}

bool solve(int *X, int *Y)
{
	if (!(*X) && !(*Y))
		return (false);
	if ((*X) > (*Y)) apply(Y, X);
	else apply(X, Y);
	return (true);
}

void apply2(int *a, int *b, string s, int index)
{
	(*a)++;
	(*b)--;
	cout << s[index] << endl;
}

bool solve2(int *X, int *Y, string s)
{
	if (!(*X) && !(*Y))
		return (false);
	if ((*X) > (*Y)) apply2(Y, X, s, 1);
	else apply2(X, Y, s, 0);
	return (true);
}

int	main(void)
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vector<string> s(n + 1);
	int A, B, C;
	A = a;
	B = b;
	C = c;
	for (int i = 0; i < n; i++) cin >> s[i];
	s[n] = "ZZ";
	bool flag;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == "AB" && s[i + 1] == "BC") flag = solve(&B, &A);
		else if (s[i] == "AB") flag = solve(&A, &B);
		else if (s[i] == "BC" && s[i + 1] == "AC") flag = solve(&C, &B);
		else if (s[i] == "BC") flag = solve(&B, &C);
		else if (s[i] == "AC" && s[i + 1] == "AB") flag = solve(&A, &C);
		else flag = solve(&C, &A);
		if (flag == false)
		{
			cout << "No" << endl;
			return (0);
		}
	}
	cout << "Yes" << endl;
	A = a;
	B = b;
	C = c;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == "AB" && s[i + 1] == "BC") solve2(&B, &A, "BA");
		else if (s[i] == "AB") solve2(&A, &B, "AB");
		else if (s[i] == "BC" && s[i + 1] == "AC") solve2(&C, &B, "CB");
		else if (s[i] == "BC") flag = solve2(&B, &C, "BC");
		else if (s[i] == "AC" && s[i + 1] == "AB") solve2(&A, &C, "AC");
		else solve2(&C, &A, "CA");
	}
	return (0);
}


Measured memory_bytes: 6424
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s, ans = "";
	cin >> s;
	for (int i = 0; i < s.size(); i ++) 
		if (s[i] == 'B') {
			if (ans.size() > 0) ans.erase(ans.size() - 1, 1);
		}
		else ans = ans + s[i];
	cout << ans << endl;
	return 0;
}


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

int main(){
  	int N;
  	cin >> N;
  	vector<int> l(N);
  	int sum = 0;
  	for(int i=0; i<N; i++){
    	cin >> l[i];
      	sum += l[i];
    }
  	string ans = "Yes";
  	for(int i=0; i<N; i++){
    	if(l[i] >= sum - l[i]){
        	ans = "No";
        }
    }
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k, n;
    cin >> n >> k;
    if(k!=1)
        cout << (n-k);
    else
        cout << 0;

    return 0;
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    loop {
        let nu = read::<u32>();
        if nu == 0 {
            break;
        }

        let n = nu as f64;
        let v = read_vec::<u32>();
        let ave = v.iter().sum::<u32>() as f64 / n;
        let sd = v.into_iter().map(|x| (x as f64 - ave).powi(2)).sum::<f64>() / n;
        println!("{}", sd.sqrt());
    }
}



Measured memory_bytes: 5060
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    x=[0]*N
    y=[0]*N
    h=[0]*N
    for i in range(N):
        a,b,c=map(int,readline().split())
        x[i]=a
        y[i]=b
        h[i]=c

    ok=False
    for Cx in range(101):
        for Cy in range(101):
            for i in range(N):
                if h[i]==0:
                    continue
                else:
                    H=h[i]+abs(x[i]-Cx)+abs(y[i]-Cy)
                    break
            for i in range(N):
                if h[i]!=max(H-abs(x[i]-Cx)-abs(y[i]-Cy),0):
                    break
            else:
                ok=True

            if ok: break
        if ok: break
    
    print(Cx,Cy,H)

if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int n,k;
vector<int> a;

int cut_sum(double l) {
    int ans = 0;
    rep(i,n) {
        ans += (int)(a[i]/l);
   }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> k;
    a.resize(n);
    rep(i,n) cin >> a[i];
    double l_left = 0;
    double l_right = 1e9;
    double l = (l_left+l_right)/2;
    while(true) {
        if(cut_sum(l) <= k) {
            l_right = l;
            l = (l_left+l_right)/2;
        } else {
            l_left = l;
            l = (l_left+l_right)/2;  
        }
        //if((int)l_right == (int)l_left) break;
        if(l_right - l_left <= 1e-6) {
            l = l_left;
            break;
        }
    }
    cout << int(ceil(l)) << endl;
}

Measured memory_bytes: 3900
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const ll maxn = 2e5 + 111;
const ll mod=1e9+7;
ll a[maxn];
ll pre[maxn];
int main() {
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;++i){
        scanf("%lld",a+i);
        pre[i]=(pre[i-1]+a[i])%mod;
    }
    for(int i=2;i<=n;++i){
        ans=(ans+pre[i-1]*a[i])%mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int Ans=0;
  int x=0;
  for(int i=0; i<N; i++){
    if(S.at(i)=='I'){
      x++;
      Ans=max(Ans, x);
    }
    else{
      x--;
    }
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
m = sorted(l)
max = m[-1][0]
sub_max = m[-2][0]
for i in range(n):
    if l[i][0] == max:
        print(sub_max)
    else:
        print(max)

Measured memory_bytes: 48636
N,M,X,Y = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
x = max(X,max(A))
y = min(Y,min(B))
 
if Y >= x and y > X and y > x:
  print('No War')
else:
  print('War')

Measured memory_bytes: 3060
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<set>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 100000000000000003;
int ne[200001], he[100001];
char C[1200100];

ll num[524300];
int kazu[524300];
const int ma = (1 << 19) - 1;
int query(ll n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return kazu[n2];
		n2 = n2 * 61 % 524287;
	}
	return 0;
}
void add(ll n, int b) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) {
			kazu[n2] |= b;
			return;
		}
		n2 = n2 * 61 % 524287;
	}
	num[n2] = n + 1;
	kazu[n2] = b;
}

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


	fread(C, 1, 1200100, stdin);
	char* ci = C, c;
	int N = 0;
	while ((c = *ci++) >= '0') N = N * 10 + c - '0';
	set<pair<int, char*>> ST;
	char* s[200001];
	rep1(i, N) {
		s[i] = ci;
		while (*ci++ >= '0');
		int n = ci - s[i] - 1;	
		if (n <= 100000) {
			ne[i] = he[n];
			he[n] = i;
		}
		else {
			ST.insert(mp(n, s[i]));
		}
	}

	ll kotae = 0;

	for (int M = 1; M <= 100000; M++) {
		for (int p = he[M]; p; p = ne[p]) {
			auto S = s[p];
			int k[26] = {};
			ll are = 0;
			for (int i = M - 1; i >= 1; i--) {
				int tmp = query(are);
				rep(j, 26) if ((tmp >> j & 1)) {
					k[j]++;
				}
				kotae += k[S[i] - 'a'];
				k[S[i] - 'a'] = 0;
				are = (are * 30 + S[i] - 'a' + 1) % mod;
			}

			kotae += k[S[0] - 'a'];
			k[S[0] - 'a'] = 0;

			add(are, 1 << (S[0] - 'a'));
		}
	}
	for (auto p : ST) {
		auto S = p.second;
		int k[26] = {};
		ll are = 0;
		for (int i = p.first - 1; i >= 1; i--) {
			int tmp = query(are);
			rep(j, 26) if ((tmp >> j & 1)) {
				k[j]++;
			}
			kotae += k[S[i] - 'a'];
			k[S[i] - 'a'] = 0;
			are = (are * 30 + S[i] - 'a' + 1) % mod;
		}

		kotae += k[S[0] - 'a'];
		k[S[0] - 'a'] = 0;

		add(are, 1 << (S[0] - 'a'));
	}
	printf("%lld\n", kotae);


	Would you please return 0;
}

Measured memory_bytes: 12560