akhauriyash/Code-Regression huggingface dataset:
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int x, y, z, k; cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	rep(i, 0, x) cin >> a[i];
	rep(i, 0, y) cin >> b[i];
	rep(i, 0, z) cin >> c[i];
	sort(a.begin(), a.end(),greater<ll>());
	sort(b.begin(), b.end(),greater<ll>());
	sort(c.begin(), c.end(),greater<ll>());
	vector<ll> sub1,sub2, ans;
	rep(i, 0, x)rep(j, 0, y) {
		sub1.push_back(a[i] + b[j]);
	}
	sort(sub1.begin(), sub1.end(), greater<ll>());
	rep(i, 0, min(k,x*y)) {
		sub2.push_back(sub1[i]);
	}
	rep(i, 0, sub2.size())rep(j, 0, z) {
		ans.push_back(sub2[i] + c[j]);
	}
	sort(ans.begin(), ans.end(), greater<ll>());
	rep(i, 0, k) cout << ans[i] << endl;
	return 0;
}

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

typedef pair<int,int> P;

int p,q,a,n;
int count=0;
int saiki=0;

P addp(P a, P b){
  P ans;
  ans.first = a.first * b.second + a.second * b.first;
  ans.second = a.second * b.second;
  //cout<<"anss:"<<ans.second;
  return ans;
}

bool eq(P a, P b){
  return a.first * b.second == b.first * a.second;
}

void solve(int step,int k,P sum){
     if(eq(sum,P(p,q))){
	  count++;
	  return;
     }
     P temp=P(1,k);
     P nsum =addp(sum,temp);
     if(nsum.second>a)return;
     
     if(sum.first*q>p*sum.second){
	  return;
     }
     solve(step,k+1,sum);
     if(step+1>n)return;
     solve(step+1,k,nsum);
     return;
}

