akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  reverse(begin(s), end(s));
  int t = 0;
  lint res = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'A') {
      if (t & 1) {
        t = 0;
      } else {
        res += t / 2;
      }
    } else if (s[i] == 'B') {
      if (t & 1) {
        ++t;
      } else {
        t = 0;
      }
    } else {
      if (t & 1) {
        t = 1;
      } else {
        ++t;
      }
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 720
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <math.h>
using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << " " << 2 * (a + b) << endl;

    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#define INF 1<<27
using namespace std;
int main(){
  int n;
  while(cin >> n,n) {
    int sum[5000] = {0},a[5000];
    for(int i = 0 ; i < n ; i++ ) {
      cin >> a[i];
      if(i == 0) sum[i] += a[i];
      else  sum[i] += a[i] + sum[i-1];

    }
    int mx = sum[0];
    for(int i = 0 ; i < n-1 ; i++ ){
      for(int j = i+1 ; j < n ; j++ ){
	mx = max(mx,max(sum[j] - sum[i],sum[j]));
      }
    }
    cout << mx << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String w = sc.next();
    char s = w.charAt(0);
    if(s=='a' || s=='i' || s=='u' || s=='e' || s=='o'){
    System.out.println("vowel");
    }else{
    System.out.println("consonant");
    }
  }
}

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

typedef pair<int, int> p;
typedef long long ll;

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  int n, m;
  ll k;
  cin >> n >> m >> k;
  vector<ll> a(n);
  vector<ll> b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  vector<ll> ra(n + 1);
  vector<ll> rb(m + 1);
  ll cnt = 0;
  for (int i = 1; i < n + 1; i++) ra[i] = ra[i - 1] + a[i - 1];
  for (int i = 1; i < m + 1; i++) rb[i] = rb[i - 1] + b[i - 1];
  /*rep(i, n + 1) cout << ra[i] << ' ';
  cout << endl;
  rep(i, m + 1) cout << rb[i] << ' ';
  cout << endl;*/
  for (int i = 0; i <= n; i++) {
    ll d = k - ra[i];
    if (d < 0) continue;
    ll l = 0;
    ll r = m + 1;
    // cout << i << endl;
    //cout << d << endl;
    while (r - l > 1) {
      ll m = (r + l) / 2;
      if (rb[m] > d)
        r = m;
      else
        l = m;
    }
    //cout << l << endl;
    if (cnt < l + i) cnt = l + i;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 9600
N = int(input()) 
P = [list(map(int, input().split())) for i in range(N)] 
P.insert(0,[0,0,0])

ans = "Yes"
for i in range(N):
	norm = abs(P[i+1][1]-P[i][1])+abs(P[i+1][2]-P[i][2])
	move = (P[i+1][0]-P[i][0]) - norm
	if ((move%2 != 0) or (move < 0)):
		ans = "No"
		break
	
print(ans)

Measured memory_bytes: 27380
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

q = int(input())
n = 100000
ass = primes(n)
lkn = []
for p in ass:
    l = (p + 1) // 2
    if l in ass:
        lkn.append(p)
cnt = 0
pre = 1
ans = {}
lkn.append(100001)
for p in lkn:
    for i in range(pre,p,2):
        ans[i] = cnt
    cnt += 1
    pre = p
for i in range(q):
    l,r = map(int,input().split())
    l = max(l-2,1)
    print(ans[r] - ans[l])
    #print(ans[r],ans[l])
#print(lkn)

Measured memory_bytes: 10428
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
  int t[2];
  cin >> t[0] >> t[1];
  ll a[2], b[2];
  cin >> a[0] >> a[1];
  cin >> b[0] >> b[1];

  if(a[0] < b[0]) {
    swap(a[0], b[0]);
    swap(a[1], b[1]);
  }

  ll c[2] = {a[0] - b[0], a[1] - b[1]};
  ll d[2] = {c[0] * t[0], c[1] * t[1]};
  if(0 < d[0] + d[1]) {
    cout << 0 << endl;
    return 0;
  }
  if(d[0] == -d[1]) {
    cout << "infinity" << endl;
    return 0;
  }

  ll dx = -d[1] - d[0];
  ll ans = 1;
  ans += 2 * (d[0] / dx);
  if(d[0] % dx == 0) ans--;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, m, c = input_a
b = input_a
cnt = 0

n.times do |i|
  a = input_a
  sum = 0
  a.each_with_index do |num, j|
    sum += num * b[j]
  end
  sum += c
  cnt += 1 if sum > 0
end
puts cnt


Measured memory_bytes: 1788
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		System.out.println(IntStream.range(1, n + 1).filter(x -> Integer.toString(x).length() % 2 == 1).count());;
	}
}


