akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python3

import array
import math
import os
import sys


def main():
    N = read_int()
    D = read_ints()
    s = 0
    for i in range(N):
        for j in range(i + 1, N):
            s += D[i] * D[j]
    print(s)


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

#define PUSH(r, c, f, m) do{			\
    rs.push(r);					\
    cs.push(c);					\
    fs.push(f); 				\
    ms.push(m); 				\
  }while(0)
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int W, H, S;
char I[55][55];
bool M[10][55][55];
int  D[2][55][55][1 << 10];

inline bool inside(int r, int c){
  return 0 <= r && r < H && 0 <= c && c < W;
}

inline bool cur_floor(int r, int c, int f, int mask){
  bool ok = f == 0;
  if(I[r][c] == '#') return false;
  if(I[r][c] == '|') return true;
  if(I[r][c] == '^' || isupper(I[r][c])) ok = !ok;
  REP(s, S) if(PARITY(mask >> s) && M[s][r][c]) ok = !ok;
  return ok;
}


int main(){
  memset(D, -1, sizeof(D));
  memset(M, false, sizeof(M));
  
  cin >> W >> H;
  int sr, sc;
  REP(r, H)REP(c, W){
    cin >> I[r][c];
    if(I[r][c] == '%'){
      sr = r;
      sc = c;
    }
  }

  cin >> S;
  char ch;  
  REP(s, S)REP(r, H)REP(c, W){
    cin >> ch;
    M[s][r][c] = ch == '*';
  }

  queue<int> rs, cs, fs, ms;
  rs.push(sr);
  cs.push(sc);
  fs.push(0);
  ms.push(0);
  D[0][sr][sc][0] = 0;
  
  int dr[4] = {0, 1, 0, -1};
  int dc[4] = {-1, 0, 1, 0};

  bool goal = false;
  while(!rs.empty()){
    int r = rs.front(); rs.pop();
    int c = cs.front(); cs.pop();
    int f = fs.front(); fs.pop();
    int mask = ms.front(); ms.pop();
    
    if(I[r][c] == '&' && cur_floor(r, c, f, mask)){
      cout << D[f][r][c][mask] << endl;
      goal = true;
      break;
    }
    
    REP(i, 4){
      int nr = r + dr[i];
      int nc = c + dc[i];
      if(inside(nr, nc) && cur_floor(nr, nc, f, mask) && D[f][nr][nc][mask] ==-1){
	D[f][nr][nc][mask] = D[f][r][c][mask] + 1;
	PUSH(nr, nc, f, mask);
      }
    }

    if(I[r][c] == '|' && D[1 - f][r][c][mask] == -1){
      D[1 - f][r][c][mask] = D[f][r][c][mask] + 1;
      PUSH(r, c, 1 - f, mask);
    }

    if(isalpha(I[r][c]) && cur_floor(r, c, f, mask)){
      int k = isupper(I[r][c]) ? I[r][c] - 'A' : I[r][c] - 'a';
      int nmask = mask ^ (1 << k);
      int nf = cur_floor(r, c, f, nmask) ? f : 1 - f;
      if(D[nf][r][c][nmask] == -1){
	D[nf][r][c][nmask] = D[f][r][c][mask] + 1;
	PUSH(r, c, nf, nmask);
      }
    }
  }
  if(!goal) cout << -1 << endl;
  return 0;
}

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

 bool BinarySearch(int t, vector<int> S)
 {
 	int start = 0;
 	int end = S.size() - 1;
 	do{
 		int middle = (end - start) / 2 + start;
 		if(t == S[middle]){
 			return true;
 		}else if(t < S[middle]){
 			end = middle - 1;
 		}else if(t > S[middle]){
 			start = middle + 1;
 		}
 //		cout << t << " " << start << " " << middle " " << end << endl;
 	}while(end - start >= 0);
 	return false;
 }

 int main()
 {
 	int Count = 0;
 	int n;
 	cin >> n;
 	vector<int> S;
 	for(int i = 0; i < n; i++){
 		int s;
 		cin >> s;
 		S.push_back(s);
 	}
 	int q;
 	cin >> q;
 	for(int i = 0; i < q; i++){
 		int t;
 		cin >> t;
 		if(BinarySearch(t, S)){
 			Count++;
 //			cout << "t:" << t << endl;
 		}
 	}
 	cout << Count << endl;
 	return 0;
 }

Measured memory_bytes: 1932
#include <stdio.h>

int main(void){
  char a;
  
  scanf("%c", &a);
  
  if((a>='a') && (a<='z')){
    printf("a\n");
  }
  if((a>='A') && (a<='Z')){
	printf("A\n");
  }
  return 0;
}



