akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            string input = this.cin.GetNext();

            input.Reverse().ToList().ForEach(x => Console.Write(x));

            Console.WriteLine();
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        public string Line { get; set; }
        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public void GetLine()
        {
            this._i = 0;
            do
            {
                this.Line = Console.ReadLine();
            } while (this.Line == "");

            if (this.Line != null)
                this._s = this.Line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);
        }

        public string GetNext()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            this.GetLine();

            return this._s[this._i++];
        }

        public int GetNextToInt()
        {
            return int.Parse(this.GetNext());
        }

        public long GetNextToLong()
        {
            return long.Parse(this.GetNext());
        }

        public double GetNextToDouble()
        {
            return double.Parse(this.GetNext());
        }
    }
}

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


int main(){
  
  string X, Y;
  cin >> X >> Y;
  
  if(X > Y){
    cout << '>' << endl;
  }
  else if(X < Y){
    cout << '<' << endl;
  }
  else{
    cout << '=' << endl;
  }
  
}

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

vector<int> A;
int N;
ll K;
vector<ll> depth;

int dfs(int v, ll k, bool resolved=false){
    if(k == K){
        return v + 1;
    }
    if(depth[v] != -1){
        if(!resolved){
            ll d = (k - 1) - depth[v] + 1;
            return dfs(v, k + (K - k) / d * d, true);
        }
    }else{
        depth[v] = k;
    }
    return dfs(A[v], k + 1, resolved);
}