Measured memory_bytes: 29140
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


const int MAX_S = 210000;
const int INF = 1<<30;
static const int LOG_MAX_S = 21;
static int SP_st[LOG_MAX_S][MAX_S];
static int SP_ln[MAX_S];
struct SparseTable {
    void init(const vector<int> &vec) {
        for (int i = 0; i < MAX_S; ++i) {
            SP_st[0][i] = INF;
            int ti = i, tln = 0;
            while (ti > 0) ti /= 2, ++tln;
            SP_ln[i] = tln - 1;
        }
        for (int i = 0; i < vec.size(); ++i) SP_st[0][i] = vec[i];
        for (int i = 1; i < LOG_MAX_S; ++i) {
		    for (int j = 0; j + (1<<(i-1)) < MAX_S; ++j) {
                SP_st[i][j] = min(SP_st[i-1][j], SP_st[i-1][j + (1<<(i-1))]);
            }
        }
    }
    
    // [a, b)
    int get(int a, int b) {
        if (a >= b) return INF;
        int bet = b - a, row = SP_ln[bet];
        return min(SP_st[row][a], SP_st[row][b - (1<<row)]);
    }
    
} st;



int N, T;
int main() {
  while (cin >> N >> T) {
	vector<int> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];
	st.init(A);

	int con = 0;
	int maxdif = -1;
	for (int i = 1; i < N; ++i) {
	  int right = A[i];
	  int left = st.get(0, i);
	  if (chmax(maxdif, right - left)) {
		con = 1;
	  }
	  else if (maxdif == right - left) {
		++con;
	  }
	  //cout << i << ": " << maxdif << ", " << con << endl;
	}

	cout << con << endl;
  }
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int id[N], a[N], L[N], R[N], len[N];
bool vis[N];
int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  long long ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    id[a[i]] = i;
  }
  for (int i = 1; i < n; i++) {
    int idx = id[i];
    L[idx] = R[idx] = idx;
    vis[idx] = 1;
    if (idx > 1 && vis[idx-1]) {
      L[idx] = L[idx-1];
    }
    if (idx < n && vis[idx+1]) {
      R[idx] = R[idx+1];
    }
    R[L[idx]] = R[idx];
    L[R[idx]] = L[idx];
    len[L[idx]] = len[R[idx]] = R[idx] - L[idx] + 1;
    if (L[idx] > 1) {
      int cnt = 1;
      if (L[idx] - 2 >= 1 && vis[L[idx]-2]) cnt += len[L[idx]-2];
      ans += 1LL * i * cnt * (R[idx] - idx + 1);
    }
    if (R[idx] < n) {
      int cnt = 1;
      if (R[idx] + 2 <= n && vis[R[idx]+2]) cnt += len[R[idx]+2];
      ans += 1LL * i * cnt * (idx - L[idx] + 1);
    }
  }
  cout << ans;
}


Measured memory_bytes: 2304
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

c = Counter(s).most_common()
d = Counter(t)

p = -1000

for k, v in c:
    p = max(p, v - d[k])

print(max(p, 0))

