akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;
ll LARGE = 1000000;


int main() {
	ll h;
	cin >> h;
	ll cnt = 0;
	ll i = 0;
	while (h > 0) {
		h /= 2;
		cnt += ll(pow(2, i));
		++i;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
from collections import deque
S = list(input())
Q = int(input())
que = [list(map(str, input().split())) for _ in range(Q)]

sq = deque(S)
cnt = 0

for i, lst in enumerate(que):
    if lst[0]=='1':
        cnt += 1
        continue
    if cnt%2==1:
        if lst[1]=='1':sq.append(lst[2])
        else:sq.appendleft(lst[2])
    else:
        if lst[1]=='1':sq.appendleft(lst[2])
        else:sq.append(lst[2])

ans = list(sq)
if cnt%2==1:
    ans.reverse()
print(''.join(ans))

Measured memory_bytes: 45940
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

int stack[1000],top=0;

void push(int x)
{
	stack[++top] = x;
}

int pop()
{
	top--;
	return stack[top+1];
}

int main()
{
	char s[100];
	int x,y;

	while(scanf("%s",s) != EOF){
		if(s[0] == '+'){
			x = pop();
			y = pop();
			push(x + y);
		}else if(s[0] == '-'){
			x = pop();
			y = pop();
			push(y - x);
		}else if(s[0] == '*'){
			x = pop();
			y = pop();
			push(x * y);
		}else{
			push(atoi(s));
		}
	}

	printf("%d\n",pop());

	return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#define ll long long
using namespace std;

ll scgsn(ll k, ll n, bool a, bool b, bool c)
{
    if(k > n) return 0;
    ll x = scgsn(k*10 + 3, n, 1, b, c),
       y = scgsn(k*10 + 5, n, a, 1, c),
       z = scgsn(k*10 + 7, n, a, b, 1);
    return (a && b && c) + x + y + z; 
}

int main()
{
    ll n;
    cin >> n;
    cout << scgsn(0, n, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 250005;

void go() {
    int n;
    cin >> n;
    vector<int>v(n);
    for (auto &i : v) {
    	cin >> i;
    }
    ll dp[n] = {};
    dp[n - 1] = 0;
    dp[n - 2] = abs(v[n - 1] - v[n - 2]);
    for (int i = n - 3 ; i >= 0 ; i--) {
    	dp[i] = min(dp[i + 2] + abs(v[i + 2] - v[i]), dp[i + 1] + abs(v[i + 1] - v[i]));
    }
    cout << dp[0] << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

Measured memory_bytes: 4520
#include<stdio.h>
#include<math.h>

int main()
{
	double x1,x2,y1,y2;
	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	printf("%.8lf\n",(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))));
	return 0;
}

Measured memory_bytes: 656
object Main extends App {
  val src = io.Source.stdin.getLines.next.split(" ").map(_.toInt).toList

  def sortDescending(li: List[Int]): List[Int] = li match {
    case Nil => Nil
    case h :: tail => insert(h, sortDescending(tail))
  }

  def insert(n: Int, li: List[Int]): List[Int] = li match {
    case Nil => List(n)
    case h :: tail => if (n > h) n :: li
                      else h :: insert(n, tail)
  }

  println(sortDescending(src).mkString(" "))
}

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

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

    if (K <= A){
    	cout << K << endl; 
    } else if (K <= A+B){
    	cout << A << endl;
    } else {
    	cout << A - (K-A-B) << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int[] K = new int[M];
		int[] P = new int[M];
		int[][] S = new int[M][];
		int answer = 0;
		for(int i = 0; i < M; i++) {
			K[i] = Integer.parseInt(sc.next());
			S[i] = new int[K[i]];
			for(int j = 0; j < K[i]; j++) {
				S[i][j] = Integer.parseInt(sc.next());
			}
		}
		for(int i = 0; i < M; i++) {
			P[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		//ビット全探索
		for(int i = 0; i < Math.pow(2, N); i++) {
			boolean check = true;
			for(int j = 0; j < M; j++) {
				int count = 0;
				//各スイッチが点灯しているかどうか確認
				for(int k = 0; k < K[j]; k++) {
					if((1 & i >> S[j][k]  - 1) == 1) count++;
				}
				//2で割った余りが一致するかどうか確認
				if(count % 2 != P[j]) {
					 check = false;
				}
			}
			if(check) {
				answer++;
			}
		}
		System.out.println(answer);
	}

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll LCM(ll a,ll b){
    return a*b/__gcd(a,b);
}
int main()
{
   // freopen("in.txt","r",stdin);
    int a,b;
    cin >> a >> b;
    ll lcm = LCM(a,b);
    cout << lcm << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(void) {
    int h, n; cin >> h >> n;
    vector<int> a(n);
    ll sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    if(h<=sum) printf("Yes\n");
    else printf("No\n");
}



Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX_N = 100005;

int n, m;
pair<int, int> jobs[MAX_N];

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

	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> jobs[i].first >> jobs[i].second;
	sort(jobs, jobs + n, greater<pair<int, int>>());

	int result = 0;
	set<pair<int, int>> s;
	for (int day = m - 1, i = n - 1; day >= 0; day--)
	{
		int reqA = m - day;
		while (i >= 0 && jobs[i].first <= reqA)
		{
			s.emplace(jobs[i].second, i);
			i--;
		}

		if (!s.empty())
		{
			auto it = s.end();
			it--;
			result += it->first;
			s.erase(it);
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 5632
#include <iostream>

using namespace std;

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

    int rc = 0, bc = 0;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        if (c == 'R') {
            rc++;
        } else {
            bc++;
        }
    }

    cout << (rc > bc ? "Yes" : "No") << endl;

    return 0;
}

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

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}



int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  Sieve sv(1000005);
  map<int,int>mp;
  rep(i,n){
    auto f=sv.factor(a[i]);
    for(auto j:f){
      mp[j.first]=max(mp[j.first],j.second);
    }
  }
  mint lcm=1;
  for(auto f:mp){
    int now=f.second;
    while(now>0){
      lcm*=f.first;
      now--;
    }
  }
  mint ans=0;
  rep(i,n){
    ans+=lcm/a[i];
  }
  cout<<ans.x;

}


Measured memory_bytes: 4988
import sys, itertools
def input(): return sys.stdin.readline()
def inpl(): return [int(i) for i in input().split()]
N, K = inpl()
Sushi = []
Neta = set()
ans = 0
for _ in range(N):
    t, d = inpl()
    Sushi.append((d, t))
Sushi.sort(reverse = True)
Db = []
Nd = []
for i in range(K):
    d, t = Sushi[i]
    if t not in Neta:
        Neta.add(t)
        ans += d
    else:
        Db.append(d)
neta = len(Neta)
Db = [0] + list(itertools.accumulate(Db))
Db.reverse()
for i in range(N-K):
    d, t = Sushi[K+i]
    if t not in Neta:
        Neta.add(t)
        Nd.append(d)
Nd = [0] + list(itertools.accumulate(Nd))
print(ans + max([(neta + i)**2 + j + k for i, (j, k) in enumerate(zip(Db, Nd))]))

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

int main(){
  int N;
  cin>>N;
  int A_cnt=0,B_cnt=0,BA_cnt=0,sum=0;

  for(int i=0;i<N;++i){
    string s;
    cin>>s;
    int n=s.size();
    if(s[0]=='B' && s[n-1]=='A') ++BA_cnt;
    else if(s[0]=='B') ++B_cnt;
    else if(s[n-1]=='A') ++A_cnt;
    for(int i=0;i<n-1;++i){
      if(s[i]=='A' && s[i+1]=='B') ++sum;
    }
  }

  if(A_cnt+B_cnt>0) cout<<sum+BA_cnt+min(A_cnt,B_cnt)<<endl;
  else{
    if(BA_cnt>0) cout<<sum+BA_cnt-1<<endl;
    else cout<<sum<<endl;
  }
  
}


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

int descending_compare(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}

int ascending_compare(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}


int main(void){
    int n;
    int k;
    int *a;
    int i;
    int cnt = 0;
    int tmp;
    scanf("%d", &n);
    scanf("%d", &k);

    a = calloc(200001, sizeof(int));

    for (i = 0; i < n; i++){
        scanf("%d", &tmp);
        a[tmp]++;
    }

    
    qsort(a, n+1, sizeof(int), descending_compare);

    i = k;

    while(a[i] != 0){
        cnt += a[i];
        i++;
    }


    printf("%d\n", cnt);





    return 0;
}

Measured memory_bytes: 1788
def examA():
    N = I()
    T = LI()
    A = LI()
    S = [-1]*N
    S[0] = T[0]; S[-1]=A[-1]
    ans = 1
    for i in range(1,N):
        if T[i]==T[i-1]:
            continue
        S[i] = T[i]
    flag = -1
    for i in range(N):
        if S[i]==A[i]:
            flag = i
            break
    if not (A[flag]==A[0] and A[flag]==T[-1]):
        print(0)
        return
    for i in range(N-1)[::-1]:
        if A[i]==A[i+1]:
            continue
        if S[i]==-1:
            S[i] = A[i]
        else:
            S[i] = max(S[i],A[i])
    #print(S)
    P = []
    pindex = []
    for i in range(N):
        if S[i]==-1:
            continue
        P.append(S[i])
        pindex.append(i)
    flag_U = True
    for i in range(len(P)-1):
        if P[i+1]>P[i]:
            if not flag_U:
                print(0)
                return
        elif P[i+1]<P[i]:
            flag_U = False
    ans = 1
    p = -1
    for i in range(N):
        if S[i]==-1:
            cur = min(P[p + 1], P[p])
            ans *= cur
            ans %= mod
        else:
            p += 1

    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()

"""

"""

Measured memory_bytes: 20272
n=int(input())
h=[int(i) for i in input().split()]
for i in range(n-1,0,-1):
    if h[i]<h[i-1]:
        if h[i]-h[i-1]==-1:
            h[i-1]-=1
        else:
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 63984
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

simulate :: [Int] -> Int -> Int
simulate _ 0 = 0
simulate (a:as) 1 = a
simulate (a:as) n = 2 * a + simulate as (n-2)

main = do
  n <- getInt
  as <- getIntList
  let as' = reverse (sort as)
  if n == 1
    then print 0
    else print $ head as' + simulate (tail as') (n-2)


Measured memory_bytes: 35300
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

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

    int n;
    string s;
    cin >> n >> s;
    long cr = 0, cb = 0, cg = 0;
    for (char c : s) {
        if (c == 'R') cr++;
        if (c == 'G') cg++;
        if (c == 'B') cb++;
    }
    long res = cr * cg * cb;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int k = j + (j - i);
            if (k < n) {
                if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) {
                    res--;
                }
            }
        }
    }
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>

#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)

using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }

