akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const int maxn = (1e5) + 10;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int n;
    cin >> n;
    int odd[maxn],even[maxn];

    REP(i,maxn)
    {
        odd[i] = 0;
        even[i] = 0;
    }

    FOR(i,1,n+1)
    {
        int temp;
        cin >> temp;
        if(i%2 != 0) odd[temp]++;
        else even[temp]++;
    }
    int maxcount1_odd = 0; int maxcount2_odd = 0;
    int maxcount1_even = 0; int maxcount2_even = 0;
    int num1_odd, num2_odd;
    int num1_even, num2_even;

    //first
    REP(i,maxn)
    {
        //odd
        if(odd[i] > maxcount1_odd)
        {
            maxcount1_odd = odd[i];
            num1_odd = i;
        }
        //even

        if(even[i] > maxcount1_even)
        {
            maxcount1_even = even[i];
            num1_even = i;
        }
    }

    odd[num1_odd] = 0;
    even[num1_even] = 0;
    //second

    REP(i,maxn)
    {
        //odd
        if(odd[i] > maxcount2_odd)
        {
            maxcount2_odd = odd[i];
            num2_odd = i;
        }
        //even

        if(even[i] > maxcount2_even)
        {
            maxcount2_even = even[i];
            num2_even = i;
        }
    }
    dump(num1_odd)
    dump(num2_odd)
    dump(num1_even)
    dump(num2_even)

    if(num1_odd != num1_even)
    {
        cout << n - maxcount1_odd - maxcount1_even << endl;
    }
    else
    {
        cout << n - max(maxcount1_odd + maxcount2_even, maxcount1_even + maxcount2_odd) << endl;
    }
}


Measured memory_bytes: 1024
import sys
#import numpy as np
N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
# DP = [1] * (2 * 10 ** 6)
# DP[K - 1] = np.prod(A[0:K])

for i in range(K, N):
    if A[i] / A[i - K] > 1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 31520
samp = input()
samp = samp.split()

a = int(samp[0])
b = int(samp[1])
c = int(samp[2])

samp =[a,b,c]

for i in range(len(samp)):
    current = samp[i]
    j = i-1
    while (j >= 0 and samp[j] >  current):
        samp[j+1] = samp[j]
        j -= 1
    
    samp[j+1] = current
    
print("{} {} {}".format(samp[0],samp[1],samp[2]))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007

using namespace std;

