akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a;
  cin >> a;
  
  if ((a == 1000 || a >= 1110) && (a % 1110 <= 9 || (a % 1000) % 111 == 0))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
C = [0]*N
A = [[] for _ in range(N)]

for i in range(N):
    tmp = list(map(int, input().split()))
    C[i] = tmp[0]
    A[i] = tmp[1:]


ans = 10**18
flag = False
for i in range(2 ** N):
    tmp = 0
    gakusyu = [0]*M
    for j in range(N):
        if ((i >> j) & 1):
            gakusyu = [x+y for x, y in zip(A[j], gakusyu)]
            tmp += C[j]
    if all([True if rikaido >= X else False for rikaido in gakusyu]):
        ans = min(ans, tmp)
        flag = True
if flag:
    print(ans)
else:
    print("-1")

Measured memory_bytes: 9252
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_A
 */
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> S(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> S[i]; cin.ignore();
    }

    int q;
    cin >> q; cin.ignore();

    vector<int> T(q);
    for (int i = 0; i < q; i++) {
        cin >> T[i]; cin.ignore();
    }

    int count = 0;
    for (int it : T) {
        S[n] = it;
        int index = 0;
        while (it != S[index++]);
        if (index < n) { count++; }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3100
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    int[] S;
    int n;
    char last;
    foreach (c; readln.chomp) {
        if (last && last == c) {
            ++n;
        } else {
            if (n) S ~= n;
            last = c;
            n = 1;
        }
    }
    S ~= n;
    if (S.length == 1) {
        writeln(S[0]);
        return;
    }

    while (S.length > 2) {
        if (S[0] < S[$-1]) {
            S[1] += S[0];
            S = S[1..$];
        } else {
            S[$-2] += S[$-1];
            S = S[0..$-1];
        }
    }
    writeln(max(S[0], S[1]));
}

Measured memory_bytes: 2584
#include <bits/stdc++.h>
using namespace std;
int main() {
int K, N;
cin >> N >> K;
int X = 0;
int V = 1;
for (int i = 0; i < N; i++){
  if ((V * 2) < (K + V)){
   V = V * 2;
  }else{
   V = K + V;
  }
}
cout << V << endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int n; int u; int v;
	while(~scanf("%d%d%d", &n, &u, &v)) {
		-- u, -- v;
		vi deg(n);
		vector<vector<int> > g(n);
		for(int i = 0; i < n - 1; ++ i) {
			int u, v;
			scanf("%d%d", &u, &v), -- u, -- v;
			++ deg[u], ++ deg[v];
			g[u].push_back(v);
			g[v].push_back(u);
		}
		bool ans;
		if(n == 2) {
			ans = true;
		} else if(n % 2 == 1 || deg[u] > 3 || deg[v] > 3) {
			ans = false;
		} else {
			ans = false;
			vi candidates;
			rep(r, 300) {
				vector<bool> vis(n);
				int i = u, j = v;
				bool ok = true;
				rep(k, n / 2) {
					if(i == -1 || j == -1 || vis[i] || vis[j] || i == j) {
						ok = false;
						break;
					}
					vis[i] = vis[j] = true;
					candidates.clear();
					each(c, g[i]) if(!vis[*c])
						candidates.push_back(*c);
					i = candidates.empty() ? -1 : candidates[rand() % candidates.size()];
					candidates.clear();
					each(c, g[j]) if(!vis[*c] && *c != i)
						candidates.push_back(*c);
					j = candidates.empty() ? -1 : candidates[rand() % candidates.size()];
				}
				ans |= ok;
			}
		}
		puts(ans ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 6960
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vectors<decltype(inner)>(x, inner); }
using ll = long long;
using ld =long double;
#define int ll
#define INF LLONG_MAX/100
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
    int N,M,R;
    cin >> N >> M >> R;
    vector<vector<int>>d(N,vector<int>(N,INF));
    rep(i,N)d[i][i] = 0;
    vector<int>r(R);
    rep(i,R) cin >> r[i];
    sort(all(r));
    int ans = INF;
    rep(i,M){
        int a,b,c; cin >> a >> b >> c;
        --a,--b;
        d[a][b] = d[b][a] = c;
    }
    rep(k,N)rep(i,N)rep(j,N)cmin(d[i][j],d[i][k]+d[k][j]);
    do{
        int temp = 0;
        rep(i,r.size()-1) temp += d[r[i]-1][r[i+1]-1];
        cmin(ans,temp);
        
    } while (next_permutation(all(r)));
    cout <<  ans << endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int a[100005];
int main(){
	int i,j,k;
	int n;
	int s=0;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		a[i]--;
	}
	for(i=0;i<n;i++){
		if(a[a[i]]==i){
			s++;
		}
	}
	s/=2;
	cout<<s<<endl;
	return 0;
}
	

Measured memory_bytes: 768
/*
h3110_fr13nd,
 
AUTHOR : @sam_jn
*/
 
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);  
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------// 

