akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  map<string,int> m;
  int n;
  string s;
  cin >>n;
  rep(i,n){
    cin>>s;
    if(m.count(s)){
      m[s]++;
    }else{
      m[s]=1;
    }
  }
  cout <<"AC x "<<m["AC"]<<endl;
  cout <<"WA x "<<m["WA"]<<endl;
  cout <<"TLE x "<<m["TLE"]<<endl;
  cout <<"RE x "<<m["RE"]<<endl;
}

Measured memory_bytes: 3648
#include <stdlib.h>
#include <stdio.h>

int main(void)
{
	int a, b, c, d;

	scanf("%d %d %d %d", &a, &b, &c, &d);

	while(a > 0 && c > 0)
	{
		c = c - b;
		if(c > 0)
			a = a - d;
	}
	if(a <= 0)
		printf("No");
	else
		printf("Yes");
	return (0);
}

Measured memory_bytes: 1708
#include <iostream>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC94();
}

void ABC94(){
    int a,b,x;
    cin>>a>>b>>x;
    if(x<a)cout<<"NO"<<endl;
    else if(x<=a+b)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a = 1; int b = 1; int sum = 0;
    while (a<10) {
        
        while (b<10) {
            sum = a * b;
            printf("%dx%d=%d\n",a,b,sum);
            b++;
        }
        
        a++;
        b = 1;
    }
    
    return 0;
}

Measured memory_bytes: 524
n = str(input())
p = int(input())

keta = len(n)
Dp = [[[0 for _ in range(2)] for _ in range(keta+1)]for _ in range(keta+1)]

Dp[0][0][1] = 1
10
for i in range(keta):
    for j in range(i+1):
        for k in range(10):
            if k == 0:
                if k < int(n[i]):
                    Dp[i+1][j][0] += Dp[i][j][0]
                    Dp[i+1][j][0] += Dp[i][j][1]
                    
                elif k == int(n[i]):
                    Dp[i+1][j][1] += Dp[i][j][1]
                    Dp[i+1][j][0] += Dp[i][j][0]
                
                else:
                    Dp[i+1][j][0] += Dp[i][j][0]
            
            else:
                if k < int(n[i]):
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                    Dp[i+1][j+1][0] += Dp[i][j][1]
                elif k == int(n[i]):
                    Dp[i+1][j+1][1] += Dp[i][j][1]
                    Dp[i+1][j+1][0] += Dp[i][j][0]
                else:
                    Dp[i+1][j+1][0] += Dp[i][j][0]

if p > keta:
    print(0)
else:
    print(sum(Dp[-1][p]))

Measured memory_bytes: 4476
N = int(input())
A = list(map(int,input().split()))
ans = 0
if N==1:
    print(0)
    quit()
for i in range(1,N):
    if A[i] < A[i-1]:
        ans += A[i-1]-A[i]
        A[i] += A[i-1]-A[i]
print(ans)

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

signed main(){
	int n;cin>>n;
	vector<int> x(n),y(n),h(n);
	rep(i,n)cin>>x[i]>>y[i]>>h[i];
	int ch,h0;
	bool flg;
	repe(cx,0,100)repe(cy,0,100){
	flg=true;
	rep(i,n)if(h[i]>0){ch=h[i]+abs(x[i]-cx)+abs(y[i]-cy);break;}
	rep(i,n){	
		h0=max(ch-abs(x[i]-cx)-abs(y[i]-cy),0ll);
		if(h0!=h[i]){flg=false;break;}
	}
	if(flg)cout<<cx<<" "<<cy<<" "<<ch<<endl,exit(0);
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        if(x >= a && x <= a + b) System.out.println("YES");
        else System.out.println("NO");
    }
}

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

int main()
{
	double x1,x2,y1,y2;
	double distance;
	
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%lf\n",sqrt(pow(x1-x2,2)+pow(y1-y2,2)));

       return 0;
	
}

Measured memory_bytes: 652
# coding: utf-8
# Your code here!

n=int(input())
S=input()
l=list("0123456789")

ret=[False]*1000
for i in (l):
    for j in (l):
        for k in (l):
            flg1=flg2=False
            for s in S:
                if s==i and not flg1:
                    flg1=True
                    continue
                if flg1 and s==j and not flg2:
                    flg2=True
                    continue
                if flg2 and s==k:
                    tmp=int(i+j+k)
                    # print(tmp)
                    ret[tmp]=True
                    break
          
print(sum(ret))

Measured memory_bytes: 47624
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
string s[11111];
int main(){
	int n,count=0,ba=0,a=0,b=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		int len=s[i].size();
		for(int j=0;j<len-1;j++){
			if(s[i][j]=='A'&&s[i][j+1]=='B') count++;
		}
		if(s[i][0]=='B'&&s[i][len-1]=='A') ba++;
		else if(s[i][0]=='B') b++;
		else if(s[i][len-1]=='A') a++;
	}
	int c=min(a,b);
	if(a==0&&b==0&&ba>0) ba--;
	cout<<count+c+ba<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e18+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=40000;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
