akhauriyash/Code-Regression huggingface dataset:
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int A[3];
  cin>>A[0]>>A[1]>>A[2];
  sort(A,A+3);
  cout << A[2]*10 + A[0] + A[1] << endl; 
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{	
	auto A = RD;
	auto B = RD;
	auto T = RD;

	writeln((T / A) * B);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
  cin>>n;
  long long int a[5];
  for(int i=0;i<5;i++)cin>>a[i];
  long long int ans=-1;
  for(int i=0;i<5;i++){
  	if(ans==-1||ans>a[i])ans=a[i];
  }
cout<<(n+ans-1)/ans+4<<endl;
}


Measured memory_bytes: 256
N=int(input())
XY=[]
for i in range(N):
    x,y=map(int,input().split())
    XY.append([x,y])
    if (XY[0][0]+XY[0][1])%2!=(XY[-1][0]+XY[-1][1])%2:
        print(-1)
        quit()
D=[2**i for i in range(31)]
if (XY[0][0]+XY[0][1])%2==0:
    D=[1]+D
print(len(D))
S=sum(D)
for d in D[::-1]:
    print(d,end=" ")
print()
def check(x,y,s):
    if abs(x)+abs(y)<=s:
        return True
    else:
        return False
for x,y in XY:
    s=S
    for d in D[::-1]:
        s-=d
        if check(x-d,y,s):
            print("R",end="")
            x-=d
        elif check(x+d,y,s):
            print("L",end="")
            x+=d
        elif check(x,y+d,s):
            print("D",end="")
            y+=d
        elif check(x,y-d,s):
            print("U",end="")
            y-=d
        else:
            print("WWWWWWWWWWWWWWWWWW")
            quit()
    print()


Measured memory_bytes: 81496
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

struct edge{
	int to,p;
	lli cap,co;
};
int n;
vector<edge> vs[105];

int ds[105];
mp bf[105];
int inf=1e8;
lli mincof(int st,int gl,int gf){
	lli res=0;
	while(gf>0){
		rep(i,n)ds[i]=inf;
		ds[st]=0;
		for(;;){
			bool ud=false;
			rep(i,n){
				if(ds[i]==inf)continue;
				rep(j,vs[i].size()){
					edge e=vs[i][j];
					if(e.cap<=0)continue;
					if(ds[e.to]>ds[i]+e.co){
						ds[e.to]=ds[i]+e.co;
						bf[e.to]=mp(i,j);
						ud=true;
					}
				}
			}
			if(!ud)break;
		}
		if(ds[gl]==inf)return -1;
		
		//rep(i,n)printf("%d / %d .. %d (%d %d)\n",gf,i,ds[i],bf[i].fir,bf[i].sec);

		lli nf=gf;
		int no=gl;
		while(no!=st){
			int to=bf[no].fir;
			edge& be=vs[to][bf[no].sec];
			nf=min(nf,be.cap);
			no=to;
		}
		
		lli cs=0;
		no=gl;
		while(no!=st){
			int to=bf[no].fir;
			edge& be=vs[to][bf[no].sec];
			be.cap-=nf;
			cs+=be.co;
			vs[no][be.p].cap+=nf;
			no=to;
		}
		res+=cs*nf;
		gf-=nf;
	}
	return res;
}

int m,gf;
int main(void){
	scanf("%d%d%d",&n,&m,&gf);
	rep(i,m){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		edge e;
		e.to=b; e.p=vs[b].size(); e.cap=c; e.co=d;
		vs[a].push_back(e);
		e.to=a; e.p=vs[a].size()-1; e.cap=0; e.co=-d;
		vs[b].push_back(e);
	}
	printf("%lld\n",mincof(0,n-1,gf));	
	return 0;
}

Measured memory_bytes: 1296
N=int(input())

min_x=[]
max_x=[]
for _ in range(N):
    A,B=map(int,input().split())
    min_x.append(A)
    max_x.append(B)

min_x.sort()
max_x.sort()

if N%2==0:
    center=N//2
    min_tmp=(min_x[center]+min_x[center-1])
    max_tmp=(max_x[center]+max_x[center-1])
    print(max_tmp-min_tmp+1)
else:
    center=N//2
    print(max_x[center]-min_x[center]+1)

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

#define ll long long
const int MAX = 2e5;
const int mod = 1e9 +  7;

string x;
ll dp[MAX][14];