void solve(){   
     int r;
    cin >> r;
    // cout << fixed << setprecision(12);
     double ans = 2.0 * 3.141592 * r;
    cout << ans;
}
int main(){


                                                            // #ifndef ONLINE_JUDGE    
                                                            // freopen("../../input", "r", stdin);
                                                            // freopen("../../output", "w", stdout);
                                                            // #else
                                                            // // online submission
                                                            // #endif


    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}
 
 
//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)  
{  
    if (baap[i] != i)  
        baap[i] = find(baap[i]);  
  
    return baap[i];  
}
 
bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}

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

#define boost ios_base::sync_with_stdio(false), cin.tie(NULL);

using namespace std;
const int N = 1e6 + 41;
const int mod = 1e9 + 7;
const long long INF = 1e16;
const int inf = 1e9;

int main () {
	boost;
	int m, k;
	cin >> m >> k;
	if (!k) {
		for (int i = 0 ; i < (1 << m) ; ++ i) cout << i << " " << i << " ";
	} else {
		int x = 0;
		int a = -1, b = -1;
		for (int i = 0 ; i < (1 << m) ; ++ i) x ^= i;
		for (int i = 0 ; i < (1 << m) ; ++ i) if ((x ^ k ^ i) < (1 << m) && (x ^ k ^ i) >= 0 && (x ^ k ^ i) != i) a = i, b = (x ^ k ^ i);
		if (a == -1) return cout << -1, 0;
		for (int i = 0 ; i < (1 << m) ; ++ i) if (i != a && i != b) cout << i << " ";
		cout << a << " " << b << " ";
		for (int i = (1 << m) - 1 ; i >= 0 ; -- i) if (i != a && i != b) cout << i << " ";
		cout << b << " " << a;
	}
}

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

int main()
{
    int n;cin>>n;
    int m=n;
    int q=0;
    while(m)
    {
        q+=m%10;
        m/=10;
    }
    if(n%q==0)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int N = scanner.nextInt();
		String S=scanner.next();


		int max=0;
		for(int k = 1;k<N;k++) {

		String X = S.substring(0, k);
		String Y= S.substring(k);


		int[] X_cnt = countChar(X);
		int[] Y_cnt = countChar(Y);

		int ans = countMatch(X_cnt,Y_cnt);
		max =(ans>max)?ans:max;
		}


		System.out.println(max);
		scanner.close();
	}

	private static int[] countChar(String s) {
		int[] cnt = new int[26];

		for(int i=0;i<s.length();i++) {
			cnt[s.charAt(i)-'a']++;
		}

		return cnt;
	}

	private static int countMatch(int[] x,int[] y) {
		int ans=0;

		for (int i = 0; i < y.length; i++) {
			if(x[i]>0 && y[i]>0) {
				ans++;
			};
		}
		return ans;
	}

}


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

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

sys.setrecursionlimit(1000000)

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

N = input()

ans = 0
for i in range(1, N + 1):
    if len(str(i)) % 2 == 1:
        ans += 1
print ans

Measured memory_bytes: 6008
def dice():
    import random as ran

    dnum = list(map(int,input().split()))
    q = int(input())
    up = dnum[0]
    un = dnum[5]
    ri = dnum[2]
    le = dnum[3]
    fr = dnum[1]
    ba = dnum[4]
    tmp = int(0)
    tmp2 = int(0)
    order = ["S","N","E","W"]

    for i in range(q):
        qup,qfr = (int(x) for x in input().split())
        while True :
            x = ran.choice(order)
            if (x == "S"):
                tmp = fr
                tmp2 = un
                fr = up
                up = ba
                un = tmp
                ba = tmp2

            elif (x == "N"):
                tmp = un
                tmp2 = up
                up = fr
                un = ba
                fr = tmp
                ba = tmp2

            elif (x == "E"):
                tmp = up
                tmp2 = un
                up = le
                un = ri
                ri = tmp
                le = tmp2

            elif (x == "W"):
                tmp = un
                tmp2 = up
                up = ri
                un = le
                ri = tmp
                le = tmp2

            if (up == qup and fr == qfr):
                print(ri)
                break
