akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

//文字列から数値に変換
int getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

//文字列から数値へ変換してkeyを作成する
long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L], com[9];

	for (i = 0; i < M; i++) {
		H[i][0] = '\0';
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", com);
		scanf("%s", str);

		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}

	return 0;
}


Measured memory_bytes: 16048
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          firstn
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define fr(i,l,u) 	for(i=l;i<=u;i++)
#define bk(i,l,u)	for(i=l;i>=u;i--)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll posx[]={1,-1,0,0};
ll posy[]={0,0,1,-1};

void solve()
{
    ll n,i,j,w;
    cin>>n>>w;
    ll wt[n+1],val[n+1],s=0;
    for(i=1;i<=n;i++)
    {
        cin>>wt[i]>>val[i];
        s+=val[i];
    }
    ll dp[s+1];
    mset(dp,0);
    for(i=1;i<=s;i++)
    dp[i]=mod;
    for(i=1;i<=n;i++)
    {
        for(j=s;j>=val[i];j--)
            dp[j]=min(dp[j],wt[i]+dp[j-val[i]]);
    }
    for(i=s;i>0;i--)
    {
        if(dp[i]<=w)
        break;
    }
    cout<<i;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    int P[N];
    for (int i = 0; i < N; i++) cin >> P[i];
    int ans = 1, min = P[0];
    for (int i = 1; i < N; i++) {
        if (P[i] <= min) {
            ans++;
            min = P[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <unordered_map>

using namespace std;
using ll = long long;
using ld = long double;
const ll inf = 1000000000000000008;
ll N, A, B, C, D;
vector<ll> mul = {2, 3, 5};
 
unordered_map<ll, ll> Map;
 
ll calc(ll n) {
	if(n == 0ll) return 0ll;
	if(n == 1ll) return D;
	if(Map.count(n)) return Map[n];
    
	ll ret = inf;
	if(n < ret / D) ret = n*D;
	for(auto x:mul) {
		ll ex;
		if(x == 2) ex = A;
		else if(x == 3) ex = B;
		else ex = C;
		if(n % x == 0) ret = min(ret, calc(n / x) + ex);
		else {
			ll up = (n / x + 1) * x;
			ll down = (n / x) * x;
			ret = min(ret, calc(down / x) + D * (n - down) + ex);
			ret = min(ret, calc(up / x) + D * (up - n) + ex);
		}
	}
	return Map[n] = ret;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll tc; cin>>tc;
	while(tc--) {
		cin >> N >> A >> B >> C >> D;
		cout << calc(N) << '\n';
		Map.clear();
	}
	return 0;
}

Measured memory_bytes: 3880
//Finite Disappointment and Infinite Hope
#include <bits/stdc++.h>
using namespace std;
#define help ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define dbg(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) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.first<<","<<v.second<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    for(auto &x:c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
const ll N=2e5+5,MOD=1e9+7;
int main(){
help
    ll n,k,s;cin>>n>>k>>s;
    if(s==1000000000){
        for(ll i=0;i<k;i++)cout<<s<<" ";
        for(ll i=k;i<n;i++)cout<<"1 ";
    }
    else{
        for(ll i=0;i<k;i++)cout<<s<<" ";
        for(ll i=k;i<n;i++)cout<<1000000000<<" ";
    }
}


Measured memory_bytes: 1280
from collections import deque
K=int(input())
q=deque([1,2,3,4,5,6,7,8,9])
for _ in range(K):
  x=q.popleft()
  a=x%10
  if a!=0:
    q.append(x*10+a-1)
  q.append(x*10+a)
  if a!=9:
    q.append(x*10+a+1)
print(x)

Measured memory_bytes: 11956
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a[3];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    if((a[0]==a[1]&&a[1]!=a[2])||(a[0]!=a[1]&&a[1]==a[2])){
        cout << "Yes"<<endl;
    }else{
        cout<<"No" <<endl;

    }   
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */
typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* global variables */

/* function */

/* main */
int main(){

    int q; cin >> q;
    int op, x;
    string key;
    map<string, int> M;

    for (int i = 0; i < q; i++) {
        cin >> op >> key;
        switch(op) {
            case 0:
                cin >> x;
                // insert(key, x) :
                // Insert an element formed by a pair of key and x to M
                M[key] = x;
                break;
            case 1:
                // get(key): Print the value with the specified key
                if (M.count(key))
                    cout << M[key] << '\n';
                else
                    cout << 0 << '\n';
                break;
            case 2:
                // delete(key)
                M.erase(key);
                break;
        }
    }

}



Measured memory_bytes: 27720
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  int n;
  string s, t;
  cin >> n >> s;
  int l = 0;
  rep(i,n) {
    if(s[i]==')'&&l==0) t = '(' + t;
    else if(s[i]==')') l--;
    else if(s[i]=='(') l++;
    t += s[i];
  }
  while(l>0) {
    t += ')';
    l--;
  }
  cout << t << endl;
  return 0;
}

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

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

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int cnt = 0;
    rep(i, a + 1)
    {
        rep(j, b + 1)
        {
            rep(k, c + 1)
            {
                if (i * 500 + j * 100 + 50 * k == x)
                    cnt++;
            }
        }
    }
    OP(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000007)
#define PI 3.14159265358979323846

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

i64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

i64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

class UnionFind {
 public:
  vector<u64> Par;
  vector<u64> sz;

  UnionFind(u64 n);
  u64 root(u64 x);
  bool same(u64 x, u64 y);
  void unite(u64 x, u64 y);
  u64 size(u64 x);
};

UnionFind::UnionFind(u64 n) {
  Par.resize(n);
  sz.assign(n, 1);
  for (u64 i = 0; i < n; ++i) Par[i] = i;
}

u64 UnionFind::root(u64 x) {
  if (Par[x] == x) {
    return x;
  } else {
    return Par[x] = root(Par[x]);
  }
}

bool UnionFind::same(u64 x, u64 y) { return root(x) == root(y); }

u64 UnionFind::size(u64 x) { return sz[root(x)]; }

void UnionFind::unite(u64 x, u64 y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  sz[x] += sz[y];
  Par[y] = x;
}

int main() {
  cout << setprecision(18);
  u32 N;
  cin >> N;
  double res = 0;
  for (u32 i = 0; i < N; ++i) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      res += x;
    } else {
      res += 380000.0d * x;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, K = map(int, raw_input().split())

DP = [0] * W
DP[K - 1] = 1
for i in range(H):
    DP_ = [0] * W
    for j in range(2 ** (W - 1)):
        B = [0] * (W - 1)
        ls = list(DP)
        for k in range(W - 1):
            if j & (1 << k):
                B[k] = 1
                hoge = ls[k]
                ls[k] = ls[k + 1]
                ls[k + 1] = hoge
        flag = False
        for k in range(W - 2):
            if B[k] and B[k + 1]:
                flag = True
        if flag:
            continue
        for k in range(W):
            DP_[k] += ls[k]
            DP_[k] %= MOD
    DP = DP_

print DP[0]


Measured memory_bytes: 2812
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;




int main(){
	int N; cin >> N;
	vector<ll> A(N),B(N);
	rep(i,N) cin >> A[i] >> B[i];
	ll cnt = 0;
	for(int i = N-1; i >= 0; i--){
		A[i] += cnt;
		A[i] %= B[i];
		if(A[i] != 0) cnt += B[i]-A[i];
	}
	cout << cnt << endl;
}



Measured memory_bytes: 1792
N = int(input())
Ls = list(map(int, input().split()))
Ls.sort()
ans = 0
for i in range(N-2):
  li = Ls[i]
  idx = i
  for j in range(i+1, N-1):
    lj = Ls[j]
    while idx < N and li + lj > Ls[idx]:
      idx += 1
    ans += idx - j - 1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int N = s.size();
    bool a = true;
    rep2(i, 1, N-1){
        if(s[i] != '9'){
            a = false;
            break;
        }
    }
    int ans = 9*(N-1)+(s[0]-'1');
    if(a) ans++;
    cout << ans << endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a<=b){
    for(int i=0;i<b;i++){
      cout << a;
    }
    cout << endl;
  }
  if(b<a){
    for(int i=0;i<a;i++){
      cout << b;
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long dp[n][n][2];
    for(int i = 0; i <n; i++){
        dp[i][i][0] = a[i];
        dp[i][i][1] = 0;
    }
    for(int k = 1; k < n; k++){
        for(int i = 0; i + k < n; i++){
            //compute dp[i][i+k][0], dp[i][i+k][1]
            if(dp[i+1][i+k][1]+a[i] - dp[i+1][i+k][0] > dp[i][i+k-1][1]+a[i+k] - dp[i][i+k-1][0]){
                dp[i][i+k][0] = dp[i+1][i+k][1] + a[i];
                dp[i][i+k][1] = dp[i+1][i+k][0];
            }
            else{
                dp[i][i+k][0] = dp[i][i+k-1][1] + a[i+k];
                dp[i][i+k][1] = dp[i][i+k-1][0];
            }
        }
    }
    cout << dp[0][n-1][0] - dp[0][n-1][1] << "\n";
    return 0;
}

Measured memory_bytes: 140672
#include <iostream>
using namespace std;
int main(){
	int i,j,last,base;
	int N,Q,L;
	int x[100001];
	int b[100001];
	int ans[100001];
	int c[100001];
	int d[100001];
	int jumb1000[100001];
		
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		scanf("%d",&x[i]);
	}
	
	scanf("%d",&L);
	i=1;j=1;
	for(;i<=N;){
		for(;j<=N;){
			if((x[j]-x[i]<=L)){
				last = j;
				j++;
				
			}else{
				b[i]=last;
				i++;
			}
		}
		if(last==N){
			b[i]=last;
			i++;
		}
	}
	
	for(i=1;i<=N;i++){
		
		base = i;
		for(j=1;j<1001;j++){
			if(b[base]<N&&base<N){
				base=b[base];
			}
			else{
				jumb1000[i] =N+1;
				break;
			}
		}
		if(jumb1000[i] !=N+1 )
			jumb1000[i] =base;
	}
	
	scanf("%d",&Q);
	for(i=1;i<=Q;i++){
		scanf("%d",&c[i]);
		scanf("%d",&d[i]);
	}
	for(i=1;i<=Q;i++){

		if(c[i]>d[i]){
			j=c[i];c[i]=d[i];d[i]=j;
		}

		if(L==1){
			ans[i]=d[i]-c[i];continue;
		}
		
		j=1;
		
		while(b[c[i]]<d[i]){
			
			if(jumb1000[c[i]]<d[i]){
				j+=1000;c[i]=jumb1000[c[i]];
				continue;
			}
			c[i]=b[c[i]];
			j++;
		}
		ans[i]=j;
	}
	for(i=1;i<=Q;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

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

    VI x(n);
    REP(i,n-1){
        int p, q, a;
        scanf("%d %d %d", &p, &q, &a);
        x[p] ^= a;
        x[q] ^= a;
    }

    VI a, c(16);
    REP(i,n){
        c[x[i]]++;
    }

    int ans = 0;
    FOR(i,1,15){
        ans += c[i] / 2;
        if (c[i] % 2) a.push_back(i);
    }

    int m = a.size();
    // REP(i,m) cout << a[i]<< endl;


    VI dp(1<<m, 0);
    FOR(mask,1,(1<<m)-1){
        int s = 0;
        REP(i,m) if ((mask >> i) & 1) s ^= a[i];
        // cout << s << endl;
        if (s) continue;
        dp[mask] = 1;
        for (int i = mask; i > 0; i = (mask & (i - 1))){
            if (i == mask) continue;
            s = 0;
            REP(j,m) if ((i >> j) & 1) s ^= a[j];
            if (s == 0){
                dp[mask] = max(dp[mask], dp[i] + dp[mask ^ i]);
            }
        }
    }

    // REP(i,1<<m) cout << dp[i] << endl;

    ans += m - dp[(1<<m)-1];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		Scanner bui = new Scanner(System.in);
		String n = bui.next();
		if(n.equals("G")){
			System.out.println("C");
		}else if(n.equals("C")){
			System.out.println("G");
		}else if(n.equals("A")){
			System.out.println("T");
		}else if(n.equals("T")){
			System.out.println("A");
		}



	}
}


Measured memory_bytes: 21332
n = int(input())
v = list(map(int, input().split()))
v1 = [v[i] for i in range(n) if i % 2 == 0]
v2 = [v[i] for i in range(n) if i % 2 == 1]
v1.sort()
v2.sort()
num1 = 0
num2 = 0
num11 = 0
num22 = 0
check1 = 1
check2 = 1
p = 0
for i in range(len(v1)-1):
    if v1[i] != v1[i+1]:
        if check1 > num1:
            num1 = check1
            p = v1[i]
        check1 = 1
    else:
        check1 += 1
        if check1 > num1:
            num1 = check1
            p = v1[i]

for i in range(len(v2)-1):
    if v2[i] != v2[i+1]:
        if check2 > num2 and v2[i] != p:
            num2 = check2
        check2 = 1
    else:
        check2 += 1
    if check2 > num2 and v2[i] != p:
        num2 = check2

check1 = check2 = 1
for i in range(len(v2)-1):
    if v2[i] != v2[i+1]:
        if check2 > num22:
            num22 = check2
            p = v2[i]
        check2 = 1
    else:
        check2 += 1
    if check2 > num22:
        num22 = check2
        p = v2[i]
        
for i in range(len(v1)-1):
    if v1[i] != v1[i+1]:
        if check1 > num11 and v1[i] != p:
            num11 = check1
        check1 = 1
    else:
        check1 += 1
        if check1 > num11 and v1[i] != p:
            num11 = check1

print(min(n-num1-num2, n-num11-num22))


Measured memory_bytes: 13984
# solution
import io
import math
from math import sqrt

data = int(input())
arr = [list(map(int,input().split())) for _ in range(data)]

result = 0
for i in range(data):
  for j in range(data):
    if i != j:
      result += sqrt((arr[i][0]-arr[j][0])*(arr[i][0]-arr[j][0])+(arr[i][1]-arr[j][1])*(arr[i][1]-arr[j][1]))
print(result/data)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[2]-a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int W, a, b;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> W >> a >> b;

  if (a <= b && b <= a + W) {
    cout << 0 << endl;
    return 0;
  }
  if (a <= b + W && b + W <= a + W) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 0;
  // b は右側
  if (a < b) {
    ans = b - (a + W);
  } else {
    ans = a - (b + W);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			int A=Integer.parseInt(sc.next());
			int B=Integer.parseInt(sc.next());
			int C=Integer.parseInt(sc.next());
			int D=Integer.parseInt(sc.next());
			int S1=A*B;
			int S2=C*D;
			System.out.println(S1>S2?S1:S2);
		}
	}
}

Measured memory_bytes: 21844
s = input()
s = s[::-1]
counter = 0

while counter <= len(s):
    if s[counter:counter+5] == "maerd":
        counter += 5
    elif s[counter:counter+5] == "esare":
        counter += 5
    elif s[counter:counter+7] == "remaerd":
        counter += 7
    elif s[counter:counter+6] == "resare":
        counter += 6
    else:
        break
if len(s) == counter:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)                    \
  for (int i = 0; i < (int)(n); i++) \
    ;

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int n;
  cin >> n;
  vector<int> count(n);
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    count.at(tmp) += 1;
  }
  if (n == 1) {
    if (count.at(0) != 1) {
      cout << 0 << endl;
      return 0;
    } else {
      cout << 1 << endl;
      return 0;
    }
  }
  long ans = 1;
  if (n % 2 == 0) {
    for (int i = 1; i < n; i = i + 2) {
      if (count.at(i) != 2) {
        cout << 0 << endl;
        return 0;
      }
      ans *= 2;
      ans %= (1000000000 + 7);
    }
  } else {
    if (count.at(0) != 1) {
      cout << 0 << endl;
      return 0;
    }
    for (int i = 2; i < n; i = i + 2) {
      if (count.at(i) != 2) {
        cout << 0 << endl;
        return 0;
      }
      ans *= 2;
      ans %= (1000000000 + 7);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3776
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int n = io.r<int>();

        int i = 1;
        while (i <= n)
        {
            int x = i;
            if (x % 3 == 0)
            {
                io.w(" " + i, false);
            }
            else
            {
                while (true)
                {
                    if (x % 10 == 3)
                    {
                        io.w(" " + i, false); break;
                    }
                    x /= 10;
                    if (x == 0)
                    {
                        break;
                    }
                }
            }
            i++;
        }
        io.w("");
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

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

int N,L[2000],ans,itr;

int main(void){
    cin >> N;
    rep(i,N)cin >> L[i];
    sort(L,L+N);
    rep(i,N-2){
        for(int j=i+1;j<N-1;j++){
            itr = lower_bound(L,L+N,L[i] + L[j]) - L;
            ans+=itr - j -1;
            //cout << itr - j -1 <<" " << j << " " << itr <<  endl;
        }
    }
    //cout << lower_bound(L,L+N,L[0] + L[1]) - L<< endl; 
    
    cout << ans << endl;
    

}


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

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
ll M = 1e9 + 7;

ll mod(ll a, ll m)
{
    if (a == 0)
        return 0;
    else
        return (a % m + m) % m;
}
int mod(string num, int a)
{

    int res = 0;

    for (int i = 0; i < num.length(); i++)
        res = (res * 10 + (int)num[i] - '0') % a;

    return res;
}
ll f(ll a)
{
    for (ll i = 2; i * i <= a; i++)
        if (a % i == 0)
            return i;
}
int main()
{
    fio;
    ll t, n, q, k, i, m, u, j, p, r, c, a, b, d;
t=1;
    while (t--)
    {
        cin >> k;
        string s;
        cin >> s;

        if (s.length() <= k)
            cout << s;
        else
        {
            for (i = 0; i < k; i++)
                cout << s[i];
            cout << "...";
        }}
        return 0;
    }

Measured memory_bytes: 3652
#各行はスペード（S）、ハート（H）、クラブ（C）、ダイヤ（D）を表すとする
tbl = [[0 for i in range(13)] for j in range(4)]

#カードの枚数を格納する
n = int(input())

#ループカウンタの初期化
i = 0

#n組のカードを入力する
while i < n:
    card = input().split()
    #スペード
    if card[0] == 'S':
        tbl[0][int(card[1])-1] = 1
    #ハート
    elif card[0] == 'H':
        tbl[1][int(card[1])-1] = 1
    #クラブ
    elif card[0] == 'C':
        tbl[2][int(card[1])-1] = 1
    #ダイヤ
    else:
        tbl[3][int(card[1])-1] = 1
    i += 1

#絵柄のリスト
pattern = ['S', 'H', 'C', 'D']

#持っていないカードを出力する
for i in range(4):
    for j in range(13):
        if tbl[i][j] == 0:
            print(pattern[i], j+1)


Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using data=pair<ll,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

void dijkstra(vector<vector<data>>& tree,vector<ll>& d,ll start){
  ll i,K=tree[start].size(),N=d.size(),cnt=1;
  data x;
  d[start]=0;
  priority_queue<data,vector<data>,greater<data>> que;
  rep(i,K){
    que.push(data(tree[start][i].second,tree[start][i].first));
  }
  while(cnt<N){
    x=que.top();que.pop();
    if(d[x.second]>0)continue;
    d[x.second]=x.first;
    cnt++;
    K=tree[x.second].size();
    rep(i,K){
      if(d[tree[x.second][i].first]<0){
        que.push(data(d[x.second]+tree[x.second][i].second,tree[x.second][i].first));
      }
    }
  }
}

int main(){
  ll i,j,N,Q,K,a,b,c;
  cin>>N;
  vector<ll> d(N,-1);
  vector<vector<data>> tree(N);
  rep1(i,N){
    cin>>a>>b>>c;
    tree[a-1].push_back(data(b-1,c));
    tree[b-1].push_back(data(a-1,c));
  }

  cin>>Q>>K;
  dijkstra(tree,d,K-1);

  rep(i,Q){
    cin>>a>>b;
    cout<<d[a-1]+d[b-1]<<endl;
  }
  return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;

  vector< int > g[3000];
  for(int i = 1; i < N; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }

  function< int(int, int) > dfs = [&](int idx, int par) {
    bool have = false;
    int lim = inf;
    for(auto& to : g[idx]) {
      if(to == par) continue;
      have = true;
      chmin(lim, dfs(to, idx));
    }
    if(have) {
      if(lim < A[idx]) return inf;
      else return A[idx];
    } else {
      return A[idx];
    }
  };
  for(int i = 0; i < N; i++) {
    if(dfs(i, -1) == inf) {
      cout << i + 1 << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 768
def main():
    co=0
    n=input()
    n=int(n)
    l1=[]
    l2=[]
    for i in range(n):
        l1.append(input())
    m=input()
    m=int(m)
    for j in range(m):
        l2.append(input())

    for l in l1:
        co=max(co,l1.count(l)-l2.count(l))


    print(co)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N, K = map(int, input().split())
MOD = 998244353
S = []

for _ in range(K):
    l, r = map(int, input().split())
    S.append((l, r))

dp = [0] * (N + 1)
accDp = [0] * (N + 1)
dp[1] = 1
accDp[1] = 1

for i in range(2, N + 1):
    for l, r in S:
        r, l = max(0, i - l), max(1, i - r)
        dp[i] += accDp[r] - accDp[l - 1]
    dp[i] %= MOD
    accDp[i] = (accDp[i - 1] + dp[i]) % MOD

print(dp[N])


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	if(a+b==15) cout <<"+";
	else if(a*b==15) cout<<"*";
	else cout<<"x";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    ll ans=1;
    ll c1=-1,c2=-1,c3=-1;
    rp(i,n){
        ll a;
        cin >> a;
        if(c1+1==a){
            if(c2+1!=a){
                c1++;
                continue;
            }else if(c3+1!=a){
                ans*=2;
                ans%=Mod;
                c1++;
                continue;
            }else{
                ans*=3;
                ans%=Mod;
                c1++;
                continue;
            }
        }else if(c2+1==a){
            if(c3+1!=a){
                c2++;
                continue;
            }else{
                ans*=2;
                ans%=Mod;
                c2++;
                continue;
            }
        }else if(c3+1==a){
            c3++;
            continue;
        }else{
            print(0);
            return;
        }
    }
    ans%=Mod;
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
const int N=2e5+5;
int n,m,now,a[N],b[N],v[N],fa[N],id[N],vi[N],nex[N],head[N];
void addedges(int x,int y){
	nex[++now]=head[x];
	head[x]=now,v[now]=y;
}
vector<int>d[N];
long long f[N],s[N];
bool com(int x,int y){
	return a[x]<a[y];
}
int find(int x){
	return fa[x]?fa[x]=find(fa[x]):x;
}
void dfs(int x){
	int si=d[x].size();
	for(int i=0;i<si;i++){
		int v=d[x][i];
		dfs(v),s[x]+=s[v];
	}
	s[x]+=b[x],f[x]=s[x]+a[x];
	for(int i=0;i<si;i++){
		int v=d[x][i];
		f[x]=min(f[x],s[x]-s[v]+max(f[v],1LL*a[x]));
	}
}
int main(){
	//freopen("1.out","w",stdout);
	//freopen("1.in","r",stdin);
	n=read(),m=read();
	for(int i=1;i<=n;i++)	a[i]=read(),b[i]=read(),a[i]=max(a[i]-b[i],0);
	for(int i=1;i<=m;i++){
		int x=read(),y=read();
		addedges(x,y),addedges(y,x);
	}
	for(int i=1;i<=n;i++)	id[i]=i;
	sort(id+1,id+n+1,com);
	for(int i=1;i<=n;i++){
		int x=id[i];	vi[x]=1;
		for(int j=head[x];j;j=nex[j])
			if(vi[v[j]]){
				int y=find(v[j]);
				if(y==x)	continue;
				d[x].push_back(y),fa[y]=x;
			}
	}
	dfs(id[n]);
	printf("%lld\n",f[id[n]]);
	return 0;
}


Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c,n) for(int i=c;i<n;i++)

int main() {
  double a,b,n,cal1,cal2,x,ans;
  cin>>a>>b>>n;

  if(n>=b){x=b-1;}
  else{x=n;}
  cal1=((a*x)/b);
  cal2=(x/b);
  ans=floor(cal1)-(a*floor(cal2));

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


Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> P;

void Input(VVI& G,int n)
{
  for(int i=0;i<n;i++)
    {
      G[i].resize(n);
      for(int j=0;j<n;j++)
	{
	cin >> G[i][j];

	}
     
    }
}

VVI rotate90(VVI G)
{
  int n = G.size();

  VVI ret;
  ret.resize(n);

  for(int i=0;i<n;i++)
    {
      ret[i].resize(n);
      for(int j=0;j<n;j++)
	ret[i][j] = G[j][n-i-1];
    }

  return ret;
}

bool check(VVI& G,VVI& G2, P p)
{

  for(int i=p.S;i<p.S+G2.size();i++)
    {
      for(int j=p.F;j<p.F+G2.size();j++)
	{	
	  //cout << G[i][j] <<  " "; 
	  if(G2[i-p.S][j-p.F] == -1)
	    continue;
	  else if(!(i < G.size() && j < G.size()) )
	    return false;
	  else if(G[i][j] != G2[i-p.S][j-p.F])
	    return false;
	}
      //cout << endl;
    }
  return true;
}

void print(VVI& G)
{
  for(int i=0;i<G.size();i++)
    {
      for(int j=0;j<G[i].size();j++)
	cout << G[i][j] << " ";
      cout << endl;
    }
  cout << endl;
    
}

int main()
{
  int n,m;
  while(cin >> n >> m,n|m)
    {
     
      VVI G,G2;
      bool Fin = false;
      G.resize(n);
      G2.resize(m);
      Input(G,n);    
      Input(G2,m);
      vector<P> vec;
    
      for(int x = 0; x < 4; x++){
	
	for(int i=0;i<G.size();i++)
	  {
	    for(int j=0;j<G.size();j++)
	      {
		//cout << j <<  " - " << i << " th" << endl;
		if(check(G,G2,P(j,i)))
		{
		  Fin = true;
		  bool f = false;
		  for(int k=0;k<G2.size();k++)
		    {
		    for(int l=0;l<G2.size();l++)
		      {
			if(G2[k][l] != -1)
			  {
			    vec.push_back(P(i+k+1,j+l+1));
			    f = true;
			    break;
			  }
		      }
		    if(f)
		      break;
		    }
		
		}
		//cout << endl;
	      }
	  }

	G2 = rotate90(G2); 
      }
      
      sort(vec.begin(),vec.end());

      if(!vec.size())
	cout << "NA" << endl;
      else 
	cout << vec[0].S << " " << vec[0].F << endl;

    }
  return 0;
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long X;
	scanf("%lld",&X);

	vector<bool> primes(200001, true);
	primes[0] = false;
	primes[1] = false;
	for (ll i = 2; i < 200001; ++i)
	{
		if (primes[i])
		{
			for (ll j = 2 * i; j < 200001; j += i)
			{
				primes[j] = false;
			}
		}
	}
	for (ll i = X; i < 200001; ++i)
	{
		if (primes[i])
		{
			cout << i << endl;
			return EXIT_SUCCESS;
		}
	}

	return 0;
}


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

// #define int long long

/* short */
#define pb push_back
#define print(Target) cout << Target << '\n'

/* REPmacro */
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}

/* const */
const int INF = INT_MAX;

signed main()
{
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vi s(n + 1); s[0] = m;
  bool flg = true;
  REP(i, n){
    int in, out;
    cin >> in >> out;
    s[i + 1] = s[i] + in - out;
    if (s[i + 1] < 0) flg = false;
  }
  flg ? print(*max_element(s.begin(), s.end())) : print("0");

  return (0);
}

Measured memory_bytes: 1240
mod = 10 ** 9 + 7
h, w, a, b = map(int, input().split())
def comb(n, r):
    if n < r:return 0
    if n < 0 or r < 0:return 0
    return fa[n] * fi[r] % mod * fi[n - r] % mod
fa = [1] * (h + w + 1)
fi = [1] * (h + w + 1)
for i in range(1, h + w + 1):
    fa[i] = fa[i - 1] * i % mod
    fi[i] = pow(fa[i], mod - 2, mod)
ans = 0
for i in range(h - a):
    ans += comb(b + i - 1, b - 1) * comb(h + w - b - i - 2, w - b - 1)
    ans %= mod
print(ans % mod)

Measured memory_bytes: 24516
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A= sc.nextInt();
		int B = sc.nextInt();
		if(A>B) {
			System.out.println(A-1);
		} else {
			System.out.println(A);
		}
	}
}

Measured memory_bytes: 22996
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


ll solve(){
    ll res = 0;
    ll N,K; cin >> N >> K;
    if(K == 0) return res = N*N;
    for(ll b = K+1; b<= N;b++){
        for(int i = 0; b*i+K <= N;i++){
            ll t = b*(i+1);
            if(t <= N){
                res += (b-K);
            }else{
                res += (N - (b*i+K)+1);
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    auto ret = solve();
    cout << ret << endl;
    return 0;
}


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

using namespace std;

int main() {
    string s;

    cin >> s;

    for (int i = 1; i < s.size(); i++) {
        if (s[i] == s[i-1]) {
            cout << i << " " << i+1 << endl;
            return 0;
        }
    }

    for (int i = 2; i < s.size(); i++) {
        if (s[i] == s[i-2]) {
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
    }

    cout << "-1" << " " << "-1" << endl;
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    private static int depth = 0;

    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(" ");
        var N = int.Parse(input[0]);
        var M = int.Parse(input[1]);

        var graph = new List<List<int>>();
        var seen = new List<bool>();
        graph.Add(new List<int>());
        seen.Add(true);
        for (int i = 0; i < N; i++)
        {
            graph.Add(new List<int>());
            seen.Add(false);
        }

        for (int i = 0; i < M; i++)
        {
            var input2 = Console.ReadLine().Split(" ");
            var A = int.Parse(input2[0]);
            var B = int.Parse(input2[1]);

            graph[A].Add(B);
            graph[B].Add(A);
        }

        var depthMax = 0;
        for (int i = 1; i < N; i++)
        {
            if (seen[i]) continue;
            depth = 0;
            dfs(graph, seen, i);
            depthMax = Math.Max(depth, depthMax);
        }

        Console.WriteLine(depthMax);
    }

    private static void dfs(List<List<int>> graph, List<bool> seen, int v)
    {
        depth++;
        // vを訪問済みにする
        seen[v] = true;

        // vから行ける各頂点next_vについて再帰処理
        foreach (var next_v in graph[v])
        {
            if (seen[next_v]) continue; //next_vが探索済みならスルー
            dfs(graph, seen, next_v);
        }
    }
}

Measured memory_bytes: 76180