ll n, a, b, c, q, k, d[100005];
vector <pair<ll, ll> > v[100005];
void dfs(ll x, ll p) {
    for (int i = 0; i < v[x].size(); i++) {
        ll u = v[x][i].f, ds = v[x][i].s;
        if (u == p) continue;
        d[u] = d[x] + ds;
        dfs(u, x);
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i < n; i++)
        cin >> a >> b >> c, v[a].pb(mp(b, c)), v[b].pb(mp(a, c));
    cin >> q >> k;
    dfs(k, 0);
    while(q--) {
        ll x, y;
        cin >> x >> y;
        cout << d[x] + d[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int h, w;
	cin >> h >> w;
	vector<vector<char>> grid(h, vector<char>(w));
	rep(i, h) rep(j, w) cin >> grid[i][j];

	// あるマスに行く場合の数
	vector<vector<int>> dp(h, vector<int>(w, 0));

	// (0, 0)から始める
	dp[0][0] = 1;
	// 配るDPにしよう
	rep(i, h) {
		rep(j, w) {
			if (grid[i][j] == '#') continue;
			rep(k, 2) {
				if (i - dy[k] >= 0 && i - dy[k] < h &&
					j + dx[k] >= 0 && j + dx[k] < w) {
					if (grid[i - dy[k]][j + dx[k]] == '.') {
						dp[i - dy[k]][j + dx[k]] += dp[i][j];
						dp[i - dy[k]][j + dx[k]] %= mod;
					}
				}
			}
		}
	}

	/*rep(i, h) {
		rep(j, w) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/

	cout << dp[h - 1][w - 1] << endl;

	return 0;
}


Measured memory_bytes: 5248
function Main(input) {
    input = input.trim().split(" ");
    var r = parseInt(input[0],10);
    var D = parseInt(input[1],10);
    var x = parseInt(input[2],10);
    var output = [];

    output[0] = r*x - D;
    for(var i = 1; i < 10; i++){
        output[i] = r*output[i-1] - D;
    }

    for(var i = 0; i < 10; i++){
        console.log(output[i]);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
#define ALL(v) v.begin(),v.end()
#define debug(var) cerr<<#var<<":"<<var<<endl; 
const ll MOD=1e9+7;
string s;
ll n,ans=1e9,bsum[200010],wsum[200010],ct[2];
int main(){
    cin>>n>>s;
    rep(i,s.size()){
        ct[0]+=s[i]=='.';
        ct[1]+=s[i]=='#';
        if(!i)continue;
        bsum[i]=bsum[i-1]+(s[i-1]=='#');
    }
    ans=min(ct[0],ct[1]);
    for(int i=s.size()-1;i>=0;--i){
        if(i==s.size()-1)wsum[i]=(s[i]=='.');
        wsum[i]=wsum[i+1]+(s[i]=='.');
    }
    rep(i,s.size())ans=min(ans,bsum[i]+wsum[i]);
    rep(i,s.size())cerr<<bsum[i]<<" "<<wsum[i]<<endl;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3716
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int cnt=0;
    forn(i,n){
        int x;
        cin>>x;
        if(x%2==1)  cnt++;
    }
    if(cnt%2==1)    cout<<"NO\n";
    else            cout<<"YES\n";
    return 0;
}



Measured memory_bytes: 3620
N,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
count = 0
for i in range(N):
    for j in range(i+1,N):
        s=0
        for k in range(D):
            s += (X[i][k]-X[j][k])**2
        s = s**0.5
        if(s==int(s)):
            count+=1
print(count)

Measured memory_bytes: 9300
#include <stdio.h>
 
int main(void)
{
	int a, b, c, d, menseki1, menseki2;
	scanf( "%d %d %d %d", &a, &b, &c, &d );
	menseki1 = a * b;
	menseki2 = c * d;
	if( menseki1 > menseki2 ){
		printf( "%d\n", menseki1 );
	}
	if( menseki2 > menseki1 ){
		printf( "%d\n", menseki2 );
	}
	if( menseki1 == menseki2 ){
		printf( "%d\n", menseki1 );
	}
	return 0;
}

Measured memory_bytes: 128
def saiki(n,A):

    if n == N:
        A.sort()
        for i in A:
            print(i)
        return

    alpha = list("abcdefghijklmnopqr")

    tmp = []

    for i in A:
        a = alpha.index(sorted(list(i))[-1])
        for j in range(a+2):
            tmp.append(i+alpha[j])
    
    saiki(n+1,tmp)

N = int(input())

saiki(1,["a"])

Measured memory_bytes: 14540
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
char c;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> c;
	if (c >= 'A' && c <= 'Z'){
		cout << 'A' << endl;
	} else {
		cout << 'a' << endl;
	}
}

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

using namespace std;

int main()
{
    string s="FESTIVAL";
    string ss;
    cin>>ss;
    int k=s.size();
    int l=ss.size();
    l=l-k;
    for(int i=0;i<l;i++){
        cout<<ss[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,c,k,l;
  l = 0;
  scanf("%d %d %d",&a,&b,&c);
  k = a;
  while(k <= b){
    if(c % k == 0){
      l++;
    }
    k++;
  }
  printf("%d\n",l);
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <map>
using namespace std;
int n,m;
map<string,int> mp;
string tmp[210];
int main()
{
	cin>>n;
	for (int i=0;i<n;i++)
	{
		cin>>tmp[i];
		mp[tmp[i]]++;
	}
	cin>>m;
	for (int i=0;i<m;i++)
	{
		cin>>tmp[n];
		mp[tmp[n]]--;
	}
	int mx=0;
	for (int i=0;i<n;i++)
	{
		if (mp[tmp[i]]>mx)
			mx=mp[tmp[i]];
	}
	cout<<mx<<endl;
	system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

// 最大公約数
long long gcd(long long a, long long b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (b == 0) return a;
    else return gcd(b, a % b);
}

// 最小公倍数
long long lcm(long long a, long long b) {
    long long g = gcd(a, b);
    return a / g * b;
}

int main() {
    long int k;
    cin >> k;
    long long int r = 0;
    long int temp1;
    for (long int a = 1; a <= k; a++)
    {
        for (long int b = 1;b <= k;b++) {
            temp1 = gcd(a,b);
            for (long int c = 1;c <= k;c++) {
                r += gcd(c,temp1);
            }
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3676
#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    float total=0.0;
    for(int i=0;i<n;i++)
    {
        float f;
        string s;
        cin>>f>>s;
        if(s[0]=='J'){
            total+=f;
        }
        else
        {
            total+=(f*380000.0);
        }
    }
    cout<<total;
}

Measured memory_bytes: 3808
#include <stdio.h>

int prime(int v){
    int i;
    if(v%2==0)
        return 0;
    
    for(i=3;i*i<v;i+=2){
        if(v%i==0){
            return 0;
        }
    }
    return 1;
}

int main(int argc, const char * argv[]) {
    int a,low,high,lflag=0,hflag=0;
    while(scanf("%d",&a)!=EOF){
        if(a%2==0){
            low=a-1;
            high=a+1;
        }else{
            low=a-2;
            high=a+2;
        }
        while(1){
            if(low==1){
                low=2;
                lflag=1;
            }
            hflag=prime(high);
            if(lflag==0)
            lflag=prime(low);
            
            if(hflag==0){
                high+=2;
            }
            if(lflag==0){
                low-=2;
            }
            if(hflag==1&&lflag==1)
                break;
            
        }
        
        printf("%d %d\n",low,high);
        lflag=0;
        hflag=0;
        
    }
    
    return 0;
}

Measured memory_bytes: 1768
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#define MAX 100000
#define INFTY 1<<30 // 2^30
using namespace std;
typedef long long llong;
 
static const int NIL = -1;
 
int n;
vector<int> G[MAX];
int color[MAX];
 
void dfs(int r, int c)
{
  stack<int> S;
  S.push(r);
  color[r] = c;
  while(!S.empty())
  {
    int u = S.top(); S.pop();
    for(int i = 0; i < G[u].size(); i++)
    {
      int v = G[u][i];
      if(color[v] == NIL)
      {
        color[v] = c;
        S.push(v);
      }
    }
  }
}
 
void assingColor()
{
  int id = 1;
  for(int i = 0; i < n; i++) color[i] = NIL;
  for(int u = 0; u < n; u++)
    if(color[u] == NIL) dfs(u,id++);
}
 
int main()
{
  int s, t, m ,q;
  cin >> n >> m;
  for(int i = 0; i < m; i++)
  {
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
 
  assingColor();
 
  cin >> q;
  for(int i = 0; i < q; i++)
  {
    cin >> s >> t;
    cout << ((color[s] == color[t]) ? "yes" : "no") << endl;
  }
  return 0;
}

Measured memory_bytes: 7060
N, K = map(int, input().split())

snuke_list = [0]*N
for i in range(K):
  snuke_sayisi = int(input())
  snukes = list(map(int, input().split()))
  for snuke in snukes:
    snuke_list[snuke-1] += 1
ans = 0
for i in snuke_list:
  if i == 0:
    ans += 1
print(ans)

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

int main() {
    int a, b, c, d, e, f, ans = 1;
    scanf("%d%d%d", &a, &b, &c), d = a&1, e = b&1, f = c&1;
    if(d == e && e == f) ans--;
    else if(d == e && e != f) a++, b++;
    else if(e == f && f != d) b++, c++;
    else if(f == d && d != e) c++, a++;
    ans += (3*max(a, max(b, c)) - a - b - c)/2;
    printf("%d", ans);
}

Measured memory_bytes: 256
//-------------
//| ConvexCut |
//| H28.03.12 |
//-------------

//---includes---//
#include<iostream>
#include<cmath>
#include<iomanip>
#include<vector>
#include<algorithm>
using namespace std;

//---defines---//
#define MAX_N 100000
#define EPS 1e-14
#define EPS2 1e-6
#define INF 1e14
#define INF2 1e12

//---ints---//
int Q;
vector<pair<long double, long double>>vec;
long double X[MAX_N], Y[MAX_N];
long double X1[MAX_N], X2[MAX_N], X3[MAX_N], X4[MAX_N];
long double Y1[MAX_N], Y2[MAX_N], Y3[MAX_N], Y4[MAX_N];

bool paralel(long double X1, long double Y1, long double X2, long double Y2, long double X3, long double Y3, long double X4, long double Y4) {
	long double xp[4], yp[4]; 
	xp[0] = X1 - X2; yp[0] = Y1 - Y2; 
	xp[1] = X3 - X4; yp[1] = Y3 - Y4;
	if (yp[0] == 0 && yp[1] == 0) { return true; }
	if (yp[0] == 0 && yp[1] != 0) { return false; }
	if (yp[0] != 0 && yp[1] == 0) { return false; }
	if ((xp[0] / yp[0]) == (xp[1] / yp[1])) { return true; }
	return false;
}
pair<long double, long double>kouten(long double X1, long double Y1, long double X2, long double Y2, long double X3, long double Y3, long double X4, long double Y4) {
	if (paralel(X1, Y1, X2, Y2, X3, Y3, X4, Y4) == true) { 
		return make_pair(INF, INF); 
	}
	if (fabs(X1 - X2) < EPS) { X1 -= EPS; }
	if (fabs(X3 - X4) < EPS) { X3 -= EPS; }
	if (fabs(Y1 - Y2) < EPS) { Y1 -= EPS; }
	if (fabs(Y3 - Y4) < EPS) { Y3 -= EPS; }
	long double XP[4], YP[4], ZP[4];

	XP[0] = X1 - X2; YP[0] = Y1 - Y2;
	XP[1] = X3 - X4; YP[1] = Y3 - Y4; 
	ZP[0] = YP[0] / XP[0]; 
	ZP[1] = YP[1] / XP[1];
	long double X5 = X1, Y5 = Y3 - (X3 - X1)*ZP[1];
	long double K = (Y5 - Y1) / (ZP[0] - ZP[1]); 
	long double L = K*ZP[0]; 
	return make_pair(X1 + K, Y1 + L);
}
void solve() {
	for (int i = 0; i < Q; i++) { 
		X1[i] = X[i]; Y1[i] = Y[i]; 
		X2[i] = X[(i + Q / 2) % Q]; 
		Y2[i] = Y[(i + Q / 2) % Q]; 
		vec.push_back(kouten(X[0], Y[0], X[Q / 2], Y[Q / 2], X1[i], Y1[i], X2[i], Y2[i])); 
	}
	sort(vec.begin(), vec.end()); 
	for (int i = 0; i < vec.size() - 1; i++) { 
		long double X_1 = vec[i].first, X_2 = vec[i + 1].first;
		long double Y_1 = vec[i].second, Y_2 = vec[i + 1].second;
		if ((X_1 < INF2 || Y_1 < INF2) && (X_2 < INF2 || Y_2 < INF2)) {
			if (fabs(X_1 - X_2) > EPS2 || fabs(Y_1 - Y_2) > EPS2) {
				cout << "NA" << endl;
				return;
			}
		}
	}
	cout << fixed << setprecision(15) << vec[0].first << ' ';
	cout << fixed << setprecision(15) << vec[0].second << endl;
}
int main() { 
	cin >> Q; 
	for (int i = 0; i < Q; i++) { 
		cin >> X[i] >> Y[i]; 
	}
	solve();
	return 0;
}

Measured memory_bytes: 3320
/*input
35897 932
*/
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define int long long
using namespace std;
const int MX = 1e5 + 100;
main () {
	unordered_map<int, int> Yeee;
	int n, k; cin >> n >> k;
	for(int i = 1; i <= n; i ++) {
		if((i % k + i % k) % k == 0) {
			Yeee[i % k] ++;
		}
	}
	int ans = 0;
	for(auto it: Yeee) ans += it.S * it.S * it.S;
	cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}



struct cands {
    int num;
    int cnt;
};

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(struct cands *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        int val;
        scanf("%d", &val);
        arr[i] = (struct cands){val, 1};
    }
    return 0;
}

#define NUM_MAX 100000

int asc(const void *a1, const void *a2) {
    return *(int*)a1 - *(int*)a2;
}

int lower_bound(int *arr, int num, int key) {
    int low = -1;
    int high = num;
    while(low + 1 < high) {
        int mid = (low + high) / 2;
        if(arr[mid] < key) {
            low = mid;
        } else {
            high = mid;
        }
    }
    return low;
}

#define QUERY_MAX 100000

int desc_by_num(const void *a1, const void *a2) {
    struct cands *ca1 = (struct cands*)a1;
    struct cands *ca2 = (struct cands*)a2;
    return ca2->num - ca1->num;
}


int main(void) {
    int num, queries;
    get_int2(&num, &queries);

    static struct cands arr[NUM_MAX+QUERY_MAX];
    fget_array(arr, num);
    int idx = num;

    int i;
    for(i = 0; i < queries; i++) {
        int cnt, val;
        get_int2(&cnt, &val);
        arr[idx++] = (struct cands){val, cnt};
    }

    qsort(arr, idx, sizeof(struct cands), desc_by_num);

    int64_t ans = 0;
    int rem = num;
    for(i = 0; i < idx; i++) {
        if(rem <= 0) break;
        int64_t picks = min(rem, arr[i].cnt);
        ans += (int64_t)arr[i].num * picks;
        rem -= picks;
    }

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

    return 0;
}

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

using namespace std;

#define int long long 
#define INF 21000000000

signed main(){
		int n;
		cin >> n;
		vector<int> a;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				a.push_back(tmp);
		}
		int ans = 0;
		int cnt = 0;
		for(int i=0;i<n-1;i++) {
				if(a[i] >= a[i+1]){
						cnt++;
				}else{
						if(ans < cnt) ans = cnt;
						cnt =0;
				}
		}
		if(ans < cnt) ans = cnt;
		cout << ans << endl;
}



Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[301],n,dp[301][301];
main(){
  while(cin>>n,n){
    int ans=0;
    r(i,n)cin>>a[i];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<n;i+=2)
      for(int j=0;j<n-i;j++){
        dp[j][j+i]=dp[j+1][j+i-1];
        if(abs(a[j]-a[j+i])<2&&dp[j+1][j+i-1]==i-1)dp[j][j+i]=i+1;
        else for(int k=1;k<i;k+=2)dp[j][j+i]=max(dp[j][j+i],dp[j][j+k]+dp[j+k+1][j+i]);
      }
    r(i,n)r(j,n)ans=max(ans,dp[i][j]);
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3428
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
const int N = 10;
vi adj[N];
bool used[N];
int n;
int ans = 0;
void dfs(int v, int cnt) {
    if (cnt == n) ans++;
    for (auto to : adj[v]) {
        if (used[to]) continue;
        used[to] = true;
        dfs(to, cnt + 1);
        used[to] = false;
    }   
}
void solve(){
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    used[1] = true;
    dfs(1, 1);
    cout << ans;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

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

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

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

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

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

k = input_n
s = input_s

if s.length > k
  puts s[0..(k - 1)] + "..."
else
  puts s
end


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

if a == 0 or b == 0 or (a < 0 and 0 < b) or (0 < a and b < 0):
    print ("Zero")
else:
    x = b - a
    if 0 < a and 0 < b:
        print ("Positive")
    else:
        if x%2 == 0:
            print ("Negative")
        else:
            print ("Positive")


Measured memory_bytes: 9052
#include<iostream>
#include<algorithm>
#include<climits>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
string s;
int main(){
  scan(s);
  int cnt=0;
  bool f=true;
  sort(s.begin(),s.end());
  if(s[0]!='a'){
    prin("a");
  }
  else{
    rep(i,s.size()-1){
      if(s[i]==s[i+1]){
	continue;
      }
      else if(s[i]+1==s[i+1]){
	cnt++;
      }
      else{
	char res=s[i]+1;
	prin(res);
	f=false;
	break;
      }
    }
    if(f&&s[s.size()-1]!='z'){
      char res=s[s.size()-1]+1;
      prin(res);
    }
    if(cnt==25){
      prin("None");
    }
  }

  return 0;
}


Measured memory_bytes: 512
def main():
    N = int(input())
    T, A = map(int, input().split())
    H = list(map(int, input().split()))

    mindiff = pow(10, 6)
    for i in range(N):
        temprature = T - 0.006*H[i]
        diff = abs(temprature - A)
        if diff < mindiff:
            ans = i+1
            mindiff = diff
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	static Set<String> s=new TreeSet<String>();
	
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		Scanner sc=new Scanner(System.in);
		int n;
		String str;
		n=sc.nextInt();
		
		while(n--!=0){
			s.clear();
			str=sc.next();
			cut(str);
			
			//System.out.println(s);
			System.out.println(s.size());
		}
	}
	
	static void cut(String str){
		String str1,str2;
		int i;
		for(i=1;i<str.length();i++){
			str1=str.substring(0,i);
			str2=str.substring(i);
			comb(str1,str2);
		}
	}
	static void comb(String str1,String str2){
		String a=str1,b=str2;
		//a=a.concat(b);
		s.add(a.concat(b));
		s.add(b.concat(a));
		String ra  , rb;
		StringBuilder x=new StringBuilder(str1),y=new StringBuilder(str2);
		ra=x.reverse().toString();
		rb=y.reverse().toString();

		s.add(ra.concat(b));
		s.add(b.concat(ra));
		
		s.add(a.concat(rb));
		s.add(rb.concat(a));
		
		s.add(ra.concat(rb));
		s.add(rb.concat(ra));
		
	}
}

Measured memory_bytes: 0
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      int A = one.get(0);
      int B = one.get(1);
      if(A == 2 || B == 2){
        myout("No");
      }else{
        myout("Yes");
      }
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32916
a,b,c,p;
main(){
	for(c='\n';p=c,c=getchar(),c!='0';){
		if(p!='\n'){
			if(c=='A')
				a++;
			if(c=='B')
				b++;
			if(c=='\n'){
				if(a>b)
					a++;
				else
					b++;
				printf("%d %d\n",a,b);
				a=b=0;
			}
		}
	}
	exit(0);
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void) {
    int n;
    cin >> n;

    vector<llint> a(n);
    vector<llint> s(n+1, 0);
    for(int in=0;in<n;++in) {
        cin >> a[in];
        s[in+1] = s[in] + a[in];
    }

    llint ans = 0, tmp1;
    for(int in=0;in<n-1;++in) {
        tmp1 = s[n] - s[in+1];
        tmp1 %= MOD;
        if(tmp1<0) tmp1 += MOD;
        ans += a[in]*tmp1;
        ans %= MOD;
        if(ans<0) ans += MOD;
    }

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


Measured memory_bytes: 6420
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int arr[400]={0};
    int next =0;
    for (int i =0;i<3;i++){
        cin>>next;
        arr[next+200]++;
    }
    for (int i =0;i<400;i++){
        if(arr[i]==1){
            cout<<i-200;
        }
    }

    return 0;
}


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

int mat[101][101];

int main(int argc,char* argv[]){
  memset(mat,0,sizeof(mat));
  int n,v,cnt,x;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>v>>cnt;
    for(int j=0;j<cnt;j++){
      cin>>x;
      mat[v][x]=1;
    }
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cout<<mat[i][j];

      if(j!=n)
	cout<<" ";
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <list>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <algorithm>
#include <cstdint>
#include <list>
#include <string.h>
#include <unordered_map>
#include <assert.h>
#include <ctype.h>
#include <queue>
#include <numeric>
#include <vector>
#include <iomanip>
#include <deque>
#include <cstdlib>
#include <stack>
#include <ctime>
#define  lld  long long int
#define newline cout << endl
#define pb push_back
#define mp make_pair
lld shouldendl = 1;
#define se second
#define fi first
#define sfind(s,ele) (s).find((ele));
#define SPEED ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define starttime chrono::time_point<chrono::system_clock> start, end; start = chrono::system_clock::now()
#define showtime end = chrono::system_clock::now();  chrono::duration<double> elapsed_seconds = end - start; time_t end_time = chrono::system_clock::to_time_t(end); cout << "elapsed time: " << elapsed_seconds.count() << "s\n"
lld  INF = (lld)(5e17+100);
lld MOD =  (lld)(1e18+100);
#define fileopen   freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
using namespace std;
lld modInverse(lld a ){   lld m = MOD,m0 = m, y = 0, x = 1;  if (m == 1) return 0;   while (a > 1) {  lld q = a / m, t = m;  m = a % m, a = t, t = y;          y = x - q * y, x = t;   } if (x < 0)  x += m0; return x; } 
lld add(long long a, long long b){return ((a%MOD)+(b%MOD))%MOD;}
lld mul(long long a, long long b){return ((a%MOD)*(b%MOD))%MOD;}
lld sub(long long a, long long b){lld ans = ((a%MOD-b%MOD))%MOD; if(ans<0) ans += MOD; return ans;}
lld gcd(lld a, lld b){if (b == 0) return a; return gcd(b, a % b);}
void MAIN(lld i,lld t);
int get(){lld t;cin>>t; ; return t;}
template<class T> int logd(T name){cout<<name<<endl; return 0;}
void test(int t) { for(lld i = 1;i<=t;i++){MAIN(i,t); if(shouldendl) cout << endl; } }
lld power(lld x, lld y) { lld res = 1; x = x%MOD; if(x==0) return 0;   while (y > 0) {   if (y & 1)      res = (res*x)%MOD; y = y>>1; x = (x*x)%MOD;} return res; }
template <typename T,typename U> std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {   return {l.first+r.first,l.second+r.second};                                    }    
#define all(v) (v).begin(),(v).end()
lld popcount(lld x){return __builtin_popcountll(x);}
lld lcm(lld a,lld b){ return (a*b)/gcd(a,b);}
template<class T> bool input(vector<T> &v, lld n = -1){ assert(v.size()!=0); if(n==-1) n = v.size();    for(auto &i:v) cin >> i; return 0;}
template<class T> bool print(vector<T> v,lld l = 0, lld r = -1){  if(r==-1) r = v.size();   for(int i = l;i<r;i++) cout << v[i] << " "; return 0;}
//Observation, binary_search, dfs on strings, simplify the problem
//Observe and ELIMINATE 
void MAIN(lld current_test_case,lld total_test_cases){ 
      int x;
      cin >> x;
      cout << (x==0);
}     
int main(){  
    SPEED;
    #ifndef ONLINE_JUDGE 
     fileopen
    #endif
    test(1);
    return 0;
}


Measured memory_bytes: 3232
/*input
4
75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define int long long
#define N 262205
#define bit(x,y) ((x>>y)&1LL)
#define loop(x) for(int xv=1; xv<=x; xv++)

#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
	return os << '(' << a.first << ", " << a.second << ')';
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
	os << '[';
	for (unsigned int i = 0; i < a.size(); i++)
		os << a[i] << (i < a.size() - 1 ? ", " : "");
	os << ']';
	return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &a) {
	os << '{';
	for (typename set<T>::iterator it = a.begin(); it != a.end(); it++) {
		typename set<T>::iterator jt = it;
		os << *it << (++jt != a.end() ? ", " : "");
	}
	os << '}';
	return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &a) {
	os << "{\n";
	for (typename map<T1, T2>::iterator it = a.begin(); it != a.end(); it++) {
		typename map<T1, T2>::iterator jt = it;
		os << "  " << it->first << ": " << it->second << (++jt != a.end() ? ",\n" : "\n");
	}
	os << '}';
	return os;
}

int n;
int a[N];

pair<int, int> f[N];

void update(int fp, int ap) {
#define MAX1 f[fp].fi
#define MAX2 f[fp].se
	if (ap == MAX1 || ap == MAX2) return;
	if (MAX2 != -1 && a[ap] <= a[MAX2]) return;
	if (MAX1 == -1 || a[ap] >= a[MAX1]) {
		MAX2 = MAX1;
		MAX1 = ap;
	}
	else {
		MAX2 = ap;
	}
#undef MAX1
#undef MAX2
}

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	memset(f, -1, sizeof(f));
	cin >> n;
	for (int i = 0; i < (1 << n); i++) cin >> a[i], update(i, i);
	for (int mask = 0; mask < (1 << n); mask++) {
		for (int i = 0; i < n; i++) {
			if (bit(mask, i) == 0) continue;
			int mask2 = mask ^ (1 << i);
			update(mask, f[mask2].fi); update(mask, f[mask2].se);
		}
	}
	int buf = 0;
	for (int mask = 1; mask < (1 << n); mask++) {
#define MAX1 f[mask].fi
#define MAX2 f[mask].se
		assert(MAX1 != -1 && MAX2 != -1);
		buf = max(buf, a[MAX1] + a[MAX2]);
		cout << buf << endl;
	}
}

Measured memory_bytes: 9216
use proconio::*;

fn main(){
	input!{
    	n:usize,
        a:[isize;n],
    }
    
    let mut sum = vec![0;n+1];
    for i in 0..n{
    	sum[i+1]+=sum[i]+a[i];
   	}
    
    let mut ans = 1<<60;
    for i in 1..n{
    	ans = ans.min(((sum[n]-2*sum[i]).abs()));
    }
    
    println!("{}",ans);
}

Measured memory_bytes: 6368
#C
a,b,c,x,y=map(int,input().split())

#雰囲気
ans = a * x + b * y
cnt = 1
while x != 0 or  y!= 0:
    x = max(x - 1, 0)
    y = max(y - 1, 0)
    ans = min(ans,a*x+b*y+c * 2 * cnt)
    cnt += 1
    #print(ans,x,y)
print(ans)

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

const long long oo = 1e18;

using namespace std;

void solve() {
    long long n, w;
    cin >> n >> w;
    vector<int> W(n + 1), V(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> W[i] >> V[i];
    }
    vector<vector<long long>> dp(n + 1, vector<long long>(1e5 + 123, oo));
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1e5; j >= 0; j--) {
            if (j >= V[i]) {
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-V[i]] + W[i]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    // for (int i = 1; i <= n; i++) {
    //     for (int j = 1; j <= 20; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    for (int i = 1e5; i >= 1; i--) {
        if (dp[n][i] <= w) {
            cout << i;
            return;
        }
    }
    cout << 0; 
}

int main() {
    #ifdef DEBUG
        freopen("solve.inp", "r", stdin);
        freopen("solve.out", "w", stdout);
    #endif
    solve();
    return 0;
}   

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

#define pb push_back
#define ll long long int
#define mpi map<int, int>
#define vi vector<int>
#define si set<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define vs vector<string>
#define pri priority_queue<int>
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define For(i, n) for (int i = 0; i < n; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, x, y) for (int i = x; i <= y; i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

double tick()
{
    static clock_t oldt, newt = clock();
    double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
    oldt = newt;
    return diff;
}

int main()
{
    ll n;
    cin >> n;
    ll sum = 100;
    int i;

    for (i = 0; sum < n; i++)
        sum += sum / 100;
    cout << i << "\n";

    cerr << "execution time is: " << tick() << "\n";
}


Measured memory_bytes: 3804
#include "bits/stdc++.h"
using namespace std;

int main() {
	while (1) {
		int N, H; cin >> N >> H;
		if (!N&&!H)break;
		set<tuple<int, int, int>>aset;
		for (int i = 0; i < H; ++i) {
			string  st; int  a, b; cin >> st >> a >> b; a--; b--;
			for (int j = 0; j < N; ++j) {
				if (st=="xy") {
					aset.insert(make_tuple(a, b, j));
				}
				else if (st=="xz") {
					aset.insert(make_tuple(a,j,b));
				}
				else {
					aset.insert(make_tuple(j,a,b));
				}
			}
			
		}
		int ans =N*N*N- aset.size();
		cout <<ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6212
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

ab_s = sorted(ab, key=lambda x: x[1])
ab_r = list(reversed(ab_s))

t = [x[0] for x in ab_r]
d = [x[1] for x in ab_r]        

t_set = len(set(t[:k]))
d_sum = sum(d[:k])

res = [t_set**2 + d_sum]

from collections import Counter
t_cou = Counter(t[:k])

dp =[0]*(n+1)
j_old = k-1

for i in t_cou:
    dp[i] = t_cou[i]

for i in range(k,n):
    t_new = ab_r[i][0]
    if dp[t_new] ==0:
        for j in range(j_old,-1,-1):
            t_old = ab_r[j][0]
            if dp[t_old] <=1:
                pass
            else:
                dp[t_new] =1
                dp[t_old] -=1
                t_set +=1
                d_sum = d_sum - ab_r[j][1] + ab_r[i][1]
                res.append(t_set**2 + d_sum)
                j_old = j-1
                break
            j_old = -1

print(max(res))

Measured memory_bytes: 36392
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int res = c-(a-b);
  if (res >= 0) {
    cout << res << "\n";
  } else {
    cout << 0 << "\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n;
    cin >> n;
    
    int a[50][26] = {};
    rep(i, n){
        string s;
        cin >> s;
        rep(j, s.length()){
            a[i][s[j]-'a']++;
        }
    }

    string ans = "";
    rep(i, 26){
        int m = mod;
        rep(j, n){
            m = min(m, a[j][i]);
        }
        rep(k, m){
            ans += 'a' + i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){

	ull n,k,memo = 1,cnt = 0,ans = 0,memo2 = 0;
  	cin >> n >> k;
  	ull a[n];
  
  	rep(i,0,n){
     	cin >> a[i]; 
      	if(a[i] % 2 != 0) cnt++;
    }
  
  
  	rep(i,1,cnt+1){
      memo = 1;
      if(cnt/2 < i){
        memo2 = cnt-i;
      }
      else{
       memo2 = i; 
      }
     rep(j,0,memo2){
       memo *= cnt-j;
     }
     rep(j,1,memo2+1){
       memo /= j;
     }
     ans += memo;
     //cout << i << " : " << memo << endl;
     i++; 
    }
  
  	if(k == 1){
      cout << (ull)ans*(ull)pow(2,n-cnt) <<endl;
       // << " " << (ull)ans << " " << (ull)pow(2,n-cnt) <<endl;
    }
  	else{
      cout << (ull)pow(2,n) - (ull)ans*(ull)pow(2,n-cnt) << endl;
        //<< " " << (ull)pow(2,n) << " " << (ull)ans << " " << (ull)pow(2,n-cnt) <<endl;
    }
  	
  	
	return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 500001

int N;

void maxHeapify(int *A, int i) {
    int l, r, largest, tmp;
    
    l = i * 2;
    r = i * 2 + 1;
    
    if (l <= N && A[l] > A[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= N && A[r] > A[largest]) {
        largest = r;
    }
    if (largest != i) {
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(int *A, int H) {
    int i;
    for (i = H / 2; i >= 1; i--) {
        maxHeapify(A, i);
    }
}

int main(void){
    int n, i, A[MAX];
    
    scanf("%d", &n);
    
    N = n;
    
    for (i = 1; i <= n; i++) {
        scanf("%d", &A[i]);
    }
    
    buildMaxHeap(A, n);
    
    for (i = 1; i <= n; i++) {
        printf(" %d", A[i]);
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 3752
FREE = -1
NOT_FREE = 1

N = 8
B = [["."] * N for _ in range(N)]
row = [FREE] * N
col = [FREE] * N
dpos = [FREE] * (2 * N - 1)
dneg = [FREE] * (2 * N - 1)

def update(r, c, FREE_OR_NOT):
    B[r][c] = "." if FREE_OR_NOT == FREE else "Q"
    row[r] = col[c] = dpos[r + c] = dneg[r - c + N - 1] = FREE_OR_NOT

def draw():
    for i in range(N):
        print("".join(B[i]))

def recursive(i):
    if i == N:
        draw()
        return
    if "Q" in B[i]:
        recursive(i + 1)

    for j in range(N):
        if NOT_FREE in [row[i], col[j], dpos[i + j], dneg[i - j + N - 1]]:
            continue
        else:
            update(i, j, NOT_FREE)
        recursive(i + 1)
        update(i, j, FREE)

k = int(input())

for _ in range(k):
    r, c = map(int, input().split())
    update(r, c, NOT_FREE)
recursive(0)


Measured memory_bytes: 5616
week = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']

S = input()

if S == 'SUN':
  answer = 7
elif S == 'MON':
  answer = 6
elif S == 'TUE':
  answer = 5
elif S == 'WED':
  answer = 4
elif S == 'THU':
  answer = 3
elif S == 'FRI':
  answer = 2
elif S == 'SAT':
  answer = 1

print(answer)

Measured memory_bytes: 3060
n=100000
p=[0]*2+[1]*(n-1)
for i in range(2,n+1):
  if p[i]:
    for j in range(i*2,n+1,i):
      p[j]=0
c=[0]*(n+1)
for i in range(2,n+1)[::-1]:
  if p[i]:
    if p[(i+1)//2]:
      c[i]=1
d=[0]*(n+1)
for i in range(1,n+1):
  d[i]=d[i-1]+c[i]

q=int(input())
for _ in range(q):
  l,r=map(int,input().split())
  print(d[r]-d[l-1])

Measured memory_bytes: 7908
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;

int main(){
	const int M=1000000007;
	int N,W;
	scanf("%d%d",&N,&W);
	vector<int>w(N);
	vector<vector<int> >bag(N+1);
	bag[0].resize(W+1);bag[0][0]=1;
	for(int i=0;i<N;i++){
		scanf("%d",&w[i]);
		bag[i+1].resize(W+1);
	}
	sort(w.begin(),w.end(),greater<int>());
	for(int i=0;i<N;i++){
		int j=W;
		for(;j>=w[i];j--)bag[i+1][j]=(bag[i][j]+bag[i][j-w[i]])%M;
		for(;j>=0;j--)bag[i+1][j]=bag[i][j];
	}
	int s=0,r=0;
	for(int i=N-1;i>=0;s+=w[i--])for(int j=max(0,W-s-w[i]+1);j<=W-s-(i!=N-1?w[i+1]:0);j++){
		r=(r+bag[i+1][j])%M;
	}
	printf("%d\n",r);
}

Measured memory_bytes: 8656
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
	int A, B, H, M;
	const long double PI = acos(-1);
	cin >> A >> B >> H >> M;
	double long a = 2 * PI * ((long double) H / 12.0 + (long double) M / 60.0 / 12.0);
	double long b = 2 * PI * (long double) M / 60.0;
	double long c = sqrt((long double) (A * A + B * B) - (long double) (2 * A * B) * cos(a - b));
	printf("%20.20Lf\n", c);
	return 0;
}

Measured memory_bytes: 4056
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

using ld=long double;


int main() {	
	int W,H;cin>>W>>H;
	vector<vector<int>>field(H,vector<int>(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin>>field[i][j];
		}
	}
	bool ok=true;
	vector<int>v(field[0]);
	int b_num=count(v.begin(),v.end(),1);
	if (b_num == W / 2 || (b_num == W / 2 + 1 && W % 2)) {
		vector<int>rev_v(v);
		for_each(rev_v.begin(), rev_v.end(), [](int &a) {a = !a; });

		int same_num=0;
		int rev_num=0;
		for (int i = 0; i < H; ++i) {
			if(field[i]==v)same_num++;
			else if(field[i]==rev_v)rev_num++;
			else {
				ok=false;
				break;
			}
		}
		if (same_num == H / 2 || (same_num == H / 2 + 1 && H % 2)) {

		}
		else {
			ok=false;
		}
	}
	else {
		ok=false;
	}
	if(ok)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
	return 0;
}

Measured memory_bytes: 6728
#include<iostream>
#include<vector>
#include<cfloat>
#include<cmath>
using namespace std;

const double INF = DBL_MAX;
const int NIL = -1;

class Store {
public:
    int id, distance, gold;
    Store() {}
    Store(int i, int d, int g) :id(i), distance(d), gold(g) {}
};

int get(int bit, int n) {
    return bit & (1 << n);
}
double weight(const vector<Store>& store, int bit) {
    double sum = 0.0;
    for(int i = 0; i < store.size(); ++i)
        if(get(bit, i)) sum += store[i].gold;
    return sum * 20.0;
}
double time(const vector<Store>& store, int from, int to, int bit) {
    double d = fabs(store[from].distance - store[to].distance);
    return d * (70.0 + weight(store, bit)) / 2000.0;
}

int main() {
    int n;
    cin >> n;
    vector<Store> store(n);
    for(auto& s: store) cin >> s.id >> s.distance >> s.gold;

    const int ALL = (1 << n) - 1;

    vector<vector<double>> dp(n, vector<double>(1 << n, INF));
    vector<vector<int>> pre_store(n, vector<int>(1 << n, NIL));
    for(int i = 0; i < n; ++i) dp[i][1 << i] = 0.0;
    for(int bit = 0; bit < (1 << n); ++bit) {
        for(int last = 0; last < n; ++last) {
            if(dp[last][bit] == INF) continue;
            for(int next = 0; next < n; ++next) {
                if(get(bit, next)) continue;
                int next_bit = bit | get(ALL, next);
                double cost = dp[last][bit] + time(store, last, next, bit);
                if(dp[next][next_bit] <= cost) continue;
                dp[next][next_bit] = cost;
                pre_store[next][next_bit] = last;
            }
        }
    }

    int s = 0;
    double min_distance = INF;
    for(int i = 0; i < n; ++i) {
        if(min_distance <= dp[i][ALL]) continue;
        min_distance = dp[i][ALL];
        s = i;
    }
    vector<int> answer;
    int bit = ALL;
    while(s != NIL) {
        int last = s;
        s = pre_store[last][bit];
        answer.push_back(last);
        bit = bit ^ get(bit, last);
    }
    cout << store[answer.back()].id;
    for(answer.pop_back(); !answer.empty(); answer.pop_back()) cout << " " << store[answer.back()].id;
    cout << endl;
}

Measured memory_bytes: 7152
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i = s; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  if (k > a) {
    k -= a;
    a = 0;
    b = max((ll)0,b-k);
  } else {
    a -= k;
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 3600