int main(){
     while(cin>>p>>q>>a>>n,p||q||a||n){
	  int start;
	  if(p/q>=1)start=1;else start=2;
	  //for(int i=start;i<(q*n/p)+1;i++){
	       solve(0,start,P(0,1));
	       //}
	  cout<<count<<endl;
	  count=0;
	  
     }
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    string t;
    cin >> t;
    rep(i,t.size()) {
        if(t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
}


Measured memory_bytes: 3784
/**
 *    author:  tourist
 *    created: 21.03.2020 15:15:22       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  vector<vector<int>> f(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i + j == 0) {
        f[0][0] = (s[0][0] == '#');
      } else {
        f[i][j] = (int) 1e9;
        if (i > 0) f[i][j] = min(f[i][j], f[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'));
        if (j > 0) f[i][j] = min(f[i][j], f[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));
      }
    }
  }
  cout << f[h - 1][w - 1] << '\n';
  return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

int atoz(){
    int frnt,bck,nibo,present,i;string s;
        frnt = abs(s[i]-present);
        bck = 26-frnt;
        nibo = min(frnt,bck);
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int X, Y; cin >> X >> Y;
    cout << X + Y/2 << endl;
    return 0;
}




Measured memory_bytes: 3604
# -*- coding:utf-8 -*-
import math


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


if __name__ == '__main__':
    data = get_sieve_of_eratosthenes(100001)
    #print(data[:10])
    
    cnt=len(data)
    SS=[0]*(10**5+1)
    S=[0]*(10**5+1)
    T=[0]*(10**5+1)
    for d in data:
      SS[d]=1
    for i in range(3,len(S)):
      if SS[i] and SS[(i+1)//2]: S[i]=1
    for i in range(len(T)):
      T[i]=cnt
      cnt-=S[i]
    #print(T[:10])
    
    Q=int(input())
    for i in range(Q):
      l,r=map(int,input().split())
      print(T[l]-T[r]+S[r])

Measured memory_bytes: 9344
import re

N=int(input())
s =[]
for i in range(N):
    s.append(str(input()))

counter = 0
B_begin=0
A_end =0
AB_in =0
B_begin_and_A_end = 0


for i in range(N):
    m = len(re.findall('AB',s[i]))
    AB_in += m

    chech_b = False
    chech_a = False

    if s[i][0]=='B':
        B_begin +=1
        chech_b = True

    if s[i][-1]=='A':
        A_end+=1
        chech_a = True

    if chech_a and chech_b:
        B_begin_and_A_end+=1

ans = 0 
mini = min(B_begin, A_end)

if mini ==0:
    ans = AB_in

elif B_begin == A_end == B_begin_and_A_end:
    if mini!=0:
        ans = AB_in + mini -1

else:
    ans = AB_in + mini

print(ans)





Measured memory_bytes: 3828
sx,sy,tx,ty=map(int,input().split())

dx=tx-sx
dy=ty-sy

ans =      "U"*dy +          "R"*dx+"D"*dy+"L"*dx
ans+="L" + "U"*dy + "U"+"R"+"R"*dx+"D"
ans+="R"+"D"*dy+"D"+"L"+"L"*dx+"U"

print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>

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

using namespace std;

int x, y;
int g[30][30];
bool b[30];

bool dfs(int i, int k){
	if(i == x){
		if(k != 0){
			return false;
		}

		rep(j, x){
			if(b[j]){
				continue;
			}

			bool f = false;
			rep(k, x){
				if(b[k] && g[j][k]){
					f = true;
					break;
				}
			}
			if(!f){
				return false;
			}
		}
		return true;
	}
	else if(k == 0){
		b[i] = 0;
		return dfs(i + 1, k);
	}
	else{
		b[i] = 0;
		bool f = dfs(i + 1, k);
		if(f){
			return true;
		}
		b[i] = 1;
		return dfs(i + 1, k - 1);
	}
}

int main(){
	while(1){
		scanf("%d%d", &x, &y);
		if(x == 0 && y == 0){
			break;
		}

		rep(i, y){
			int a, b;
			scanf("%d%d", &a, &b);
			g[a][b] = g[b][a] = 1;
		}

		for(int k = 1; k <= x; ++k){
			if(dfs(0, k)){
				printf("%d\n", k);
				break;
			}
		}

		rep(i, 30){
			rep(j, 30){
				g[i][j] = 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

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

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    int D = scanner.nextInt();
    int E = scanner.nextInt();
    int F = scanner.nextInt();

    int maxWeight = 100 * A;
    int maxSugar = 0;
    for (int n1 = 0; n1 <= F / (100 * A); n1++) {
      for (int n2 = 0; n2 <= F / (100 * B); n2++) {
        int water = 100 * A * n1 + 100 * B * n2;
        for (int n3 = 0; n3 <= water / 100 * E / C; n3++) {
          for (int n4 = 0; n4 <= water / 100 * E / D; n4++) {
            int sugar = C * n3 + D * n4;
            if (water + sugar > F) continue;
            if (water / 100 * E < sugar) continue;

            if (sugar * maxWeight > maxSugar * (water + sugar)) {
              maxWeight = water + sugar;
              maxSugar = sugar;
            }
          }
        }
      }
    }
    System.out.printf("%d %d\n", maxWeight, maxSugar);
  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll n;
  cin >> n;
  cout << (n/111+(n%111!=0)) * 111 << endl;
  return 0;
}

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

int main(void) {
  char s[50], s1[50];

  if(scanf("%s", s) == 1);

  s1[0] = s[5];
  s1[1] = s[6];

  if(atoi(s1) <= 4) {
    s1[0] = s[8];
    s1[1] = s[9];
    if(atoi(s1) <= 30) {
      printf("Heisei");
    } else {
      printf("TBD");
    }
  } else {
    printf("TBD");
  }

  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt(); //社員数
		int A[] = new int[N-1]; //直属の上司

		for(int i=0; i<(N-1); i++) {
			A[i] = sc.nextInt();
		}
		int count[] = new int[N]; //部下の人数のリスト

		for(int n=0; n<(N-1); n++) {
				count[A[n]-1]++;
		}

		for(int c : count) {
			System.out.println(c);
		}
	}

}


Measured memory_bytes: 62412
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N;
int A[200001];
int E[400001], ne[400001], he[200001];
int V[200001], v;
void dfs(int p, int mae) {
	if (V[v - 1] < A[p]) {
		V[v++] = A[p];
		for (auto to = he[p]; to; to = ne[to]) {
			if (E[to] != mae) {
				dfs(E[to], p);
			}
		}
		he[p] = v--;
	}
	else {
		int itr = lower_bound(V, V + v, A[p]) - V;
		swap(V[itr], A[p]);
		for (auto to = he[p]; to; to = ne[to]) {
			if (E[to] != mae) {
				dfs(E[to], p);
			}
		}
		he[p] = v;
		V[itr] = A[p];
	}
}

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
inline int getintA() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}
char dn[1300000], *di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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

	N = getint();
	rep1(i, N) A[i] = getintA();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		E[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		E[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	V[v++] = 2000000000;
	dfs(1, -1);

	rep1(i, N) putint(he[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}


Measured memory_bytes: 17164
#include<stdio.h>
int main(void){
    int N, M, P;
    int i,sum;

    while (1){
		int X[100] = {};
		sum=0;
		scanf("%d %d %d",&N,&M,&P);
        if (N == 0 && M == 0 && P == 0){
            break;
        }
        for (i = 0; i < N; i++){
            scanf("%d", &X[i]);
        }

        for (i = 0; i < N; i++){
            sum = sum + X[i];
        }
		if(X[M-1]==0){
			printf("0\n");
		}
		else{
			printf("%d\n", sum*(100-P)/X[M-1]);
		}
    }
    return 0;
}

Measured memory_bytes: 612
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#


def main():
    N, K = mis()
    A = [0] + lmis()
    for i in range(1, len(A)):
        A[i] = ((A[i] - 1) + A[i-1]) % K
    #
    C = defaultdict(int)
    ans = 0
    for i in range(len(A)):
        if i >= K:
            C[A[i-K]] -= 1
        a = A[i]
        ans += C[a]
        C[a] += 1
    print(ans)

main()


Measured memory_bytes: 33512
def main():
    A, B, C, D = list(input())
    for i in ['+','-']: 
        for j in ['+','-']:
            for k in ['+','-']:
                tmp = A + i + B + j + C + k + D
                if eval(tmp) == 7:
                    print(tmp+'=7')
                    exit()

if __name__ == "__main__":
    main()

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

int main(){
  string S;
  cin >> S;
  if(S.at(0)=='S'){
    cout << "Cloudy" << endl;
  }
  else if(S.at(0)=='C'){
    cout << "Rainy" << endl;
  }
  else{
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int read() {
	int x; scanf("%lld", &x); return x;	
}
const int maxn = 3e5 + 10;
const int INF = 1e9;
int mod = 1e9 + 7;
using namespace std;
int n, a[maxn], b[maxn];
main() {
	#ifdef LOCAL
		freopen("1.in", "r", stdin);
	#endif
	n = read();
	if (n >= 30) puts("Yes");
	else puts("No");
	return 0;	
}
 	

Measured memory_bytes: 3764
#include <stdio.h>
int main()
{
  int i,k=0,j;
  char a,cou[27];
  for(i=0;i<28;i++){
    cou[i]=0;
  }                       //syokika
  //  for(i=0;i<1201;i++){
  while(scanf("%c",&a) != EOF ){
    //printf("%c\n", a);
    if('a'<=a&&a<='z'){
      cou[a-'a'+1]+=1;
    }
    if('A'<=a&&a<='Z'){
      cou[a-'A'+1]+=1;
    }
  }
  // printf("hoge\n");
  for(j='a';j<='z';j++){
    k+=1;
    printf("%c : %d\n",j,cou[k]);
  }
  return 0;
}

Measured memory_bytes: 972
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define int long long
#define endl '\n'
#define pi 3.14159265
#define double long double
ll p(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b%2!=0)
            res*=a;
        a*=a;
        b/=2;
    }
    return res;
}
int32_t main()
{           
    IOS;
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min(c,b/a);
} 

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

N = int(input())

Graph = [[] for _ in range(N)]
edges = []

for _ in range(N - 1):
  a, b = [int(x) - 1 for x in input().split()]
  edges.append((a, b))
  
for a, b in edges:
  Graph[a].append(b)
  Graph[b].append(a)
  
k = max(len(edges) for edges in Graph)

colors = [color for color in range(1, k + 1)]
usedcolor = [None for _ in range(N)]
colored = {}

def colors_except(x):
  for c in colors:
    if c == x:
      continue
    yield c

for v in range(N):
  unused_colors = colors_except(usedcolor[v])
  for edge in Graph[v]:
    # 未着色
    if (v, edge) not in colored and (edge, v) not in colored:
      color = next(unused_colors)
      colored[(v, edge)] = colored[(edge, v)] = color
      usedcolor[edge] = color

print(k)

for a, b in edges:
  print(colored[(a, b)])
  

Measured memory_bytes: 101612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K,X;
  cin >> A >> B >> C >> K;
  if(A>K){
   X = K;
  }
  else if((A+B)>K){
    X = A;
  }
  else{
   X = A-(K-A-B) ;
  }
  cout << X << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int r,D,x;
    cin>>r>>D>>x;
    rep(i,10){
        x=r*x-D; 
        cout<<x<<endl;
    }
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	vector<string> s(a);
	for (int i = 0; i < a; i++) {
		cin >> s.at(i);
	}
	for (int i = 0; i < b + 2; i++) {
		cout << "#";
	}
	cout << endl;
	for (int i = 0; i < a;i++) {
		cout << "#" + s.at(i) + "#" << endl;
	}
	for (int i = 0; i < b + 2; i++) {
		cout << "#";
	}
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		sc.close();
		out.println((n+1)/2);
	}
}


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

int main(){
  int k;
  vector<string> dweek(7);
  dweek = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string S;
  cin >> S;
  for(int i=0; i<7; i++){
    if(S==dweek.at(i)){
      k=7-i;
      break;
    }
  }
  cout << k << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,q,a[100],b[100],c[100],d[100];
int ans;
vector<int> v;
void dfs(int x,int deep){
	if (deep==n){
		int num=0;
		for (int i=0;i<q;i++) if (abs(v[b[i]-1]-v[a[i]-1])==c[i]) num+=d[i];
		ans=max(ans,num);
		return ;
	}
	for (int i=x;i<=m;i++){
		v.push_back(i);
		dfs(i,deep+1);
		v.erase(v.begin()+v.size()-1);
	}
	return ;
}
int main(){
	cin>>n>>m>>q;
	for (int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
	dfs(1,0);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int CUT = 14;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k; cin >> n >> k;
    string s; cin >> s;
    char mn = 'z';
    for (int i = 0; i < n; i++) {
        if (mn - 'a' > s[i] - 'a') mn = s[i];
    }
    vector<int> loc;
    vector<pair<pair<int, int>, char>> blocks;
    string t = "";
    for (int i = 0; i < n; i++) t += s[i];
    for (int i = n - 1; i >= 0; i--) t += s[i];
    int it1 = 0, it2 = 0;
    while (it1 != 2 * n) {
        while (it2 != 2 * n - 1 && t[it1] == t[it2 + 1]) it2++;
        blocks.emplace_back(make_pair(it1, it2), t[it1]);
        it1 = ++it2;
    }
    int b_size = 0;
    for (auto block: blocks) {
        if (block.second == mn) {
            b_size = max(b_size, block.first.second - block.first.first + 1);
        }
    }
    for (auto block: blocks) {
        if (block.second == mn && block.first.second - block.first.first + 1 == b_size && block.first.second >= n - 1) {
            loc.push_back(block.first.second);
        }
    }
    if (k >= CUT) {
        for (int i = 0; i < n; i++) cout << mn;
        cout << '\n';
    } else if (k == 1) {
        string ans = s;
        for (int i = 0; i < n; i++) {
            string check = "";
            for (int j = 0; j < n; j++) {
                check += t[i + j];
            }
            ans = min(ans, check);
        }
        cout << ans << '\n';
    } else {
        string ans = "";
        for (int i = 0; i < n; i++) ans += 'z';
        for (int pos: loc) {
            string check = "";
            for (int i = pos; i >= pos - n + 1; i--) check += t[i];
            reverse(check.begin(), check.end());
            for (int i = 0; i < k - 2; i++) {
                for (int i = n - 1; i >= 0; i--) check += check[i];
                int last = n - 1;
                for (int j = n - 1; j >= 0; j--) {
                    if (check[j] == mn) last = j;
                    else break;
                }
                string nxt = "";
                for (int j = n - last; j <= n - last + n - 1; j++) {
                    nxt += check[j];
                }
                swap(check, nxt);
            }
            int last = n - 1;
            for (int j = n - 1; j >= 0; j--) {
                if (check[j] == mn) last = j;
                else break;
            }
            for (int j = n - 1; j >= 0; j--) check += check[j];
            string res = "";
            for (int j = last; j <= last + n - 1; j++) {
                res += check[j];
            }
            ans = min(ans, res);
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 3808
h,w,n=[int(j) for j in input().split()]
R,C=[int(j) for j in input().split()]
s=input()
t=input()

#LR
x=C
l,r=1,w
for i in range(n)[::-1]:
    if t[i]=="R":
        l-=1
    elif t[i]=="L":
        r+=1
    if l==0:
        l=1
    if r>w:
        r=w
    if s[i]=="R":
        r-=1
    elif s[i]=="L":
        l+=1
    if  l>r:
        print("NO")
        exit()
if not l<=x<=r:
    print("NO")
    exit()
#UD
x=h+1-R
l,r=1,h
for i in range(n)[::-1]:
    if t[i]=="U":
        l-=1
    elif t[i]=="D":
        r+=1
    if l==0:
        l=1
    if r>h:
        r=h
    if s[i]=="U":
        r-=1
    elif s[i]=="D":
        l+=1
    if l>r:
        print("NO")
        exit()
if not l<=x<=r:
    print("NO")
    exit()
print("YES")

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

int main(int argc, char const *argv[])
{
    int a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    for(int i = a; i <= b; i++) {
        if(c % i == 0)
            ans++;
        if(b < c && i == (c + 1) / 2)
            break;
    }

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



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	cin>>a;
	cin>>b;
	sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    sort(a.begin(),a.end());
	if(a<b)
		cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main() {
  int N,M,X,small=0,big=0;
  cin >> N >> M >> X;
  vector <int> A(N);
  for (int i=0;i<M;i++){
  cin >> A.at(i);
    if (A.at(i)< X){
    small++;
    }
    else if (A.at(i)>X){
    big++;
    }
  }
  cout << min(small,big) << endl;

 }

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

int main()
{
  int n;
  cin >> n;
  
  vector<int> a(n), b(n), c(n - 1);
  for (int i = 0; i < n; i ++)
    cin >> a.at(i);
  for (int i = 0; i < n; i ++)
    cin >> b.at(i);
  for (int i = 0; i < n - 1; i ++)
    cin >> c.at(i);
  
  int sum = 0;
  int prev = 51;
  int curr;
  for (int i = 0; i < n; i ++)
  {
    curr = a.at(i) - 1;
    sum += b.at(curr);
    if (prev == curr - 1)
      sum += c.at(prev);
    prev = curr;
  }
  
  cout << sum << endl;
  return 0;
}

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

int n;
int h[100];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> h[i];
	
	int ans = 0;
	while (true) {
		for (i = 0; i < n; i++) if (h[i] > 0) break;
		if (i == n) break;
		
		int l, r;
		for (l = 0; l < n; l++) if (h[l] != 0) break;
		for (r = l; r < n; r++) if (h[r] == 0) break;

		//区間[l, r)に水やり
		int minH = h[l];
		for (i = l; i < r; i++) minH = min(minH, h[i]);
		for (i = l; i < r; i++) h[i] -= minH;
		ans += minH;
	}
	cout << ans << endl;
	return 0;
}

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

K = abs(A - (T - H[0] * 0.006))
x = 0
ans = 0

for i in H:
    x += 1
    if K >= abs(A - (T - i * 0.006)):
        K = abs(A - (T - i * 0.006))
        ans = x

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
#include<utility>
using namespace std;
int arr[101];
int main (){
	int N;
	long long int min=1000000001, max=-1,aux;
	cin>>N;
	for (int i=0;i<N;i++){
		cin>>aux;
		aux=abs(aux);
		if (aux>max)
			max=aux;
		if (aux<min)
			min=aux;
	}
	cout<<max-min<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int m,f,r;
    int p;
    
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1 && f==-1 && r==-1){
            break;
        }
        p=m+f;
        if(m==-1 || f==-1){
            printf("F\n");
        }
        else if(p>=80){
            printf("A\n");
        }
        else if(p<80 && p>=65){
            printf("B\n");
        }
        else if(p<65 && p>=50){
            printf("C\n");
        }
        else if((p<50 && p>=30) && r>=50){
            printf("C\n");
        }
        else if(p<30){
            printf("F\n");
        }
         else if(p<50 && p>=30){
            printf("D\n");
        }
    }
}



Measured memory_bytes: 2032
#include <iostream>

using namespace std;

const int MAX_N = 2e5 + 5;
const int ALPH = 26;

int arr [MAX_N];
int rmost [ALPH][MAX_N]; // rightmost appearance of i that is <= j
int lmost [ALPH][MAX_N];
int dp [MAX_N][ALPH];

void report (int length, int start) {
  int cur = start, pos = lmost[start][0];
  for (int k = length - 1; k >= 0; k--) {
    cout << (char) ('a' + cur);    
    if (k != 0) {
      for (int i = 0; i < ALPH; i++) {
        if (dp[k][i] <= pos) {
          pos = lmost[i][pos + 1];
          cur = i;
          break;
        }
      }
    }
  }
  cout << endl;
  exit(0);
}

int main () {
  ios::sync_with_stdio(false);

  string s;
  cin >> s;

  int n = s.size();
  for (int i = 1; i <= n; i++) {
    arr[i] = s[i - 1] - 'a';
  }

  for (int i = 1; i <= n; i++) {
    rmost[arr[i]][i] = i;
    lmost[arr[i]][i] = i;
  }

  for (int i = 0; i < ALPH; i++) {
    lmost[i][n + 1] = n + 1;
    for (int j = n; j >= 0; j--) {
      if (lmost[i][j] == 0) {
        lmost[i][j] = lmost[i][j + 1];
      }
    }
  }

  for (int i = 0; i < ALPH; i++) {
    for (int j = 1; j <= n; j++) {
      if (rmost[i][j] == 0) {
        rmost[i][j] = rmost[i][j - 1];
      }
    }
  }

  for (int i = 0; i < ALPH; i++) {
    dp[1][i] = rmost[i][n];
    if (dp[1][i] == 0) {
      report(1, i);
    }
  }

  for (int k = 2; k <= n; k++) {
    int mn = n;
    for (int i = 0; i < ALPH; i++) {
      mn = min(mn, dp[k - 1][i]);
    }

    for (int i = 0; i < ALPH; i++) {
      dp[k][i] = rmost[i][mn - 1];
      if (dp[k][i] == 0) {
        report(k, i);
      }
    }
  }
}


Measured memory_bytes: 44692
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

mod = 10 **9 + 7


def calc(n):
    ans = 0
    if n & 1:
        Y = [33746491, 897911890, 741553367, 922649390, 82466138, 30593036, 407570181, 119032926, 718747607, 27251510, 15690675, 2549638, 225225, 11620, 330, 4]
    else:
        Y = [0,       296640693, 751721723, 240221668, 869628520, 30593036, 407570181, 119032926, 718747607, 27251510, 15690675, 2549638, 225225, 11620, 330, 4]

    x = 1
    for y in Y:
        ans = (ans + x*y%mod) % mod
        x = x*n%mod
    ans = ans * pow(167382319104000, mod-2, mod) % mod
    return ans

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)

    ans = [0] * N
    for i in range(N):
        n = next(it)
        ans[i] = calc(n)

    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 65492
/**
 *    author:  FromDihPout
 *    created: 2020-06-25
**/

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    set<int> unique;
    for (int i = 0; i < n; i++) {
        unique.insert(a[i]);
    }
    
    int m = (int) unique.size();
    if ((n & 1) && (m & 1)) {
        cout << m << endl;
    }
    else {
        cout << m - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 8264
h,w=gets.split.map(&:to_i)
f=true
c=[]
10.times do
  c << gets.split.map(&:to_i)
end
while f
  f=false
  10.times do |i|
    10.times do |j|
      10.times do |k|
        if c[j][i]>c[k][i]+c[j][k]
          c[j][i]=c[k][i]+c[j][k]
          f=true if !f
        end
      end
    end
  end
end
l=[0]*10
h.times do
  a=gets.split.map(&:to_i)
  a.each do |aa|
    next if aa==-1||aa==1
    l[aa]+=1
  end
end
ans=0
10.times do |i|
  ans+=l[i]*c[i][1]
end
puts ans


Measured memory_bytes: 2300
#include <iostream>
#include <cstdio>

using namespace std;

int n;
int ans;

int main()
{
    scanf("%d", &n);
    for(int i = 11; n; i+=10)
    {
        bool v = false;
        for(int j = 2; j * j <= i; j++)
        {
            if(i % j == 0)
            {
                v = true;
                break;
            }
        }
        if(!v)
        {
            printf("%d ", i);
            n--;
        }
    }
    return 0;
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

#define N_MAX 100000

ll N, X;
ll x[N_MAX];
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> X;
    REP(i, N) {cin >> x[i];x[i] = abs(x[i]-X);}
    
    ll ans = x[0];
    REP(i, N-1) {
        ans = gcd(ans, x[i+1]);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define pint pair<int, int>
#define mp make_pair

using namespace std;

typedef long long ll;


const int INF = 1e9;

struct edge
{
	int to, co;
	edge(int t, int c) : to(t), co(c) {}
};

int N, M, K;
int main() {
	iostream::sync_with_stdio(false);

	cin >> N >> M >> K;

	vector< vector<edge> > g(N);

	for (int i = 0; i < M; i++) {
		int a, b, l;
		cin >> a >> b >> l;
		a--; b--;

		g[a].push_back(edge(b, l));
		g[b].push_back(edge(a, l));
	}

	priority_queue<pint, vector<pint>, greater<pint>> pq;
	vector<int> cost(N, INF);
	vector<bool> used(N, false);

	for (int i = 0; i < K; i++) {
		int s;
		cin >> s;
		s--;
		pq.push(mp(0, s));
		cost[s] = 0;
	}

	while (!pq.empty())
	{
		int c = pq.top().first;
		int v = pq.top().second;
		pq.pop();

		if (used[v]) continue;
		used[v] = true;

		for (auto e : g[v]) {
			if (cost[e.to] > cost[v] + e.co) {
				cost[e.to] = cost[v] + e.co;
				pq.push(mp(cost[e.to], e.to) );
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (auto e : g[i]) {
			int l = abs(cost[i] - cost[e.to]);
			if (e.co == l) ans = max({ans, cost[i], cost[e.to]});
			else {
				ans = max(ans, (cost[i] + cost[e.to] + e.co + 1) / 2);
			}
		}
	}

	cout << ans << endl;


	return 0;
}




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


int main() {
  // ここにプログラムを追記

  string a;
  int ans;
  
  cin >> a;
  if(a[0] == '1' ) ans++;
  if(a[1] == '1' ) ans++;
  if(a[2] == '1') ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        List<List<Integer>> edge = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            edge.add(new ArrayList<>());
        }
        for (int i = 0; i < m; i++) {
            int a = scanner.nextInt() - 1;
            int b = scanner.nextInt() - 1;
            edge.get(a).add(b);
            edge.get(b).add(a);
        }
        List<Integer> path = new ArrayList<>();
        boolean[] visited = new boolean[n];
        int node = 0;
        loop: while (true) {
            visited[node] = true;
            path.add(0, node);
            for (int i : edge.get(node)) {
                if (!visited[i]) {
                    node = i;
                    continue loop;
                }
            }
            break;
        }
        node = 0;
        loop: while (true) {
            visited[node] = true;
            if (node != 0) {
                path.add(node);
            }
            for (int i : edge.get(node)) {
                if (!visited[i]) {
                    node = i;
                    continue loop;
                }
            }
            break;
        }
        System.out.println(path.size());
        for (int i : path) {
            System.out.println(i + 1);
        }
    }
}

Measured memory_bytes: 103356
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 305;
const int mod = 998244353;
int dp[N][N][N], f[N][N][N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    int k;
    cin >> k;
    vector <int> a;
    int p = 0;
    while(p < s.length() && s[p] == '1') p++;
    while(p < s.length()){
        if (s[p] == '0'){
            p++;
            int x = 0;
            while(p < s.length() && s[p] == '1'){
                x++;
                p++;
            }
            a.pb(x);
            continue;
        }
    }
    reverse(a.begin(), a.end());
    a.pb(0);
    int n = (int)a.size();
    int ans = 0;
    int t = 0;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++){
        t += a[i - 1];
        for (int j = t; j >= 0; j--){
            for (int k = 0; k <= t; k++){
                for (int l = 0; l <= a[i - 1] && l <= j && l <= k; l++){
                    dp[i][j][k] = (dp[i][j][k] + dp[i - 1][j - l][k - l]) % mod;
                }
                dp[i][j][k] = (dp[i][j][k] + f[i - 1][k][j + 1]) % mod;
                f[i][k][j] = (f[i][k][j + 1] + dp[i][j][k]) % mod;
            }
        }
    }
    for (int i = 0; i <= min((int)s.length(), k); i++){
        ans = (ans + dp[n][0][i]) % mod;
    }
    cout << ans;
}


Measured memory_bytes: 110852
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 100000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

vector<ll> dijkstra(int n, vector<vector<PL>>& G,int& s) {
    vector<ll> dist(n,HINF);
    dist[s] = 0;

    priority_queue<PL,vector<PL>,greater<P>> q;
    q.push({0,s});

    while (!q.empty()) {
        PL p = q.top(); q.pop();
        ll d = p.first;
        int v = p.second;
        if (dist[v] < d) continue;
        for (PL p: G[v]) {
            int e = p.first;
            ll cost = p.second;
            if (dist[e] > dist[v] + cost) {
                dist[e] = dist[v] + cost;
                q.push({dist[e],e});
            }
        }  
    }
    return dist;
}

int main() {
    int N,M,s,t; cin >> N >> M >> s >> t;
    --s; --t;
    vector<vector<PL>> A(N),B(N);
    rep(i,M) {
        int u,v,a,b; cin >> u >> v >> a >> b;
        --u; --v;
        A[u].emplace_back(v,a);
        A[v].emplace_back(u,a);
        B[u].emplace_back(v,b);
        B[v].emplace_back(u,b);
    } 
    vector<ll> Adist = dijkstra(N,A,s);
    vector<ll> Bdist = dijkstra(N,B,t);
    vector<ll> ans(N);
    ll x = HINF;
    irep(i,N) {
        x = min(x,Adist[i] + Bdist[i]);
        ans[i] = 1000000000000000LL - x;
    }
    rep(i,N) cout << ans[i] << '\n';
    return 0;
}

Measured memory_bytes: 22288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

int cost[10][10];

void warshall_floyd(int n) {
  rep(i, n) {
    rep(j, n) {
      rep(k, n) {
        cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
      }
    }
  }
}

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

  int h, w;
  cin >> h >> w;
  rep(i, 10) rep(j, 10) cin >> cost[i][j];

  warshall_floyd(10);

  int ans = 0;
  int x;
  rep(i, h) rep(j, w) {
    cin >> x;
    if (x != -1) ans += cost[x][1];
  }
  cout << ans << endl;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int m;
	cin>>m;
	int arr[m];
	for(int i = 0; i < m; i++){
		cin>>arr[i];
	}
	for(int i = 0; i < m; i++){
		n -= arr[i];	
	}
	if(n > -1)
		cout<<n;
	else
		cout<<"-1";
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define PI 3.141592653589


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    float r;
    cin>>r;
    float ans=2*PI*r;
    printf("%.20f",ans);
    return 0;
}




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

template<typename T, typename U> void dmin(T &x, U y) { if(x > y) x = y; }

const int MAX_N = 100;
const int INF = 1001001001;

int main() {
  int n, r, c;
  int rc[MAX_N][2];
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> r >> c;
    rc[i][0] = r; rc[i][1] = c;
  }

  int dp[MAX_N][MAX_N];
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      dp[i][j] = INF;
    }
    dp[i][i] = 0;
  }

  for (int l=2; l<=n; l++) {
    for (int i=0; i+l-1<n; i++) {
      for (int j=1; j<l; j++) {
        dmin(dp[i][i+l-1], dp[i][i+j-1] + rc[i][0]*rc[i+j-1][1]*rc[i+l-1][1] + dp[i+j][i+l-1]);
      }
    }
  }

  cout << dp[0][n-1] << endl;
  return 0;
}