ll compute (int i, int k) {
	//printf("%d %d\n", i, k);
	if (i >= x.length()) {
		if (k == 5)
			return 1;
		return 0;
	}
	if (dp[i][k] != -1)
		return dp[i][k];
	if (x[i] != '?') {
		dp[i][k] = compute (i + 1, (k * 10 + (int)(x[i] - '0')) % 13) % mod;
		return dp[i][k] % mod;
	}
	dp[i][k] = 0;
	for (int j = 0; j < 10; j++) {
		dp[i][k] += compute (i + 1, (k * 10 + j) % 13) % mod;
	}
	return dp[i][k] % mod;
}

int main() {
	cin >> x;
	memset(dp, -1, sizeof dp);
	cout << compute (0, 0) << endl;
	return 0;
}

Measured memory_bytes: 28544
a,b,c,d = map(int, input().split())
alice = list(range(a,b+1))
bob = list(range(c,d+1))
ab = alice + bob
l= [i for i in set(ab) if ab.count(i) > 1]
if 0 == len(l) or 1 == len(l):
    print(0)
elif 2 == len(l):
    print(1)
else:
    print(max(l) - min(l))

Measured memory_bytes: 9204
import sys
import time
s1 = time.time()
*data, = map(int, sys.stdin.read().split()[::-1])

def inp():
    global data
    return data.pop()
R, C, k = inp(), inp(), inp()
grid = [[0] * C for _ in range(R)]

for _ in range(k):
    ri, ci, v = inp(), inp(), inp()
    grid[ri - 1][ci - 1] = v


dp = []
for _ in range(4):
    dp.append([[0] * (C + 1) for _ in range(R + 1)])

# print(time.time() - s1)
mx = 0
for row in range(1, R + 1):
    for col in range(1, C + 1):
        level = 0
        dp[1][row][col] = max(dp[1][row][col], dp[3][row - 1][col] + grid[row - 1][col - 1])
        dp[0][row][col] = max(dp[0][row][col], dp[3][row - 1][col])
        level = 1
        v = grid[row - 1][col - 1]
        while level < 4:
            dp[level][row][col] = max(
                dp[level - 1][row][col],
                dp[level][row][col],
                dp[level][row][col - 1],
                dp[level - 1][row][col - 1] + v,
            )
            mx = max(mx, dp[level][row][col])
            level += 1

# print(time.time() - s1)
print(mx)


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

int main(void) {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  vector<pair<int, int>> LR(K);
  rep(i, K) {
    cin >> LR[i].first >> LR[i].second;
    LR[i].second++;
  }

  const int64_t mod = 998244353;
  vector<int64_t> DP(N + 1, 0);
  DP[1] = 1;
  vector<int64_t> ACC(N + 1, 0);
  ACC[1] = 1;

  for (int i = 1; i <= N; ++i) {
    rep(k, K) {
      int il = i + LR[k].first;
      if (il <= N) {
        DP[il] = (DP[il] + ACC[i]) % mod;
      }

      int ir = i + LR[k].second;
      if (ir <= N) {
        DP[ir] = (DP[ir] - ACC[i] + mod) % mod;
      }
    }
    ACC[i + 1] = (ACC[i] + DP[i + 1]) % mod;
  }
  cout << DP[N] << endl;
  return 0;
}


Measured memory_bytes: 6400
n = int(input())
x = input().split()
x = [int(xx) for xx in x]
y = sorted(x)
m = y[int(n/2)]
for i in range(n):
    if x[i] >= m:
        print(y[int(n/2) - 1])
    else:
        print(y[int(n/2)])