Measured memory_bytes: 9408
#include<stdio.h>
int main(void)
{
	int i,j,n,d[101],flg[101],a;
	scanf("%d",&n);
	a=n;
	for(i=0;i<n;i++){
		scanf("%d",&d[i]);
		flg[i]=0;
	}
	for(i=0;i<n-1;i++){
		if(flg[i]==0){
			for(j=i+1;j<n;j++){
				if(d[i]==d[j]){
					flg[j]=1; a--;
				}
			}
		}
	}
	//for(i=0;i<n;i++) printf("flg[%d]=%d
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
int vac,jap,math,jap_cap,math_cap,jpc,mtc;
cin>>vac>>jap>>math>>jap_cap>>math_cap;
jpc=jap/jap_cap;
mtc=math/math_cap;
if(jap%jap_cap!=0)jpc++;
if(math%math_cap!=0)mtc++;
if(jpc>=mtc)cout<<vac-jpc<<endl;else cout<<vac-mtc<<endl;
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define SUM(n) ((n)+1)*(n)/2
#define all(v) v.begin(),v.end()
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = (1e9)+7;
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

    int n;
    cin >> n;
    int h[105];
    reps(i,n){
      cin >> h[i];
    }
    int sum = 0, ans= 0;
    reps(i,n){
      if(sum < h[i]){
	ans += h[i] - sum;
	sum = h[i];
      } else{
	sum = h[i];
      }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import heapq
def func():
    N, M = map(int, input().split())
    A = list(map(lambda x: -int(x), input().split()))
    heapq.heapify(A)

    for i in range(M):
        tmp = -heapq.heappop(A) // 2
        heapq.heappush(A,-tmp)
    
    print(-sum(A))

if __name__ == '__main__':
    func()


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

bool compare(int a, int b) {
    if (a % 10 == 0) return true;
    if (b % 10 == 0) return false;
    return (a % 10) > (b % 10);
}

int main() {

    int arr[5];
    for (int i=0; i<5; i++) {
        cin >> arr[i];
    }
    sort(arr, arr+5, compare);
    int sm = 0;
    for (int i=0; i<4; i++) {
        sm += arr[i];
        if (sm % 10 == 0) continue;
        sm += 10 - (sm % 10);
    }
    cout << sm + arr[4];

}

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

int main() {
  int N;
  string S;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> S;
    
      if (S == "Y") {
        cout << "Four" << endl;
        break;
      }      
      
      else if (i == N - 1) {
        cout << "Three" << endl;
      }      
      
  }    
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main (){
	char a[1000001];
	cin>>a;
	for(int i=0;i<=strlen(a)-1;++i){
		if(a[i]==',')
		{
			cout<<" ";
		}
		else
		{
			cout<<a[i];			
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
/**Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
long long fact[100006];
long long BigMod(long long B,long long P,long long M)
{
    long long R=1;
    while(P>0)
    {
        if(P%2==1)
        {
            R=(R*B)%M;
        }
        P/=2;
        B=(B*B)%M;
    }
    return R;
}
long long ncr(long long n,long long r,long long mod)
{
    long long g=(fact[r]*fact[n-r])%mod;
    g=BigMod(g,mod-2,mod);
    g*=fact[n];
    g%=mod;
    return g;
}
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q,add=0,sub=0,mod=1000000007;
    fact[0]=1;
    for(i=1; i<=100005; i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }
    cin>>n>>k;
    for(i=0; i<n; i++)
    {
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(i=k-1; i<n; i++)
    {
        add+=v[i]*ncr(i,k-1,mod);
        add%=mod;
    }
    for(i=0; i<=n-k; i++)
    {
        sub+=v[i]*ncr(n-i-1,k-1,mod);
        sub%=mod;
    }
    f=add+mod-sub;
    f%=mod;
    cout<<f<<'\n';
    return 0;
}


Measured memory_bytes: 2168
from bisect import bisect_left

n = int(input())
s = [int(i) for i in input().split()]
q = int(input())
t = [int(i) for i in input().split()]

ans = 0
for ti in t:
    idx = bisect_left(s, ti)
    if s[idx] == ti:
        ans += 1

print(ans)


Measured memory_bytes: 16928
#include <iostream>
#include <cstdint>

using namespace std;

int64_t N, K;

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

    int64_t ret = 0;
    for (int j = 0; j < N-1; ++j) {
        ret += 1 + ret / (K-1);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3076
/**
 *    author:  yoseph
 *    created: 09.09.2020 19:42:20      
**/
#include <bits/stdc++.h>
using namespace std;

const long M = 1000000007;

#if 0
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	
	long long ans = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			ans = (ans % M + (v[i] % M * v[j] % M) % M) % M;
		}
	}
	cout << ans << "\n";

	return 0;
}
#endif

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	long long sum =0;
	vector<int> A(n);
	for (int i = 0; i < n; ++i) {
		cin >> A[i];
		sum += A[i];
		sum %= M;
	}

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		sum -= A[i];
		if (sum < 0)
			sum += M;
		ans += A[i] * sum;
		ans %= M;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin >> k;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1];
    return 0;
}

Measured memory_bytes: 256
H,W = map(int,input().split())

N = int(input())

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

res = []
j = 0
st = 0 # リスト添え字管理

for i in range(H):
    j = 0
    while j < W:
        while 0 < a[st] and j < W:
            res.append(str(st+1))
            j += 1
            a[st] -= 1
        if a[st] == 0:
            st += 1
    if i % 2 == 1:
        res.reverse()
    print(' '.join(res))
    res = []

Measured memory_bytes: 9104
import re
while 1:
    s=input()
    if s=='#':break
    s=re.split('[w|n]',s)[1:];c=1
    d=90 if s[-1]=='est' else 0
    for x in s[:-1][::-1]:
        d*=2
        d+=90if x=='est'else-90
        c*=2
    while d&1==0 and c&1==0:d//=2;c//=2
    if c==1:print(d)
    else:print(d,c,sep='/')