dice()



Measured memory_bytes: 8172
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>

using namespace std;

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

signed main()
{
	double L; cin >> L;
	double l = L/3.0;
	printf("%lf\n", l*l*l);
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	d := ReadInts(N)

	m := make(map[int]bool)
	for _, di := range d {
		m[di] = true
	}
	fmt.Println(len(m))
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1860
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>   pii;
typedef vector< pii>      vii;
typedef vector<int>     vi;
typedef vector< vi >    vvi;
typedef long long int   LL;
#define pb push_back
#define mp make_pair
#define scan(n) scanf("%d",&n)
#define print(n) printf("%d\n",n)
#define longscan(n) scanf("%lld",&n)
#define longprint(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
/*void sieve(int n)
  {
          for(int i=2;i*i<=100000;i++) for(int j=2*i;j<=100000;j+=i) if(!sie[j]) sie[j]=1;
          }*/
int main()
{
     int n, W;
     cin >> n >> W;
     long long int dp[n+1][100009];
     for(int i=0;i<=n;i++) for(int j=0;j<=1e5;j++) dp[i][j] = 2e9;
     long long int v[n+1], w[n+1];
     for(int j=0;j<n;j++){
         cin >> w[j] >> v[j];
     }
     dp[0][0] = 0;
     for(int i=1;i<=n;i++)
     {
         for(int j=0;j<=1e5;j++)
         {
             dp[i][j] = dp[i-1][j];
         }
         for(int j=v[i-1];j<= 1e5;j++)
         {
             dp[i][j] = min(dp[i][j], dp[i-1][j-v[i-1]] + w[i-1]);
         }
     }
     int ans = 0;
     for(int j=1e5;j>=0;j--)
     {
         if(dp[n][j] <= W){
             cout << j << "\n";
             ans = 1;
             break;
         }
     }
     if(!ans){
         cout << ans << "\n";
     }
     return 0;
}


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

int main(){
	int n,m;cin>>n>>m;
	vector<pair<int,int> >std;
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		std.push_back({a,b});
	}
	vector<pair<int,int> > pts;
	for(int i=0;i<m;i++){
		int x,y;cin>>x>>y;
		pts.push_back({x,y});
	}
	for(int i=0;i<n;i++){
		int mn=1e9;
		int ind;
		for(int j=m-1;j>=0;j--){
			int now=abs(std[i].first-pts[j].first)+abs(std[i].second-pts[j].second);
			if(now<=mn){
				mn=now;
				ind=j+1;
			}
		}
		cout<<ind<<endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,n,t,a,position;
    cin >> n >> t >> a;
    int h[n];
    double df[n],test=1000000;
    for(i=0;i<n;i++){
        cin >> h[i];
        df[i] = t-h[i]*0.006-a;
        if(df[i]<0){
            df[i] = -df[i];
        }
    }
    for(i=0;i<n;i++){
        if(df[i]<test){
            test = df[i];
            position = i+1;
        }
    }
    cout << position;
}

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

int main(void)
{
  char w[10];
  char t[1000];
  int i;
  int cou=0; //w???????????¨??????s?????°

  //w?????¨??¨?°?????????§??????
  scanf("%s",w);
  for(i=0; (w[i])!='\0'; i++){
    if(isupper(w[i])){
      w[i] = tolower(w[i]);
    }
  }

  do{
    scanf("%s",t);
    if((strcmp(t,"END_OF_TEXT")) == 0){ //END_OF_TEXT??????????????????????????????
      break;
    }
    //s?????¨??¨?°?????????§??????
    for(i=0; (t[i])!='\0'; i++){
      if(isupper(t[i])){
	t[i] = tolower(t[i]);
      }
    }
    //t??¨w????????´??????????????????????¢????
    if((strcmp(t,w)) == 0){
      cou++;
    }
  }while(1);

  printf("%d\n",cou);
  
  return(0);
}

Measured memory_bytes: 980
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
typedef unsigned long long Long;

const int N = 2e5 + 5;
const int MOD = round(1e9 + 7);

int nxt[N];
int arr[N];
int n;

void buildNxt() {
  vector<int> last(N, n);

  for (int i = n - 1; i >= 0; --i) {
    nxt[i] = last[arr[i]];
    last[arr[i]] = i;
  }
}

int memo[N][2];

int calc(int ind, bool acc) {
  if (ind == n) return !acc;
  int& res = memo[ind][acc];
  if (res != -1) return res;

  if (acc) {
    res = calc(ind + 1, false);
    res = (res + calc(nxt[ind], true)) % MOD;
  } else {
    res = calc(ind, true);
  }

  return res;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  memset(memo, -1, sizeof memo);

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    if (i > 0 && arr[i] == arr[i - 1]) {
      --i , --n;
    }
  }

  buildNxt();

  cout << calc(0, false) << endl;

}



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