Measured memory_bytes: 25556
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, k, ans = 0;
    cin >> n >> k;
    if(k == 1){
        ans = 0;
    }else{
        ans = n - k;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vb vector<bool>
#define vs vector<string>
#define px(x) cout << x << endl
#define pfi(x) printf("%d\n", x)
#define pfs(x) printf("%s\n", x)
#define sfi(x) scanf("%d", &x)
#define sfs(x) scanf("%s", x)

int main() {
   unordered_map<int, int> mp;
   int a,b,c;
   cin >> a >> b >> c;
   mp[a] += 1;
   mp[b] += 1;
   mp[c] += 1;

   if(mp.size() == 2){
        cout << "Yes" << endl;
   }else{
        cout << "No" << endl;
   }










	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N, D = na()
ans = 0
for _ in range(N):
    x, y = na()
    if x * x + y * y <= D * D:
        ans += 1

print(ans)


Measured memory_bytes: 68448
#include <bits/stdc++.h>
    #include <stdio.h>
    #include <vector> 
    #include <algorithm>
    #include <functional>
    using namespace std;
     
    int main(){
      int N, M;
      cin >> N >> M;
      
      vector<int> vec(N);
      for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
      }
      
      std::sort(vec.begin(), vec.end(), std::greater<int>());
      int sum = std::accumulate(vec.begin(), vec.end(), 0);
      
      bool condition = (vec[M-1] * M * 4 >= sum);

      cout << (condition?"Yes":"No") << endl;
      
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll f[2000001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n+r]*((InverseEuler(f[r], MOD) * InverseEuler(f[n], MOD)) % MOD)) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll mod=1e9+7;
    f[0] = 1;
    for(ll i = 1 ; i <= 2000000 ; i++)
        f[i] = (f[i-1]*i)%mod;
    ll x=nxtl(),y=nxtl();
    if((2*x-y)%3||(2*y-x)%3||2*x-y<0||2*y-x<0)
    {
        cout<<"0\n";
        return 0;
    }
    ll n1=(2*x-y)/3;
    ll n2=(2*y-x)/3;
    //cout<<n1<<" "<<n2<<endl;
    cout<<C(n1,n2,mod)<<endl;

    

    return 0;   
}


 
 


Measured memory_bytes: 16000
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  	int n, d;
  	cin >> n >> d;
  	int ret =  n / (2 * d + 1);
  	if (n % (2* d + 1) != 0) ret++;
    cout << ret << endl;
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
using System;

namespace ALDS1_10_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = new int [50];
            a[0] = a[1] = 1;
            int i = 2;
            int n = int.Parse(Console.ReadLine());
            for (; i <= n; i++)
            {
                a[i] = a[i - 1] + a[i - 2];
            }
            Console.WriteLine(a[i-1]);
        }
    }
}

Measured memory_bytes: 9184
N = int(input())
*H, = map(int, input().split())
ans = 0

l, r = 0, 1
while l < N:
    v = H[l]
    a = 0
    while r < N:
        if H[r]<=v:
            a += 1
            v = H[r]
            r += 1
        else:
            l = r-1
            r = l+2
            break
    ans = max(ans, a)
    l+=1
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int temp = 0;
  rep(i, 3) {
    if(s[i] == 'R') {
      temp++;
    } else {
      temp = 0;
    }
    ans = max(ans, temp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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;} //最小公倍数

//-------------------------------------------------
//
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
//

//push_front() : void
//push_back() : void


//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s ;
  cin >> s ;
  int q ;
  cin >> q ;
  int n = SZ(s) ;
  deque<char> data ;
  REP(i,n){
    data.push_back(s.at(i)) ;
  }
  
  int rev = 0 ;
  
  for(int i=0; i<q; i++){
    int qq ;
    cin >> qq ;
    if(qq==1){
      rev += 1 ;
    }
    else{
      int qqq ;
      char c ;
      cin >> qqq >> c ;
      if(rev%2==0){
        if(qqq==1){
        	data.push_front(c) ;
        }
      	else{
        	data.push_back(c) ;
      	}
      }
      else{
        if(qqq==2){
        	data.push_front(c) ;
        }
      	else{
        	data.push_back(c) ;
      	}    
      }
    }
  }
  
  int m = SZ(data) ;
  
  if(rev%2==1){
    RREP(i,m){
      cout << data.at(i) ;
    }
  }
  else{
     REP(i,m){
        cout << data.at(i) ;
     }
  }
  cout <<endl ;
  
  
  return 0 ;
}



Measured memory_bytes: 976
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

if __name__ == "__main__":
    n = int(input())
    dp = [0]*(10**7+1)
    for i in range(1,n+1):
        for j in range(i,n+1,i):
            dp[j]+=1
    ans = 0
    for i in range(1,n+1):
        ans += i*dp[i]
    print(ans)

Measured memory_bytes: 152512
#include <iostream>
using namespace std;
int main(){
  int n,a[6]={0};
  cin>>n;
  for(int i=0;i<n;i++){
    double h;
    cin>>h;
    if(h<165)a[0]++;
    if(165<=h&&h<170)a[1]++;
    if(170<=h&&h<175)a[2]++;
    if(175<=h&&h<180)a[3]++;
    if(180<=h&&h<185)a[4]++;
    if(h>=185)a[5]++;
  }
  for(int i=0;i<6;i++){
    cout<<i+1<<":";
    for(int j=0;j<a[i];j++){
      cout<<"*";
    }
    cout<<endl;
  }
}

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

