akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <sstream>

using namespace std;
typedef long long ll;


int main(){
    int N;
    int joho[15][29] = {0};
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> joho[i][0];
        for (int j = 1; j <= joho[i][0] * 2; j++) {
            cin >> joho[i][j];
        }
    }
    int M = 0;
    for (int bit = 0; bit < (1<<N); bit++) {
        // cout << N << endl;
        // cout << bit << endl;
        int owari = 0;
        for (int n = 0; n < N; n++) {
            if (!(bit>>n & 1)) {
                continue;
            }
            for (int a = 1; a <= joho[n][0] * 2; a += 2) {
                if (((bit>>joho[n][a]-1) & 1) != joho[n][a+1]) {
                    owari = 1;
                } else {
                    // cout << bit << ' '<< n << ' ' << a << ' ' << ((bit>>joho[n][a]-1) & 1) << ' ' << joho[n][a+1] << endl;
                }
                if (owari) break;
            }
            if (owari) break;
        }
        if (!owari) {
            int shojiki = 0;
            for (int x = 0; x < N; x++) {
                if (bit & 1<<x) {
                    shojiki++;
                    // cout << bit << endl;
                }
            }
            M = max(shojiki, M);
        }
    }
    cout << M << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int main(){
  int n;
  double p1x=0.0,p1y=0.0,p2x=100.0,p2y=0.0;
  scanf("%d",&n);
  printf("%f %f\n",p1x,p1y);
  cla(p1x,p1y,p2x,p2y,n);
  return 0;
}

int cla(double p1x,double p1y,double p2x,double p2y,int n){
  double c=M_PI/3;
  double sx,sy,tx,ty,ux,uy;

  if(n==0){
    printf("%f %f\n",p2x,p2y);
    return 0;
  }

  else{
  sx=((p2x-p1x)/3)+p1x;
  sy=((p2y-p1y)/3)+p1y;

  tx=((p2x-p1x)*2/3)+p1x;
  ty=((p2y-p1y)*2/3)+p1y;

  ux=(cos(c)*(tx-sx)-sin(c)*(ty-sy))+sx;
  uy=(sin(c)*(tx-sx)+cos(c)*(ty-sy))+sy;

  cla(p1x, p1y, sx, sy, n-1);
  cla(sx, sy, ux, uy, n-1);
  cla(ux, uy, tx, ty, n-1);
  cla(tx, ty, p2x, p2y, n-1);
  }
 
}

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

class Solve {
private:
	using vc = std::vector<char>;
	using vvc = std::vector<vc>;

public:
	bool is_last_query{};
	Solve()
	{
		std::string S;
		std::cin >> S;
		if (S == "#")
		{
			is_last_query = true;
			return;
		}

		vvc board(1);
		for (auto& e: S)
		{
			if (e == '/') board.push_back({});
			else if (e == 'b') board.back().push_back('#');
			else
			{
				for (int i{}; i < e - '0'; i++)
					board.back().push_back('.');
			}
		}
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		a--; b--; c--; d--;
		board[a][b] = '.';
		board[c][d] = '#';

		std::string jfen;
		for (auto& e: board)
		{
			jfen += '/';
			for (auto& f: e)
			{
				if (f == '.')
				{
					if ('0' <= jfen.back() && jfen.back() <= '9')
						jfen.back()++;
					else
						jfen.push_back('1');
				}
				else
					jfen.push_back('b');
			}
		}
		for (int i{1}; i < (int)jfen.size(); i++)
			putchar(jfen[i]);
		putchar('\n');
	}
};