int main() {
  int n, m;
  vector<vector<int>> a;

  cin >> n >> m;
  each(i, n) {
    int k;
    cin >> k;
    a.push(vector<int>());
    each(j, k) {
      int tmp;
      cin >> tmp;
      a[i].push(tmp);
    }
  }

  vector<bool> result = {};
  each(i, m) {
    result.push(true);
  }

  each(i, m) {
    int num = i+1;
    bool t = true;

    for (auto v : a) {
      if (find(v.begin(), v.end(), num) == v.end()) {
        t = false;
      }
    }

    if (!t) {
      result[i] = false;
    }
  }

  cout << count(result.begin(), result.end(), true) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=300050;
int lim=300001;
int s[maxn<<2];
int a[maxn],dp[maxn];
int n,k;

void pushup(int x){
	s[x]=max(s[x<<1],s[x<<1|1]);
}
void update(int x,int l,int r,int k,int val){
	if(l==r){
		s[x]=max(s[x],val);return;
	}
	int mid=(l+r)>>1;
	if(mid>=k)	update(x<<1,l,mid,k,val);
	if(mid<k)	update(x<<1|1,mid+1,r,k,val);
	pushup(x);
}
int query(int x,int l,int r,int L,int R){
	if(L<=l&&r<=R)	return s[x];
	int mid=(l+r)>>1,res=0;
	if(mid>=L)	res=max(res,query(x<<1,l,mid,L,R));
	if(mid<R)	res=max(res,query(x<<1|1,mid+1,r,L,R));
	return res;
}
void solve(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]++;
	}
	for(int i=1;i<=n;i++){
		int l=max(a[i]-k,1),r=min(a[i]+k,lim);
		dp[i]=query(1,1,lim,l,r)+1;
		update(1,1,lim,a[i],dp[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++)	ans=max(ans,dp[i]);
	printf("%d\n",ans);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 8172
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll M = (ll)1e9+7;

li dp[3007][3007], x, y;
string a, b, res;

int main () {
    fastIO;
    cin >> a >> b;
    for(li i = 0; i <= b.size(); i ++) dp[i][a.size()] = 0;
    for(li i = 0; i <= a.size(); i ++) dp[b.size()][i] = 0;

    for(li i = b.size()-1; i >= 0; i --) {
        for(li j = a.size()-1; j >= 0; j --) {
            if(b[i]==a[j]) dp[i][j] = dp[i+1][j+1]+1;
            else dp[i][j] = max(dp[i+1][j], dp[i][j+1]);
        }
    }

    li i = 0, j = 0;
    while(dp[i][j]!=0) {
        if(dp[i][j] == dp[i+1][j]) i ++;
        else if(dp[i][j] == dp[i][j+1]) j ++;
        else res += b[i], i++, j++;
    }
    cout << res;
}


Measured memory_bytes: 70784
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int a, b, c;
  cin >> a >> b >> c;

  cout << ((a + b + c) - max(max(a, b), c)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n, k, p = 1e9 + 7;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i <= n + 1; i++) {
		ll minsum = i * (i - 1) / 2 % p, maxsum = (minsum + (n - i + 1) * i % p) % p;
		//cout << minsum << " " << maxsum << endl;
		ll x = maxsum - minsum + 1;
		if (x < 0) x += p;
		x %= p;
		ans += x;
		ans %= p;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3640
n = int(input())%10
if n==2:
    print("hon")
if n==4:
    print("hon") 
if n==5:  
    print("hon")
if n==7:
    print("hon")
if n==9:
    print("hon")
if n==1:
    print("pon")
if n==8:
    print("pon") 
if n==6:
    print("pon")   
if n==3:
    print("bon")
if n==0:
    print("pon")

Measured memory_bytes: 9032
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>

void print(vector<int> arr){for(auto i:arr){printf("%d ",i);}cout<<endl;}

int main()
{
    int n,m;scanf("%d %d",&n,&m);
   	if(m<=(500*n)) printf("Yes");
  	else printf("No"); 
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	char a;
	cin >> a;
	cout << char(a+1) << endl;
}	


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

int main() {
  int N, M, X, A, B = 0;
  cin >> N >> M >> X;

  for (int i = 0; i < M; i++) {
    cin >> A;
    if (A < X) B++;
  }

  cout << min(B, M - B) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
  
int main()
{
  int t[4][14];
  int n, i,j,c;
  char m, d;
  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      t[i][j]=0;
    }
  }
 scanf("%d", &c);
  for(i = 0; i < c; i++){
    scanf("%c", &d);
    scanf("%c %d", &m, &n);
    if(m == 'S'){
      t[0][n] = 1;
    }
    else if(m == 'H'){
      t[1][n] = 1;
    }
    else if(m == 'C'){
      t[2][n] = 1;
    }
    else if(m == 'D'){
      t[3][n] = 1;
    }
  }
  for(j=1; j < 14; j++){
    if(t[0][j] != 1){
      printf("S %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[1][j] != 1){
      printf("H %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[2][j] != 1){
      printf("C %d\n", j);
    }
  }
  
 for(j=1; j < 14; j++){
    if(t[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}


Measured memory_bytes: 2072
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	string s,t;
	cin>>s>>t;
	if(t.size()!=s.size()+1)
	{
		cout<<"No\n";
		return 0;
	 } 
	rep(i,s.size())
	{
		if(s[i]!=t[i])
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	return 0;
}



Measured memory_bytes: 3600
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args){
        String[] str = next().split("");

        Long count = 0L;
        Long w = 0L;
        for(int i=0; i<str.length; i++){
            if(str[i].equals("W")){
                count += i-w;
                w++;
            }
        }

        println(count);
    }

    static int nextInt(){
        return Integer.parseInt(next());
    }
    static Long nextLong(){
        return Long.parseLong(next());
    }
    static String next(){
        return sc.next();
    }
    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


Measured memory_bytes: 53444
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);    
    cin.tie(0);
    string s;
    cin>>s;
    if(s=="ARC")
    {
    	cout<<"ABC";
    }
    else
    {
    	cout<<"ARC";
    }
  }		


Measured memory_bytes: 3648
a, b, h, m = map(int, input().split())

import math

theta = math.radians(abs((h / 12 * 360 + m / 2) - (m / 60 * 360)))

cc = a ** 2 + b ** 2 - 2 * a * b * math.cos(theta)

ans = math.sqrt(cc)

print(ans)


Measured memory_bytes: 62380
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <cmath>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  cin >> N;
  vector<double> foo(N);
  vector<double> bar(N);
  rep (i, N) cin >> foo[i];
  rep (i, N) cin >> bar[i];

  double ans1 = 0;
  rep (i, N) ans1 += abs(foo[i] - bar[i]);

  double ans2 = 0;
  rep (i, N) {
    double tmp = pow(foo[i] - bar[i], 2);
    ans2 += tmp;
  }
  ans2 = pow(ans2, 0.5);

  double ans3 = 0;
  rep (i, N) {
    double tmp = pow(abs(foo[i] - bar[i]), 3);
    ans3 += tmp;
  }
  ans3 = pow(ans3, 0.33333333333333333333333333);

  double ansInf = 0;
  rep (i, N) {
    double tmp = abs(foo[i] - bar[i]);
    if (ansInf < tmp) ansInf = tmp;
  }

  cout << ans1 << endl;
  cout << ans2 << endl;
  cout << ans3 << endl;
  cout << ansInf << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3492
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;
typedef pair<int, int> P;

struct BIT{
	int size;
	vector<int> bit;
	BIT(){size = 0;}
	BIT(int s){
		size = s;
		bit.resize(size+1);
		init();
	}
	void init(){
		for(int i = 1; i <= size; i++) bit[i] = 0;
	}
	int query(int i){
		int ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i&(-i);
		}
		return ret;
	}
	void add(int i, int x){
		while(i <= size){
			bit[i] += x;
			i += i&(-i);
		}
	}
	int range(int l, int r){
		return query(r) - query(l-1);
	}
};

int n, k;
int p[500005], pinv[500005];
int pred[500005], succ[500005];
int prenum[500005], sucnum[500005];
int presum[500005], sucsum[500005];
int order[500005], ans[500005];
set<int> S;
BIT bit(500005);

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> p[i];
	for(int i = 1; i <= n; i++) pinv[p[i]] = i;
	if(k == 1){
		for(int i = 1; i <= n; i++) cout << i << endl;
		return 0;
	}
	k--;
	
	for(int i = 1; i <= k; i++) S.insert(p[i]);
	for(int i = 1; i <= n; i++){
		if(i+k <= n) S.insert(p[i+k]);
		S.erase(p[i]);
		auto it = S.upper_bound(p[i]);
		if(it == S.begin()) continue;
		it--;
		pred[i] = pinv[*it];
	}
	
	S.clear();
	for(int i = n; i > n-k; i--) S.insert(p[i]);
	for(int i = n; i >= 1; i--){
		if(i-k >= 1) S.insert(p[i-k]);
		S.erase(p[i]);
		auto it = S.upper_bound(p[i]);
		if(it == S.end()) continue;
		succ[i] = pinv[*it];
	}
	
	for(int j = 1; j <= n; j++){
		int i = pinv[j];
		bit.add(i, 1);
		if(pred[i] != 0) prenum[i] = bit.range(i+1, pred[i]);
		if(succ[i] != 0) sucnum[i] = (i-succ[i]) - bit.range(succ[i], i-1);
	}
	
	for(int i = n; i >= 1; i--){
		if(pred[i] != 0) presum[i] = presum[pred[i]] + prenum[i];
	}
	for(int i = 1; i <= n; i++){
		if(succ[i] != 0) sucsum[i] = sucsum[succ[i]] + sucnum[i];
	}
	
	for(int i = 1; i <= n; i++){
		ans[i] += presum[i];
		ans[i] += (i-1) - sucsum[i];
		ans[i] += 1;
	}
	for(int i = 1; i <= n; i++) cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 48384
import java.util.Map.Entry;
import java.io.*;
import java.util.*;

public class Main {
	
	static int MOD = 1000000007;
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int n = sc.nextInt();
		int INF = 2000000000;
		int[] dp = new int[n];
		Arrays.fill(dp, INF);
		int ans = 0;
		
		for(int i = 0; i < n; i++){
			int a = sc.nextInt();			
			int index = lowerBound(dp, a);
			dp[index] = a;
			ans = Math.max(ans, index + 1);
		}
		
		System.out.println(ans);
	}
	
	public static int lowerBound(int[] a, int key){
		int ng = -1;
		int ok = a.length;
		
		while(Math.abs(ok - ng) > 1){
			int mid = (ok + ng) / 2;
			if(a[mid] >= key) ok = mid;
			else ng = mid;
		}
		
		return ok;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}



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

int main()
{

        vector<int> H;
        vector<int> W;

        while (1) {
                int h, w;
                cin >> h >> w;
                if (h == 0 && w == 0) {
                        break;
                }
                H.push_back(h);
                W.push_back(w);
        }
        int n = H.size();
        for (int i = 0; i < n; ++i) {

                bool s = false;
                for (int j = 0; j < H[i]; ++j) {

                        if (s) s = false;
                        else s = true;

                        bool sc = s;
                        for (int k = 0; k < W[i]; ++k) {

                                if (sc) cout << '#';
                                else cout << '.';
                                if (sc) sc = false;
                                else sc = true;

                        }
                        cout << endl;
                }
                cout << endl;
        }


}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m,n;
pair<ll,ll> p[1000005];
vector<pair<ll,ll> > v;

int main()
{
    while(cin>>n>>m)
    {
        v.clear();
        for(ll i=0;i<n;i++)
        {
            cin>>p[i].first>>p[i].second;
            v.push_back(p[i]);
        }
        sort(v.begin(),v.end());
        ll sum=0;
        for(ll i=0;i<n;i++)
        {
            ll num=v[i].second;
            ll price=v[i].first;
            if(num<=m)
            {
                sum+=price*num;
                m=m-num;
            }
            else
            {
                sum+=price*m;
                m=0;
                //break;
            }
        }
        cout<<sum<<"\n";

    }
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
 
typedef vector<int> v64;
typedef pair<int,int> p64;
typedef vector<p64> vp64;
typedef set<int> s64;
typedef map<int,int> m64;
typedef multiset<int> ms64;
typedef multimap<int,int> mm64;
typedef greater<int> g64;
typedef unordered_set<int> us64;
typedef unordered_map<int,int> um64;
 
int32_t main(){
    int a,b;
    cin>>a>>b;
    if(a>=1 && a<=9 && b>=1 && b<=9) cout<<a*b<<"\n";
    else cout<<"-1\n";       
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1000000007;

int main() {
    int N, M;
    cin >> N >> M;

    vector<vector<int>> G(N);
    for(int i=0;i<M;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<int> que;
    que.push(0);

    vector<int> ans(N, -1);
    ans[0] = 0;
    int cnt = 0;
    while(!que.empty()){
        int v = que.front();
        que.pop();
        cnt++;
        for(int to : G[v]){
            if(ans[to] == -1){
                ans[to] = v;
                que.push(to);
            }
        }
    }
    if(cnt == N){
        cout << "Yes" << endl;
        for(int i=1;i<N;i++){
            cout << ans[i] + 1 << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 10212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()

const int N = 100010;
int a[N][3], n;
int f[N][3];

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

  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) cin >> a[i][j];
  }

  for (int i = 0; i < 3; i++) f[n - 1][i] = a[n - 1][i];
  
  for (int i = n - 2; i >= 0; i--) {
     for (int j = 0; j < 3; j++) {
        f[i][j] = 0; 
        for (int k = 0; k < 3; k++) if (j != k) {
          f[i][j] = max(f[i][j], a[i][j] + f[i + 1][k]);
        }
     }
  }

  int ans = 0;
  for (int i = 0; i < 3; i++) ans = max(ans, f[0][i]);
  cout << ans << "\n";
}



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

int main() {

  long long N, A, B;
  cin >> N >> A >> B;
  
  if ((B - A) % 2 == 0) {
    cout << (B - A) / 2 << endl;
  }
  else {
    if (A - 1 <= N - B) {
      cout << A + (B - A - 1) / 2 << endl;
    }
    else {
      cout << N - B + 1 + (- A + B - 1) / 2 << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	string S;
	cin >> S;
	int n = S.size();
	int l = 0, r = 1;
	set<char> st = {'A', 'C', 'G', 'T'};
	int res = 0;
	while (l < n) {
		while (l < n && !st.count(S[l])) ++l;
		if (l == n) break;
		r = l + 1;
		while (r < n && st.count(S[r])) ++r;
		res = max(res, r - l);
		l = r + 1;
	}
	cout << res << endl;

	return 0;
}


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

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

const int INF=1e9;

using namespace std;

int m, n;
int c[21];

int dp[21][100005];

int dfs(int i, int sum){
  if(i==m){
    if(n==sum)
      return 0;
    else
      return INF;
  }

  if(dp[i][sum] != -1) return dp[i][sum];

  int ret;

  ret=dfs(i+1,sum);

  if(sum+c[i] <= n){
    ret=min(ret,dfs(i,sum+c[i])+1);
  }

  return dp[i][sum] = ret;
}

int main(){
  rep(i, 21)rep(j, 100005) dp[i][j] = -1;
  cin>>n>>m;
  rep(i,m)cin>>c[i];
  cout<<dfs(0,0)<<endl;
}

Measured memory_bytes: 13648
int main(){
    int n,x,count,i,j,k;
    while (1){
        scanf("%d %d",&n,&x);
        if (n==0) break;
        count=0;
        for (i=1;i<n-1;i++){
            for (j=i+1;j<n;j++){
                for (k=j+1;k<n+1;k++){
                    if (i+j+k==x) count+=1;
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;   
}


Measured memory_bytes: 2100
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int maxi = 0;
    int x    = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'I')
            x++;
        else
            x--;
        chmax(maxi, x);
    }
    cout << maxi << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
const int mod = 1000000007;
int n;
int main() {
	scanf("%d", &n);
	int ret = 1;
	for (int i = 1; i <= n; i++) ret = 1LL * ret * i % mod;
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 128
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_B
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string frst;

//string shuffle(string input, int sh){
void shuffle(int sh){
//  string shu = input.substr(input.begin(), input.begin()+sh-1);
  //string shu = input.substr(0, sh);
  string shu = frst.substr(0, sh);
  //cout << shu << endl;
  //input.erase(input.begin(), input.begin()+sh-1);
  frst.erase(0, sh);
  //cout << input << endl;
  frst = frst + shu;
  //cout << input << endl;
  //return input;
}

int main(){
//  string frst;
  int n,sh;
  while(cin >> frst >> n){
    if(frst == "-") break;
    else{
      for(int i = 0; i<n; i++){
        cin >> sh;
//        shuffle(frst, sh);
        shuffle(sh);
      }
    }
    cout << frst << endl;
  }
}

Measured memory_bytes: 1232
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string s; cin >> s;

    set<char> c;
    for(char i = 'a'; i <= 'z'; i++) c.insert(i);

    for(char i : s) {
        if(c.count(i)) c.erase(i);
    }

    if(c.empty()) cout << "None";
    else cout << *c.begin();

    return 0;
}


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

int main()
{
	while (true){
		string s, t;
		cin >> s;
		if (!s.size()) break;
		cin >> t;
		int dp1[4001] = { 0 }, dp2[4001] = { 0 }, mx = 0;
		for (int i = 0; i < s.size(); i++){
			for (int j = 0; j < t.size(); j++){
				if (s[i] == t[j]){
					dp2[j + 1] = dp1[j] + 1;
					mx = max(mx, dp2[j + 1]);
				}
			}
			for (int j = 0; j <= t.size(); j++){
				dp1[j] = dp2[j];
				dp2[j] = 0;
			}
		}
		cout << mx << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
import math
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]

ans = 0
for j in range(N):
    for i in range(j):
        distant2 = 0
        for k in range(D):
            distant2 += (X[j][k]-X[i][k])**2
        if math.sqrt(distant2) % 1 == 0:
            ans += 1

print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		
		int temp = n.length() - 1;
		
		if(n.charAt(temp) == '3') System.out.println("bon");
		else if(n.charAt(temp) == '0' || n.charAt(temp) == '1' || n.charAt(temp) == '6' || n.charAt(temp) == '8') System.out.println("pon");
		else System.out.println("hon");
		
	}

}


Measured memory_bytes: 35792
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
b=i2()
c=[]
e=0
for i in range(n):
 c.append([a[i]-b[i],i])
c.sort()
d=[c[n-1][0],n-1]
if c[0][0]<0:
   e+=1
for i in range(n):
 if c[i][0]<0:
    d[0]+=c[i][0]
    e+=1
    if d[0]<0:
       d[1]-=1
       d[0]+=c[d[1]][0]
       e+=1
 else:
    break
if (sum(a)-sum(b))<0:
   print(-1)
else:
   print(e)

Measured memory_bytes: 91952
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;

long long Mapping2(long long ball,long long box){
    long long A = 1;
    for(long long i = 0; i < ball;++i){
        A *= (box - i);
        A %= MOD;
    }
    return A;
}

signed main() {
    long long n,k;cin >> n >> k;
    cout << Mapping2(n,k) << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>

#define mp make_pair
#define pb push_back
#define ppb pop_back

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
typedef vector<vl> vvl;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fors(i, n, s) for (int i = 0; i < (int)(n); i += s)
#define forn1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forn11(i, n) for (int i = 1; i < (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

#define prOk(ok) cout << ((ok) ? "Yes" : "No")


int main()
{

	string s;
	cin >> s;
ll other = 0;
	ll unclosed = 0;
	for(char c : s)
	{
		if(unclosed > 0 && c == 'T')
			unclosed--;
		else if(c == 'T')
			other++;
		else unclosed++;
	}

	cout << unclosed + other;
	return 0;
}

Measured memory_bytes: 640
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

ave = sum(a)/n

diff = 10**18
thum = -1
for i, ai in enumerate(a):
    if abs(ai-ave) < diff:
        diff = abs(ai-ave)
        thum = i

print(thum)

Measured memory_bytes: 3316
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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


	int N, M, A, B, C;
	string S, T;
	cin >> A >> B >> C;
	cout << C << " " << A << " " << B << endl;

	return 0;
}



Measured memory_bytes: 256
def simulate(N):
    for A in As:
        N -= N % A
    return N

K = int(input())
As = list(map(int, input().split()))

iLft, iRgt = 1, sum(As) - K + 3
while iRgt - iLft > 1:
    iMid = (iLft + iRgt) // 2
    if simulate(iMid) < 2:
        iLft = iMid
    else:
        iRgt = iMid
ansMin = iRgt

iLft, iRgt = 1, sum(As) - K + 3
while iRgt - iLft > 1:
    iMid = (iLft + iRgt) // 2
    if simulate(iMid) <= 2:
        iLft = iMid
    else:
        iRgt = iMid
ansMax = iLft

if ansMin <= ansMax:
    print(ansMin, ansMax)
else:
    print(-1)


Measured memory_bytes: 14252
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int N, K, ans;
int a[100000];
int d[100000];
vector<int> child[100000];

int f(int n) {
	if(d[n] != -1) return d[n];
	return d[n] = f(a[n]) + 1;
}

int f2(int n, int depth) {
	int md = d[n];
	for(int c : child[n]) {
		int dd = f2(c, depth + 1);
		if(dd - depth + 1 > K) {
			ans++;
		}
		else {
			md = max(md, dd);
		}
	}
	return md;
}

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

	cin >> N >> K;
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		a[i]--;
		if(i != 0) {
			child[a[i]].push_back(i);
		}
	}

	memset(d, -1, sizeof d);
	d[0] = 0;
	for(int i = 0; i < N; i++) {
		f(i);
	}
	d[0] = f(a[0]) + 1;

	bool ok = true;
	for(int i = 0; i < N; i++) {
		if(a[0] == 0 && d[i] <= K || a[0] != 0 && d[i] == K) continue;
		ok = false;
		break;
	}
	if(ok) {
		cout << 0 << endl;
		return 0;
	}

	ans += a[0] != 0;
	a[0] = 0;
	for(int c : child[0]) {
		f2(c, 1);
	}
	cout << ans << endl;
}

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

int main(){
  int l[11];
  int v1,v2,sum;
  int x;

  //std::cout << (int)(5/2+0.51) <<std::endl;

  while(std::cin >> l[1]){
    sum = l[1];
    for(int i=2;i<11;i++){
      std::scanf(",%d",&l[i]);
      sum += l[i];
    }
    std::scanf(",%d,%d",&v1,&v2);
    if((sum*v1)%(v1+v2)==0){
      x = (sum*v1)/(v1+v2);
    }else{
      x = (sum*v1)/(v1+v2);
      ++x;
    }
    sum = 0;
    for(int i=1;i<11;i++){
      sum += l[i];
      if(x<=sum){
        std::cout << i << std::endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3020