int main() {
    cin >> N >> K;
    A.resize(N);
    for(auto& e : A){
        cin >> e;
        e--;
    }
    depth.assign(N, -1);
    cout << dfs(0, 0) << endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9


int main(){
  int X;
  cin >> X;
  vector<int> sosu(min((ll)X*X+1, (ll)1e5+7), 0);
  FOR(i, 2, X+1){
    if(sosu[i] != 0){
      continue;
    }
    for(ll j = 2; i*j < (ll)min((ll)X*X+1, (ll)1e5+7); j++){
      sosu[i*j] = 1;
    }
  }
  ll i = X;
  while(1){
    if(sosu[i] == 0){
      cout << i << endl;
      return 0;
    }
    i++;
  }
  return 0;
}


Measured memory_bytes: 640
k = int(input())
a, b = map(int, input().split())
if (k <= (b-a)):
    print("OK")
else:
    count = 0
    for i in range(a, b+1):
        if i % k == 0:
            print("OK")
            count = 1
            break;
    if count == 0:
        print("NG")

Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;

bool comp(const int& a, const int& b) {
	return a > b;
}

int main()
{
	int K, N;
	cin >> N >> K;
	vector<int>vec(N, 0);
	for (int i = 0; i < N;i++) {
		int t;
		cin >> t;
		for (int j = 0; j < t; j++) {
			int tt;
			cin >> tt;
			vec[tt-1]++;
		}
	}
	size_t n_count = count(vec.begin(), vec.end(), 0);
	cout << n_count << endl;
}

Measured memory_bytes: 3168
#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
struct Dice{
    int s[6];
    
    void roll(char x){
        int t;
        if(x=='S'){
            t=s[0];
            s[0]=s[4];
            s[4]=s[5];
            s[5]=s[1];
            s[1]=t;
        }
        if(x=='E'){
            t=s[0];
            s[0]=s[3];
            s[3]=s[5];
            s[5]=s[2];
            s[2]=t;
        }
        if(x=='W'){
            t=s[0];
            s[0]=s[2];
            s[2]=s[5];
            s[5]=s[3];
            s[3]=t;
        }
        if(x=='N'){
            t=s[0];
            s[0]=s[1];
            s[1]=s[5];
            s[5]=s[4];
            s[4]=t;
        }
    }
    int top(){
        return s[0];
    }
};
int main(){
    Dice d;
    for(int i=0;i<6;i++) cin >> d.s[i];
    string s;cin >> s;
    for(int i=0;i<s.size();i++) d.roll(s[i]);
    cout << d.top() << endl;
    return 0;
}





Measured memory_bytes: 3196
void main() {
    int n = readln.chomp.to!int;
    string[] s = readln.split;
    s.sort!"a < b";
    auto g = s.group.array;
    writeln(g.length == 3 ? "Three" : "Four");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main(int argc, char const *argv[])
{
  int i = 1;

  while(true)
  {
    int x;
    cin >> x;
    if(x == 0) break;
    cout << "Case " << i << ": " << x << endl;
    i++;
  }

  return 0;
}

Measured memory_bytes: 3028
package main 

import (
  "fmt"
)

func main() {
  var n, a int
  fmt.Scan(&n, &a)

  c := make([]int ,n)
  t := make([]int ,n)
  for i := 0; i < n; i++ {
    var x, y int
    fmt.Scan(&x, &y)
    c[i] = x
    t[i] = y
  }  
  
  var ans, tmp int
  ans = 10000
  
  for i := 0; i < n; i++ {
    if t[i] <= a {
      tmp = c[i]   
      if ans > tmp {
        ans = tmp
      }
    }
  }
  
  if ans < 10000 {
    fmt.Println(ans)
  } else {
    fmt.Println("TLE")
  }
  
}


Measured memory_bytes: 512
#include <stdio.h>
#include <limits.h>
#define MAX 100

enum status {
	WHITE = 0,
	GRAY,
	BLACK,
};
int n;
int M[MAX][MAX];

void dijkstra() {
	int minv, i, v, u;
	int d[MAX], color[MAX];
	
	for (i = 0; i < n ; i++) {
		d[i] = INT_MAX;
		color[i] = WHITE;
	}

	d[0] = 0;
	color[0] = GRAY;
	while (1) {
		minv = INT_MAX;
		u = -1;
		for (i = 0; i < n; i++) {
			if ( minv > d[i] && color[i] != BLACK) {
				u = i;
				minv = d[i];
			}
		}

		if ( u == -1) break;
		color[u] = BLACK;
		for ( v = 0; v < n; v++) {
			if ( color[v] != BLACK && M[u][v] != INT_MAX ) {
				if ( d[v] > d[u] + M[u][v] ) {
					d[v] = d[u] + M[u][v];
					color[v] = GRAY;
				}
			}
		}					   
	}

	for (i = 0; i < n; ++i) {
		printf("%d %d\n", i, d[i]);
	}
}

int main() {

	int i, j, u, k ,v, c;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		for (j = 0; j < n; ++j) {
			M[i][j] = INT_MAX;
		}
	}

	for (i = 0; i < n; ++i) {
		scanf("%d ", &u);
		scanf("%d ", &k);
		for (j = 0; j < k; ++j) {
			scanf("%d", &v);
			scanf("%d", &c);
			M[u][v] = c;
		}
	}

	dijkstra();
	
	return 0;
}

Measured memory_bytes: 636
L = str(input())

n = len(L)
MOD = 10**9+7
 
dp = [[0]*2 for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
  for k in range(2):
    nd = int(L[i])
    for d in range(2):
      ni = i+1
      nk = k
      if k == 0:
        if d > nd:
          continue
        elif d < nd:
          nk = 1
        else:
          pass
      if d == 1:
        dp[ni][nk] += (dp[i][k]*2)%MOD
      else:
        dp[ni][nk] += (dp[i][k])%MOD
        
#print(dp)
print(sum(dp[-1])%MOD)

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

#define rep(i,N)  for(int i=0; i<N; i++)
#define ol(a) cout << a << endl;
#define PI 3.14159265359
using namespace std;

int main(){
  //int64_t n,m;  cin >> n >> m;
  char s; cin >> s;
  char t = (char)toupper(s);
  
  //(char)toupper(s);
  if(s == t){
    ol('A')
  }
  else{
    ol('a')
  }
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		System.out.println((a >= 3200) ? s : "red");
	}
	
}

Measured memory_bytes: 23124
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"

using namespace std;
using ll = long long int;


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

	ll d, x;
	cin >> d >> x;
	vector<string> a;
	vector<ll> p;
	for (int i = 0; i < x; ++i) {
		string s;
		ll q;
		cin >> s >> q;
		a.push_back(s);
		p.push_back(q);
	}
	ll y;
	cin >> y;
	for (int i = 0; i < y; ++i) {
		string s;
		ll q;
		cin >> s >> q;
		a.push_back(s);
		p.push_back(q);
	}

	ll n = x + y, ret = 0;
	for (ll i = 0; i < (1LL << n); ++i) {
		ll cnt = 0, score = 0;
		for (ll j = 0; j < n; ++j) {
			if (i & 1LL << j) {
				if (j < x) {
					if (a[j] == "D") {
						cnt++;
						score += p[j];
					}
					else {
						cnt = 1000;
					}
				}
				else {
					if (a[j] == "DD") {
						cnt += 2;
						score += p[j];
					}
					else {
						cnt = 1000;
					}
				}
			}

			if (cnt <= d) {
				ret = max(ret, score);
			}
		}
	}

	cout << ret << endl;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int n;
int a[212345], ans[212345];

int main() {
	cin >> n;
	REP(i, n) scanf("%d", a + i);
	
	if (n % 2 == 0) {
		int p = 0;
		for (int i = n; i > 0; i -= 2) ans[p++] = a[i - 1];
		for (int i = 1; i < n; i += 2) ans[p++] = a[i - 1];
	}
	else {
		int p = 0;
		for (int i = n; i > 0; i -= 2) ans[p++] = a[i - 1];
		for (int i = 2; i < n; i += 2) ans[p++] = a[i - 1];
	}
	
	REP(i, n) printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');
	
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
const int N=100010,Mod=998244353;
const double pi=acos(-1.0);
typedef long long int ll;
typedef pair<int,int> pii;
int n;
int main()
{
  cin>>n;
  cout<<(3*n*n)<<endl;
  return 0;
}


Measured memory_bytes: 256
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int gcd(int a,int b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=a*c;
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
import java.util.Arrays;
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 q = sc.nextInt();
        long[] s = new long[a];
        long[] t = new long[b];

        for(int i=0; i<a; i++) {
            s[i] = sc.nextLong();
        }
        for(int i=0; i<b; i++) {
            t[i] = sc.nextLong();
        }

        for(int i=0; i<q; i++) {
            long p = sc.nextLong();
            int si = - Arrays.binarySearch(s, p) - 1;
            int ti = - Arrays.binarySearch(t, p) - 1;
            long min = Long.MAX_VALUE;

            if(si>0 && ti>0) {
                min = Math.min(min, Math.max(p-s[si-1], p-t[ti-1]));
            }
            if(si>0 && ti<b) {
                min = Math.min(min, p-s[si-1] + t[ti]-p + Math.min(p-s[si-1], t[ti]-p));
            }
            if(si<a && ti<b) {
                min = Math.min(min, Math.max(s[si]-p, t[ti]-p));
            }
            if(si<a && ti>0) {
                min = Math.min(min, s[si]-p + p-t[ti-1]  + Math.min(s[si]-p, p-t[ti-1]));
            }
            System.out.println(min);
        }

    }

}


Measured memory_bytes: 98880
/*
[agc039] B - Graph Partition
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 200;
const int INF = 1e9;

int N;
string S[MAX_N];
int color[MAX_N];
int dist[MAX_N][MAX_N];

bool is_bipartite(int v, int c) {
    bool ret = true;
    if (color[v] != 0) {
        return (color[v] == c);
    }
    color[v] = c;
    for (int to = 0; to < N; to++) {
        if (S[v][to] != '1') {
            continue;
        }
        ret = ret && is_bipartite(to, -color[v]);
    }
    return ret;
}

void warshall_floyd() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) {
                dist[i][j] = 0;
            } else if (S[i][j] == '1') {
                dist[i][j] = 1;
            } else {
                dist[i][j] = INF;
            }
        }
    }

    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

ll solve() {
    if (!is_bipartite(0, 1)) {
        return -1;
    }

    warshall_floyd();

    int dia = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dia = max(dia, dist[i][j]);
        }
    }

    return dia + 1;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 512
h=int(input())
w=int(input())
n=int(input())
mass = 0
if h <= w:
  for i in range(0, h+1):
    mass = i*w
    if mass >= n:
      print(i)
      break
else:
  for i in range(0, w+1):
    mass = i*h
    if mass >= n:
      print(i)
      break


Measured memory_bytes: 2940
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*n 
for i in range(1,n):
    if i==1:
        dp[i]=abs(a[i]-a[i-1]) 
    else:
        dp[i]=dp[i-1]+abs(a[i]-a[i-1])
        for j in range(2,k+1):
            if j<=i:
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]))
            else:
                break
print(dp[n-1])        

Measured memory_bytes: 52448
a, b, c, d = map(int, list(input()))
for i in (-1,1):
  for j in (-1,1):
    for k in (-1,1):
      if a + i * b + j * c + k * d == 7:
        op1 = '+' * ((1+i)//2) + '-' * ((1-i)//2)
        op2 = '+' * ((1+j)//2) + '-' * ((1-j)//2)
        op3 = '+' * ((1+k)//2) + '-' * ((1-k)//2)
        print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
        exit()

Measured memory_bytes: 3064
import heapq
n = int(input())
ans = 0
cost = []
for i in range(n):
    L = list(map(int,input().split()))
    cost.append(L)
used = [False]*n
used[0] = True #島0から探索を始める。
edge = []
for i in range(n):
    T = []
    edge.append(T)
for i in range(n):
    for j in range(n):
        if cost[i][j] != -1:
            edge[i].append([cost[i][j],j])
P = edge[0]
P.sort()
while len(P) != 0:
    cur = heapq.heappop(P)
    d = cur[0]
    next = cur[1]
    if used[next] == True:
        continue
    used[next] = True
    ans += d
    for e in edge[next]:
        heapq.heappush(P,[e[0],e[1]])
print(ans)


Measured memory_bytes: 7212
#include <iostream>
using namespace std;
int main() {
    int a, b;
    char op;
    while(cin >> a >> op >> b, op != '?'){
        if(op == '+'){
            cout << a+b << endl;
        }
        else if(op == '-'){
            cout << a-b << endl;
        }
        else if(op == '*'){
            cout << a*b << endl;
        }
        else{
            cout << a/b << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
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(){
    ll n;cin>>n;
    vl d(3);rep(i,3)cin>>d[i];
    vector<l_l> q;
    rep(i,n){
        string s;cin>>s;
        int a,b;
        if(s=="AB")a=0,b=1;
        if(s=="AC")a=0,b=2;
        if(s=="BC")a=1,b=2;
        q.pb({a,b});
    }
    string ans;
    auto add=[&](int a,int b){
        d[a]++;
        d[b]--;
        ans+='A'+a;
    };
    q.pb({0,1});
    rep(i,n){
        int a=q[i].fi,b=q[i].se;
        if(!d[a]&&!d[b]){
            cout<<"No"<<endl;
            return 0;
        }
        else if(!d[a]){
            add(a,b);
        }
        else if(!d[b]){
            add(b,a);
        }
        else{
            int na=q[i+1].fi;
            int nb=q[i+1].se;
            if(a==na||a==nb){
                add(a,b);
            }
            else{
                add(b,a);
            }
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb push_back
const int N=1e5+5;
// const ll M = 998244353;
const ll M=1e9+7;
const ll inf=1e18;

double dp[3000];

int main()
{
	var(n);
	memset(dp,0,sizeof(dp));
	rep(i,1,n+1)
	{
		double p;
		scanf("%lf",&p);
		if(i==1)
		{
			dp[i] = p;
			dp[0] = 1-p;
		}
		else
		{
			for(int j=i;j>=0;j--)
			{
				dp[j]*=1-p;
				dp[j]+=dp[j-1]*p;
			}	
		}
		// for(int j=0;j<=i;j++)
		// 	printf("%f ",dp[j]);
		// printf("\n");
		
	}
	double ans = 0;
	for(int i=0;i<=n;i++)
	{
		int tails = n-i;
		if(tails<i)
			ans+=dp[i];
		// printf("%f ",dp[i]);
	}
	printf("%.10lf\n",ans);
}

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

int main() {
  string S;
  cin >> S;
  string ans = "NO";
  for (int i = 0; i <= S.size(); i++) {
    for (int j = 0; j <= S.size() - i; j++) {
      string T = S;
      T.erase(T.begin() + j, T.begin() + j + i);
      if (T == "keyence") ans = "YES";
    }
  }
  cout << ans << endl;
}

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

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

    int answer = 0;
    for (int i1 = 0; i1 <= 9; i1++)
    {
        for (int i2 = 0; i2 <= 9; i2++)
        {
            for (int i3 = 0; i3 <= 9; i3++)
            {
                int i1index = s.find(to_string(i1));
                if (i1index == string::npos)
                {
                    continue;
                }
                int i3index = s.rfind(to_string(i3));
                if (i3index == string::npos)
                {
                    continue;
                }
                if (i1index + 2 <= i3index)
                {
                    int i2index = s.substr(i1index + 1, (i3index - i1index) - 1).find(to_string(i2));
                    if (i2index != string::npos)
                    {
                        answer++;
                    }
                }
            }
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n,h; cin >> n >> h;
  int mxa = 0;
  int a[n],b[n];
  REP(i,n) {
    cin >> a[i] >> b[i];
    chmax(mxa, a[i]);
  }
  vector<int> arrb;
  REP(i,n) {
    if (mxa < b[i]) {
      arrb.push_back(b[i]);
    }
  }
  sort(ALL(arrb));

  int ans = 0;
  while(h > 0) {
    if (!arrb.empty()) {
      int v = arrb.back();
      arrb.pop_back();
      h-=v;
      ans++;
    } else {
      ans += h/mxa;
      if (h%mxa) ans++;
      h = 0;
    }
  }

  COUT(ans);
  return 0;
}

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

using namespace std;

#define INF (1ll << 62)
#define pb push_back
#define ii pair<int,int>
#define OK cerr <<"OK"<< endl
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define endl '\n'
#define double long double

int n;
vector<double> arr;
bool vis[3002][3002];

double dp[3002][3002];
double f(int id, int head, int tail) {

	if(id == n)
		return (head > tail);

	double &ret = dp[head][tail];
	if(vis[head][tail]) 
		return ret;

	vis[head][tail] = true;
	return dp[head][tail] = arr[id]*f(id + 1, head + 1, tail) + (1 - arr[id])*f(id + 1, head, tail + 1);
}

signed main () {
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> n;

  arr.resize(n);
  for(double &x: arr)
  	cin >> x;

  cout << fixed << setprecision(10) << f(0, 0, 0) << endl;
}

Measured memory_bytes: 150144
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
#define int ll
using namespace std;
 
const ll MOD = 1e9+7;
const ll INF = 1e12;
const ll LOG = 29;
#define PI 3.141592653589793238 
 
 
long long binpow(long long a, long long b) {
    a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD;
        a = (a * a)%MOD;
 
        
        b >>= 1;
    }
    res%=MOD;
    return res;
}
const ll N =(2e5+5);
ll nxt[N];
ll a[N];
void solve(){
	ll n,k;
	cin>>n;
	cin>>k;
	nxt[0]=1;
	for(int i =1;i<=n;i++){
		cin>>a[i];
		nxt[i]=a[i];
	}
	ll sz = 0;
	ll cur = 1;
	set<ll> se;
	vll gg;
	ll pos = -1;
	while(true){
		if(se.find(cur) != se.end()) {pos = cur;break;}
		sz++;
		se.insert(cur);
		gg.pb(cur);
		cur = nxt[cur];
	}
 
	ll xd = 0;
	for(int i =0;i<(ll)gg.size();i++){
		if(gg[i]==pos)break;
		else xd++;
	}
	if(k <= xd){
		cout<<gg[k]<<endl;
		return;
	}
	k-=xd;
	vll gg2;
	for(int i = xd;i<(ll)gg.size();i++){
		gg2.pb(gg[i]);
	}
	ll sz2 = 1ll*gg2.size();
	k%=sz2;
	cout<<gg2[k]<<endl;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     
    ll t=1;
 //   cin>>t;
    while(t--){
        solve();
    }    
}

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

using namespace std;
#define ll long long
const int N  =200005;

int n, a[11][11];
ll ans;

int f (int x){
while (x/10) x/=10;
return x;
}

int main()
{
    cin >> n;
    for (int i=1; i<=n; i++){
        int first = f(i), last = i%10;
        a[first][last]++;
    }

    for (int i=1; i<=n; i++){
        int first = f(i), last = i%10;
        ans+= a[last][first];
    }
        cout << ans;
    return 0;
}


Measured memory_bytes: 3632
import sys
import collections
s=sys.stdin.readlines()
n,q=map(int,s[0].split())
d=collections.deque(e.split()for e in s[1:])
t=0
while d:
 k,v=d.popleft()
 v=int(v)
 if v>q:
  v-=q
  t+=q
  d.append([k,v])
 else:
  t+=v
  print(k,t)


Measured memory_bytes: 20980
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 0;
	for(int i = 0; i < 1000; ++i) {
		string tmp;
		
		tmp += (char)((i / 100) + '0');
		tmp += (char)(((i / 10) % 10) + '0');
		tmp += (char)((i % 10) + '0');
		
		int k = 0;
		for(int j = 0; j < n; ++j) {
			if( s[j] == tmp[k] ) k++;
			if( k == 3 ) break;
		}
		
		if( k == 3 ) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3660
import sys
import numpy as np
import itertools
from collections import deque

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

# input
S = list(input())

if S[2] == S[3] and S[4] == S[5]:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)


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

int main(){
    string a,b;
    int c=0;
    cin >>a>>b;
    for(int i=0;i<a.size();i++){
        if(a.at(i)!=b.at(i)){
            c=1;
            break;
        }
    }
    if(c==0){
        cout << "Yes"<< endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 3632
require 'prime'

Q_MAX = 10**5

pm = Array.new(Q_MAX + 2, false)
Prime.each(Q_MAX+1) do |n|
  pm[n] = true
end

like2017 = Array.new(Q_MAX + 2, 0)

(Q_MAX+1).times do |i|
  if i.odd? && pm[i] && pm[(i+1)/2]
    like2017[i] = 1
  end
end

(Q_MAX + 1).times do |i|
  like2017[i+1] += like2017[i]
end

q = gets.chomp.to_i
q.times do 
  l, r = gets.chomp.split(" ").map(&:to_i)
  puts like2017[r] - like2017[l-1]
end


Measured memory_bytes: 5144
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <string.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> edgeTo;
typedef pair<int, ll> distTo;

#define maxN 500000
#define INF 1e18

vector<edgeTo> g[maxN];
int n, m, s;
ll d[maxN]; //d[u]: do dai dd ngan nhat tu s den u

void ReadGraph()
{
    int u, v, c;
    cin>>n>>m>>s;
    for (int i = 0; i < m; ++i)
    {
        cin>>u>>v>>c;
        g[u].push_back(edgeTo(v, c));
    }
}

void Init()
{
    for (int u = 0; u < n; ++u)
        d[u] = INF;
    d[s] = 0;
}

void BFS()
{
    Init();
    queue<distTo> q;
    q.push(distTo(s, d[s]));
    while (!q.empty())
    {
        int u = (int)q.front().first; ll du = (ll)q.front().second;
        q.pop();

        if (du != d[u]) continue;

        for (int i = 0; i < g[u].size(); ++i)
        {
            int v = (int)g[u][i].first, c = (int)g[u][i].second;
            if (d[v] > d[u] + c)
            {
                d[v] = d[u] + c;
                q.push(distTo(v, d[v]));
            }
        }
    }
}

void WriteANS()
{
    for (int u = 0; u < n; ++u)
    {
        if (d[u] == INF)
            cout<<"INF\n";
        else cout<<d[u]<<"\n";
    }
}

int main()
{
    ReadGraph();
    BFS();
    WriteANS();
    return 0;
}

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

int main()
{
    int a,b,c,x,y,z;
    cin >> x >> y >> z;
    a=z;
    b=x;
    c=y;
    cout << a <<" "<< b <<" "<< c << endl;

    return 0 ;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}

Measured memory_bytes: 3600
C = input()
alf = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(len(alf)):
    if alf[i] == C:
        print(alf[i+1])


Measured memory_bytes: 2940
#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 all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    vi a, b;
    cin >> n;
    rep(i, n)
    {
        int t;
        cin >> t;
        a.emplace_back(t);
        cin >> t;
        b.emplace_back(t);
    }
    sort(all(a));
    sort(all(b));
    int ans = 0;
    if (n % 2 == 0)
    {
        ans = (b[n / 2 - 1] + b[n / 2]) - (a[n / 2 - 1] + a[n / 2]) + 1;
    }
    else
    {
        ans = b[n / 2] - a[n / 2] + 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6592
#include <bits/stdc++.h>
#include <cstdlib>  //abs()で絶対値を取得する（整数）
#include <cmath>    //abs()かfabs()で絶対値を取得する（少数）
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int h, a;
    cin >> h >> a;
    int b = h % a;
    int c = h / a;
    if (b == 0){
        cout << c << endl;
    }
    if (b != 0){
        int ans = c+1;
        cout << ans << endl;
    }
}

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

int main() {
  int N , a;
  cin>>N;
  a=0;
  for(int i=0 ; i<N ; i++){
    int l , r ;
    cin>> l >>r ;
    a=a+r-l+1;
  }
 cout<< a << endl;
}
  

Measured memory_bytes: 3560
MOD = 998244353
n, a, b, k = map(int, input().split())
memo = [0]*(n//2+1)


def com(n, r):
    if n < r or r < 0:
        return 0
    if n-r < r:
        r = n-r
    if r == 0:
        memo[r] = 1
        return memo[r]
    if memo[r] != 0:
        return memo[r]
    X = Y = 1
    for i in range(1, r+1):
        Y = Y*i % MOD
        X = X*(n-i+1) % MOD
        memo[i] = X*pow(Y, MOD-2, MOD)
    return memo[r]


com(n, n//2)
ans = 0
for x in range(n+1):
    y, r = divmod(k-a*x, b)
    if y < 0:
        continue
    if r == 0:
        ans += com(n, x)*com(n, y)
        ans %= MOD
print(ans % MOD)


Measured memory_bytes: 43868
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1e18


void solve()
{
  int a,ans;
  for(int i=1;i<=5;i++)
  {
      cin>>a;
      if(a==0) ans=i;
  }
  cout<<ans<<endl;
}

int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //sieve();
    //int cnt=1;
    //int t; scanf("%d",&t); while(t--) solve();
    solve();
}


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

string s;
int ans;

int main(){
	cin >> s;
	for(int i=0; i<s.size(); ++i){
		if(i % 2 == 0 && s[i] == 'p') --ans;
		if(i % 2 == 1 && s[i] == 'g') ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define N 1000000007

int main()
{
  long long int ans = 1;
  int n;
  cin >> n;
  for(int i = 1 ;i< n+1;i++){
    ans = (ans * i )%N;
  }
  cout << ans <<endl;

  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 100000;
vector<int> g[MAX_N];
int nim[MAX_N];

int f(int v, int prev) {
  int x = 0;
  for (int u : g[v]) if (u != prev) {
    x ^= f(u, v);
  }
  x += 1;
  // cout << v << " " << x << endl;
  return nim[v] = x;
}

int main2() {
  int N = nextInt();
  REP(i, N) g[i].clear();
  REP(_, N-1) {
    int x = nextInt() - 1;
    int y = nextInt() - 1;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int nim = f(0, -1) - 1;
  if (nim == 0) cout << "Bob" << endl; 
  else cout << "Alice" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 12288
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int ind = -1;
  rep (i, n) {
    int tmp;
    scanf("%d", &tmp);
    if (tmp == 1) {
      ind = i;
    }
  }
  int ans = 0;
  int a = ind;
  int b = n - 1 - ind;
  if (a > b) {
    swap(a, b);
  }
  ans += (a / (k - 1));
  b += (a % (k - 1));
  ans += ((b + k - 2) / (k - 1));
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long int
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0){
    	return a;
	} 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
int dsu[1000001],s[100005];
pair<int,int>pz[100001],po[100001];
void init(int n,int m){
	for(int i=1;i<=n;i++){
		dsu[i]=i;
		s[i]=1;
	}
}
int root(int x){
	while(dsu[x]!=x){
		x = dsu[x];
	}
	return x;
}
void uni(int x,int y){
	int p = root(x);
	int q = root(y);
	if(p==q){
		return;
	}
	else{
		if(s[p]<s[q]){
			s[q]+=s[p];
			dsu[p] = q;
		}
		else{
			s[p]+=s[q];
			dsu[q] = p;
		}
	}
}
int power(int x, unsigned int y)  
{  
    int res = 1;
    x = x ; 
    if (x == 0) return 0;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x);   
        y = y>>1;  
        x = (x*x);  
    }  
    return res;  
}
bool visited[100001]={false};

//void dfs(int x){
//	visited[x]=true;
//	//ans.push_back(x);
//	//c[x]=1;
//	for(auto &child:graph[x]){
//		if(!visited[child]){
//			dfs(child);	
//			//c[x]+=c[child];
//		}
//	}
//}
signed main(){
	FAST
	int n,w;
	cin>>n>>w;
	int arr[n][2];
	for(int i=0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1];
	}
	int dp[n][w+1];
	for(int i=0;i<n;i++){
		for(int j=0;j<=w;j++){
			if(i==0){
				if(j<arr[i][0])dp[i][j]=0;
				else{
					dp[i][j]=arr[i][1];
				}
			}
			else{
				if(j<arr[i][0]){
					dp[i][j]=dp[i-1][j];
				}
				else{
					dp[i][j]=max(arr[i][1]+dp[i-1][j-arr[i][0]],dp[i-1][j]);
				}
			}
			//cout<<dp[i][j]<<"  ";
		}
		//cout<<endl;
	}
	cout<<dp[n-1][w];
}

Measured memory_bytes: 78336
ABK = [int(i) for i in input().split()]
answer = 0
count = 0
num_list = [i for i in range(1,101)]
index = 0
while(count != ABK[2]):
    index -= 1
    if(ABK[0] % num_list[index] == 0 and ABK[1] % num_list[index] == 0):
        count += 1

print(num_list[index])

Measured memory_bytes: 3064
function main(input) {
   	const args = input.split('\n');
   	const N = parseInt(args[0],10),
		cards = args[1].split(' ').map(n => parseInt(n,10));

   var aSum = 0;
       bSum = 0;
   
   cards.sort((a,b) => (a < b ? 1 : -1)).forEach((n,i) => {
	   (i % 2 === 0)? aSum += n: bSum += n;
   });
	console.log(aSum - bSum);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

																											


Measured memory_bytes: 7628
#include<iostream>

#include <math.h>
using namespace std;

typedef  long long ll;

int main(){
  	

  	int a,b;
  	cin >> a>>b;
	if(a>b+1)cout<<2*a-1 <<endl;
	else if(b>a+1)cout<<2*b-1 <<endl;
 	else cout<<a+b <<endl;
}

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

if k-a >= 0:
  k = k-a
  a = 0
  if b-k >= 0:
    b = b-k
  else:
    b = 0
else:
  a = a-k
    
print(a, end="")
print(" ", end="")
print(b)

Measured memory_bytes: 2940
import java.util.*;

// ABC 80-D
// https://beta.atcoder.jp/contests/abc080/tasks/abc080_d

public class Main {

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

		int N = in.nextInt();
		
		int[][] stores = new int[N][11];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 10; j++) {
				stores[i][j] = in.nextInt();
			}
		}
		
		int[][] points = new int[N][11];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 11; j++) {
				points[i][j] = in.nextInt();
			}
		}
		
		long answer = Long.MIN_VALUE;
		
		// Try all patterns
		for (int i = 1; i < (1 << 10); i++) {
			long n = 0;
			// Go through stores
			for (int j = 0; j < N; j++) {
				int numOverlappings = 0;
				// Check if there is overlapping
				for (int k = 0; k <= 9; k++) {
					if ((i & (1 << k)) > 0 && stores[j][k] == 1) {
						numOverlappings++;
					}
				}
				n += points[j][numOverlappings];
			}
			answer = Math.max(answer, n);
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 26312
import itertools

N = int(input())
p_i = tuple(map(int, input().split()))
q_i = tuple(map(int, input().split()))

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

for v in itertools.permutations(N_lists, N):
    order.append(v)

print(abs(order.index(p_i) - order.index(q_i)))


Measured memory_bytes: 8052
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef unsigned long long ull;
#define PI 3.14159265358979323846  
#define MOD 1000000007;
typedef pair<int, int> P;


int main() {
	ull x,y;
	int ans=0;
	cin >> x >> y;
	while (x <= y) {
		x *= 2;
		ans++;
		//cout << "ok";
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
//Uneven Numbers
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<(x)<<endl
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){//階乗の計算
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}
ll gcd(ll a ,ll b){return b ? gcd(b,a%b) : a;}//最大公約数
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}//最小公倍数
int num_digit(ll a){//桁数を求める
    int num_dig = 0;
    while(a!=0){
        a /= 10;
        ++num_dig;
    }
    return num_dig;
}
vector<ll> digit(ll a){//桁の数字を求める
    vector<ll> dig(num_digit(a));
    for(int i=num_digit(a)-1; i>=0; --i){
        dig[i] = a%10;
        a /= 10; 
    }
    return dig;
}

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

    vector<int> a = {9,0,900,0,90000};

    int keta = 0;
    int n_kari = n;
    while(n_kari!=0){
        n_kari /= 10;
        ++keta;
    }

    int sum=0;
    if(keta%2==0){
        rep(i,keta-1) sum += a[i];
    }
    if(keta%2!=0){
        sum += n - pow(10,keta-1) + 1;
        rep(i,keta-1) sum += a[i];
    }
    cout(sum);
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    list_D = [input() for i in range(N)]

    answer = "No"
    counter = 0
    for D in list_D:
        D1, D2 = D.split()

        if D1 == D2:
            counter = counter + 1

            if counter == 3:
                answer = "Yes"
                break

        else:
            counter = 0
    
    print(answer)

if __name__ == "__main__":
    main()

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

using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)

template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }


///////////////

#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])

template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;

int sgn(ld a, ld b = 0) {
	if (a > b + EPS) return 1;
	if (a < b - EPS) return -1;
	return 0;
}

ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }

int ccw(P a, P b, P c) {
	b -= a;
	c -= a;
	if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise or counter clockwise
	if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
	if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
	return 0;                                      // a--c--b
}

struct L : public vector<P> {
    L(P a, P b) { push_back(a); push_back(b); }
};

bool iSS(CR<L> s, CR<L> t, bool strict = false) {
	return (strict ? 0 : 1) > ccw(s[0], s[1], t[0])*ccw(s[0], s[1], t[1])
		&& (strict ? 0 : 1) > ccw(t[0], t[1], s[0])*ccw(t[0], t[1], s[1]);
}


//////////////

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	ll n; cin >> n;
	while (n--) {
		ld x0, y0, x1, y1, x2, y2, x3, y3;
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		P p0(x0, y0), p1(x1, y1), p2(x2, y2), p3(x3, y3);
		cout << iSS(L{ p0, p1 }, L{ p2, p3 }) << endl;
	}

	return 0;
}

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;

  if (S[A] != '-') {
    cout << "No" << endl;
    return 0;
  }

  int cnt = 0;
  for (int i = 0; i < (int)S.size(); ++i) {
    if (S[i] == '-') cnt++;
  }

  cout << ((cnt == 1) ? "Yes" : "No") << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        cout << *t++;
        if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int digitsum(int x) {
    int ret = 0;
    while(x) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

ll power(ll x, int n) {
    if(n == 0)
        return 1;
    else if(n % 2)
        return x * power(x, (n - 1));
    else
        return power(x * x, n / 2);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, n, m, t = 0;
    ll x;
    cin >> a >> n >> m;
    rep(i, 1, 73) {
        x = power(a + i, n);
        if(digitsum(x) == i && x < m) t++;
    }
    cout << t << endl;
}



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

using namespace std;

typedef long long int ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define nl '\n'
#define debug1(x)       cout<<" #x "<< ": " << x << endl
#define debug2(x, y)    cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define debug3(x, y, z) cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z << endl

string to_upper(string &in)
{
    for (int i = 0; i < in.length(); i++)
          if('A'<=in[i] and 'Z'>=in[i]){
              continue;
          }
          else{
              in[i] = in[i] - 'a' + 'A';
          }
          return in;
}

void solve(){
  int r;
  cin>>r;
  cout << setprecision(15) <<2*3.141592653589793238*r<< '\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3832