Measured memory_bytes: 3164
using System;
using System.Collections.Generic;
using System.Linq;

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var nr = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            var n = nr[0];
            var r = nr[1];

            // n: コンテスト参加回数
            // r: 表示レーティング
            // answer: 内部レーティングをこたえよ

            // 表示レーティングは
            // if(n >= 10) answer = n;
            // if(n < 10) answer = r + 100 * (10 - k)

            if (n >= 10)
            {
                Console.WriteLine(r);
            }
            else
            {
                Console.WriteLine($"{r + 100 * (10 - n)}");
            }
        }
    }
}


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

int main()
{
  int i,j,k;
  int N;
  int syou;
  char S[101];
  scanf("%s",S);
  N = strlen(S);
  
  syou = N/2;
  
  k = 0;
  for(i=0;i<syou;i++){
    j = (N-1)-i;
    if( S[i] == S[j] ){
    }
    else{
      k++;
    }
  }
  
  printf("%d\n",k);
  
  return 0; 
}

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

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

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

int f[N][N], s[N][N], C[N][N];

int main() {
	reg n = read(), k = read(), m = read();
	fo(i, 0, k) f[1][i] = 1, s[1][i] = k - i + 1;
	C[0][0] = 1; fo(i, 1, n) {C[i][0] = 1; fo(j, 1, i) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % m;}
	fo(i, 2, n + 1) {
		fo(j, 0, k) fo(h, 1, i - 1) f[i][j] = (f[i][j] + (LL)f[i - h][j] * s[h][j + 1] % m * C[i - 2][h - 1]) % m;
		s[i][k] = f[i][k]; fd(j, k - 1, 1) s[i][j] = (s[i][j + 1] + f[i][j]) % m;
	} pr2(f[n + 1][0]);
	return 0;
}