int main() {

    int n, m;
    scanf("%d %d", &n ,&m);

    if (n == m) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
X, N = map(int, input().split())
p = list(map(int, input().split()))
s = set(p)
d = 10**18
ans = 0

for i in range(-1000, 1000):
    if i not in s and abs(X-i)<d:
        d = abs(X-i)
        ans = i

print(ans)

Measured memory_bytes: 64552
x = int(input())
if x < 600:
    ans = 8
elif x < 800:
    ans = 7
elif x < 1000:
    ans = 6
elif x < 1200:
    ans = 5
elif x < 1400:
    ans = 4
elif x < 1600:
    ans = 3
elif x < 1800:
    ans = 2
else:
    ans = 1
print(ans)

Measured memory_bytes: 9176
N,M = map(int,input().split())
MOD = 10**9+7

MAXN = N+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
def comb(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

ans = 1
for i in range(N):
    ans *= (M-i)
    ans %= MOD

ps = [1]
for i in range(N):
    ps.append((ps[-1] * (M-N+1+i)) % MOD)
ps.reverse()

tmp = 0
for i,p in enumerate(ps):
    t = p * comb(N,i)
    if i%2:
        t *= -1
    tmp += t

ans *= tmp
ans %= MOD
print(ans)

Measured memory_bytes: 91660
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);++i)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<int> L(N); IN(L);
	SO(L);
	LL ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			int index = lower_bound(L.begin(), L.end(), L[i]+L[j]) - L.begin();
			int cnt = index - j - 1;
			ans += cnt;
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

Measured memory_bytes: 256
class Card(object):
    def __init__(self, card):
        self._suit = card[0]
        self._value = int(card[1])

    def __eq__(self, other):
        if other is None:
            return False
        return self.__dict__ == other.__dict__

    def getValue(self):
        return self._value

    def toString(self):
        return self._suit + str(self._value)


def card_bubbleSort(lst, n):
    for i in range(0, n):
        for j in range(n-1, i, -1):
            if lst[j].getValue() < lst[j-1].getValue():
                tmp = lst[j]
                lst[j] = lst[j-1]
                lst[j-1] = tmp

    return lst


def card_selectionSort(lst, n):
    for i in range(0, n):
        minj = i
        for j in range(i, n):
            if lst[j].getValue() < lst[minj].getValue():
                minj = j

        if i != minj:
            tmp = lst[i]
            lst[i] = lst[minj]
            lst[minj] = tmp

    return lst


def isStable(in_lst, out_lst, n):
    for i in range(0, n):
        for j in range(i+1, n):
            for a in range(0, n):
                for b in range(a+1, n):
                    if in_lst[i].getValue() == in_lst[j].getValue() \
                            and in_lst[i] == out_lst[b] \
                            and in_lst[j] == out_lst[a]:
                                return False
    return True


if __name__ == "__main__":
    n = int(input())
    lst = input().split()
    func_table = [card_bubbleSort, card_selectionSort]
    for func in func_table:
        cards = [Card(item) for item in lst]
        result = func(cards, n)
        cards = [Card(item) for item in lst]
        print(" ".join([card.toString() for card in result]))
        if isStable(cards, result, n):
            print("Stable")
        else:
            print("Not stable")