int main()
{
	while (!Solve().is_last_query);

	return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N; cin >> N;
    ll ans = N*(N-1)/2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// Aizu Vol-3 0319: Programming Contest
// 2017.8.25

#include <stdio.h>
#include <stdlib.h>

int p[103];

int cmp(int *a, int *b) { return *b - *a; }

int main()
{
	int N, i;

	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d", p + i);
	qsort(p, N, sizeof(p[0]), cmp);
	for (i = 0; i < N; i++) if (p[i] <= i)  break;
	printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 600
while True:
    H,W = [int(x) for x in input().split()]
    if(H,W) == (0,0):break
    
    for i in range(H):
        for j in range(W):
            if i == 0 or i == H-1 or j == 0 or j ==W-1: 
                print('#',end='')
            else:
                print('.', end='')
        print('')
        
    print('')


Measured memory_bytes: 7020
'use strict';
(function(stdin) {
  var inputs  = stdin.toString();
  var flines = inputs.split('\n')[0].split(' ').map(Number);
  var a = flines[0];
  var b = flines[1];
  var area = a * b;
  var periphery = 2 * (a + b);

  console.log(area,periphery);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7376
#include <bits/stdc++.h>
using namespace std;
/*
int main() {
  int n, k, ans(0);
  n = 3;
  k = 200;
  vector<long long> rec(k + 1, 1);
  //unordered_map<int, int> rec;
  for (int i = 1; i < n; ++i) {
    vector<long long> nr(k + 1);
    for (int j = 1; j <= k; ++j) {
      for (int x = 1; x <= k; ++x) {
          nr[gcd(x, j)] += rec[x];
        }
  	}
    swap(nr, rec);
  }
  for (int x = 1; x <= k; ++x) {
    ans += x * rec[x];
  }
  cout << ans << '\n';
  return 0;
}
*/
const int mod = 1e9 + 7;

long long my_pow(long long a, long long b) {
    long long ans(1);
    long long base(1);
    while (b) {
        if (b % 2) {
            ans *= a;
            ans %= mod;
        }
        a *= a;
        a %= mod;
        b /= 2;
    }
    return ans;
}

vector<int> p(int n) {
    vector<int> ans(n + 1);
    ans[0] = ans[1] = 1;
    for (int i = 2; i <= n; ++i) {
        if (ans[i]) continue;
        for (int j = 2 * i; j <= n; j += i) {
            ans[j] = 1;
        }
    }
    vector<int> ps;
    for (int i = 2; i <= n; ++i)
        if (ans[i] == 0) ps.push_back(i);
    return ps;
}

vector<long long> etf(int n) {
    vector<int> primes = p(n);
    vector<long long> ans(n + 1);
    for (int i = 1; i <= n; ++i) {
        ans[i] = i;
        for (int p: primes) {
            if (p > i) break;
            if (i % p == 0) {
                ans[i] /= p;
                ans[i] *= (p - 1);
            }
        }
    }
    return ans;
}

int main() {
    int n, k;
    cin >> n >> k;
    long long ans(0);
    vector<long long> g = etf(k);
    for (int i = 1; i <= k; ++i) {
        ans += my_pow(k / i, n) * g[i] % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3964
#include <iostream>
#include<algorithm>
#include<vector> //動的配列
#include<string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, int> P;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}


int s;
const int mod=10;


int main(){
    cin>>s;
    int ans=10e8;
    for (int i=1;i+i<=s;i++){
        int a=i;
        int sum=0;
        int b=s-i;
        while(a>0){
            sum+=a%mod;
            a/=mod;
        }
        while(b>0){
            sum+=b%mod;
            b/=mod;
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void){
	int lis[10];
	int i = 0;
	int j = 0;
	int n = 0;
	for(i = 0;i != 10;i++){
		scanf("%d",&lis[i]);
	}
	for(i = 0;i != 10;i++){
		for(j = 0;j != 9;j++){
			if(lis[j]>lis[j+1]){
				n = lis[j];
				lis[j] = lis[j+1];
				lis[j+1] = n;
			}
		}
	}
	printf("%d\n",lis[9]);
	printf("%d\n",lis[8]);
	printf("%d\n",lis[7]);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };

struct dice{
	int face[6];
	int top;
	int front;
	int right;
	int left;
	int back;
	int bottom;
	int n;
	void init(){
		top=face[0];
		front=face[1];
		right=face[2];
		left=face[3];
		back=face[4];
		bottom=face[5];
	}
	void spin(char x){
		if(x=='E'){
			n=top;
			top=left;
			left=bottom;
			bottom=right;
			right=n;
		}
		if(x=='W'){
			for(int i=0;i<3;i++){
				spin('E');
			}
		}
		if(x=='S'){
			n=top;
			top=back;
			back=bottom;
			bottom=front;
			front=n;
		}
		if(x=='N'){
			for(int i=0;i<3;i++){
				spin('S');
			}
		}
		if(x=='R'){
			n=front;
			front=left;
			left=back;
			back=right;
			right=n;
		}
	}
	bool check(dice P){
		if(P.top!=top) return false;
		if(P.front!=front) return false;
		if(P.right!=right) return false;
		if(P.left!=left) return false;
		if(P.back!=back) return false;
		if(P.bottom!=bottom) return false;
		return true;
	}

};

int main() {
	int n;
	bool f;
	cin>>n;
	dice p[110];
	for(int i=0;i<n;i++){
		for(int j=0;j<6;j++){
			cin>>p[i].face[j];
		}
		p[i].init();
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<4;j++){
			p[0].spin('R');
			f=p[0].check(p[i]);
			if(f){
				cout<<"No"<<endl;
				return 0;
			}
		}
		p[0].spin('E');
		for(int j=0;j<4;j++){
			p[0].spin('R');
			f=p[0].check(p[i]);
			if(f){
				cout<<"No"<<endl;
				return 0;
			}
		}
		p[0].spin('W');
		p[0].spin('W');
		for(int j=0;j<4;j++){
			p[0].spin('R');
			f=p[0].check(p[i]);
			if(f){
				cout<<"No"<<endl;
				return 0;
			}
		}
		p[0].spin('E');
		p[0].spin('N');
		for(int j=0;j<4;j++){
			p[0].spin('R');
			f=p[0].check(p[i]);
			if(f){
				cout<<"No"<<endl;
				return 0;
			}
		}
		p[0].spin('S');
		p[0].spin('S');
		for(int j=0;j<4;j++){
			p[0].spin('R');
			f=p[0].check(p[i]);
			if(f){
				cout<<"No"<<endl;
				return 0;
			}
		}
		p[0].spin('S');
		for(int j=0;j<4;j++){
			p[0].spin('R');
			f=p[0].check(p[i]);
			if(f){
				cout<<"No"<<endl;
				return 0;
			}
		}
		p[0].spin('N');
		p[0].spin('N');
	}
	cout<<"Yes"<<endl;
}

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

int main(){
	int N;
	string S;
	cin >> N >> S;
	int ans[N+1] = {0};
	for(int i = 0; i < N; i++){
		if(S.at(i) == '#')
			ans[N]++;
	}
	for(int i = N-1; i >= 0; i--){
		if(S.at(i) == '.')
			ans[i] = ans[i+1]+1;
		else
			ans[i] = ans[i+1]-1;
	}
	sort(ans,ans+N+1);
	cout << ans[0] << endl;
	return 0;
}

Measured memory_bytes: 1412
n = gets.to_i
s2 = Hash.new(0)
n.times{s2[gets.chomp] += 1}

m = gets.to_i
t2 = Hash.new(0)
m.times{t2[gets.chomp] += 1}

max = 0
s2.each{|k, v|
    plusminus = v - t2[k]
    max = plusminus if max < plusminus
}
puts max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc141_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, K, Q;
  cin >> N >> K >> Q;

  map<int, int> m;
  rep(i, Q) {
    int a;
    cin >> a;
    a--;
    m[a]++;
  }

  rep(i, N) {
    ll ans = m[i];
    string ret = "No";
    if (K - Q + ans > 0) ret = "Yes";
    cout << ret << endl;
  }

}

Measured memory_bytes: 5376
using System;
using System.Text.RegularExpressions;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] data = Console.ReadLine().Split(' ');
                int h = Convert.ToInt32(data[0]);
                int w = Convert.ToInt32(data[1]);

                if (h == 0 && w == 0) { break; }

                bool flag = true;
                for (int x = 0; x < h; x++)
                {
                    if (flag)
                    {
                        string sharp = new string('#', w);
                        Console.WriteLine(Regex.Replace(sharp, "##", "#."));
                    }
                    else
                    {
                        string sharp = new string('.', w);
                        Console.WriteLine(Regex.Replace(sharp, "..", ".#"));
                    }

                    flag = !flag;
                }

                Console.WriteLine(string.Empty);
            }
        }
    }
}

Measured memory_bytes: 11748
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    lint n;
    cin >> n;

    set<lint> st;

    for(lint i = 2 ; i * i <= n ; ++i){
        lint t = i;
        while(t < n){
            t *= i;
        }
        if(t == n){
            st.insert(i);
        }

        lint m = n;
        while(m % i == 0LL){
            m /= i;
        }
        if(m % i == 1LL){
            st.insert(i);
        }

        if((n - 1LL) % i == 0LL){
            st.insert(i);
            st.insert((n - 1LL) / i);
        }
    }
    st.insert(n);
    st.insert(n - 1LL);
    st.erase(1LL);

    cout << st.size() << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 256
N=input()
a=[tuple( map(int,raw_input().split()) ) for i in range(N-1)]

for i in range(N-1):
	val=0
	for c,s,f in a[i:]:
		if val<=s:
			val=s+c
		else:
			if val%f==0:
				val=f*(val/f)
			else:
				val=f*((val/f)+1)
			val+=c

	print val
print 0


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second
#define pii pair<ll , ll>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;
int add(int a , int b)
{
	return a + b >= mod ? a + b - mod : a + b;
}
int mult(int a , int b)
{
	return a * (ll)b % mod;
}

int fact[100005];
int inv[100005];
int a(int x , int y)
{
	return mult(fact[x] , inv[y]);
}
int modPow(int a , int step)
{
	int ans = 1;
	while(step)
	{
		if(step & 1)
			ans = mult(ans , a);
		a = mult(a , a);
		step >>= 1;
	}
	return ans;
}
int main()
{
	fact[0] = inv[0] = 1;
	for(int i = 1; i <= 100000; i++)
	{
		fact[i] = mult(fact[i - 1] , i);
		inv[i] = modPow(fact[i] , mod - 2);
	}
	int n;
	cin >> n;
	vector<int> x(n);
	for(int i = 0; i < n; i++)
		cin >> x[i];
	int dp = 0 , fct = 1 , ans = 0;
	for(int j = 1; j < n; j++)
	{
		dp = add(mult(j , dp) , fct);
		fct = mult(fct , j);
		ans = add(ans , mult(x[j] - x[j - 1] , mult(dp , a(n - 1 , j))));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1408
N = int(input())
a = list(map(int,input().split()))
s = [0]*(len(a)+1)
for i in range(len(a)):
    s[i+1] = s[i] + a[i]
b = {}
for x in s:
    if str(x) not in b:
        b[str(x)] = 1
    else:
        b[str(x)] += 1
n = 0
for x in b:
    n += b[x]*(b[x]-1)/2
print(int(n))

Measured memory_bytes: 52488
N = int(input())
A=[]
S={}
for i in range(N):
    a = list(input())
    a.sort()
    b = ''.join(a)
    if b not in S:
        S[b] = 1
    else:
        S[b] += 1


count=0
for i in S.values():
    if i==1:
        continue
    count += i*(i-1)//2
print(count)

Measured memory_bytes: 17808
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){

ll no;
cin>>no;
ll arr[2*no];
for(int i=0;i<2*no;i++) 
  cin>>arr[i];
 sort(arr,arr+2*no);
 ll sum=0;
 for(int i=0;i<2*no;i+=2) 
   sum+=arr[i];
    cout<<sum;

    return 0;
}


Measured memory_bytes: 3588
#include <cstdio>
#include <algorithm>
using namespace std;
#define fup(i,a,b) for(int i=a;i<=b;i++)
typedef long long LL;
inline int read()
{
    int X=0,w=1; char ch=0;
    while(ch<'0' || ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0' && ch<='9') X=(X<<3)+(X<<1)+ch-'0',ch=getchar();
    return X*w;
}
const int N = 1000005;
const int mo = 998244353;
int n,m,sum,fac[N],inv[N];
inline int C(int n,int m){ return 1LL*fac[n]*inv[m]%mo*inv[n-m]%mo; }
int main()
{
    n = read(),m = read();
    if(n<m) swap(n,m);
    fac[0] = fac[1] = inv[0] = inv[1] = 1;
    fup(i,2,n+m) 
    {   
        fac[i] = 1LL*fac[i-1]*i%mo;
        inv[i] = 1LL*(mo-mo/i)*inv[mo%i]%mo;
    }
    fup(i,2,n+m) inv[i] = 1LL*inv[i]*inv[i-1]%mo;
    fup(i,1,m) sum = (1LL*C(i<<1,i)*C(n+m-(i<<1),n-i)+sum)%mo;
    printf("%d",(1LL*sum*inv[2]%mo*inv[n+m]%mo*fac[n]%mo*fac[m]+n)%mo);
    return 0;
}

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

int main() {
  int N, M, L, R, max_l = 1, min_r = 100000;
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (int i=0; i<M; i++)  {
	cin >> L >> R;
    max_l = max(max_l, L);
    min_r = min(min_r, R);
  }
  cout << max(min_r - max_l + 1, 0) << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <queue>

#define gc (c = getchar())
#define gi(x) scanf("%d",&x)
#define gid(x, y) scanf("%d%d",&x,&y)
#define gll(x) scanf("%lld",&x);

#define pi(x) printf("%d\n",&x)

#define pll(x) printf("%lld\n",&x)
#define dbg(x) std::cerr << #x << " " << x << std::endl

inline long long max(long long x, long long y) { return x > y ? x : y; }

inline long long min(long long x, long long y) { return x > y ? y : x; }

int main(){
    long long a,b,c;
    std::cin >> a >> b >>c;
    std::cout << (c > (a - b)? c - a + b : 0 ) <<std::endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from sys import stdin


def solve(tc):
    x = int(stdin.readline().strip())
    div = x // 100
    mod = x % 100

    if div >= 20 or div*5>=mod:
        print(1)
        return

    print(0) 


LOCAL_TEST = not __debug__
if LOCAL_TEST:
    infile = __file__.split('.')[0] + "-test.in"
    stdin = open(infile, 'r')

tcs = (int(stdin.readline().strip()) if LOCAL_TEST else 1)
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

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

using namespace std;

int main(void) {
	int A, B, C;
	string ans;
	cin >> A >> B >> C;
	ans = "No";
	if (A <= C && C <= B) {
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char str[1000005];
struct node{
	int l,r;
	bool operator <(node b)const{
		//原来是从大轮到小。 
		//return 0:前者大于后者，前者置前。
		//return 1:后者置前 
	//if(l==b.l) return r<b.r;
	//else return l>b.l;
		//return r-l<b.r-b.l;
		if(r-l>=0) {
			if(b.r-b.l<=0) return 0;
			else return b.l<l;
		}
		else if(r-l<=0) {
			if(b.r-b.l>=0) return 1;
			else return b.r>r;
		} 
	}
};
int main(){
	int n;
	scanf("%d",&n);
	getchar();
	priority_queue<node>pq;
	for(int i=1;i<=n;i++) {
		fgets(str,1000005,stdin);
		str[strlen(str)-1]='\0';
		int l=0,r=0;
		for(int j=0;j<strlen(str);j++){
			if(str[j]=='('){
				r++;
			}
			else{
				if(r!=0) r--;
				else l++;
			}
		}
		if(l==0&&r==0) continue;
		pq.push(node{l,r});
	}
	int l=0,r=0;
	if(pq.empty()){
		printf("Yes\n");
		return 0;
	}
	node cur=pq.top();
	pq.pop();
	//printf("%d %d\n",cur.l,cur.r);
	l=cur.l,r=cur.r;
	while(!pq.empty()){
		cur=pq.top();
		pq.pop();
		//printf("%d %d\n",cur.l,cur.r);
		int tl=cur.l,tr=cur.r;
		if(r>tl) {
			r-=tl;
			r+=tr;
		}
		else {
			l+=(tl-r);
			r=tr;
		}
		if(l!=0) break;
	}
	if(r==0&&l==0) printf("Yes\n");
	else printf("No\n");
} 

Measured memory_bytes: 11572
#include<bits/stdc++.h>
#include<iostream>
#define ll long long 
#define ld long double
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define sz(v) sizeof(v)
#define MOD 1000000007
#define MAX (ll)1e12+5


using namespace std;


int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
//////
// prime Seive
/*
bitset<1000005> bt;
//unordered_map<ll,bool> is_prime;
vector<ll> primes;
void pS(ll n){
    ll val = min(n+1,(ll)1000006);
    for(ll i=3;i<=val;i+=2){
        bt[i] =true;
    }
    bt[0] =false;
    bt[1] =false;
    bt[2] =false;
    //is_prime[2] =true;
    primes.pb((ll)2);
    for(ll i=3;i<=val;i+=2){
        if(bt[i])
            for(ll j=i*i;j<=val;j+=2*i)
                bt[j] =false;
    }
    for(ll i=3;i<=val;i+=2){
        if(bt[i]){primes.pb(i);
        //is_prime[i]=true;
        //cout<<i<<" :PRIME\n";
        }
    }
    return;
}
*/          
/////
// Fenwick Tree
/*
BIT[200005] ={0};
//BUILD BIT
// for(int i=1;i<1;i++){ cin>>a[i];update(i,a[i],n);};
 
void update(int i,int val,int n){
    while(i<=n){
    BIT[i]+= inc;
    i+= (i&(-i));
    }
}
ll query(int i){
    ll ans =0;
    while(i>0){
        ans+= BIT[i];
        i-=(i&(-i));
    }
    return ans;
}
 
*/
//__builtin_popcount(4)
ll logPow(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1){
            ans*=a;
        }
        a*=a;
        b= b>>1;
    }
    return ans;
}

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



/*
// dsu
const int N = 500009;
int p[N],cmp[N];
int getP(int cn){
    return ((cn==p[cn])?cn:(p[cn]=getP(p[cn])));
}

void unite(int a,int b){
    a = getP(a);
    b = getP(b);
    if(a==b) return ;
    if(cmp[a]<cmp[b])
        swap(a,b);
    p[b] = a;
    cmp[a] += cmp[b];
}
*/

/*
//dfs
bool dfs(ll src ,ll dest,unordered_map<ll,bool> &vis,unordered_map<ll,vector<ll>> &g){
    vis[src] =true;
    if(src== dest) return true;
    bool  ans =false;
    for(auto nbr: g[src]){
        if(!vis[nbr])
            ans = ans|dfs(nbr,dest,vis,g);
    }
    return ans;
}

*/
// bfs
/*
ll bfs(ll i,unordered_map<ll,bool> &vis){
    queue<ll> q;q.push(i);vis[i] =true;ll ans =0;
    while(!q.empty()){
        ans++;ll cur = q.front();q.pop();
        for(auto nbr: g[cur]){
            if(!vis[nbr]){
                vis[nbr] =true;q.push(nbr);
    }}}
    return ans;
}
*/

unordered_map<ll,vector<ll>> g;

ll modPow(ll a,ll b){
    ll ans =1;
    while(b>0){
        if(b&1){
            ans*=a;
            ans= (ans+MOD)%MOD;
        }
        a*=a;
        a= (a+MOD)%MOD;
        b = b>>1;
    }
    return  ans;
}


int main(){
    ll t=1; 
    //cin>>t;
    while(t--){
        ll a; cin>>a;
        cout<<a+a*a+a*a*a<<"\n";
    }
    return 0;
}

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

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

    while(A>0&&C>0){
        C-=B;
        A-=D; 
    }
    if(A<=0&&C<=0){
        cout<<"Yes"<<endl;
    }
    else if(A<=0){
        cout<<"No"<<endl;
    }
    else if(C<=0){
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3592
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,c,i;(n=s.nextInt())>0;System.out.println(c-1)){for(a=new int[n*n],l=a.clone(),i=0;i<n*n;)a[i++]=s.nextInt()+s.nextInt()*n;for(c=1;i-->0;)if(f(a[i],c)==c)l[i]=f(a[i],c++);}}static int[]l,a;static int f(int x,int c){return l[x]>0?l[x]:(l[x]=f(a[x],l[x]=c));}}

Measured memory_bytes: 13000
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int sg (int n,int k)
{
	if (n< k) return 0;
	if (n%k==0) return n/k;
	int x=n/k,m=x*k,y=(n-m)/(x+1);
	if (n-y*(x+1)==m) return x;
	return sg (n-(y+1)*(x+1),k);
}
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int T,ans=0; sc(T);
	while (T--)
	{
		int n,k; sc(n),sc(k);
		ans^=sg (n,k);
	}
	puts(ans?"Takahashi":"Aoki");

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
hList = list(map(int, input().split()))
ans = 0
dp = [0] * N
dp[0] = 0

for i in range(1, N):
    minT = 1000000000
    for j in range(i - 1, i - K - 1, -1):
        tmp = dp[j] + abs(hList[j] - hList[i])
        minT = min(minT, tmp)
        if j == 0:
            break
    dp[i] = minT

print(dp[N - 1])

Measured memory_bytes: 52448
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


int main(){
    int N;cin>>N;
    map<long,long>mp;
    REP(i,N){
        long A;
        cin>>A;
        mp[A]++;
    }
    vector<LL>p;
    p.PB(0);p.PB(0);
    for(auto itr:mp){
        if(itr.second>=2)p.PB(itr.first);
        if(itr.second>=4)p.PB(itr.first);
    }
    sort(p.begin(),p.end(),greater<long>());
    cout<<p[0]*p[1]<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int nums[10000];
	int n, size, half;
	while(scanf("%d", &n), n){
		size = 0;
		half = (n-1) / 2;
		reep(i, 1, n)
			nums[size++] = (i*i) % n;

		sort(nums, nums + size);
		size = distance(nums, unique(nums, nums + size));

		vi ans(half+1, 0);
		rep(i, size){
			rep(j, i+1){
				int p = abs(nums[i]-nums[j]);
				if(p>half) p = n - p;
				++ans[p];
			}
		}
		reep(i, 1, half+1)
			printf("%d\n", ans[i]*2);
	}

	return 0;
}

Measured memory_bytes: 868
import java.io.*;
import java.util.*;
import java.lang.*;

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

		int arr[] = new int[5];

		for(int i = 0;i<5;i++)
		{
			arr[i] = sc.nextInt();
		}	

		int index = 0;

		for(int i = 0;i<5;i++)
		{
			if(arr[i] == 0)
			{
				index = i;
				break;
			}
		}

		out.println(index + 1);
		out.flush();
	}
}

Measured memory_bytes: 27124
#include <bits/stdc++.h>
#include <atcoder/all>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
	if (ref < value) ref = value;
}