Measured memory_bytes: 1280
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	int n; cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		v[i]--;
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		int love = v[i];
		if (v[love] == i) res++;
	}
	cout << res / 2 << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;
// const ll MOD = 1000000007;
const ll inf = 999999999999;

bool check(vector<pair<int,int>> v) {
    int h = 0;
    for (auto p : v) {
        int b = h + p.first;
        if (b < 0) return false;
        h += p.second;
    }
    return true;
}

int main() {
   int n; cin >> n;
   vector<pair<int,int>> ls,rs;
   int total = 0;
   for (int i = 0; i < n; i++) {
       string s; cin >> s;
       int saikaten = 0;
       int last = 0;
       for (int i = 0; i < s.size(); i++) {
           if (s[i] == '(') last++;
           else last--;
           saikaten = min(last,saikaten);
       }
       total += last;
       if (last > 0) ls.emplace_back(saikaten, last);
       else rs.emplace_back(saikaten-last,-last);
    }
    sort(ls.rbegin(),ls.rend());
    sort(rs.rbegin(),rs.rend());
    if (check(ls) && check(rs) && total == 0) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 18764
N = int(input())
A = list(map(int,input().split()))

A.sort(reverse = True)
max_num = []
before_num = 0

for j in A:
        if before_num == j:
                max_num.append(j)
                if len(max_num) == 2:
                        break
                else:
                        before_num = 0
        else:
                before_num = j

if len(max_num) >= 2:
        print(max_num[0]*max_num[1])
else:
        print("0")

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll dp[105][100005];

void Main() {
    int N, W;
    cin >> N >> W;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    rep(i, N) {
        rep(j, W + 1) {
            if (j - items[i].first >= 0) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - items[i].first] + items[i].second);
            }
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 79360
import java.util.Scanner

object Main {
//  def getLucas(n: Int): Long = {
//    val l: Long = if (n == 0) {
//      2
//    } else if (n == 1) {
//      1
//    } else {
//      getLucas(n - 1) + getLucas(n - 2)
//    }
//    return l
//  }

//  def getLucas(n: Int): Long = {
//    var lucasArr: Array[Long] = Array.empty
//    lucasArr = lucasArr :+ 2.toLong
//    lucasArr = lucasArr :+ 1.toLong
//    for (i <- (2 to n)) {
//      lucasArr = lucasArr :+ (lucasArr(i - 1) + lucasArr(i - 2)).toLong
//    }
//    lucasArr(n)
//  }

  def main(args: Array[String]): Unit = {
    val input = new Scanner(System.in)
    val n: Int = input.nextInt

    var lucasArr: Array[Long] = Array.empty
    lucasArr = lucasArr :+ 2.toLong
    lucasArr = lucasArr :+ 1.toLong
    for (i <- (2 to n)) {
      lucasArr = lucasArr :+ (lucasArr(i - 1) + lucasArr(i - 2)).toLong
    }
    println(lucasArr(n))
  }
}

Measured memory_bytes: 25904
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

L, R, d = map(int, input().split())

ans = 0
for i in range(L, R+1):
    if i % d == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9176