Measured memory_bytes: 7892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin>>N>>M;
  vector<int>v(M);
  for(int X=0;X<N;X++){
    int K;
    cin>>K;
    for(int Y=0;Y<K;Y++){
      int H;
      cin>>H;
      v[H-1]++;
    }
  }
  int G=0;
  for(int X=0;X<M;X++){
    if(v[X]==N){
      G++;
    }
  }
  cout<<G<<endl;
}

Measured memory_bytes: 3580
#include<stdio.h>

#define rep(i,n) for(int i=0; i< (int)(n); i++)
#define max(x,y) x>y?x:y

int main() {
  int n;
  // int n = 5;

  scanf("%d\n", &n);
  long long int a[n];
  // long long int a[] = {2, 1, 5, 4, 3};
  rep(i,n){
    scanf("%lld\n", &a[i]);
  }
  long long int res = 0, mx = -1;
  rep(i,n){
    res += max(mx-a[i],0);
    mx = max(mx,a[i]);
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 3248
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	for sc.Scan() {
		if sc.Text() == "0 0" {
			break
		}
		chunks := strings.Split(sc.Text(), " ")
		n, _ := strconv.Atoi(chunks[0])
		r, _ := strconv.Atoi(chunks[1])
		cards := make([]int, n, n)
		for i := 0; i < n; i++ {
			cards[i] = n - i
		}
		for i := 0; i < r; i++ {
			sc.Scan()
			chunks := strings.Split(sc.Text(), " ")
			p, _ := strconv.Atoi(chunks[0])
			c, _ := strconv.Atoi(chunks[1])
			block := make([]int, c, c)
			for j := 0; j < c; j++ {
				block[j] = cards[p+j-1]
			}
			for j := p - 2; j >= 0; j-- {
				cards[j+c] = cards[j]
			}
			for j := 0; j < c; j++ {
				cards[j] = block[j]
			}
		}
		fmt.Println(cards[0])
	}
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> L(M);
    vector<int> R(M);
    for(int i = 0; i < M; ++i){
        cin >> L[i] >> R[i];
    }
    
    int ans = 0;
    
    int max_L = *max_element(cbegin(L), cend(L));
    int min_R = *min_element(cbegin(R), cend(R));
    
    ans = max(0, min_R - max_L + 1);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];

    string ans = "second";
    rep(i, n) {
        if (a[i] & 1) {
            ans = "first";
            break;
        }
    }

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

Measured memory_bytes: 640
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    var a, b = sc.nextInt

    do {
      if (a < b) println(s"$a $b")
        else println(s"$b $a")
      a = sc.nextInt
      b = sc.nextInt
    } while ( a != 0 || b != 0)
  }
}

Measured memory_bytes: 53584
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;cin>>n>>k;
    vector<int> vec;
    vector<bool> check(1<<n,false);
    if(n == 1) {
        if(k >= 1) {
            cout << -1 << endl;
        } else {
            cout << "0 0 1 1" << endl;
        }
        return 0;
    }
    if(k >= 1<<n) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, 1<<n) {
        if (i != k) {
            vec.push_back(i);
        }
    }
    for(auto x: vec) {
        cout << x << " ";
    }
    cout << k << " ";
    for(int i=vec.size()-1;i>=0;i--) {
        cout << vec[i] << " ";
    }
    cout << k << endl;

    return 0;
}


Measured memory_bytes: 2552
import sys
import numpy as np
from numba import njit,i8

R,C,K = map(int,input().split())
item = np.zeros((R,C),np.int64)
for _ in range(K):
    r,c,v = map(int,input().split())
    item[r-1][c-1] = v
    

@njit(i8(i8[:,:],i8,i8), cache = True)
def solve(item,R,C):
    dp = np.zeros((R+1,C+1,4),np.int64)
    for ri in range(R):
        for ci in range(C):
            dp[ri+1][ci+1][0] = max(dp[ri+1][ci][0], dp[ri][ci+1][3])
            dp[ri+1][ci+1][1] = max(dp[ri+1][ci][1], dp[ri+1][ci][0]+item[ri][ci], dp[ri][ci+1][3]+item[ri][ci], dp[ri+1][ci+1][0])
            dp[ri+1][ci+1][2] = max(dp[ri+1][ci][2], dp[ri+1][ci][1]+item[ri][ci], dp[ri+1][ci+1][1])
            dp[ri+1][ci+1][3] = max(dp[ri+1][ci][3], dp[ri+1][ci][2]+item[ri][ci], dp[ri+1][ci+1][2])
        

    return dp[-1][-1][3]