using namespace atcoder;

const ll mod = 998244353;

ll mpow(ll x, ll n) {
    ll ans = 1; x %= mod;
    while (n != 0) {
        if (n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return ans;
}

ll op(ll a, ll b) {
    return max(a, b);
}

ll e() {
    return 0;
}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> as(n);
    rep(i, n) cin >> as[i];
    segtree<ll, op, e> tree(300010);
    tree.set(as[0], 1);
    for (int i = 1; i < n; i++) {
        ll a = as[i];
        ll left = max(0LL, a - k);
        ll right = min(300000LL, a + k);
        ll p = tree.prod(left, right+1);
        //cout << i << "," << left << "," << right << "," << a << "," << p << endl;
        tree.set(a, p + 1);
    }
    auto ans = tree.prod(0, 300000);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 16216
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<int, int> P;

int N, M;
std::string A[51], B[51];

int main()
{
	in >> N >> M;
	rep(i, N) { in >> A[i]; }
	rep(i, M) { in >> B[i]; }

	rep(x, (N - M) + 1)
	{
		rep(y, (N - M) + 1)
		{
			bool same_flag = true;
			for (int i = 0; i < M; ++i)
			{
				for (int j = 0; j < M; ++j)
				{
					if (A[x + i][y + j] != B[i][j])
					{
						same_flag = false;
						break;
					}
				}
				if (same_flag == false)
				{
					break;
				}
			}
			if (same_flag == true)
			{
				out << "Yes" << std::endl;
				return 0;
			}
		}
	}
	out << "No" << std::endl;
	return 0;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
t=[0]
x = [0]
y = [0]

for i in range(n):
    a,b,c = list(map(int,input().split()))
    t.append(a)
    x.append(b)
    y.append(c)

flag = True
for i in range(1,n+1):

    if (t[i]-t[i-1])%2 != (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2 or (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))>t[i]-t[i-1]:
        flag = False


if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 91980
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n, k;
    cin >> n >> k;
    vector<P> a(n);
    rep(i, n){
        int t, d;
        cin >> t >> d;
        a[i] = {d, t};
    }
    sort(ALL(a), greater<P>());

    priority_queue<int, vector<int>, greater<int>> pq;
    set<int> s;
    int ans = 0;
    int kind = 0;
    for(int i = 0; i < k; i++){
        ans += a[i].first;
        if(s.find(a[i].second) != s.end()){
            pq.push(a[i].first);
            continue;
        }
        s.insert(a[i].second);
        kind++;
    }
    ans += kind * kind;

    int tmp = ans;
    for(int i = k; i < n; i++){
        if(pq.empty()){
            break;
        }
        if(s.find(a[i].second) != s.end()){
            continue;
        }
        tmp -= pq.top();
        pq.pop();
        tmp += a[i].first;
        tmp += (kind + 1) * (kind + 1) - kind * kind;
        s.insert(a[i].second);
        kind++;

        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5244
n = int(input())
a = [int(input()) for _ in range(n)]

b = [x for x in a if x % 10]

s = sum(a)

if s % 10:
    print(s)
else:
    if len(b):
        m = min(b)
        print(s-m)
    else:
        print(0)



Measured memory_bytes: 2940
program kadai
implicit none
integer ::  n,i
integer,allocatable :: h(:)


read(*,*) n
allocate(h(n))
read(*,*) h

do i=1,n-1
    if (h(i+1)-h(i)<-1) then
        write(*,*) "No"
        stop
    end if
    if (h(i+1)-h(i)==-1) then
        h(i+1)=h(i+1)+1
    end if
end do

write(*,*) "Yes"


stop

end program kadai

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

using namespace std;

string S;

long long int M = 1000000007;

long long int dp[100005][5];

int main(void) {

	cin >> S;

	int N = S.size();

	S = "#" + S;

	dp[0][0] = 1;

	for (int i = 1; i <= N; i++) {
		if (S[i] == 'A') {
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = (dp[i-1][0] + dp[i - 1][1])%M;
			dp[i][2] = dp[i-1][2];
			dp[i][3] = dp[i - 1][3];
		}
		else if (S[i] == 'B') {
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = dp[i - 1][1];
			dp[i][2] = (dp[i - 1][1] + dp[i - 1][2])%M;
			dp[i][3] = dp[i - 1][3];
		}
		else if (S[i] == 'C') {
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = dp[i - 1][1];
			dp[i][2] = dp[i - 1][2];
			dp[i][3] = (dp[i - 1][2] + dp[i - 1][3]) % M;
		}
		else {
			dp[i][0] = (3 * dp[i - 1][0]) % M;
			dp[i][1] = (dp[i - 1][1]*3+dp[i-1][0]) % M;
			dp[i][2] = (dp[i - 1][2]*3 + dp[i - 1][1]) % M;
			dp[i][3] = (dp[i - 1][3]*3 + dp[i - 1][2]) % M;
		}
	}

	/*int i = 2;
	for (int j = 0; j <= 3; j++) {
		cout << "dp[" << i<<"][" << j<<"]= " <<dp[i][j] << endl;
	}*/

	cout << dp[N][3] << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 4348
#include <vector>
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <unordered_set>

using namespace std;
typedef long long ll;
typedef vector<int> VI;

int main(void)
{
	int n;
	cin >> n;
	vector<double> vs(n);
	for (int i = 0; i < n; i++) {
		cin >> vs[i];
	}
	sort(vs.begin(), vs.end());
	ll sum = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			auto a = vs[i];
			auto b = vs[j];
			auto ab = a + b - 0.01;
			auto f = vs.begin() + j + 1;
			auto u = upper_bound(f, vs.end(), ab);
			sum += u - f;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	H := readInt()
	N := readInt()
	AB := make([]struct{ A, B int }, N)
	for i := 0; i < N; i++ {
		AB[i].A = readInt()
		AB[i].B = readInt()
	}

	dp := make([]int, 100000)
	for i := 0; i < 100000; i++ {
		dp[i] = math.MaxInt64
	}

	dp[0] = 0
	for i := 0; i < H; i++ {
		if dp[i] == math.MaxInt64 {
			continue
		}
		for j := 0; j < N; j++ {
			a := AB[j].A
			b := AB[j].B
			if dp[i]+b < dp[i+a] {
				dp[i+a] = dp[i] + b
			}
		}
	}
	result := math.MaxInt64
	for i := H; i < 100000; i++ {
		if dp[i] < result {
			result = dp[i]
		}
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 1536
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int A, B; cin >> A >> B;
    vector<int> strength = {0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

    if (strength[A] > strength[B]) cout << "Alice" << endl;
    else if (strength[A] == strength[B]) cout << "Draw" << endl;
    else cout << "Bob" << endl;
}


Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun count-ab (s)
  (loop for i from 1 below (length s)
        count (and (char= #\A (aref s (- i 1)))
                   (char= #\B (aref s i)))))
(defun main ()
  (let* ((n (read))
         (pre-b 0)
         (suf-a 0)
         (both 0)
         (res 0))
    (dotimes (i n)
      (let ((line (read-line)))
        (cond ((and (char= #\B (aref line 0))
                    (char= #\A (aref line (- (length line) 1))))
               (incf both))
              ((char= #\B (aref line 0))
               (incf pre-b))
              ((char= #\A (aref line (- (length line) 1)))
               (incf suf-a)))
        (incf res (count-ab line))))
    (let ((bonus 0))
      (incf bonus (min pre-b suf-a))
      (decf pre-b (min pre-b suf-a))
      (decf suf-a (min pre-b suf-a))
      (incf bonus (max 0 (- both 1)))
      (when (and (not (zerop both))
                 (or (not (zerop suf-a)) (not (zerop pre-b ))))
        (incf bonus 1))
      (println (+ res bonus)))))

#-swank(main)


Measured memory_bytes: 22884
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import deque

inf = 10**18
mod = 10**9+7

n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
kind = 0
for k,v in c.items():
    if v%2==0:
        kind+=1
if kind%2==0:
    print(len(c))
else:
    print(len(c)-1)

Measured memory_bytes: 61548
from collections import deque
n,m=map(int,input().split())
l=[[] for _ in range(n)]
edge=[]
ans=0
for _ in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)
  edge.append([a-1,b-1])
for i,j in edge:
  q=deque([i])
  visited=[0]*n
  while q:
    x=q.pop()
    if x==j:
      break
    visited[x]=1
    for k in l[x]:
      if visited[k]==0 and not (x==i and k==j):
        q.append(k)
  else:
    ans+=1
print(ans)

Measured memory_bytes: 3436
def main():
    import sys

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

    n = int(input())
    s = input()
    cnt = [0]
    for i in range(n):
        cnt.append(cnt[-1])
        if s[i] == '#':
            cnt[-1] += 1
    
    m = cnt[-1]
    ans = 10**9
    for i in range(n+1):
        tmp = cnt[i] + (n-i)-(m-cnt[i])
        ans = min(tmp, ans)
    print(ans)


        
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 17024
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){
  long long int H, W, N;
  scanf("%lld%lld%lld", &H, &W, &N);
  
  std::cerr << "Answer: " << std::endl;
  if(H>W){
    std::cout << (N-1)/H + 1;
  }
  else{
    std::cout << (N-1)/W + 1;
  }std::cerr << std::endl;

  return 0;
}


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

#define fs first
#define sc second

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::deque Debug
template<typename T>
ostream& operator<<(ostream& os, const deque<T>& d) {
    os << "[";
    bool a = 1;
    for (auto e : d) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
    int a, b; cin >> a >> b;

    if (abs(a - b) % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (a + b) / 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using namespace std;

#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll mod = (1000000007LL);

inline ll poww(ll a, ll b)
{
    ll res = 1;
    while (b > 0)
    {
        if(b & 1) res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
inline pii operator+(pii A, pii B){
	return pii(A.f + B.f, A.s + B.s);
}
inline pii operator-(pii A, pii B){
	return pii(A.f - B.f, A.s - B.s);
}
inline ll mult(ll a, ll b){
	return (a * b) % mod;
}

ll gcd (ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

/*
	>Colocar (>DEFINE INT LONG LONG<) no inicio do template
	>mod = (1e9 + 7), por padrao (NAO ESQUECER DE ALTERAR)
	>NAO ESQUECER DEFINE INT LONG LONG
	> N = 1 ? 
*/

///CUIDADO COM MAXN
#define N 55

int n, m, q, k, v[N];

pii TT, w[N];
int A[N], B[N], cost[N];
string s;
vector<pii> grafo[N];
vector<pii> edges;
vector<int> path;

void dfs(int x, int p, vector<int> &w){
    w.pb(x);
    for(auto v: grafo[x]){
        if(v.f == p) continue;
        dfs(v.f, x, w);
    }
}
int dp[2][1048580];
int solve(){
    for(int i = n-1; i >= 0; i--){
     for(int mask = (1<<q) - 1; mask >= 0; mask --){
            if(i == n - 1){
                dp[i&1][mask] = (mask == (1<<q) - 1 ? 1 : 0);
            }
            else dp[i&1][mask] = dp[(i+1)&1][(mask|cost[i])] + dp[(i + 1)&1][mask];
        }
    }
    return dp[0][0];
}

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

    cin>>n;
    for(int i = 1, a, b; i < n; i++){
        cin>>a>>b;
        grafo[a].pb({b, i});
        grafo[b].pb({a, i});
        edges.pb({a, b});
    }
    cin>>q;
    for(int i = 0; i < q; i++) cin>>A[i]>>B[i];

    for(int i = 0; i < n - 1; i++){
        vector<int> L, R;
        dfs(edges[i].f, edges[i].s, L);
        dfs(edges[i].s, edges[i].f, R);
        sort(all(L)), sort(all(R));
        for(int j = 0; j < q; j++){
            if(binary_search(all(L), A[j]) and binary_search(all(R), B[j])) cost[i] |= (1<<j);
            if(binary_search(all(R), A[j]) and binary_search(all(L), B[j])) cost[i] |= (1<<j);
        }
    }
    cout<<solve()<<"\n";
}

Measured memory_bytes: 16640