int main()
{
	int i,j,k,l,m,n;
	string s;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	l=0;
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k])
					continue;
				if(a[i]+a[j]>a[k])
					l++;
			}
		}
	}
	cout<<l;
}

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

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define input_txt() freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define si set<int>
#define msi map<string, int>
#define test ll t; cin>>t; while(t--)
#define input(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define sqr(a) (a)*(a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
const double PI = acos(-1);
const int inf=2000000000;
const ll infLL=9000000000000000000;


void case_i()
{
    int n;cin>>n;if(n<30) cout<<"No"<<endl;else cout<<"Yes"<<endl;
}

int main()
{
    IOS;
    //    input_txt();
    //test
    case_i();
    /**/
    return 0;
}



//End up here once more;






Measured memory_bytes: 3632
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


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

const int N = 200005;
int n, rcomp[N], tcomp[N], ans[N];
vector<int> radj[N], tadj[N], storage[N], now;


void dfs(int v, int c){
    rcomp[v] = c;
    for(auto vv : radj[v])
        if(rcomp[vv] == 0)
            dfs(vv, c);
}

void dfs2(int v){
    now.pb(v);
    storage[rcomp[v]].pb(v);
    tcomp[v] = 1;
    for(auto vv : tadj[v])
        if(tcomp[vv] == 0)
            dfs2(vv);
}


int main(){

    ios_base::sync_with_stdio(0);

    int r, t;
    cin>>n>>r>>t;
    while(r--){
        int a, b;
        cin>>a>>b;
        radj[a].pb(b);
        radj[b].pb(a);
    }
    while(t--){
        int a, b;
        cin>>a>>b;
        tadj[a].pb(b);
        tadj[b].pb(a);
    }

    int z = 0;
    for(int i=1;i<=n;i++)
        if(rcomp[i] == 0)
            dfs(i, ++z);

    for(int i=1;i<=n;i++)
        if(tcomp[i] == 0){
            dfs2(i);
            for(auto v : now){
                ans[v] = (int)storage[rcomp[v]].size();
            }
            for(auto v : now){
                storage[rcomp[v]].clear();
            }
            now.clear();
        }

    for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";
    return 0;
}








Measured memory_bytes: 27128
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
int main(void){
    ll K,X;cin>>K>>X;

    ll l=X-K+1,r=X+K;
    FOR(i,l,r){
        cout<<i<<" ";
    }cout<<"\n";
}



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

using namespace std;

const int NMAX = 2000 + 5;

int N;
bitset <NMAX * NMAX> dp;