Measured memory_bytes: 7600
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val k = sc.nextLong()
    println(problem161c(n, k))
}

fun problem161c(n: Long, k: Long): Long {
    return Math.min(n % k, k - (n % k))
}

Measured memory_bytes: 31136
n, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    if a[i] + a[i-1] > x:
        ans += min(a[i], a[i] + a[i-1] - x)
        a[i] = max(0, x - a[i-1])
    if a[i] + a[i-1] > x:
        ans += a[i-1] - x
        a[i-1] = x
print(ans)

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

typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++) // no semicoron
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>0;i--)
#define FORD(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
//#define PI 3.14159265359

using namespace std;

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

    vector<ll> boss (N+1);
    REP(i, N+1) boss[i] = 0;

    ll num;

    FOR(i, 2, N+1){
        cin >> num;
        boss[num]++;
    }
    FOR(i, 1, N+1){
        cout << boss[i] << endl;
    }

}

Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;

inline void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[5001][5002];

string g[1002];
ll dp[1002][1002] = {};

signed main(){
	IOS();
	ll H, W;
	cin >> H >> W;
	for (int i = 0;i < H;++i) {
		cin >> g[i];
	}
	
	dp[0][0] = 1;	
	for (int i = 0;i < H;++i) {
		for(int j = 0;j < W;++j) {
			if(i == 0 && j == 0)continue;
			else if(g[i][j] == '#')dp[i][j] = 0;
			else if(i == 0)dp[i][j] = dp[i][j - 1];
			else if(j == 0)dp[i][j] = dp[i - 1][j];
			else dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= MOD;
		}
	}
		
	cout << dp[H - 1][W - 1] << endl;
	
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll r, d, x;
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i++) {
    x = r * x - d;
    cout << x << endl;
  }
  return 0;
}


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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a + b >= 10) cout << "error" << endl;
	else cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[110],b[110];
ll dp[110][110000];
int main(){
    ll n,w;
    cin>>n>>w;
    rep(i,0,n)cin>>a[i]>>b[i];
    rep(i,0,n){
        rep(j,0,w+1){
            if(j-a[i]>=0)dp[i+1][j]=max(dp[i+1][j],dp[i][j-a[i]]+b[i]);
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
        }
    }
    cout<<dp[n][w];
}