using namespace std;

bool palindromic(string &S) {
	int len = S.size();
	for (int i = 0; i < len/2; i++)
		if (S[i] != S[len - 1 - i])
			return false;
	return true;
}
int main() {
	ios::sync_with_stdio(false);
	int a, b;
	string s;
	cin >> a >> b;

	int cnt = 0;
	for (int i = a; i<=b; i++) {
		ostringstream ostr;
		ostr << i;
		s = ostr.str();
		if (palindromic(s))
			cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

  int n,i,x;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    x=i;
    if(x%3==0){
      printf(" %d",i); 
    } else  if(x%10==3 || x/10%10==3 || x/100%10==3 || x/1000%10==3){
	printf(" %d",i);
    }
  }
  printf("\n");
  return 0;
  }

Measured memory_bytes: 596
/* 根付き木 */
#include<bits/stdc++.h>
#define N 100000
#define Nil -1
using namespace std;
typedef struct{
	int par,left,right;
}Node;
vector<Node> data(N);
int n;

int getDepth(int u){
	int d = 0;
	while(data.at(u).par != Nil){
		u = data.at(u).par;
		d++;
	}
	return d;
}
/*
int getSib(int u){
	if(data.at(u).par == Nil) return Nil;
	if(data.at(data.at(u).par).left != Nil && data.at(data.at(u).par).left != u)
		return data.at(data.at(u).par).left;
	if(data.at(data.at(u).par).right != Nil && data.at(data.at(u).par).right != u)
		return data.at(data.at(u).par).right;
	return Nil;
}
*/
/*
int getDeg(int u){
	int a=0;
	if(data.at(u).left != Nil) a++;
	if(data.at(u).right != Nil) a++;
	return a;
}
*/
/*
int setHeight(int u){
	int h1=0,h2=0;
	if(data.at(u).left != Nil){
		h1 = setHeight(data.at(u).left)+1;
	}
	if(data.at(u).right != Nil){
		h2 = setHeight(data.at(u).right)+1;
	}
	if(h1 > h2) return h1;
	else return h2;
}
*/
/*
void getType(int u){
	if(data.at(u).par == Nil) cout << "root, ";
	else if(data.at(u).left == Nil) cout << "leaf, ";
	else cout << "internal node, ";
}
*/

void printData(){
	int c=0,j,i,fl;
	for(i=0;i<n;i++){
		cout << "node " << i << ": parent = " << data.at(i).par << ", depth = " << getDepth(i) << ", ";

	if(data.at(i).par == Nil) cout << "root, ";
	else if(data.at(i).left == Nil) cout << "leaf, ";
	else cout << "internal node, ";
	cout << "[";
	
	fl = 0;
	c = data.at(i).left;
	while(c != Nil){
		if(fl > 0) cout << ", ";
		fl++;
		cout << c;
		c = data.at(c).right;
	}
	/*
	for(j=0,c=data.at(i).left;c != Nil;i++,c=data.at(c).right){
		if(i) cout << ", ";
		cout << c;
	}
	*/
	cout << "]" << endl;
		}
}

int main(){
	int v,l,r,num,val;
	//vector<INFO> data(N);
	cin >> n;
	//親の初期化
	for(int i=0;i<n;i++) data.at(i).par = data.at(i).left = data.at(i).right = Nil;
	
	for(int i=0;i<n;i++){
		//v:節点番号
		cin >> v >> num;
			for(int j=0;j<num;j++){
				cin >> val;
				if(j == 0) data.at(v).left = val;
				else data.at(l).right = val;
				l = val;
				data.at(val).par = v;
			}
		/*
		data.at(v).left = l;
		data.at(v).right = r;
		if(l != Nil) data.at(l).par = v;
		if(r != Nil) data.at(r).par = v;
		*/
		}
	printData();
	}
	


Measured memory_bytes: 3728
#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;
}

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 %s", com, str);

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