print(solve(item,R,C))

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	pair<string,int> a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i].first>>a[i].second;
		a[i].second*=-1;
	}
	pair<string,int> b[n]=a;
	sort(b,b+n);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (a[j].second==b[i].second)
			{
				cout<<j+1<<endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;
#define ll long long
#define pb push_back
#define pp pair<long long,long long>
#define ppp pair<pair<long long,long long>,long long>
#define f first
#define s second
#define pd pair<double,long long>
set<pp> st1,st2;
ll arr[200100],barr[200100],ans[200100];
vector<ll> vec1[200100];
int main() {
	ll t,n,i,j,k,l,m;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll p;
	t=1;
	//cin>>t;
	while (t--) {
		cin>>n;
		for (i=0;i<n;i++)
			cin>>j,arr[j]++,vec1[j].pb(i);
		for (i=0;i<n;i++)
			cin>>j,barr[j]++;
		for (i=1;i<=n;i++) {
			if (arr[i]!=0)
				st1.insert(pp(-arr[i],i));
			if (barr[i]!=0)
				st2.insert(pp(-barr[i],-i));
		}
		bool flag=true;
		while (!st1.empty()) {
			pp x = *(st1.begin());
			st1.erase(st1.begin());
			ll freq = x.f;
			ll num = x.s;
			pp y = *(st2.begin());
			st2.erase(st2.begin());
			if (y.s==-num) {
				if (st2.empty()) {
					flag=false;
					break;
				}
				pp z=*(st2.begin());
				st2.erase(st2.begin());
				st2.insert(y);
				y=z;
			}
			ll freq2=y.f;
			ll num2=y.s;
			ll idx1 = vec1[num].back();
			ans[idx1]=-num2;
			vec1[num].pop_back();
			freq++,freq2++;
			if (freq!=0)
				st1.insert(pp(freq,num));
			if (freq2!=0)
				st2.insert(pp(freq2,num2));
		}
		if (flag) {
			cout<<"Yes\n";
			for (i=0;i<n;i++)
				cout<<ans[i]<<' ';
			cout<<'\n';
		} else {
			cout<<"No\n";
		}

	}
	return 0;
}

Measured memory_bytes: 44244
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a=sorted(a)
b=sorted(b)
c=sorted(c)
c.insert(0,-1)
c.append(10**10)
a.insert(0,-1)
a.append(10**10)
ans=0
for i in range(n):
    x=b[i]
    l=0
    r=n+1
    while r-l>1:
        m=(l+r)//2
        if a[m]<x:
            l=m
        else:
            r=m
    L=0
    R=n+1
    while R-L>1:
        M=(L+R)//2
        if c[M]<=x:
            L=M
        else:
            R=M
    ans+=l*(n+1-R)
print(ans)


Measured memory_bytes: 103972
#include <iostream>
#include <string>
using namespace std;
int main(){
string S,T;
cin>>S>>T;
int A,B;
cin>>A>>B;
string U;
	cin>>U;
	if(S==U){
	cout<<A-1<<" "<<B;
	}	
		else{cout<<A<<" "<<B-1;}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  vector<ll> a(N);
  for(int i = 0;i < N;i++)cin >> a[i];
  ll ans = 0;
  for(int i = 0;i < N;i++)ans += a[i] - 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
a,h,x = [int(j) for j in input().split()]
# y = (h*a - x/a)*(2/a**2)
# y = a**2/(2*h*a-2*x)
y = 2*h/a - 2*x/a**3
z = (h**2)*a/(2*x)
# try:
# print(y)
b = x/(a**2)
if b>h/2:
    print(math.degrees(math.atan(y)))
else:
    print(math.degrees(math.atan(z)))

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  for (int i = 0; i < N; i++) {
    cout << S[i] << T[i];
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
using P = pair<int,int>;
 
int main() {
  #define int long long
  int n;
  cin >> n;
  vint A(n);
  vint B(n);
  rep(i,n) cin >> A[i];
  rep(i,n) cin >> B[i];
  vint up(0);
  int sum = 0;
  int count = 0;
  rep(i,n){
    if(A[i] < B[i]){
      sum += B[i] - A[i];
      count++;
    }
    else if(A[i] > B[i]){
      up.push_back(A[i] - B[i]);
    }
  }
  sort(up.begin(),up.end());
  reverse(up.begin(),up.end());
  rep(i,up.size()){
    if(sum <= 0) break;
    sum -= up[i];
    count++;
  }
  if(sum <= 0)
    cout << count << endl;
  else if(sum > 0)
    cout << -1 << endl;
} 

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(b <= c || a >= d) cout << 0 << endl;
    else cout << min(b, d) - max(a, c) << endl;
    
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define T3I tuple<int, int, int>
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    ll n;
    cin >> n;
    ll ans = 0;
    ans += n/500*1000;
    n %= 500;
    ans += n/5*5;
    cout << ans << endl;
}


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

using namespace std;

int main(){
  char b;
  cin >> b;
  if(b=='A') cout << "T" << endl;
  if(b=='T') cout << "A" << endl;
  if(b=='G') cout << "C" << endl;
  if(b=='C') cout << "G" << endl;
  
  return 0;
}

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

int main(void){
    string T;
    cin >> T;
    for(int i = 0; i < T.length(); i++) if(T[i] == '?') T[i] = 'D';
    cout << T << endl;
    return 0;
}


Measured memory_bytes: 3724
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
string ReplaceString
(
      std::string String1   // 置き換え対象
    , std::string String2   // 検索対象
    , std::string String3   // 置き換える内容
)
{
    std::string::size_type  Pos( String1.find( String2 ) );
 
    while( Pos != std::string::npos )
    {
        String1.replace( Pos, String2.length(), String3 );
        Pos = String1.find( String2, Pos + String3.length() );
    }
 
    return String1;
}
ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

int main(){

    
    string T;
    string S="";
    cin >> T;

    cout << ReplaceString(T,"?","D") << endl;

}

Measured memory_bytes: 3920
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int ans = 0;
        for(int a=0;a<=A;a++){
            for(int b=0;b<=B;b++){
                for(int c=0;c<=C;c++){
                    if(500*a+100*b+50*c==X)ans++;
                }
            }
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll n;
    cin >>n;
    string ans="";
    char c = 'a';
    ll check = 26;
	while(n){
        n--;
        char next =n %check +c;
        ans+=next;
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}
    



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int M = max({a, b, c});
    int n = 3 * M - (a + b + c);
    if(n % 2 != 0) n += 3;
    cout << n / 2 << endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Array

main :: IO ()
main = do
  n <- readLn
  grp <- map (drop 2 . map read . words) <$> replicateM n getLine
  let arr = listArray ((0,0),(n-1,n-1)) $ repeat 0
      adj = trans grp 0 arr

  forM_ [0..n-1] $ \i -> do
    forM_ [0..n-1] $ \j -> do
      when (j>0) $ putChar ' ' 
      putStr $ show $ adj ! (i,j)

    putStrLn ""

trans :: [[Int]] -> Int -> Array (Int, Int) Int -> Array (Int, Int) Int
trans [] _ adj = adj
trans (x:xs) i adj = trans xs (i+1) (adj // upd)
  where
    upd = foldl (\acc v -> ((i,v-1), 1):acc) [] x

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

int main() {
  char b;
  cin >> b;

  char ans;
  switch (b) {
    case 'A':
      ans = 'T';
      break;
    case 'T':
      ans = 'A';
      break;
    case 'C':
      ans = 'G';
      break;
    case 'G':
      ans = 'C';
      break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
q, h, s, d = map(int, input().split())
n = int(input())

a = (n // 2 * d) + n % 2 * int(min(s, h // 0.5, q // 0.25))
b = n * int(min(s, h // 0.5, q // 0.25))
ans = min(a, b)
print(int(ans))


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

int main(){
	int k,s;	cin>>k>>s;

	int ans=0;
	int z;
	for(int x=0;x<=k;x++){
		for(int y=0;y<=k;y++){
			z=s-x-y;
			if(0<=z && z<=k)ans++;

		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl

const int MOD = 1000000007;

int n;
int main() {
    cin >> n;
    vector<ll> a(n), b(n+1, 0);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) b[i+1] = b[i] + a[i];

    ll ans = 0;
    rep(i, 0, n){
        ll t = b[n] - b[i+1]; t %= MOD;
        ans += a[i]*t;
        ans %= MOD;
    }

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


Measured memory_bytes: 5952
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

ll mod=1000000007;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0,c=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j]) c++;
        }
    }
    ans=c*k%mod;
    c=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i]>a[j]) c++;
        }
    }
    ans+=k*(k-1)/2%mod*c%mod;
    ans%=mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
N,M=map(int,input().split())
ab=[[int(i) for i in input().split()] for _ in range(N)]
cd=[[int(i) for i in input().split()] for _ in range(M)]

def dist(a,b):
    return abs(a[0]-b[0])+abs(a[1]-b[1])

for x in ab:
    idx=0
    for i in range(M):
        if dist(x,cd[i]) < dist(x,cd[idx]):
            idx=i
    print(idx+1)


Measured memory_bytes: 3064
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin>>n;
	int d=-1,c=0;
	rep(i,n){
		int a,b;cin>>a>>b;
		c+=b;d+=a*b;
	}
	cout<<c-1+d/9<<endl;
}












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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main()
{
  string s;
  int ans = INF;
  cin >> s;
  
  for(char c = 'a'; c <='z'; c++) {
    vector<int> v;
    v.pb(-1);
    for(int i=0; i<s.size(); i++) {
      if( s[i] == c ) v.pb(i);
    }
    if( v.size() == 1 ) continue;

    int ma = 0;
    for(int i=1; i<v.size(); i++) {
      ma = max(ma, v[i] - v[i-1] - 1);
    }
    //cout << ma << endl;

    ans = min(ans, max((int)s.size() - v[v.size()-1] - 1, ma));
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
a,b,x = list(map(int, input().split()))

volume = a*a*b

import math
# 半分以下
if 2 * x <= volume:
    print(90 - math.degrees(math.atan(2*(x/b/a)/b)))
else:
    print(math.degrees(math.atan(2*(volume-x)/a/a/a)))

Measured memory_bytes: 9380
#解説参照
k = int(input())
a = list(map(int, input().split( )))
l = 2
r = 2
for i in range(k-1,-1,-1):
    if (r//a[i])*a[i]<l:
        print(-1)
        exit()
    r2 = (r//a[i])*a[i]+a[i]-1
    l2 = ((l+a[i]-1)//a[i])*a[i]
    r = r2
    l = l2
print(l,r)

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

typedef long long LL;
const int MAXN=1e6+10;

int n;
LL A,B;
int f[5*MAXN];
vector<pair<LL,LL>> g;
vector<LL> h;
map<LL,int> mp;

int main(){
    int a,b; cin>>a>>b;
    if (a<=0 && b>=0) puts("Zero");
    else if (a>0) puts("Positive");
    else if ((b-a+1)%2==0) puts("Positive");
    else puts("Negative");
    return 0;
    scanf("%d%lld%lld",&n,&A,&B);
    LL C=A/__gcd(A,B+1)*B;
    int tag=0; if (C>1e18) tag=1;
    LL ans=0;
    for(int i=1;i<=n;i++){
        LL l,r; scanf("%lld%lld",&l,&r);
        if (tag) ans+=r-l+1;
        else{
            LL a,b;
            if (r-l+1>=C){
                a=0,b=C-1;
                g.push_back(make_pair(a,b));
            } else{
                a=l%C;
                b=r%C;
                if (a<=b){
                    g.push_back(make_pair(a,b));
                } else{
                    g.push_back(make_pair(a,C-1));
                    g.push_back(make_pair(0,b));
                }
            }            
        }
    }
    if (tag) printf("%lld\n",ans);
    else{
        sort(g.begin(),g.end());
        LL nl=g[0].first,nr=g[0].second;
        for(int i=1;i<g.size();i++){
            if (g[i].first<=nr){
                nr=max(nr,g[i].second);
            } else{
                ans+=nr-nl+1;
                nl=g[i].first;
                nr=g[i].second;
            }
        }
        ans+=nr-nl+1;
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    ll N;
    cin>>N;
    ll w,ww,www;
    for(ll n=1;n<=3500;n++){
        for(ll h=1;h<=3500;h++){
            ll z=4*n*h-n*N-h*N;
            if(z<=0) continue;
            ll a=N*h*n;
            if(a%z==0){
                w=a/z;
                ww=h;
                www=n;
                break;
            }
        }
    }
    cout<<w<<' '<<ww<<' '<<www<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算の際にオーバーフローに注意せよ！(適切にmodをとれ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
*/

Measured memory_bytes: 256