Measured memory_bytes: 87424
#include <stdio.h>
int main()
{
    double x;
    scanf("%lf",&x);
    double a = x*x*3.141592653589793238462643383279502884197169399375105;
    double c = x*2*3.141592653589793238462643383279502884197169399375105;
    printf("%lf %lf\n",a,c);
    
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define int 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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) max_element(x.begin(),x.end())
#define MIN(x) min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
//fixed<<setprecision(15);
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
signed main(){
    int k,s; cin >> k >> s;
    vint a(k+1); rep(i,k+1) a[i]=i;
    int res=0;
    rep(i,k+1){
        rep(j,k+1){
            if(binary_search(all(a),s-a[i]-a[j])) res++;
        }
    }
    cout<<res<<endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 1e4 + 5;

int n;
vector <int> num;
int d;
string s;
int dp[N][105][2];

ll go(int idx, int sum, bool limit) {
  if(idx == n) return sum == 0;
  if(dp[idx][sum][limit] !=  -1) return dp[idx][sum][limit];
  ll total = 0;
  int R = -1;
  if(limit == 0) R = num[idx];
  else R = 9;
  for(int p = 0; p <= R; p++) {
    bool nlimit = limit;
    if(limit == 0 and p < R) nlimit = 1;
    total = (total + go(idx + 1, (sum + p) % d, nlimit)) % MOD;
  }
  return dp[idx][sum][limit] = total;
}

int main() {
  memset(dp, -1, sizeof dp);
  cin >> s >> d;
  n = s.length();
  for(auto c : s) num.push_back(c - '0');
  //reverse(num.begin(), num.end());
  cout << (go(0, 0, 0) - 1 + MOD) % MOD << '\n';
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

string s;
bool used[26];

int main() {
    cin >> s;
    for (char c : s) used[c - 'a'] = true;
    if ((int)s.length() < 26) {
        char let = 'a';
        while (used[let - 'a']) {
            ++let;
        }
        s.pb(let);
        cout << s << endl;
        return 0;
    }
    for (int i = 25; i >= 0; --i) {
        for (int j = s[i] - 'a' + 1; j < 26; ++j) {
            if (!used[j]) {
                s[i] = 'a' + j;
                cout << s << endl;
                return 0;
            }
        }
        used[s[i] - 'a'] = false;
        s.pop_back();
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
# 入力
O=list(input())
E=list(input())

s=''
while True:
    # 各文字列両方とも空になったら終章
    if len(O)==0 and len(E)==0:
        break

    if len(O)!=0:
        s+=O[0]
        O.remove(O[0])

    if len(E)!=0:
        s+=E[0]
        E.remove(E[0])

# 出力
print(s)

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

int inf = 1000000000;

int main() {
	srand(42);
	int n, k, s;
	cin >> n >> k >> s;
	for(int i = 0; i < k; ++i) cout << s << " ";
	for(int i = k; i < n; ++i) cout << inf - 42 << " ";
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>

int main()
{
	int a, b;

	std::cin >> a >> b;

	if (a < b) {
		std::cout << "a < b" << std::endl;
	}
	else if (a > b) {
		std::cout << "a > b" << std::endl;
	}
	else if (a==b) {
		std::cout << "a == b" << std::endl;
	}

    return 0;
}

Measured memory_bytes: 3048
// D - Not Divisible

// 高速な素因数分解を用いた解法

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

class FastPF {
private:
	vector<int> primes;
	vector<bool> isprime;
	vector<int> min_factor;
public:
	FastPF(int MAX) : primes(), isprime(MAX+1, true), min_factor(MAX+1, -1) {
		isprime[0] = isprime[1] = false;
		min_factor[0] = 0, min_factor[1] = 1;
		for (int i = 2; i <= MAX; ++i) {
			if (!isprime[i]) continue;
			primes.push_back(i);
			min_factor[i] = i;
			for (int j = i*2; j <= MAX; j += i) {
				isprime[j] = false;
				if (min_factor[j] == -1) min_factor[j] = i;
			}
		}
	}

	// prime factorization
	vector<pair<int,int>> prime_factorize(int n) {
		vector<pair<int,int>> res;
		while (n != 1) {
			int prime = min_factor[n];
			int exp = 0;
			while (min_factor[n] == prime) {
				++exp;
				n /= prime;
			}
			res.push_back(make_pair(prime, exp));
		}
		return res;
	}
};

void dfs_create_divisor(vector<pair<int,int>>& prime_list, int k, int product, vector<int>& divisor_list) {
	if (k == prime_list.size()) {
		divisor_list.push_back(product);
		return;
	}

	int num = prime_list[k].first;
	int cnt = prime_list[k].second;

	for (int i=0; i<=cnt; i++) {
		dfs_create_divisor(prime_list, k+1, product * pow(num, i), divisor_list);
	}
}

vector<int> enum_divisor(vector<pair<int,int>> prime_list) {
	vector<int> divisor_list;

	dfs_create_divisor(prime_list, 0, 1, divisor_list);

	return divisor_list;
}

int A[200000];
unordered_map<int, int> cnt;

int main() {
	FastPF fpf(1000000);

	int N;
	cin >> N;

	for (int i=0; i<N; i++) {
		cin >> A[i];
		cnt[A[i]]++;
	}

	int ans = 0;

	for (int i=0; i<N; i++) {
		if (cnt[A[i]] >= 2) continue;

		cnt[A[i]]--;

		vector<pair<int,int>> prime_list = fpf.prime_factorize(A[i]);
		vector<int> divisors = enum_divisor(prime_list);
		bool has_divisor = false;
		for (int d : divisors) {
			if (cnt[d] > 0) {
				has_divisor = true;
				break;
			}
		}

		if (has_divisor == false) ans++;

		cnt[A[i]]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 37380
import sys
import decimal

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = []
    x = decimal.Decimal(1)
    for i in range(N - K):
        prev = x
        x *= decimal.Decimal(A[i + K])
        x /= decimal.Decimal(A[i])
        if x > prev:
            print("Yes")
        else:
            print("No")


if __name__ == '__main__':
    main()


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

int main(){
  int N, A, B, C, D;
  string S;
  
  cin >> N >> A >> B >> C >> D;
  cin >> S;
  
  vector<int> rock;
  vector<int> jump;
  
  for(int i=0; i<N-1; i++){
    
    if(S.at(i) == '#' && S.at(i+1) == '#')
      rock.push_back(i+1);

    if(i != 0){
      if(S.at(i-1) == '.' && S.at(i) == '.' && S.at(i+1) == '.')
        jump.push_back(i+1);
    }
  
  }
  

  bool flag = false;

  for(int i=0; i<rock.size(); i++){
    
    if(rock.at(i) > A && rock.at(i) < C){
      flag = true; break;
    }
    if(rock.at(i) > B && rock.at(i) < D){
      flag = true; break;
    }
  
  }
  
  if(C > D){
    //入れ替えが必要
    flag = true;
    for(int i=0; i<jump.size(); i++){
      
      if(jump.at(i) >= B && jump.at(i) <= D){
        flag = false; break;
      }
    
    }
  
  }

  
  if(flag)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

}

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var k int
	a := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&a[i])
	}
	fmt.Scan(&k)
	if a[4]-a[0] > k {
		fmt.Println(":(")
		return
	}
	fmt.Println("Yay!")
}


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

int main()
{
    string s;
    int k,i;
    cin >> k >> s;
    if(s.length() <= k)
        cout << s << endl;
    else
    {
        for(i=0;i<k;i++)
            cout << s[i];
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int L = Integer.parseInt(sc.next());
    int ans = 0;
    int a = 10000;
    int b = 0;
    for(int i = 0; i < N; i++){
      ans += L+i;
      if(Math.abs(L+i) < a){
        a = Math.abs(L+i);
        b = L+i;
      }
    }
    ans -= b;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
def dfs(gen,naga,saidai):
    global n,ans
    if(naga==n):
        ans.append(gen)
        return
    gen*=10
    for i in range(saidai+2):
        dfs(gen+i,naga+1,max(saidai,i))

n=int(input())

ans=[]
dfs(0,1,0)
alpha=["a","b","c","d","e","f","g","h","i","j"]

retu=["a"]*n
for a in ans:
    s=str(a)
    for i in range(n):
        if(i<n-len(s)):
            retu[i]="a"
        else:
            retu[i]=alpha[int(s[i-n+len(s)])]
    print("".join(retu))

Measured memory_bytes: 54748
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;

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

struct State { int tx, ty, kx, ky, cost; };
int X, Y;
int d[52][52];
bool used[52][52][52][52];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> X >> Y, X) {
		int tx, ty, kx, ky;
		cin >> tx >> ty >> kx >> ky;
		for (int i=0; i<=Y+1; ++i) {
			for (int j=0; j<=X+1; ++j) {
				if (i==0 || i==Y+1 || j==0 || j==X+1) d[i][j] = 1;
				else cin >> d[i][j];
			}
		}
		memset(used, false, sizeof used);
		queue<State> q;
		q.push((State){tx, ty, kx, ky, 0});
		int res = -1;
		while ( ! q.empty()) {
			State s = q.front(); q.pop();
			if (used[s.tx][s.ty][s.kx][s.ky]) continue;
			used[s.tx][s.ty][s.kx][s.ky] = true;
			if (s.tx == s.kx && s.ty == s.ky) {
				res = s.cost;
				break;
			}
			for (int i=0; i<4; ++i) {
				if (d[s.ty+dy[i]][s.tx+dx[i]] && d[s.ky-dy[i]][s.kx-dx[i]]) continue;
				int tx2 = s.tx, ty2 = s.ty;
				if ( ! d[s.ty+dy[i]][s.tx+dx[i]]) {
					tx2 += dx[i];
					ty2 += dy[i];
				}
				int kx2 = s.kx, ky2 = s.ky;
				if ( ! d[s.ky-dy[i]][s.kx-dx[i]]) {
					kx2 -= dx[i];
					ky2 -= dy[i];
				}
				if ( ! used[tx2][ty2][kx2][ky2] && s.cost+1 < 100) {
					q.push((State){tx2, ty2, kx2, ky2, s.cost+1});
				}
			}
		}
		if (res < 0) {
			cout << "NA" << endl;
		} else {
			cout << res << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 8868
#include<bits/stdc++.h>
#define ff(x,a,b) for(int x=a;x<=b;x++)
#define fff(x,a,b) for(int x=a;x>=b;x--)
#define void inline void
using namespace std;
typedef long long ll;
int n,a[300006];
int main()
{
	cin>>n;
	ff(i,1,n) scanf("%d",a+i);
	int s=a[1];
	ff(i,2,n) s=s^a[i];
	if(!s) puts("Yes");
	else puts("No");
} 

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.IO;

namespace AtCoderPractice
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var X = cin.ReadInt;
            var A = cin.ReadInt;
            var t = (X < A) ? 0 : 10;

            Console.WriteLine($"{t}");
        }
    }

    public class ConsoleInput
    {
        private readonly TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;

        public ConsoleInput(TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        public string ReadLine
        {
            get { return _stream.ReadLine(); }
        }

        public int ReadInt
        {
            get { return int.Parse(Read); }
        }

        public long ReadLong
        {
            get { return long.Parse(Read); }
        }

        public double ReadDouble
        {
            get { return double.Parse(Read); }
        }

        public string[] ReadStrArray(long N)
        {
            var ret = new string[N];
            for (long i = 0; i < N; ++i) ret[i] = Read;
            return ret;
        }

        public int[] ReadIntArray(long N)
        {
            var ret = new int[N];
            for (long i = 0; i < N; ++i) ret[i] = ReadInt;
            return ret;
        }

        public long[] ReadLongArray(long N)
        {
            var ret = new long[N];
            for (long i = 0; i < N; ++i) ret[i] = ReadLong;
            return ret;
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int K;
    cin >> K;
    K--;
    for(int i = 0; i < N; i++){
        if(S[i] != S[K]){
            S[i] = '*';
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
N=int(input())
H=list(map(int,input().split()))

DPLIST=[None]*N
DPLIST[0]=0
DPLIST[1]=abs(H[1]-H[0])

for i in range(2,N):
    DPLIST[i]=min(DPLIST[i-1]+abs(H[i]-H[i-1]),DPLIST[i-2]+abs(H[i-2]-H[i]))

print(DPLIST[N-1])

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

long long int v[3][800001];
long long int tot[3];
long long int a[200001];
int q[200001];
long long int query(int i,int l,int r,int idx,int L,int R){
	if(r<L||l>R)	return 1e18;
	if(r<=R&&l>=L)	return v[i][idx];
	int mid=(l+r)/2;
	return min(query(i,l,mid,idx*2,L,R),query(i,mid+1,r,idx*2+1,L,R));
}

void modify(int i,int l,int r,int idx,int pos,long long int val){
	if(l==r){
		if(i==0)
			v[i][idx]=min(v[i][idx],val-tot[i]);
		else if(i==1)
			v[i][idx]=min(v[i][idx],val-tot[i]-l);
		else
			v[i][idx]=min(v[i][idx],val-tot[i]+l);
		return;
	}
	int mid=(l+r)/2;
	if(pos<=mid)
		modify(i,l,mid,idx*2,pos,val);
	else
		modify(i,mid+1,r,idx*2+1,pos,val);
	v[i][idx]=min(v[i][idx*2],v[i][idx*2+1]);
}
void build(int i,int l,int r,int idx){
	if(l==r){
		if(i==0)
			v[i][idx]=a[l];
		else if(i==1)
			v[i][idx]=a[l]-l;
		else v[i][idx]=a[l]+l;
		return;
	}
	int mid=(l+r)/2;
	build(i,l,mid,idx*2);
	build(i,mid+1,r,idx*2+1);
	v[i][idx]=min(v[i][idx*2],v[i][idx*2+1]);
}

int N,Q,A,B;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>N>>Q>>A>>B;
	for(int i=1;i<=Q;i++)
		cin>>q[i];
	q[0]=A;
	for(int i=1;i<=N;i++)
		a[i]=abs(B-i);
	for(int i=0;i<3;i++)
		build(i,1,N,1);
	for(int qq=1;qq<=Q;qq++){
		long long int tmp=min(query(1,1,N,1,1,q[qq])+q[qq],query(2,1,N,1,q[qq],N)-q[qq])+tot[0];
		for(int i=0;i<3;i++)
			tot[i]+=abs(q[qq]-q[qq-1]);
		for(int i=0;i<3;i++)
			modify(i,1,N,1,q[qq-1],tmp);

	}
	cout<<query(0,1,N,1,1,N)+tot[0]<<endl;
}


Measured memory_bytes: 20736
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e6 + 7, M = 1e9 + 7;

int dp[N][4];

void add(int &a, int b) {
	a += b;
	if(a >= M) a -= M;
}

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	dp[0][0] = 1;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 4; j++) {
			if(j == 0) {
				add(dp[i + 1][j], dp[i][j] * 8 % M); // put 1 - 8
				add(dp[i + 1][1], dp[i][j]); // put 0
				add(dp[i + 1][2], dp[i][j]); // put 9
			} else if(j == 1) { // has 0
				add(dp[i + 1][1], dp[i][j] * 9 % M); // put 0 - 8
				add(dp[i + 1][3], dp[i][j]); // put 9
			} else if(j == 2) { // has 9
				add(dp[i + 1][2], dp[i][j] * 9 % M); // put 1 - 9
				add(dp[i + 1][3], dp[i][j]); // put 0
			} else { // has 0 and 9
				add(dp[i + 1][3], dp[i][j] * 10 % M);
			}
		}
	}
	cout << dp[n][3] << endl;

}



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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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; }


int main()
{
    int A,B,C;
    cin >> A >> B >> C;

    cout << max(0, C - A+B) << endl;
}


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

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

    int total = 0;

    vector<int> A(N);
    for (int i = 0; i<N; i++) {
        cin >> A.at(i);

        total += A.at(i);
    }

    double less = total*1.0/(4*M);

    int count = 0;

    for (int i = 0; i<N; i++) {
        if (A.at(i)>=less) {
            count++;
        }
    }

    if (count>=M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;

template<typename T>
class BIT {
public:
    explicit BIT(int n) : N(calcN_(n)), mVal(calcN_(n)+1, 0) {}
    void add(int idx, T val){
        for(int x=idx;x<=N;x+=x&-x) mVal[x] += val;
    }
    T sum(int idx){
        T res = 0;
        for(int x=idx;x>0;x-=x&-x) res += mVal[x];
        return res;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    const int N;
    vector<T> mVal;
};

struct Query {
    explicit Query(int l, int r, int id) : l(l), r(r), id(id){}
    int l, r, id;
    bool operator < (const Query& q) const { return r < q.r; }
};

int main(){
    int N, Q; cin >> N >> Q;
    vector<int> c(N);
    for(auto& t : c){ cin >> t; --t; }
    vector<Query> vq;
    for(int i=0;i<Q;i++){
        int l, r; cin >> l >> r;
        --l;
        vq.emplace_back(l, r, i);
    }
    sort(vq.begin(), vq.end());
    vector<int> res(Q);
    vector<int> last(N, -1);
    int end = 0;
    BIT<int> bit(N);
    for(auto& q : vq){
        for(int i=end;i<q.r;i++){
            if(last[c[i]] != -1) bit.add(last[c[i]], -1);
            bit.add(i+1, 1);
            last[c[i]] = i+1;
        }
        end = q.r;
        res[q.id] = bit.sum(q.r) - bit.sum(q.l);
    }
    for(auto& t : res) cout << t << endl;
}

Measured memory_bytes: 17468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

double a[200];

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int N; cin >> N;
    REP(i,N) cin >> a[i];

    double sum = 0;
    REP(i, N) sum += a[i];
    double ave = sum/N;

    double sub = 10000;
    int ans = 0;
    REP(i, N) {
        if (sub > abs(ave-a[i])) {
            sub = abs(ave-a[i]);
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = sc.next();
		String ss = S.substring(0,N/2);
		String sss = S.substring(N/2);
		String ans = "A";
		if( ss.equals(sss) ){
			ans = "Yes";
		}else{
			ans = "No";
		}
		if( N%2!=0 ){
			ans = "No";
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  int a[]={10000,5000,1000,500,};
  int sum=0;
  in(int,n);
  int i;
  rep(i,4){
    while(n-a[i]>=0){
      n-=a[i];
      sum+=a[i];
    }
  }
  putv(sum);
  return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int N;

void dfs(string s, char mx){
  if(s.size()==N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c < mx; c++){
      dfs(s + c, mx);
    }
    dfs(s+mx, mx+1);
  }
}

int main(){
  cin >> N;
  dfs("", 'a');
}



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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define cr const reg&
using namespace std;
const int N = 1e5 + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

int A[N], B[N], C[2 * N];
LL s[N * 2];

int main() {
	reg n = read();
	LL l1 = 0, l2 = 0;
	fo(i, 1, n) {
		A[i] = read(), B[i] = read();
		l1 += A[i], l2 += B[i];
		C[i * 2 - 1] = A[i], C[i * 2] = B[i];
	} sort(C + 1, C + 2 * n + 1);
	fo(i, 1, n) s[i] = s[i - 1] + C[i];
	LL ans = min(l1, l2);
	fo(i, 1, n) {
		reg x = A[i], y = B[i];
		if(x > y) swap(x, y);
		if(lower_bound(C + 1, C + 2 * n + 1, x) - C <= n - 2) {
			if(lower_bound(C + 1, C + 2 * n + 1, y) - C <= n - 1) ans = min(ans, s[n]);
			else ans = min(ans, y + s[n - 1]);
		} else ans = min(ans, x + y + s[n - 2]);
	} printf("%lld\n", ans);
	return 0;
}



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

int main(void)
{
  string o, e;
  cin >> o;
  cin >> e;
  for ( int i=0; i<o.length()||i<e.length(); i++ ) {
    if ( i < o.length() ) {
      cout << o[i];
    }
    if ( i < e.length() ) {
      cout << e[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256