Measured memory_bytes: 16992
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N=scan.nextInt();
		int[] frame = new  int[N];
		float sumAllFrameNum = 0;

		for(int i=0; i<N; i++) {
			frame[i] = scan.nextInt();
			sumAllFrameNum+= frame[i];
		}
		scan.close();

		float average = sumAllFrameNum / N;

		float minSa = 100;
		int kouho = 0;
		float sa = 0;
		for(int i=0; i<N; i++) {
			if(frame[i]==average) {
				System.out.println(i);
				return;
			} else {
				sa = Math.abs(frame[i] - average);
				if(sa < minSa) {
					minSa = sa;
					kouho = i;
				}

			}
		}
		System.out.println(kouho);
	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    int N;
    cin >> N;
    vector<vector<char>> S(N, vector<char>(N));
    rep(i, N) rep(j, N) cin >> S[i][j];
    int ans = 0;
    vector<vector<char>> T(N, vector<char>(N));
    rep(A, N) {
        rep(i, N) rep(j, N) T[i][j] = S[(i + A) % N][j];
        bool judge = true;
        rep(i, N) rep(j, N) {
            if (T[i][j] != T[j][i]) judge = false;
        }
        if (judge) ans += N;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 436
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n;
pii p[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=1; i<=n; i++) cin >> p[i].second >> p[i].first;
 	sort(p+1, p+n+1);
 	ll cur = 0;
 	bool ok = 1;
 	for(int i=1; i<=n; i++)
 	{
 		cur += p[i].second;
 		if(cur>p[i].first)
 		{
 			ok = 0;
 			break;
 		}
 	}
 	if(ok) cout << "Yes\n";
 	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 1792
#define __STDC_FORMAT_MACROS
#define p64 PRId64

#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;

ll A, B;

bool check(ll mid)
{
    const string asc = "asc";
    const string dsc = "dsc";

    const string bg = "bg";
    const string eq = "eq";
    const string sl = "sl";

    const ll mn = -1;
    const ll zr = 0;
    const ll ps = 1;
    const ll ps2 = 2;

    const pair<string, string> asb = make_pair(asc, bg);
    const pair<string, string> ase = make_pair(asc, eq);
    const pair<string, string> asl = make_pair(asc, sl);

    const pair<string, string> dsb = make_pair(dsc, bg);
    const pair<string, string> dse = make_pair(dsc, eq);
    const pair<string, string> dsl = make_pair(dsc, sl);

    // A や B を除いて要素を mid 並べる
    // A 昇順 asc small < big
    // B 降順 dsc big > small
    map<pair<string, string>, ll> CenterOdd
    {
        {asb, zr},
        {ase, ps},
        {asl, ps},
        {dsb, zr},
        {dse, ps},
        {dsl, ps},
    };

    map<pair<string, string>, pair<ll, ll> > CenterEven
    {
        {asb, make_pair(CenterOdd[asb], ps)},
        {ase, make_pair(CenterOdd[ase], ps2)},
        {asl, make_pair(CenterOdd[asl], ps2)},
        {dsb, make_pair(ps, CenterOdd[dsb])},
        {dse, make_pair(ps2, CenterOdd[dse])},
        {dsl, make_pair(ps2, CenterOdd[dsl])},
    };

    ll mx = -1000000001;
    ll mHalf = mid / 2;

    // mid が奇数ならば
    // A や B を除く前の中央は 1 点に定まる
    if (mid % 2 != 0) mHalf++;

    pair<string, string> symbla;

    if (mHalf < A) symbla = asb;
    else if (mHalf == A) symbla = ase;
    else symbla = asl;

    pair<string, string> symblb;

    if (mHalf < B) symblb = dsb;
    else if (mHalf == B) symblb = dse;
    else symblb = dsl;

    if (mid % 2 == 0)
    {
        // 中央 左
        // 中央 右
        ll al = mHalf + CenterEven[symbla].first;
        ll au = mHalf + CenterEven[symbla].second;

        if (au == A) au++;

        ll bl = mHalf + CenterEven[symblb].first;

        if (bl == B) bl++;

        ll bu = mHalf + CenterEven[symblb].second;

        mx = max(mx, al * bl);
        mx = max(mx, au * bu);
        mx = max(mx, (ll)0);
    }
    else
    {
        ll a = mHalf + CenterOdd[symbla];
        ll b = mHalf + CenterOdd[symblb];

        mx = max(mx, a * b);
        mx = max(mx, (ll)0);
    }

    return mx < A * B;
}

// Bisection Method
// [left, right]
// to narrow the range
ll BisectionMethod(ll left, ll right)
{
    bool flg = false;

    int times = 0;

    // A * B より小さいという条件を満たさない間は
    // 探索を継続する
    while (1 < abs(right - left) || !flg)
    {
        ll mid = (left + right) / 2;

        flg = check(mid);

        if (flg) left = mid;
        else right = mid;

        times++;
    }

    return (left + right) / 2;
}

int main()
{
    ll Q;
    cin >> Q;

    while (Q--)
    {
        cin >> A >> B;
        if (B < A) swap(A, B);
        cout << BisectionMethod(0, 2 * B) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;

namespace AOJ.Volume1
{
    public class MiddleSquareMethod
    {
        public static int Main()
        {
            int data_set = int.Parse(Console.ReadLine());
            for (int i = 1; i <= data_set; i++)
            {
                ulong seed = ulong.Parse(Console.ReadLine());
                Console.WriteLine(string.Format("Case {0}:", i));
                for (int s = 1; s <= 10; s++)
                {
                    seed = seed * seed;
                    // 8桁と見なして真ん中の4桁(3,4,5,6桁目)を出力する
                    seed = ulong.Parse(seed.ToString("D8").Substring(2, 4));
                    Console.WriteLine(seed);
                }
            }
            return 0;
        }
    }
}

Measured memory_bytes: 9044
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from heapq import heapify,heappop,heappush
def dijkstra(G,s = 0): #sを始点とした最短経を求める
    n = len(G)
    dist = [INF] * n
    dist[s] = 0
    q = [(0,s)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for e,cost in G[v]:
            if dist[e] > dist[v] + cost:
                dist[e] = dist[v] + cost
                heappush(q,(dist[e],e))
    return dist

from math import hypot
def main():
    sy,sx,gy,gx = map(int,input().split())
    N = int(input())
    circles = [(sy,sx,0)] + [tuple(map(int,input().split())) for _ in range(N)] + [(gy,gx,0)]
    N += 2

    G = [[] for _ in range(N)]
    for i in range(N):
        x,y,z = circles[i]
        for j in range(i + 1,N):
            p,q,r = circles[j]
            d = max(0,hypot(x - p,y - q) - z - r)
            G[i].append((j,d))
            G[j].append((i,d))
    
    dist = dijkstra(G)
    ans = dist[-1]
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 167664
n,q = map(int,input().split())
s = input()

li = [0]*(n+1)
for i in range(1,n+1):
  if s[i-1:i+1] == "AC":
    li[i] = li[i-1] + 1
  else:
    li[i] = li[i-1]
for i in range(q):
  l,r = map(int,input().split())
  print(li[r-1]-li[l-1])

Measured memory_bytes: 6140
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define endl '\n'
#define first F
#define second S
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int x, n; cin>>x>>n;
	map<int, int> m;
	for(int i=0; i<n; i++){
		int y; cin>>y;
		m[y]++;
	}
	int dif=1e5;
	for(int i=0; i<102; i++){
		if(m[i]==0){
			dif=min(dif, abs(x-i));
		}
	}
	if(m[x-dif] == 0)cout<<x-dif<<endl;
	else cout<<x+dif<<endl;
}


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

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

  vector<int>c(m);
  for (int i = 0; i < m; i++)
  {
    cin >> c[i];
  }

  vector<int> dp(n+1, 50000);
  dp[0]=0;
  for (int i = 1; i <= n; i++)
  {
    for(int ci: c){
      if(ci<=i) dp[i] = min(dp[i],dp[i-ci]+1);
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int tree[1000000];
int N, Q;

int getSum(int p, int l, int r, int a, int b) {
  if (l <= a && b <= r) {
    return tree[p];
  } else if (b <= l || r <= a) {
    return 0;
  } else {
    int x = getSum(2*p+1, l, r, a, (a+b)/2);
    int y = getSum(2*p+2, l, r, (a+b)/2, b);
    return x+y;
  }
}

int getSum(int l, int r) {
  return getSum(0, l, r+1, 0, N);
}

void add(int p, int x) {
  p += N-1;
  tree[p] += x;
  while (p>0) {
    p = (p-1)/2;
    tree[p] = tree[2*p+1] + tree[2*p+2]; 
  }
}

int main() {
  int M;
  cin >> M >> Q;

  N = 1;
  while (N < M || N == 1) N *= 2;
  for (int i=0;i<N*2;i++) tree[i]=0;
  
  for (int i=0;i<Q;i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 0) {
      add(b-1, c);
    } else {
      cout << getSum(b-1, c-1) << endl;
    }
  }
}



Measured memory_bytes: 4108
import sys
input = sys.stdin.readline

S = list(input().rstrip())
L = len(S)

# binary indexed tree
bit = [0 for _ in range(L+1)]

# 0からiまでの区間和
# 立っているビットを下から処理
def query_sum(i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= i & -i
    return s

# i番目の要素にxを足す
# 覆ってる区間すべてに足す
def add(i, x):
    while i <= L:
        bit[i] += x
        i += i & -i

def main():
    A = {}
    for i, s in enumerate(S):
        if not s in A.keys():
            A[s] = [i]
        else:
            A[s].append(i)
    odd = 0
    dic = {}
    for al, c in A.items():
        dic[al] = 0
        if len(c)%2 != 0:
            odd += 1
    if odd > 1:
        print(-1)
    else:
        make_ind = []
        for s, B in A.items():
            l = len(B)
            if l%2 == 1:
                mid = B[l//2]
            for j, b in enumerate(B):
                if j < l//2:
                    make_ind.append(b)
        make_ind.sort()
        IND = [None]*L
        for i, m in enumerate(make_ind):
            s = S[m]
            IND[m] = i+1
            inv = A[s][len(A[s])-1-dic[s]]
            IND[inv] = L-i
            dic[s] += 1
        if L%2 == 1:
            IND[mid] = L//2+1
        

        ans = 0
        for j, a in enumerate(IND):
            ans += j - query_sum(a)
            add(a, 1)
        
        print(ans)

if __name__ == "__main__":
    main()

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

int main(){
    int N; cin >> N;
    vector< int > A( N * 2 );
    for( int i = 0; i < N * 2; ++i )
        cin >> A[ i ];
    int ans = 0;
    sort( A.begin(), A.end() );
    for( int i = 0; i < N * 2; i += 2 )
        ans += A[ i ];
    cout << ans << "\n";
    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 100100;

int A[MAX];
int main()
{
	//freopen("in.txt", "r", stdin);

	int n;
	cin>>n;
	FOR(i,0,n)
	{
		cin>>A[i];
	}

	LL ans = LINF;

	FOR(it,0,2)
	{
		LL s = 0;
		LL cur = 0;
		FOR(i,0,n)
		{
			s += A[i];
			if(s== 0 || ((s<0) != (i+it)%2))
			{
				cur += abs(s)+1;
				if(s == 0)
				{
					if((i+it)%2 == 0)s = 1;
					else s = -1;
				}
				else if(s>0)s = -1;
				else s = 1;
			}
		}

		ans = min(ans,cur);
	}

	cout<<ans;
}


Measured memory_bytes: 640
#include<stdio.h>

int main (void)
{
	int i=1,input;
	
	do
	{
		scanf("%d",&input);
		if(input == 0)
		{
			break;
		}
		printf("Case %d: %d\n",i,input);
		i++;
	}while(i <= 10000);
	return 0;
}


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

A_len = len(A)
A_len -= K
if A_len <= 0:
    print(1)
else:
    if A_len % (K-1) == 0:
        print(A_len // (K-1) + 1)
    else:
        print(A_len // (K-1) + 2)

Measured memory_bytes: 14008
// AOJ GRL_1_B Single Source Shortest Path (Negative Edges)
// 2018.5.4 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF   0x10101010
#define MAX_V  1002
#define MAX_E  2002

typedef struct { int s, t, d; } EDGE;
EDGE edge[MAX_E]; int E;
int V;
int dist[MAX_V];

int bellmanFord(int s)
{
	int i;
	int update, cnt;
	EDGE *ep;

	memset(dist, INF, V<<2);
	dist[s] = 0;	// start node
	update = 1, cnt = 0;
	while (update) {
		update = 0;
		if (++cnt > V) return -1;
		for (i = 0; i < E; i++) {
			ep = edge+i;
			if (dist[ep->s] != INF && dist[ep->t] > dist[ep->s] + ep->d) {
				dist[ep->t] = dist[ep->s] + ep->d;
				update = 1;
			}
		}
	}
	return 0;
}

int main()
{
	int s, i;

	V = in(), E = in(), s = in();
	for (i = 0; i < E; i++) {
		edge[i].s = in(), edge[i].t = in(), edge[i].d = in();
	}
	if (bellmanFord(s) < 0) puts("NEGATIVE CYCLE");
	else for (i = 0; i < V; i++) {
		if (dist[i] == INF) puts("INF");
		else printf("%d\n", dist[i]);
	}
	return 0;
}



Measured memory_bytes: 2128
N,K = map(int,input().split())
A = list(map(int,input().split()))
UP = max(A)
UL = UP.bit_length()
KL = K.bit_length()
L = max(UL,KL)
INF = float("inf")
#dp[i][j]: 上からi桁目までを決めて、N未満で確定ならj=1、Nと一致しているならばj=0
dp = [[-INF] * 2 for _ in range(L+1)]
dp[0][0]=0
ZF = True
for i in range(1,L+1): #今上からi桁目(1index)
  fac = pow(2,L-i)
  one = 0; zero = 0
  keta = L-i
  if K>>keta&1 == 1:
    ZF = False
  #print(ZF)
  for j in range(N): #N個見る
    if A[j]>>keta&1 == 1: #上からi桁目つまり下から
      one +=1
    else:
      zero +=1
  one,zero = zero,one
  MAX = max(one,zero)
  #print(fac,one,zero)
  if K>>keta&1 == 1: #完全一致の場合
    dp[i][0] = dp[i-1][0]+fac*one
  else:
    dp[i][0] = dp[i-1][0]+fac*zero
  #完全一致でない場合
  if ZF: #この桁以上が全部0だと選択の余地なし。
    dp[i][1] = 0
  else:
    if K>>keta&1 == 1: #どちらでも選べる。
      dp[i][1] = max(dp[i-1][1]+fac*MAX,dp[i-1][0]+fac*zero)
    else: #この桁が0なので上の桁も一致していたら不可。
      dp[i][1] = dp[i-1][1]+fac*MAX
#print(dp)
ans = max(dp[L][0],dp[L][1])
print(ans)
  

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<double> a(n);
    int sum = 0.0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    rep(i, n) {
        if (a[i]*4*m < sum) continue;
        cnt++;
    }
    if (cnt >= m) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    if n==0:
        return 0

    ans,up = '',0
    flg = 0
    if n<0:
        flg = 1
        n = -n

    for i in range(40):
        d = (n>>i&1)+up
        if i%2==flg:
            if d==0:
                ans,up = '0'+ans,0
            elif d==1:
                ans,up = '1'+ans,0
            elif d==2:
                ans,up = '0'+ans,1
            else:
                assert(False)
        else:
            if d==0:
                ans,up = '0'+ans,0
            elif d==1:
                ans,up = '1'+ans,1
            elif d==2:
                ans,up = '0'+ans,1
            else:
                assert(False)

    return ans[ans.find('1'):]

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = std::numeric_limits<T>::max() / 10;
std::mt19937 mt{std::random_device{}()};
int main()
{
    int N, x;
    std::cin >> N >> x;
    std::vector<int> a(N);
    for (int i = 0; i < N; i++) { std::cin >> a[i]; }
    std::sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (x < a[i]) { break; }
        ans++, x -= a[i];
    }
    if (ans == N and x > 0) { ans--; }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main() {
	int n;
	cin >> n;
	VE vec(n);
	REP(i, n) {
		cin >> vec[i];
	}
	sort(vec.begin(), vec.end());
	int ans = 0;
	REP(i, n - 1) {
		auto old_itr = vec.begin() + i + 2;
		for (int k = i + 1; k < n; ++k) {
			int sh = vec[i] + vec[k];
			auto itr = lower_bound(old_itr, vec.end(), sh);
			int dist = distance(vec.begin() + k, itr) - 1;
			ans += dist;
			old_itr = itr;
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  map<string, vector<P>>mp;
  rep(i, N){
    string s;
    ll p;
    cin >> s >> p;
    mp[s].push_back({p, i+1});
  }

  for(auto imp:mp){
    sort(rALL(imp.second));
    for(auto ic: imp.second){
      cout << ic.second<<endl;
    }
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n, a; cin >> n >> a;
  cout << n * n - a << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
int main() {
    int n;cin >> n;
    int p[n];rep(i,n)cin >> p[i];
    int ans = 0;
    srep(i,1,n-1)if(min(p[i-1],p[i+1])<p[i]&&p[i]<max(p[i-1],p[i+1]))ans++;
    cout << ans << endl;
    return 0;
}
 
 


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

#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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);
    cin.tie(nullptr);
    int i, j;
    string a = "ACL";
    string ans = "";
    int k;
    cin >> k;
    for (i = 0; i < k; i++) ans += a;
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}

int main(){
  int N; cin >> N;
  cout << 1-N << endl;
  return 0;
}


Measured memory_bytes: 3616
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

// xのn乗%modを計算
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll K;
    cin>>K;
    ll ans=1;
    ll num=7;

    if(K%2==0){
        ans=-1;
    }else{
        ans=1;
        num=7;
        while(num%K!=0){
            num+=7*mod_pow(10,ans,K);
            num%=K;
            ans++;
            if(ans>2000000) break;
        }
        if(num%K!=0) ans=-1;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3620