Measured memory_bytes: 1556
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main(void) {
    ll x;
    cin >> x;

    ll now = 0;

    for (int i = 1; ;i++) {
        now += i;
        if (now >= x) {
            cout << i << endl;
            return 0;
        }
  
    }

    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,M,Q;
  cin >> N >> M >> Q;
  vector<int> L[505];
  FOR(i,0,M) {
    int l, r;
    cin >> l >> r;
    L[l].push_back(r);
  }
  FOR(i,0,505) {
    L[i].push_back(-1);
    L[i].push_back(1e9);
    sort(L[i].begin(), L[i].end());
  }
  FOR(i,0,Q) {
    int p, q;
    cin >> p >> q;
    int ans = 0;
    FOR(j,p,q+1) {
      ans += upper_bound(L[j].begin(), L[j].end(), q) - L[j].begin() - 1;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;



const long long int mod=1000000007;
const long long int INF=99999999999999999;

long long int res=0,a[200005],sum=0,now=1,h,w,k,firsth=999999,cake[305][305];
bool atta;
string str[305];

int main() {
	cout << fixed << setprecision(10);
    cin>>h>>w>>k;
    for(int i=0;i<h;i++){
        cin>>str[i];
    }
    for(int i=0;i<h;i++){
        atta=false;
        for(int j=0;j<w;j++){
            if(now==1&&str[i][j]=='#'){
                firsth=i;
            }
            if(str[i][j]=='#'&&atta==false){
                for(int p=0;p<=j;p++){
                    cake[i][p]=now;
                }
                atta=true;
                now++;
            }else if(str[i][j]=='#'){
                now++;
                cake[i][j]=now-1;
            }else if(str[i][j]=='.'&&atta==true){
                cake[i][j]=now-1;
            }
        }
        if(atta==false&&firsth!=999999){
            for(int j=0;j<w;j++){
                cake[i][j]=cake[i-1][j];
            }
        }
    }
    if(firsth==0){}
    else{
        for(int i=firsth-1;i>=0;i--){
            for(int j=0;j<w;j++){
                cake[i][j]=cake[firsth][j];
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<cake[i][j]<<" ";
        }
        cout<<endl;
    }
} 


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  vector<string> s(n),b;
  for(int i=0;i<n;i++) cin>>s[i];
  b=s;
  sort(b.begin(),b.end());
  for(int i=0;i<n;i++){
    int res=0;
    res+=upper_bound(b.begin(),b.end(),s[i])
      -lower_bound(b.begin(),b.end(),s[i])-1;
    res+=distance(b.begin(),lower_bound(b.begin(),b.end(),s[i]))*3;
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 8612
import math
n,k = map(int, input().split())
a = list(map(int, input().split()))
c = int(math.log2(max(k,max(a)))+1)
d = [0]*c
for i in a:
  b = format(i, 'b')
  for j,l in enumerate(b[::-1]):
    if l == "1":
      d[j] += 1
ans = 0
for i,j in enumerate(d[::-1]):
  zero = n - j
  one = j
  if k >= 2 ** (c-i-1):
    if zero > one:
      ans += zero * (2 ** (c-i-1))
      k -= 2 ** (c-i-1)
    else:
      ans += one * (2 ** (c-i-1))
  else:
    ans += one * (2 ** (c-i-1)) 
print(ans)

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

int main()
{
  string s;
  int cnt = 0;

  cin >> s;

  for (int i = 1; i < s.size(); i++) {
    if (s[i - 1] != s[i]) {
      cnt++;
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 512
<?php
$a = [];
while(true)
{
    $in = trim(fgets(STDIN));
    if($in == 0)
    {
        break;
    }
    else
    {
        $a[] = $in;
    }

}
for($i = 0; $i < count($a); $i++)
{
    $index = $i + 1;
    echo "Case " . $index . ": " . $a[$i] . "\n";
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<int, ll> i_ll;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
typedef pair<ll_i, int> P;
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;
struct edge { int v, a, b; };

int main() {
	int N, K; cin >> N >> K;
	vector<int> b(N);
	rep(i, N) {
		int x; scanf("%d", &x);
		b[x - 1]++;
	}
	sort(b.begin(), b.end());
	int ans = 0;
	rep(x, N - K) ans += b[x];
	cout << ans << endl;
}


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

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    
    int x_max = -100;
    for(int i = 0; i < N; ++i) {
        int x;
        cin >> x;
        if(x > x_max) x_max = x;
    }
    if(X > x_max) x_max = X;

    int y_min = 100;
    for(int i = 0; i < M; ++i) {
        int y;
        cin >> y;
        if(y < y_min) y_min = y;
    }
    if(Y < y_min) y_min = Y;
    
    if(x_max >= y_min) {
        cout << "War" << endl;
    }else {
        cout << "No War" << endl;
    }
    
}


Measured memory_bytes: 256
from statistics import median

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
a = [i for i, j in ab]
b = [j for i, j in ab]

if n % 2 == 1:
    print(abs(median(b) - median(a)) + 1)
else:
    print(int(abs(median(b) - median(a)) * 2) + 1)

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

using namespace std;

#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi >
#define mp make_pair
#define ALL(x)	x.begin(),x.end() 

typedef long long ll;
//const double PI = 4*atan(1.);
//const int INF = 0x3f3f3f3f;
const int maxn = 2e5+10;
const int mod = 1e9 + 7;

int num[70];
ll dp[70][70][2][2][2];
int sum[70];

ll dfs(int pos, bool lim, bool vBig, bool adj, int pre1) { // u <= v
    if (pos == -1)  return pre1 && !adj;
    if (~dp[pos][pre1][lim][vBig][adj])   return dp[pos][pre1][lim][vBig][adj];
    int up = lim ? num[pos] : 1;
    ll ans = 0;
    // cout << "pos : " << pos << '\n';
    for (int i = 0; i <= up; ++i) { // a + b = v
        int upp = vBig ? 1 : i;
        for (int j = 0; j <= upp; ++j) { // a xor b = u
            // if (j == 1 && pre1 == pos + 1)   continue ;
            // cout << "   cur i j : " << pos << ' ' << i << ' ' << j << '\n';
            // sum[pos] = sum[pos + 1] + (j == 1);
            if (i < j) { // 0 1   
                // int cnt = sum[pos] - sum[pre1 + 1];
                // if (cnt > 0)    continue ;
                if (pre1 - 1 < pos + 1) //continue ;
                (ans += dfs(pos - 1, lim && i == up, vBig, adj, pos)) %= mod;
            } else if (j == 1) { // 1 1
                (ans += dfs(pos - 1, lim && i == up, vBig, adj || (pre1 != 66 && pre1 == pos + 1), pre1)) %= mod;
            } else { // 0 0, 1 0
                (ans += dfs(pos - 1, lim && i == up, vBig || i > j, adj, i == 1 ? pos : pre1)) %= mod;
            }
            // cout << "   pos ans : " << pos << ' ' << ans << '\n';
            // sum[pos] -= j == 1;
        }
    }
    // cout << "cur ans : " << pos << ' ' << ans << '\n';
    return dp[pos][pre1][lim][vBig][adj] = ans;
}

ll solve(ll x) {
    int pos = 0;
    while (x) {
        num[pos++] = x & 1;
        x >>= 1;
    }
    return dfs(pos - 1, 1, 0, 0, 66);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    cout << solve(n) << '\n';
    return 0;
}


Measured memory_bytes: 3900
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int N,sum=0;
	cin>>N;
	int data[N][3],data2[N][3]={0},so[3]={0};
	for (int A=0;A<N;A++){
		cin>>so[0]>>so[1]>>so[2];
		sort(so,so+3);
		data[A][0]=so[0];
		data[A][1]=so[1];
		data[A][2]=so[2];
		data2[A][0]=so[0];
		data2[A][1]=so[1];
		data2[A][2]=so[2];
	}
	for (int A=0;A<N;A++){
		data2[A][0]=0;
		data2[A][1]=0;
		data2[A][2]=0;
		for (int B=0;B<N;B++){
			if (data[A][0]==data2[B][0]&&data[A][1]==data2[B][1]&&data[A][2]==data2[B][2]&&A!=B){
				sum++;
				data2[B][0]=0;
				data2[B][1]=0;
				data2[B][2]=0;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}




Measured memory_bytes: 3180
n = gets.chomp.to_i

rn = Math.sqrt(n).to_i + 1
arr = []
arr2 = []
(1..rn).each { |num|
    arr << num if n % num == 0
}
a1 = arr[-1]
a2 = n / a1
m = a1 + a2 - 2
puts m

Measured memory_bytes: 14400
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<string>
#include <vector>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

using namespace std;

int main(){
	int n, R[200000], minR, ans;

	scanf("%d", &n);
	REP(i, n){
		scanf("%d", &R[i]);
	}
	minR = R[0];
	ans = R[1] - R[0];

	FOR(i, 1, n){
		if (R[i] - minR > ans){
			ans = R[i] - minR;
		}
		if (R[i] < minR){
			minR = R[i];
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 3948
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 101000

char c[N];
int a[N];
int main(void){


int n;
int ans;
int x,y,z,w;
int bb;
bool v;
f(i,N)c[i]=0;
scanf("%s",c);
n=strlen(c);
f(i,n)a[i]=c[i]-'0';
x=100;
y=-1;
f(i,n){
if(a[i]<x)x=a[i];
if(y<a[i])y=a[i];
}
ans=y-x;
x=100;
y=-1;
z=0;
bb=0;
v=true;
while(z<n){
if(a[z]==1){
if(z>=n-1)v=false;
w=10+a[z+1];
z+=2;
}
else{
w=a[z];
z++;
}
bb++;
if(w<x)x=w;
if(y<w)y=w;
}
if(bb<2)v=false;
if(v){
if(y-x<ans)ans=y-x;
}
for(z=2;z<=(n/2);z++){
if(n%z==0){
v=true;
x=100;
y=0;
bb=0;
f(i,z-2){
f(j,(n/z)){
if(a[j*z+i]!=a[i])v=false;
}
}
f(i,(n/z)){
w=(10*a[((i+1)*z)-2])+a[((i+1)*z)-1];
if(w<x)x=w;
if(y<w)y=w;
bb++;
}
if(bb<2)v=false;
if(v){
if(y-x<ans)ans=y-x;
}
}
}

printf("%d\n",ans);

return 0;
}


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

typedef long long ll;
using namespace std;

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> trains(n + 1);
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        trains[l].push_back(r);
    }
    for (int i = 0; i < n; i++)
        sort(trains[i].begin(), trains[i].end());
    for (int i = 0; i < q; i++) {
        int cnt = 0;
        int p, q;
        cin >> p >> q;
        for (int k = p; k <= q; k++)
            cnt += upper_bound(trains[k].begin(), trains[k].end(), q) - trains[k].begin();
        cout << cnt << endl;
    }
    return 0;
}


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

int main(){
  char a,b;
  cin>>a>>b;
  if(a==b){
    cout<<"="<<endl;
  }else if(a>b){
    cout<<">"<<endl;
  }else{
    cout<<"<"<<endl;
  }
}


Measured memory_bytes: 3612
a,b,k = map(int,input().split())

if (b-a+1) > 2*k:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Measured memory_bytes: 3060
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<i32>();
    let m=read::<i32>();
    let a=(0..n).map(|_|read::<i32>()).collect::<Vec<i32>>();
    println!("{}",n+(m-a.iter().sum::<i32>())/a.iter().min().unwrap())
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int H,N,a,total;
cin>>H>>N;
total=0;
for(int i=0;i<N;++i){
  cin>>a;
  total+=a;
}
if(total>=H){
  cout<<"Yes"<<"\n";
}
else{
  cout<<"No"<<"\n";
}
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M;
vector<int> E[101010];
int ans[101010];
bool vis[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		a--; b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}

	queue<int> que;
	que.push(0);
	vis[0] = true;

	while (!que.empty()) {
		int cu = que.front(); que.pop();
		fore(to, E[cu]) if (!vis[to]) {
			ans[to] = cu;
			vis[to] = true;
			que.push(to);
		}
	}

	printf("Yes\n");
	rep(i, 1, N) printf("%d\n", ans[i] + 1);
}







Measured memory_bytes: 10632
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b = readInts()
    for i in range(1,1001):
        a_ = int(i * 0.08)
        b_ = int(i * 0.1)
        if a_ == a and b_ == b:
            print(i)
            exit()
    print(-1)
if __name__ == '__main__':
  main()


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, l;
	cin >> n >> l;
	string s[120];
	for (int i = 0; i < n; i++)
		cin >> s[i];
	stable_sort(s, s + n);
	for (int i = 0; i < n; i++)
		cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
N=int(input())
div=[]

for i in range(1,int(N**0.5)+1):
  if N%i == 0:  
    div.append(i)
    div.append(N/i)

div=list(map(int,div))
div.sort()
num=len(div)//2

x=div[num]
y=div[num-1]

print(x+y-2)

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

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

    rep(i, n)
    {
        double a;
        cin >> a;
        sum += 1 / a;
    }

    cout << fixed << setprecision(6) << 1 / sum << endl;

    return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

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

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

	int H, W;
	
	cin >> H >> W;
	int c[10][10];
	rep(i, 10)
	{
		rep(j, 10)
		{
			cin >> c[i][j];
		}
	}

	rep(k, 10)
	{
		rep(i, 10)
		{
			rep(j, 10)
			{
				if (c[i][j] > c[i][k] + c[k][j])
				{
					c[i][j] = c[i][k] + c[k][j];
				}
			}
		}
	}

	ll total = 0;
	rep(i, H)
	{
		rep(j, W)
		{
			int a;
			cin >> a;
			if (a != -1)
			{
				total += c[a][1];
			}
		}

	}
	
	cout << total << endl;
	
	return 0;
}


Measured memory_bytes: 256
S,n;main(s){for(;scanf("%d",&n)*n;printf("%d\n",S)){int d[]={S=1,2,3},a,t;for(;n--;S+=*d)scanf("%s",&s),t=d[a=s%51/19],d[a]=d[s=s%6/2],d[s]=7-t;}}

Measured memory_bytes: 0
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


void solve(void){
  
  int X;
  cin >> X;
  
  int Y=(X/500)*1000;
  X=X%500;
  Y = Y + (X/5)*5;
  
  cout << Y << endl;
  
  return;
   
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {


    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    long double B = 0;
    vector<double>A(N);
    rep(i, N) {
        cin >> A[i];
        B += 1 / A[i];
    }
    cout << fixed << setprecision(100) <<1/B<< endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define maxn 100086

using namespace std;

int n;

int main(){
	scanf("%d", &n);
	if(n < 600) return printf("8"), 0;
	if(n < 800) return printf("7"), 0;
	if(n < 1000) return printf("6"), 0;
	if(n < 1200) return printf("5"), 0;
	if(n < 1400) return printf("4"), 0;
	if(n < 1600) return printf("3"), 0;
	if(n < 1800) return printf("2"), 0;
	if(n < 2000) return printf("1"), 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define ll                long long int
#define ld                long double
#define pb                push_back
#define pf                push_front
#define ppb               pop_back
#define ppf               pop_front
#define sz                size()
#define pi                acos(-1.0)
#define mod               1000000007
#define F                 first
#define S                 second
#define C                 continue
#define G                 goto done
#define maxe              max_element
#define mine              min_element
#define min3(a,b,c)       min(a,min(b,c))
#define max3(a,b,c)       max(a,max(b,c))
#define min4(a,b,c,d)     min(a,min(b,min(c,d)))
#define max4(a,b,c,d)     max(a,max(b,max(c,d)))
#define mem(a,b)          memset(a,b,sizeof(a))
#define all(a)            (a).begin(),(a).end()
#define gcd(a,b)          __gcd(a,b)
#define lcm(a,b)          ((a)*((b)/gcd(a,b)))
#define case(a)           cout<<"Case "<<(a)<<": "
#define point(a)          fixed<<setprecision(a)
#define get(a)            for(auto &x:a) cin>>x
#define print(a)          for(auto x:a) cout<<x<<" "; cout<<endl
#define see(x)            cout<<#x<<" = "<<x<<endl
#define uniq(a)           sort(all(a)); (a).erase(unique((a).begin(),(a).end()),(a).end())
#define big(a)            transform((a).begin(),(a).end(),(a).begin(),::toupper)
#define small(a)          transform((a).begin(),(a).end(),(a).begin(),::tolower)
#define ischar(a)         (('a'<=a&&a<='z')('A'<=a&&a<='Z'))
#define isvowel(a)        (a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
#define fast              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define tc                int test; cin>>test; while(test--)
using namespace std;
int main()
{
    ll n; cin>>n;
    ld s=0;
    while(n--)
    {
        ld a; cin>>a; s+=(1/a);
    }
    cout<<point(6)<<(1/s)<<endl;
}




















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

int main() {
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3=0,x4=0,y3=0,y4=0;
  x3=x2+y1-y2;
  y3=y2+x2-x1;
  x4=x3-x2+x1;
  y4=y3-y2+y1;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする
 
using namespace std;
typedef long long int ll;
typedef pair< long long int , long long int> P;

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

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

struct edge{long long int to;
long long int cost;};

 
int main(void){

	int a,p;

	cin>>a>>p;

	cout<<(3*a+p)/2<<endl;

}



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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var text = "";
			while ((text = Console.ReadLine()) != "END OF INPUT")
			{
				var n = string.Join("", text.Split(' ').Select(s => s.Length.ToString()).ToArray());
				Console.WriteLine(n);
			}
		}
	}
}

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

int main() {
  int a , b , c , d;
  cin >> a >> b >> c >> d; 
  int l=a+b;
  int r=c+d;
  if( l > r ){
    cout << "Left" << endl;
  }else if( l < r ){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define endl '\n'
#define EPS 1e-9
#define PI acos(-1)
 
using ll = long long;
using pll = pair<ll,ll>;
using ii = pair<int,int>;
using iii = pair<pair<int,int>,int>;
using viii = vector<iii>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
using ui = unsigned int;
 

int dp[100005][4];
int a[100005];
int b[100005];
int c[100005];
void iniciar(){
	for(int i =0;i<100005;i++){
		for(int j =0;j<4;j++){
			dp[i][j] = -1;
		}
	}
}

int maximo(int a,int b,int c){
	if(a > b && a > c) return a;
	if(b > a && b > c) return b;
	return c;
}

int f(int dia,int opcion){
	//printf("%d %d \n",dia,opcion);
	if(dia == 0){
		return 0;
		
	}
	if(dp[dia][opcion] == -1){
		
		if(opcion == 1){
			return dp[dia][opcion] = max(f(dia-1,2) + b[dia],f(dia-1,3)+c[dia]);
		}
		else if(opcion == 2){
			return dp[dia][opcion] = max(f(dia-1,1) + a[dia],f(dia-1,3)+c[dia]);
		}
		else if(opcion == 3){
			return dp[dia][opcion] = max(f(dia-1,1) + a[dia],f(dia-1,2)+b[dia]);
		}
	}
	else return dp[dia][opcion];
}
 
int main() {
    ofstream out("output.txt");
    ios_base::sync_with_stdio(false);
	
	iniciar();
	int n;
	cin>>n;
	for(int i =1;i<=n;i++) cin>>a[i]>>b[i]>>c[i];
	
	cout<<maximo(f(n-1,1)+a[n],f(n-1,2)+b[n],f(n-1,3)+c[n]);
	
	
    return 0;
}   


Measured memory_bytes: 6144
//#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
//#include <cstdio>
//#include <cstdlib>
//#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int a, b;
	// char ;

	cin >> a >> b;

	cout <<a * b <<" " << 2 * (a + b) <<endl;

	return 0;
}

/*
for(i=0;i<N;i++){
	cin >> X[i];
}


for(i=0;i<N;i++){
	for(j=0;j<N;j++){
		cin >> X[i][j];
	}
}
*/

Measured memory_bytes: 1164
def main():
    N = int(input())
    A = list(map(int, input().split()))
    bubbleSort(A, N)


def bubbleSort(A, N):
    count = 0
    flag = 1
    while flag:
        flag = 0
        for i in reversed(range(1, N)):
            if A[i] < A[i - 1]:
                x = A[i]
                y = A[i - 1]
                A[i] = y
                A[i - 1] = x
                flag = 1

                count += 1

    print(*A)
    print(count)

main()


Measured memory_bytes: 5608
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  if((b-a)%2==0){cout<<(b-a)/2<<endl;}
  else{cout<<min(a+(b-a-1)/2,n-b+1+(b-a-1)/2)<<endl;}
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, K, S, T, A[51];
	scanf("%d %d %d %d", &N, &K, &S, &T);
	for (i = 1; i <= N; i++) {
		scanf("%d", &(A[i]));
		if ((A[i] & S) != S || (A[i] | T) != T) {
			i--;
			N--;
		}
	}
	
	int j, bit[20];
	long long comb[51][51];
	for (i = 1, bit[0] = 1; i < 20; i++) bit[i] = bit[i-1] << 1;
	for (i = 1, comb[0][0] = 1; i <= N; i++) {
		for (j = 1, comb[i][0] = 1, comb[i][i] = 1; j < i; j++) comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
	}

	int k, l, m, X = S ^ T, Y, count[51] = {}, appear[51];
	long long ans = 0, tmp;
	for (i = 1; i <= K; i++) ans += comb[N][i];
	for (i = 1; i <= X; i++) {
		if ((i | X) != X) continue;
		for (j = 0, k = 0, Y = 0; j < 20; j++) {
			if ((i & bit[j]) != 0) {
				k++;
				Y |= bit[j];
			}
		}
		for (j = 1, m = 0; j <= N; j++) {
			for (l = 0; l < m; l++) if ((A[j] & Y) == appear[l]) break;
			if (l == m) {
				appear[m] = A[j] & Y;
				count[m++] = 1;
			} else count[l]++;
		}
		for (l = 0, tmp = 0; l < m; l++) {
			for (j = 1; j <= count[l] && j <= K; j++) tmp += comb[count[l]][j];
		}
		
		if (k % 2 == 0) ans += tmp;
		else ans -= tmp;
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1712
// inputに入力データ全体が入る
function Main(input) {
  
   input = input.split("\n");
   var ABT = input[0].split(" ");
  var A= parseInt(ABT[0], 10);
 var B= parseInt(ABT[1], 10);
 var T= parseInt(ABT[2], 10);
   
 var  S = ( T + 0.5 ) /A;
 var  S = Math.trunc(S);
 console.log(S * B);
   
   
   
                   
  }
 
  
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7500
fun main(args: Array<String>) {
    val N = nextInt()
    val A = Array(N) { nextInt() }
    val (first, second) = A.sortedDescending()
    val ans = IntArray(N)
    A.forEachIndexed { n, a ->
        ans[n] = if (a == first) second else first
    }
    println(ans.joinToString("\n"))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun nextLong() = java.lang.Long.parseLong(next())
fun nextLong(offset: Long = 0L) = nextLong() + offset
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }
fun listOfLong(offset: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + offset }
fun listOfDouble() = listOfString().map { it.toDouble() }


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

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>

#define ll long long
#define ull unsigned long long

using namespace std;

typedef pair<int,int> P;

const int INF = 100100100;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
	//標準入力を登録
	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	for (int ii = 0; ii < H; ++ii){
		cin >> s[ii];
	}

	//処理実行
	int maxScore = 0;
	for (int a = 0; a < H; ++a){
		for (int b = 0; b < W; ++b){
			//スタート位置を(a,b)とする
			if (s[a][b] == '#'){
				continue;
			}
			//準備
			vector < vector<int> > dist(H, vector<int>(W, INF));
			queue<P> q;

			//スタート位置をキューに入れる
			dist[a][b] = 0;
			q.push(P(a,b));

			//隣接マスがなくなるまで処理実行
			while (!q.empty()) {
				int aa = q.front().first;
				int bb = q.front().second;	q.pop();
				for (int ii = 0; ii < 4; ++ii){
					int aaa = aa + di[ii];
					int bbb = bb + dj[ii];
					//範囲外だったら何もしない
					if (aaa<0||aaa>=H||bbb<0||bbb>=W){
						continue;
					}
					//壁だったら何もしない
					if (s[aaa][bbb] == '#'){
						continue;
					}
					//すでに訪れていないときだけ処理実行
					if (dist[aaa][bbb] == INF){
						dist[aaa][bbb] = dist[aa][bb] + 1;
						maxScore = max(maxScore, dist[aaa][bbb]);
						q.push(P(aaa,bbb));
					}
				}
			}

		}
	}

	cout << maxScore << endl;

	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> S(N);
  for(int i=0; i<N; i++){
    cin >> S.at(i);
  }
  
  int ans = 0;
  int sum = 0;
  
  for(int i=0; i<N; i++){
    sum += S.at(i);
  }

  if(sum % 10 != 0){
    ans = sum;    
  }
  else{
    int odd = sum;
    for(int i=0; i<N; i++){
      if(S.at(i) % 10 != 0 && S.at(i) < odd){
        odd = S.at(i);
      }
    }
    if(odd != sum){
      ans = sum - odd;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> a;
	for(int i = 0; i < N; i++) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	vsort_r(a);
	int alice = 0;
	int bob = 0;
	for(int i = 0; i < N; i++) {
		if(i % 2 == 0) alice += a[i];
		else bob += a[i];
	}

	cout << alice - bob << endl;
}


Measured memory_bytes: 256
import math

mod = 10**9+7
N,M,K = map(int, input().split())
MAX = min(N*M,mod)

facts = [1 for i in range(MAX)]
invs = [1 for i in range(MAX)]

def inv(x):
	return pow(x,mod-2,mod)

for i in range(1,MAX):
    facts[i] = (facts[i-1] * i)% mod
    invs[i] = inv(facts[i])

def nCr(n,r):
	return facts[n] * invs[r] * invs[n-r] % mod

def main():
    ans = 0
    complement = nCr((N*M-2)%mod,(K-2)%mod)
    for i in range(1,N):
        ans += i * (N-i) * M**2
    for i in range(1,M):
        ans += i * (M-i) * N**2
    print((ans*complement) % mod)

main()


Measured memory_bytes: 18928
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a!=b&&b==c&&a!=c)
		cout<<a;
	if(a!=b&&b!=c&&a==c)
		cout<<b;
	if(a==b&&b!=c&&a!=c)
		cout<<c;
	return 0;
} 

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

int main() {
    string s;
    cin >> s;
    bool f[26];

    for (int i = 0; i < 26; i++) {
        f[i] = false;
    }

    int len = s.length();
    for (int i = 0; i < len; i++) {
        f[s[i] - 'a'] = true;
    }

    bool g = false;
    for (int i = 0; i < 26; i++) {
        if (f[i] == false) {
            printf("%c\n", i + 'a');
            g = true;
            break;
        }
    }
    if (!g) {
        cout << "None" << endl;
    }
    
}

Measured memory_bytes: 512
#include<bits/stdc++.h>//1[max=a,now=b] 2[now=c] 
using namespace std;
int main(){
	int a,b,c;
	int ans;
	cin>>a>>b>>c;
	ans=c-(a-b);
	if(ans<=0) ans=0;
	cout<<ans<<endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  ll k;
  cin >> s >> k;
  if((int)s.size() == 1) {
    cout << k / 2 << endl;
    return 0;
  }

  ll res = 0;
  ll res1 = 0;
  ll left = 0;
  ll right = 0;
  bool flag = true;
  REP(i, (int)s.size() - 1) {
    if(s[i] == s[i + 1]) {
      if(flag) left++;
      res1++;
    } else {
      if(res1 > 0 && !flag) res += (res1 % 2 == 0 ? res1 / 2 : (res1 + 1) / 2);
      flag = false;
      res1 = 0;
    }
  }
  if(res1 == (int)s.size() - 1) {
    if(res1 % 2 == 0) {
      ll res2 = (res1 + 1) * (k / 2);
      cout << (k % 2 == 0 ? res2 : res2 + res1 / 2) << endl;
    } else {
      cout << (res1 + 1) / 2 * k << endl;
    }
    return 0;
  }
  right = res1;
  res *= k;
  if(s[0] == s.back()) {
    if(left > 0) res += (left % 2 == 0 ? left / 2 : (left + 1) / 2);
    if(right > 0) res += (right % 2 == 0 ? right / 2 : (right + 1) / 2);
    ll buf = left + right + 1;
    res += (buf % 2 == 0 ? buf / 2 : (buf + 1) / 2) * (k - 1);
  } else {
    if(left > 0) res += (left % 2 == 0 ? left / 2 : (left + 1) / 2) * k;
    if(right > 0) res += (right % 2 == 0 ? right / 2 : (right + 1) / 2) * k;
  }
  // cout << left << " " << right << endl;
  cout << res << endl;
  return 0;
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    double answer = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i >= k)
        {
            answer++;
            continue;
        }
        double j = i;
        while (j < k)
        {
            j *= 2;
        }
        answer += 1 / (j / i);
    }
    answer /= n;
    cout << setprecision(20) << answer << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    while (true)
    {
        c -= b;
        if (c <= 0)
            break;
        a -= d;
        if (a <= 0)
            break;
    }

    if (a > 0)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3612
import java.util.*

fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val (n, m) = sc.intList()
        val edges = Array(n) { mutableListOf<E>() }
        for (i in 0 until m) {
            val l = sc.nextInt() - 1
            val r = sc.nextInt() - 1
            val d = sc.nextInt()
            edges[l].add(E(r, d))
            edges[r].add(E(l, -d))
        }

        val ans = Array(n) { Long.MAX_VALUE }
        for (i in 0 until n) {
            if (ans[i] != Long.MAX_VALUE) continue
            val q = ArrayDeque<Int>()
            q.add(i)
            ans[i] = 0
            while (q.any()) {
                val pop = q.pop()
                for (j in edges[pop].indices) {
                    val to = edges[pop][j]
                    if (ans[to.R] == Long.MAX_VALUE) {
                        ans[to.R] = ans[pop] + to.D
                        q.add(to.R)
                    } else {
                        if (ans[pop] + to.D != ans[to.R]) {
                            println("No")
                            return
                        }
                    }
                }
            }
        }

        for(i in edges.indices){
            for(j in edges[i].indices){
                val e = edges[i][j]
                if(ans[i] + e.D != ans[e.R]){
                    println("No")
                    return
                }
            }
        }

        println("Yes")
    }
}

data class E(val R: Int, val D: Int)

class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

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

int  main()
{
	long x,t; cin >> x >> t;

	if (x >= t)
		cout << x - t << endl;
	else
		cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
/* ****GT_18**** */

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define INF			1000000000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
using namespace __gnu_pbds;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n;
		cin>>n;
		ll x,m;
		cin>>x>>m;
		vi mods;
		mods.pb(x);
		bool used[m+1];
		memset(used,0,sizeof(used));
		used[x]=1;
		ll ans=x;
		rep(i,2,n+1){
			ll curr = mods.back();
			ll newval = (curr*curr) %m;
			if(used[newval]){
				ll len = 0;
				ll cyclesum = 0;
				bool f=0;
				rep(j,0,sz(mods)){
					if(mods[j]==newval){
						len = sz(mods)-j;
						f=1;
					}
					if(f)cyclesum+=mods[j];
				}
				ll rem = n-i+1;
				ll fullcycles = rem/len;
				ll left  = rem%len;
				ans+=fullcycles*cyclesum;
				ll st = sz(mods)-len;
				while(left--){
					ans+=mods[st++];
				}
				break;

			}
			else{
				mods.pb(newval);
				used[newval]=1;
				ans+=newval;
			}
		}	
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 			1000000007
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl 			'\n'
#define inf 			1e18
#define fi 				first
#define se 				second

int XX[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int YY[8]={+1, 0, -1, +1, -1, +1, 0, -1};
int dx[4]={-1,1,0,0};
int dy[4]={0,0,1,-1};


signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	int n,x,t;
	cin>>n>>x>>t;

	if(n%x==0){
		cout<<(n/x)*t<<endl;
	}else{
		if(n<x){
			cout<<t<<endl;
		}else{
			int cnt=1;
			while(n>x){
				cnt++;
				n-=x;
			}

			cout<<cnt*t<<endl;
		}
	}


	return 0;
}

Measured memory_bytes: 3644