int main()
{
    ios_base :: sync_with_stdio(false);
    cin >> N;
    dp[0] = 1;
    int S = 0;
    for (int i = 1; i <= N; ++ i) {
        int A;
        cin >> A;
        dp |= (dp << A);
        S += A;
    }

    int best = S;
    for (int i = 1; i <= S - i; ++ i)
        if (dp[i])
            best = S - i;
    cout << best << '\n';
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

string S;
int N, ans;

int main()
{
    int i, j;

    cin>>S;
    N=S.size();

    char x=S[0]; ans++;
    for(i=1; i<S.size(); i++)
    {
        if(x==S[i])
        {
            if(i+1<N) ans++;
            i++, x='0';
        }
        else ans++, x=S[i];
    }
    printf("%d", ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M; //Nは都市,Mは道路
  cin >> N >> M;
  vector<int> vec(2*M),ans(N);
  
  for (int i = 0; i < 2*M; i++) {
    cin >> vec.at(i);
    ans.at(vec.at(i)-1)+=1;
  }
  
  for (int i = 0; i < N; i++) cout << ans.at(i) <<endl;
  
}

Measured memory_bytes: 256
S = input()

count = 0
if S[0] == S[1] and S[2] == S[3]:
    count += 1

if S[0] == S[2] and S[1] == S[3]:
    count += 1

if S[0] == S[3] and S[1] == S[2]:
    count += 1

if count == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
from itertools import accumulate
from collections import Counter

n, m = map(int, input().split())
a = [int(i) % m for i in input().split()]
b = list(accumulate(a))
b = []
b.append(a[0])
for i in range(n - 1):
    k = (b[-1] + a[i+1]) % m
    b.append(k)
count = Counter(b)
ans = count[0]
for i in count.values():
    ans += i * (i - 1) // 2
print(ans)

Measured memory_bytes: 16628
import java.util.Scanner;

public class Main {
	private static int[] heap;
	private static int n;
	public static void main(String[] atgs){
		final Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		heap=new int[n+1];
		for(int i=1;i<=n;i++) heap[i]=sc.nextInt();
		
		for(int i=n/2;i>=1;i--) maxHeap(i);
		
		for(int i=1;i<=n;i++) System.out.print(" " +heap[i]);	
		System.out.println("");
	}
	
	private static void maxHeap(int i){
		int l=2*i;
		int r=2*i+1;
		int max;
		if(l<=n && heap[l]>heap[i]) max=l;
		else max=i;
		if(r<=n && heap[r]>heap[max]) max=r;
		
		if(max!=i){
			int tmp=heap[i];
			heap[i]=heap[max];
			heap[max]=tmp;
			maxHeap(max);
		}
	}

}

Measured memory_bytes: 169876
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string C;
  cin >> C;
  if(C == "a" || C == "i" || C == "u" || C == "e" || C == "o")
  {
    cout << "vowel" << endl;
  }
  else
  {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3620
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());

        int sum = 0;
        for (int i = 1; i < n + 1; i++) {
            int c = 0;
            int j = i;
            while (true) {
                if (j / 10 != 0) {
                    c += j % 10;
                    j = j / 10;
                } else {
                    c += j % 10;
                    if (c >= a && c <= b) {
                        sum += i;
                    }
                    break;
                }
            }
        }
        System.out.println(sum);

    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

const int INF = 1e9 + 5;

vector <int> h;
vector <int> dp;
int n;

int main(){

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

    dp.assign(n,INF);
    
    for(int i=0;i<n;i++){
        int height;
        scanf("%d",&height);
        h.push_back(height);
    }

    dp[0] = 0;

    for(int i=0;i<n;i++){
        for(int j=i+1; j<=i+k; j++){
            if(j < n){
                dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
            }
        }
    }

    printf("%d\n",dp[n-1]);
    return 0;
}

Measured memory_bytes: 1276
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

import itertools

N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

li = [i+1 for i in range(N)]

cnt = 0
for i in itertools.permutations(li):
    if list(i) == P:
        a = cnt
    if list(i) == Q:
        b = cnt
    cnt += 1

print(abs(a-b))








Measured memory_bytes: 3060
n,p = map(int, input().split( ))
f = {}
for i in range(2,int(p**(1/2))+7):
    cnt = 0
    while (not p%i) and p>=i:
        cnt += 1
        p//=i
    if cnt:
        f[i]= cnt
if p>1:###
    f[p] = 1
ans = 1
for i in f:
    ans *= pow(i,f[i]//n)
print(ans)

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

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

int main () {
    int n; cin >> n;
    vector<tuple<string, int, int>> sp;
    for (int i = 1; i <= n; ++i) {
        string s;
        int p; cin >> s >> p;
        // pを降順にするため
        p = -p;
        sp.push_back(tie(s, p, i));
    }

    sort(sp.begin(), sp.end());
    rep(i, n) {
        auto t = sp[i];
        cout << get<2>(t) << endl;
    }
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
    WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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 long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long all_sum(int64_t k) {
  int64_t sum = k * (k+1) / 2;
  return sum;
}

int main() {
      cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  int64_t ans = 0;
  for(int64_t i = K; i <= N + 1; i++) {
    ans += all_sum(N) - all_sum(N-i) - all_sum(i-1) + 1;
    ans %= MOD;
  }
  cout << ans << endl;
    // PLEASE GIVE ME THE "ACCEPTED" !
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;
#define fors(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long ll;
const int Size=1<<18;
inline char getch(){
    static char buf[Size],*p1=buf,*p2=buf;
    return p1==p2 && (p2=(p1=buf)+fread(buf,1,Size,stdin),p1==p2) ? EOF : *p1++;
}
int read(){
    int s=0,f=1;
    char c=getch();
    while(c>'9' || c<'0'){if(c=='-') f=-1; c=getch();}
    while(c<='9' && c>='0'){s=(s<<1)+(s<<3)+c-'0';c=getch();}
    return s*f;
}

const int maxn=100007;
const long long inf=12345678987654321;
struct node
{
    int to,next,val;
}edge[maxn<<2];
int head[maxn],tot,n,m,vis[maxn],visq[maxn];
ll dis[maxn];

void add(int x,int y,int w){
    edge[++tot].to=y;
    edge[tot].next=head[x];
    head[x]=tot;
    edge[tot].val=w;
}

queue<int> q;
int spfa(int s){
    q.push(s);
    dis[s]=0,vis[s]=1;
    ll maxs=0,mins=0;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(int i=head[u];i;i=edge[i].next){
            int to=edge[i].to;
            if(dis[to]==inf){
                dis[to]=dis[u]+edge[i].val;
                maxs=max(maxs,dis[to]);
                mins=min(mins,dis[to]);
                if(maxs-mins>10000000000) return 0;
                visq[to]=1;
                if(!vis[to])
                    q.push(to);
            }
            else if(dis[to]!=dis[u]+edge[i].val) return 0;
        }
        vis[u]=0;
    }
    return 1;
}
int main(int argc, char const *argv[])
{
    fill(dis,dis+maxn-1,inf);
    n=read(),m=read();
    fors(i,1,m){
        int l=read(),r=read(),w=read();
        add(l,r,w);
        add(r,l,-w);
    }
    fors(i,1,n)
        if(!visq[i]){
            visq[i]=1;
            int flag=spfa(i);
            if(!flag){
                printf("No\n");
                return 0;
            }
        }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 7552
import sys
from math import degrees, atan

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    a, b, x = MAP()

    if a*a*b/2 > x: print(degrees(atan((a*b*b)/(2*x))))
    else: print(degrees(atan(2*(a*a*b-x)/(a*a*a))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <map>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    ll res;
    res = (N+1)/2;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
int n, m;
vector<vector<P> > vec;

ll dp[151][1001][77];

ll dfs(int x, int y, int z){
  if(dp[x][y][z] != -1)return dp[x][y][z];
  if(x == n - 1){
    return dp[x][y][z] = 0;
  }else if(x == n - 2 && z + 1 <= m){
    return dp[x][y][z] = 0;
  }
  int tmp = 0;
  for(P p: vec[x]){
    if(p.first == y){
      tmp = p.second;
      break;
    }
  }
  ll res = linf;
  // 1 step
  for(P q: vec[x+1]){
    res = min(res, (tmp + q.second) * abs(y - q.first) + dfs(x+1, q.first, z));
  }
  // 2 step
  if(z + 1 <= m && x + 2 < n){
    for(P q: vec[x+2]){
      res = min(res, (tmp + q.second) * abs(y - q.first) + dfs(x+2, q.first, z+1));
    }
  }
  return dp[x][y][z] = res;
}

int main(int argc, char const* argv[])
{
  while(true){
    cin >> n >> m;
    if(n == 0)break;
    vec.clear();
    vec.resize(n);
    for(int i = 0; i < n; i++){
      for(int j = 0; j < 1001; j++){
        for(int k = 0; k <= m; k++){
          dp[i][j][k] = -1;
        }
      }
    }
    for(int i = 0; i < n; i++){
      int k;
      cin >> k;
      for(int j = 0; j < k; j++){
        int a, b;
        cin >> a >> b;
        a--;
        vec[i].pb(mk(a, b));
      }
    }
    ll res = linf;
    for(P p: vec[0]){
      res = min(res, dfs(0, p.first, 0));
    }
    if(m != 0){
      for(P p: vec[1]){
        res = min(res, dfs(1, p.first, 1));
      }
    }
    cout << res << endl;
  }
	return 0;
}



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

int main()
{
    long long n,a,t,i,j,k;
    cin>>n>>a;
    i=(n*2)-1;
    j=(a*2)-1;
    i=max(i,j);
    k=n+a;
    k=max(i,k);
    cout<<k<<endl;
      return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
          
   var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long M = inputArray[1];

			var tsunagari = new Dictionary<int, List<int>>();

			for (int i = 1; i <= N; i++) {
				tsunagari.Add(i, new List<int>());
			}

			for (int i = 0; i < M; i++) {
				var inp = retreiveLongArray();
				var x = (int)inp[0];
				var y = (int)inp[1];
				tsunagari[x].Add(y);
				tsunagari[y].Add(x);
			}
			// 道しるべをどのように置いたか格納するDicionary
			var michishirube = new Dictionary<int, int>();

			michishirube.Add(1, 0);//1の部屋は出口(0)につながっているとする

			var tansakuQ = new Queue<int>();

			//幅優先探索する
			tansakuQ.Enqueue(1);

			while (tansakuQ.Count() > 0) {
				var kiten = tansakuQ.Dequeue();
				var ikeruheya = tsunagari[kiten];
	
				foreach (var heya in ikeruheya) {
					if (michishirube.ContainsKey(heya)) {//すでに行ったことのある部屋には何もしない
						continue;
					}
					michishirube.Add(heya, kiten);
					tansakuQ.Enqueue(heya);
				}
			}

			if(michishirube.Count < N) {//到達できない部屋がある場合
				Console.WriteLine("No");
				return;
			}


			Console.WriteLine("Yes");
			for (int i = 2; i <= N; i++) {
				Console.WriteLine(michishirube[i]);
			}

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 58404
import math

n,m=map(int,input().split())

if abs(n-m)>1:
    print(0)
elif abs(n-m)==1:
    print((math.factorial(max(n,m))*math.factorial(min(n,m)))%(10**9+7))
else:
    print((2*math.factorial(n)*math.factorial(m))%(10**9+7))


Measured memory_bytes: 5188
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string n,n1,n2,n3;
  cin >> n >> n1 >> n2 >> n3;
  if(n!=n2)pri(1);
  else pri(0);
  return 0;
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    int p[n];
    rep(i,n)    cin >> p[i];

    int k(0);
    rep(i,n)    if(p[i]!=i+1)   k++;
    if(k<=2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m, 0);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int a;
      cin >> a;
      v.at(a - 1)++;
    }
  }

  int ans = 0;
  for (int x : v) {
    if (x == n) ans++;
  }
  cout << ans << endl;
}


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

int main()
{
    int n, m, l;
    long long c;
    long long A[100][100], B[100][100], C[100][100];
    cin >> n >> m >> l;
    for (int i = 0; i != 100; ++i)
    {
        for (int j = 0; j != 100; ++j)
        {
            A[i][j] = 0;
            B[i][j] = 0;
            C[i][j] = 0;
        }
    }
    for (int i = 0; i != n; ++i)
    {
        for (int j = 0; j != m; ++j)
        {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i != m; ++i)
    {
        for (int j = 0; j != l; ++j)
        {
            cin >> B[i][j];
        }
    }
    for (int i = 0; i != n; ++i)
    {
        for (int j = 0; j != l; ++j)
        {
            c = 0;
            for (int k = 0; k != m; ++k)
            {
                c += A[i][k] * B[k][j];
            }
            C[i][j] = c;
        }
    }
    for (int i = 0; i != n; ++i)
    {
        for (int j = 0; j != l; ++j)
        {
            if (j) cout << " ";
            cout << C[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3344
H, W=map(int,input().strip().split(' '))

def w_f():
    cost=[]
    for i in range(10):
        cost.append(list(map(int,input().strip().split(' '))))

    for k in range(10):
        for i in range(10):
            for j in range(10):
                cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j])
    return cost
    
d=w_f()
ans=0
for i in range(H):
    a=list(map(int,input().strip().split(' ')))
    for j in a:
        if j!=-1:
            ans+=d[j][1]
print(ans)




Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;

ll a[200005], cum[200005];

ll sum(int l, int r){ return cum[r] - cum[l - 1]; }
ll calc(ll A, ll B, ll C, ll D){
	return max({A, B, C, D}) - min({A, B, C, D});
}

int main()
{
	int N; scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		scanf("%d", &a[i]);
		cum[i] = cum[i - 1] + a[i];
	}

	ll A = a[1], B = a[2], C = a[3], D = cum[N] - cum[3];
	int le = 1, rs = 4;
	while(rs < N && C + a[rs] < D - a[rs]){
		C += a[rs]; D -= a[rs]; rs++;
	}
	
	ll ans = calc(A, B, C, D);
	if(rs < N) ans = min(ans, calc(A, B, C + a[rs], D - a[rs]));

	for(int mid = 3; mid < N - 1; mid++){
		B += a[mid]; C -= a[mid];
		while(le < mid - 1 && A + a[le + 1] < B - a[le + 1]){
			A += a[le + 1]; B -= a[le + 1]; le++;
		}
		while(rs < N && C + a[rs] < D - a[rs]){
			C += a[rs]; D -= a[rs]; rs++;
		}
		ans = min(ans, calc(A, B, C, D));
		if(le < mid) ans = min(ans, calc(A + a[le + 1], B - a[le + 1], C, D));
		if(rs < N) ans = min(ans, calc(A, B, C + a[rs], D - a[rs]));
		if(le < mid && rs < N) ans = min(ans, calc(A + a[le + 1], B - a[le + 1], C + a[rs], D - a[rs]));
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;
int N, K;
int a[100010];
bool dp[300010];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N >> K;
	rep(i, N)cin >> a[i];
	rep(i, K + 1) {
		rep(j, N) {
			if (i - a[j] >= 0 && !dp[i - a[j]]) {
				dp[i] = 1;
			}
		}
	}
	if (dp[K])cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;



int main() {
  int N; cin >> N;
  string s_tmp; cin >> s_tmp;
  bool s[N]; rep(i, N) s[i] = (s_tmp[i]=='o');

  bool a[N+2];
  string result = "";
  a[0] = true; a[1] = true;
  for(int i=1; i<=N; i++) a[i+1] = ( s[i-1] == (a[i]==a[i-1]) );
  if (a[0]==a[N]&&a[1]==a[N+1]) {
    result = "";
    for(int i=1; i<=N; i++) result+= (a[i] ? "S" : "W");
    cout << result << endl;
    return 0;
  }

  a[0] = true; a[1] = false;
  for(int i=1; i<=N; i++) a[i+1] = ( s[i-1] == (a[i]==a[i-1]) );
  if (a[0]==a[N]&&a[1]==a[N+1]) {
    result = "";
    for(int i=1; i<=N; i++) result+= (a[i] ? "S" : "W");
    cout << result << endl;
    return 0;
  }

  a[0] = false; a[1] = true;
  for(int i=1; i<=N; i++) a[i+1] = ( s[i-1] == (a[i]==a[i-1]) );
  if (a[0]==a[N]&&a[1]==a[N+1]) {
    result = "";
    for(int i=1; i<=N; i++) result+= (a[i] ? "S" : "W");
    cout << result << endl;
    return 0;
  }

  a[0] = false; a[1] = false;
  for(int i=1; i<=N; i++) a[i+1] = ( s[i-1] == (a[i]==a[i-1]) );
  if (a[0]==a[N]&&a[1]==a[N+1]) {
    result = "";
    for(int i=1; i<=N; i++) result+= (a[i] ? "S" : "W");
    cout << result << endl;
    return 0;
  }

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

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N;cin>>N;
    int x;cin>>x;

    int ans[2*N-1];
    if(x==1||x==2*N-1)cout<<"No"<<endl;
    else{
        ans[N-1]=x;
        ans[N-2]=x-1;
        ans[N]  =x+1;

        int cnt =2*N-1;
        REP(i,2*N-1){
            if(i>=N-2&&i<=N)continue;

            while(cnt>=x-1&&cnt<=x+1)cnt--;
            ans[i]=cnt--;
        }
        cout<<"Yes"<<endl;
        REP(i,2*N-1)cout<<ans[i]<<endl;

    }


    return 0;
}

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

int main() {
  int a, b, c, d, p;
  cin >> a >> b >> c >> d >> p;
  int x = a * p;
  int y;
  if (p <= c) y = b;
  else y = b + d * (p - c);
  cout << min(x, y) << "\n";
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define f first
#define s second
#define pb push_back

pair<int, int> t[800005];

void build(int a[], int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = {a[tl], tl};
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        if(t[2*v].f>t[2*v+1].f){
        	t[v]=t[2*v];
        }
        else{
        	t[v]=t[2*v+1];
        }
    }
}

pair<int, int> maxi(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return {0, 0};
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    auto u1=maxi(v*2, tl, tm, l, min(r, tm));
    auto u2=maxi(v*2+1, tm+1, tr, max(l, tm+1), r);
    if(u1.f>u2.f){
    	return u1;
    }
    else{
    	return u2;
    }
}

void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = {new_val, tl};
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        if(t[2*v].f>t[2*v+1].f){
        	t[v]=t[2*v];
        }
        else{
        	t[v]=t[2*v+1];
        }
    }
}

main() {
	int n;
	cin>>n;
	int a[n];
	int b[n];
	for(int i=0; i<n; i++){
		cin>>a[i];
	}
	for(int i=0; i<n; i++){
		cin>>b[i];
	}
	build(b, 1, 0, n-1);
	int num=0;
	while(1){
		auto u=maxi(1, 0, n-1, 0, n-1);
		if(u.f==0){
			cout<<num;
			return 0;
		}
		int ind=u.s;
		int ne=0;
		if(u.f==a[ind]){
			update(1, 0, n-1, ind, 0);
			continue;
		}
		if(ind==0){
			int red=b[1]+b[n-1];
			if(red+a[ind]>b[ind]){
				cout<<-1;
				return 0;
			}
			int times=(b[ind]-a[ind])/red;
			num+=times;
			ne=b[ind]-times*red;
		}
		
		else if(ind==n-1){
			int red=(b[0]+b[ind-1]);
			if(red+a[ind]>b[ind]){
				cout<<-1;
				return 0;
			}
			int times=(b[ind]-a[ind])/red;
			num+=times;
			ne=b[ind]-times*(red);
		}
		else{
			int red=b[ind-1]+b[ind+1];
			if(red+a[ind]>b[ind]){
				cout<<-1;
				return 0;
			}
			int times=(b[ind]-a[ind])/red;
			num+=times;
			ne=b[ind]-times*red;
		}
		if(ne<a[ind]){
			cout<<-1;
			return 0;
		}
		if(ne>a[ind]){
			update(1 , 0, n-1, ind, ne);
			b[ind]=ne;
			continue;
		}
		update(1, 0, n-1, ind, 0);
		b[ind]=ne;
	}
	return 0;
}

Measured memory_bytes: 14940
#include<iostream>
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
  int a, b, c ;
  cin >> a >> b >> c  ;
  
  vector<int> od = {a,b,c} ;
  sort(od.begin(), od.end(), greater<int>());
  
  cout << (od[0]*10)+od[1]+od[2] << endl ;

  return 0 ;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {

		String str="";
		StringTokenizer stk;
		int sets;
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		double[] tama1,tama2;
		String[] jh;
		double dist1=0,dist2=0;

		try {
			str=bfr.readLine();
			sets =Integer.parseInt(str);
			tama1=new double[3];
			tama2=new double[3];
			for(int i=0; i<sets; i++) {
				str=bfr.readLine();
				jh=str.split(" ",6);
				for(int j=0; j<3; j++) {
					tama1[j]=Double.parseDouble(jh[j]);
				}
				for(int j=0; j<3; j++) {
					tama2[j]=Double.parseDouble(jh[j+3]);
				}
				dist1=Math.sqrt((tama2[1]-tama1[1])*(tama2[1]-tama1[1])+(tama2[0]-tama1[0])*(tama2[0]-tama1[0]));
				dist2=tama1[2]+tama2[2];

				if(dist1>dist2) {
					System.out.println("0");
				}
				else if(dist1<=dist2 && Math.abs(tama1[2]-tama2[2])<=dist1) {
					System.out.println("1");
				}
				else if(dist1<tama1[2]-tama2[2]) {
					System.out.println("2");
				}
				else if(dist1<tama2[2]-tama1[2]) {
					System.out.println("-2");
				}
			}
		}catch(IOException e) {

		}
	}
}


Measured memory_bytes: 24424
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int lbpow2(int a){
  for(int i = 1; i < 30; i++){
    a /= 2;
    if(a % 2 != 0) return i;
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int ans = 0;
  
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] % 2 == 0) ans += lbpow2(A[i]);
  }
  cout << ans;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <regex>
#define pb push_back
using namespace std;

int main() {
	int a, b;
	int long long summ=0,temp;
	cin >> a >> b;
	vector<int> c;
	for (int i = 0; i < a; i++)
	{
		cin >> temp;
		c.pb(temp);
	}
	sort(c.begin(), c.end());
	if (b > a) {
		cout << 0;
	}
	else {
		for (int i = 0; i < a-b; i++)
		{
			summ = summ + c[i];
		}
		cout << summ;
	}
	return 0;
}


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

#define SWAP(a, b) a = a ^ b; b = a ^ b; a = a ^ b

void swap(int * a, int * b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void print_int(int n)
{
    printf("%d\n",n);
    
}

void sort(int a[], int n)
{
    int h, i, j;

    for(h = 1; h < n / 9; h = h * 3 + 1)
        continue;

    for(; h > 0; h /= 3)
    {
        for(i = h; i < n; i++)
        {
            j = i;
            while(j >= h && a[j] < a[j-h])
            {
                swap(&a[j], &a[j-h]);
                j -= h;
            }
        }
    }
}

void print_list(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
}

void intcpy(int a[], const int b[], int count)
{
    for(int i = 0; i < count; i++)
    {
        a[i] = b[i];
    }
}

int list_sum(int a[], int n)
{
    int sum = 0;

    for(int i = 0; i < n; i++)
    {
        sum += a[i];
    }

    return sum;
}


void permutate(int s[], int count, int n)
{
    if(n == count)
        return;

    for(int i = n; i < count; i++)
    {
        swap(&s[i], &s[n]);

        if(i != n)
        {
            //intcpy(result[j++], s, count);
        }
        
        permutate(s, count, n+1);
        swap(&s[i], &s[n]);
    }
}

int ans[10];

int main(void)
{
    char a[10];
    char b[4] = {'A', 'T', 'C', 'G'};
    int j = 0;
    scanf("%s", a);
    for (int i = 0; i < strlen(a); i++)
    {
        if(a[i] == b[0] || a[i] == b[1] || a[i] == b[2] || a[i] == b[3])
        {
            ans[j]++;
        }
        else
        {
            j++;
        }
        
        
    }
    sort(ans,10);
    print_int(ans[9]);
    
    
    
    return 0;
}



Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

char S[5050];
int K;

int main()
{
	scanf("%s%d", S, &K);

	vector<string> cand;
	int N = strlen(S);
	for (int i = 0; i < N; ++i) {
		string buf;
		for (int j = 0; j < K && i + j < N; ++j) {
			buf.push_back(S[i + j]);
			cand.push_back(buf);
		}
	}

	sort(cand.begin(), cand.end());
	cand.erase(unique(cand.begin(), cand.end()), cand.end());

	printf("%s\n", cand[K - 1].c_str());

	return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int n;
struct MaximumFlow {
    struct Edge {
        int to;
        int capacity;
        Edge *rev;
        Edge(int to, int capacity) : to(to), capacity(capacity) {
        }
    };
    int n;
    int source, sink;
    vector<vector<Edge *>> graph;
    vector<bool> check;
    MaximumFlow(int n, int source, int sink) : n(n), source(source), sink(sink) {
        graph.resize(n);
        check.resize(n);
    };
    void add_edge(int u, int v, int cap) {
        Edge *ori = new Edge(v,cap);
        Edge *rev = new Edge(u,0);
        ori->rev = rev;
        rev->rev = ori;
        graph[u].push_back(ori);
        graph[v].push_back(rev);
    }
    void add_edge_from_source(int v, int cap) {
        add_edge(source, v, cap);
    }
    void add_edge_to_sink(int u, int cap) {
        add_edge(u, sink, cap);
    }
    int dfs(int x, int c) {
        if (check[x]) return 0;
        check[x] = true;
        if (x == sink) {
            return c;
        }
        for (int i=0; i<graph[x].size(); i++) {
            if (graph[x][i]->capacity > 0) {
                int nc = graph[x][i]->capacity;
                if (c != 0 && c < nc) {
                    nc = c;
                }
                int f = dfs(graph[x][i]->to, nc);
                if (f) {
                    graph[x][i]->capacity -= f;
                    graph[x][i]->rev->capacity += f;
                    return f;
                }
            }
        }
        return 0;
    }
    int flow() {
        int ans = 0;
        while (true) {
            fill(check.begin(),check.end(),false);
            int f = dfs(source, 0);
            if (f == 0) break;
            ans += f;
        }
        return ans;
    }
};
struct Point {
    int x,y;
    Point(){}
    Point(int x,int y):x(x),y(y){}
    bool operator < (const Point & other) const {
        return (x==other.x)?(y<other.y):(x<other.x);
    }
} p[110],q[110];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i=1;i<=n;i++) cin>>p[i].x>>p[i].y;
    for(int i=1;i<=n;i++) cin>>q[i].x>>q[i].y;
    MaximumFlow mf(2*n+3,0,2*n+1);
    for(int i=1;i<=n;i++) mf.add_edge(0,i,1);
    for(int i=1;i<=n;i++) mf.add_edge(n+i,2*n+1,1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(p[i].x<q[j].x && p[i].y<q[j].y) mf.add_edge(i,j+n,1);
        }
    }
    cout<<mf.flow()<<'\n';
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  int a0 = 0, a1 = 1, b0 = 0, b1 = -1;
  int c0 = a0-b0, c1 = a0-b1, c2 = a1-b0, c3 = a1-b1;
  for(int i = 0; i < s.size(); i += 2) {
    char c = s[i];
    if(c=='0')      { --a0; --a1; --b0; --b1; }
    else if(c=='1') { ++a0; ++a1; ++b0; ++b1; }
    else            { --a0; --a1; ++b0; ++b1; }
    if(a0 < 0) a0 += 2;
    if(b0 > 0) b0 -= 2;
    c0 = std::max(c0, a0-b0);
    c1 = std::max(c1, a0-b1);
    c2 = std::max(c2, a1-b0);
    c3 = std::max(c3, a1-b1);
    c = s[i+1];
    if(c=='0')      { --a0; --a1; --b0; --b1; }
    else if(c=='1') { ++a0; ++a1; ++b0; ++b1; }
    else            { --a0; --a1; ++b0; ++b1; }
    if(a1 < 0) a1 += 2;
    if(b1 > 0) b1 -= 2;
    c0 = std::max(c0, a0-b0);
    c1 = std::max(c1, a0-b1);
    c2 = std::max(c2, a1-b0);
    c3 = std::max(c3, a1-b1);
  }
  if(s.size()%2==1) {
    char c = s.back();
    if(c=='0')      { --a0; --a1; --b0; --b1; }
    else if(c=='1') { ++a0; ++a1; ++b0; ++b1; }
    else            { --a0; --a1; ++b0; ++b1; }
    if(a0 < 0) a0 += 2;
    if(b0 > 0) b0 -= 2;
    c0 = std::max(c0, a0-b0);
    c1 = std::max(c1, a0-b1);
    c2 = std::max(c2, a1-b0);
    c3 = std::max(c3, a1-b1);
  }
  fin(std::min(std::min(c0, c1), std::min(c2, c3)));
  return 0;
}



Measured memory_bytes: 4760
K, N = map(int, input().split())
AList = list(map(int, input().split()))

AList.sort()

maxIso = -1

for indx in range(N-1):
    if (AList[indx+1] - AList[indx]) > maxIso:
        maxIso =  AList[indx+1] - AList[indx]

if (AList[0] + (K - AList[N-1])) > maxIso:
    maxIso = AList[0] + (K - AList[N-1])

print(K - maxIso)

Measured memory_bytes: 25452
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

STR = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
L = [int(x) for x in STR.split(",")]

N = int(input())
print(L[N-1])


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

using namespace std;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) (x.size())
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007
#define EPS 1e-7


typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<ll> vi;



const int N  = 1e5 + 5;
class FenwickTree {
    private:
        vi ft;
    public:
        int LSOne(int x){ // least significant bit (1)
            return (x & (-x));
        }
        FenwickTree(int n) {
            ft.assign(n + 1, 0);
        }
        ll rsq(int b) {
            ll sum = 0;
            for( ; b; b -= LSOne(b)) sum += ft[b];
            return sum;
        }
        ll rsq(int a, int b) {
            return rsq(b) - (a == 1 ? 0 : rsq(  a - 1));
        }
        // updates value of the k-th element by v (v can be +ve/inc or -ve/dec)
        //like freq[x]++ || freq[x]--
        void update(int k, ll v) { // note: n = ft.size() - 1
            for (; k < (int)ft.size(); k += LSOne(k)) ft[k] += v;
        }
};
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("test cases\\in.txt", "r", stdin);
    //freopen("test cases\\in.txt", "w", stdout);

    ll f[N] = {};
    int n; cin >> n;
    ll a[n];
    for(auto &i : a) cin >> i, f[i]++;
    FenwickTree ft(N);
    for(auto &i: a) ft.update(i, i);
    int q; cin>>q;
    while(q--){
        ll b, c; cin >> b >> c;
        if(f[b]){
            ft.update(b, -f[b] * b);
            ft.update(c, f[b] * c);
            f[c] += f[b];
            f[b] = 0;
        }
        cout<<ft.rsq(1, N)<<endl;//count of number from l to r
    }
    return 0;
}


Measured memory_bytes: 5568
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	long long int n,m,j=1,a,b,resp=1000000000;
	
	cin >> n >> m;

	vector<long long int>v(20000000 ,  1000000000000);
	vector<pair<long long int, long long int>>l;
	v[0]=0;

	for(int i=0;i<m;i++){
		cin >> a >> b;

		j=0;
		while(j+a<n+a+300){
			v[j+a] = min(v[j+a], b + v[j]);
			j++;

		}

	}

	sort(all(l));

	resp = v[n];

	for(int i=n;i<v.size();i++){
		resp = min(resp, v[i]);
	}

	cout << resp << endl;
	return 0;
}

Measured memory_bytes: 156544
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const double N = 3.305785;

int main(void){
    for(double a, b; cin >> a >> b; printf("%.4f\n", a * b / N));

    return 0;
}

Measured memory_bytes: 1240