akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int L[500000],R[500000];
int cnt;

void merge(int A[],int n,int left,int mid,int right){
    int n1,n2;
    int i,j,k;
    n1=mid-left;
    n2=right-mid;
    for(i=0;i<n1;i++){
        L[i]=A[left+i];
    }
    for(i=0;i<n2;i++){
        R[i]=A[mid+i];
    }
    L[n1]=R[n2]=2000000000;
    i=0;j=0;
    for(k=left;k<right;k++){
        cnt++;
        if(L[i]<=R[j]){
            A[k]=L[i++];
        }
        else{
            A[k]=R[j++];
        }
    }
}

void mergeSort(int A[],int n,int left,int right){
    int mid;
    if(left+1<right){
        mid=(left+right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int main(){
    int A[500000],n,i;
    cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    mergeSort(A,n,0,n);
    for(i=0;i<n-1;i++){
        if(i){
            printf(" ");
        }
        printf("%d",A[i]);
    }
    printf(" %d\n",A[i]);
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 5696
#include <stdio.h>

int abs(int k)
{
	return k>0?k:-k;
}
int check[2010];
int dist[2010][2010];
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=1;i<a;i++) for(int j=i+1;j<=a;j++) dist[i][j] = (j-i);
	for(int i=1;i<b;i++) for(int j=b+1;j<=a;j++) dist[i][j] = dist[i][j] < abs(b-i)+abs(j-c)+1? dist[i][j] : abs(b-i)+abs(j-c)+1;
	for(int i=b;i<c;i++) for(int j=i+1;j<=a;j++) dist[i][j] = dist[i][j] < abs(b-i)+abs(j-c)+1? dist[i][j] : abs(b-i)+abs(j-c)+1;
	for(int i=1;i<=a;i++) for(int j=i+1;j<=a;j++) check[dist[i][j]]++;
	for(int i=1;i<a;i++) printf("%d\n",check[i]);
}

Measured memory_bytes: 15232
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
using namespace std;
string b[1000000];
bool cmp(string a, string b)
{
    return a < b;
}
int main()
{
    

    int n,l;
    cin >> n >> l;
    for(int i = 1;i <= n;++i)
        cin >> b[i];
    sort(b + 1,b + 1 + n,cmp);   //sort
    for(int i = 1;i <= n;++i)
        cout << b[i];
    return 0;
}

Measured memory_bytes: 8064
N_kai, K_ban = map(int, input().split())

dic = {}

for i in range(N_kai):
    a, b_ko = map(int, input().split())
    
    if (a not in dic.keys()):
        dic[a] = b_ko
    else:
        dic[a] = dic[a] + b_ko

sorted_dic = sorted(dic.items(), key=lambda x: x[0])
number = 0

if (K_ban == 1):
    print(sorted_dic[0][0])
else:
    for i in range(len(sorted_dic)):
        number += sorted_dic[i][1]
        
        if (number >= K_ban):
            print(sorted_dic[i][0])
            break


Measured memory_bytes: 20896
a = input()

for i in range(len(a)):
  if i % 2 == 0: 
    if a[i] == 'R' or a[i] == 'U' or a[i] == 'D':
      pass
    else:
      print('No')
      exit()
  else:
    if a[i] == 'L' or a[i] == 'U' or a[i] == 'D':
      pass
    else:
      print('No')
      exit()
print('Yes')

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

int main() {
  vector<int> a(5);
  for(int i=0;i<5;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<5;i++){
    if(a.at(i) == 0){
      cout << i+1 << endl;
      return(0);
    }
  }
  return(0);
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
	int k, s, a;

	cin >> k;
	cin >> s;

	a = 0;
	for (int x = 0; x <= k; x++){
		for(int y = 0; y <= k; y++){
			if (s - (x + y) <= k && s - (x + y) >= 0){
				a++;
			}
		}
	}

	cout << a << endl;

}


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

using namespace std;

typedef long long int ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	
	ll a, b;
	
	cin >> a >> b;
	
	ll s = a + b;
	
	if(s % 2 == 0){
		cout << s / 2 << endl;
	}
	else{
		cout << "IMPOSSIBLE" << endl;
	}
	
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var (
		a, b, ans int
		op string
	)
	for {
		fmt.Scan(&a, &op, &b)
		if op == "?" {
			break
		}
		switch op {
		case "+": ans = a + b
		case "-": ans = a - b
		case "*": ans = a * b
		case "/": ans = a / b
		default:
			fmt.Println("op is incorrect.")
		}
		fmt.Println(ans)
	}
}


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

int h, w;
pair<int, int> st, g;   //スタートとゴールの座標
vector<vector<bool>> s; //s: 道ならtrue, 壁ならfalse  dict: 魔法を何回使えばその座標に行けるか。-1で初期化
vector<vector<int>> dict;
vector<pair<int, int>> ite = {pair<int, int>(1, 0), pair<int, int>(0, 1), pair<int, int>(-1, 0), pair<int, int>(0, -1)};
queue<pair<int , int>> que; // fillで埋めたいところのlist
queue<pair<int, int>> next; //魔法を使ってたどり着ける場所のリスト。次のcntでfillしたい。
queue<pair<int, int>> filled; //名前通りfillし終わったところ。


void fill(int x, int y, int num){ //座標(x, y)から歩いて行ける場所のdictをすべて num にする。
    dict[x][y] = num;
    filled.push(pair<int, int>(x, y));
    
    rep(i, 4){
        int x_ = x+ite[i].first;
        int y_ = y+ite[i].second;
        if(x_<0 || y_<0 || x_>=h || y_>= w)continue;
        if(s[x_][y_] && dict[x_][y_]==-1)fill(x_, y_, num);
    }
}



int main(){
    
    cin >> h >> w;
    
    cin >> st.first >> st.second;
    cin >> g.first >> g.second;
    st.first--;st.second--;
    g.first--;g.second--;
    
    
    s.resize(h);
    dict.resize(h);
    rep(i, h){
        s[i].resize(w);
        dict[i].resize(w);
        rep(j, w)dict[i][j]=-1;
    }
    
    rep(i, h){
        rep(j, w){
            char c;
            cin >> c;
            s[i][j] = bool(c=='.');
        }
    }
    
    
    int cnt = 0;
    
    
    que.push(st);
    
    while(1){
        
        if(que.empty())break;
        while(!que.empty()){
            
            int x=que.front().first;
            int y=que.front().second;
            que.pop();
            
            if(s[x][y])fill(x, y, cnt);
        }
        
        if(dict[g.first][g.second]!=-1)break;
        
        
        while(!filled.empty()){
            int x=filled.front().first;
            int y=filled.front().second;
            filled.pop();
            
            rep2(i, -2, 3){
                rep2(j, -2, 3){
                    if(x+i<0 || x+i>=h || y+j<0 || y+j>=w)continue;
                    if(s[x+i][y+j] && dict[x+i][y+j]==-1)que.push(pair<int, int>(x+i, y+j));
                }
            }
        }
        
        cnt++;
    }
    
    cout << dict[g.first][g.second] << endl;

    
}

Measured memory_bytes: 7944
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long const mod = 1e9+7;
    
    long dp[4][4][n+1];
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            dp[i][j][3] = 4;
            for(int k=0;k<3;k++)dp[i][j][k] = 1;
        }
            
        
    }
    dp[2][1][3] = 3;
    dp[1][2][3] = 3;
    dp[0][1][3] = 3;

    

    //021,012,201は除外
    char ACGT[4] = {'A','C','G','T'};
    
    for(int num = 4;num<=n;num++){
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                dp[i][j][num] = 0;
                for(int k=0;k<4;k++){
                    int tmp = 100*k + 10*i + j;
                    if(tmp != 21 && tmp != 12 && tmp!=201)dp[i][j][num] += dp[k][i][num-1];
                }
                if(j == 3 && i != 3)dp[i][j][num]-= dp[0][2][num-2];
                dp[i][j][num] = (dp[i][j][num]+mod)%mod;
            }
        }
    }
    long ans = 0;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            ans += dp[i][j][n];
        }
    }
    cout << ans%mod << endl;
}

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

using namespace std;

const int MOD=1e9+7;
//const int MOD=998244353;

const double PI=3.14159265359;



int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int a,b,c;
    cin>>a>>b>>c;
    
    cout<<b+min(c,a+b+1);
    
    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a_list = []
for i in range(h):
    a_list.append(str(input()))

b_list = a_list.copy()

for i in range(h):
    sharp = ["#"] * (w+2)
    sharp = "".join(sharp)
    if i == 0:
        b_list.insert(0, sharp)
    if i == h-1:
        b_list.append(sharp)
    
    replace = str('#') + str(a_list[i]) + str('#')
    b_list[i+1] = replace

for i in range(len(b_list)):
    print(b_list[i])


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;

using ll=long long;

template <typename T>
T in(){
    T x;
    cin >> x;
    return x;
}

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

main(){
    ll n=in<ll>(),a=in<ll>(),b=in<ll>();
    if ((b-a)%2==0) cout << (b-a)/2 << endl;
    else{
        if (n-b<a-1){
            cout << (-a+b-1)/2+n-b+1 << endl;
        }
        else{
            cout << (b-a-1)/2+a << endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Set<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(sc.next());
        }

        // 主処理
        String result = set.size() == 3 ? "Three" : "Four";

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21204
#include <stdio.h>

int main(void) {
  int a, b, x;

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

  if(a + b < x){
    printf("NO");
  } else if(a > x) {
    printf("NO");
  } else {
    printf("YES");
  }

  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(n==0 && a==0 && b==0) break;
			
			int cnt = 0;
			boolean[] f = new boolean[n+1];
			f[0] = true;
			for(int i=1;i<=n;i++){
				if(i-a>=0 && f[i-a]==true) f[i] = true;
				if(i-b>=0 && f[i-b]==true) f[i] = true;
				if(f[i]==false) cnt++;
			}
			
			System.out.println(cnt);
		}	
	}	
}

Measured memory_bytes: 24156
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)

	fmt.Println(dfs(s, 0, uint(len(s))-1))
}

func dfs(s string, f int, d uint) int {
	if d == 0 {
		return calc(s, f)
	}
	return dfs(s, f, d-1) + dfs(s, f|(1<<(d-1)), d-1)
}

func calc(s string, f int) int {
	v, j := 0, 0
	for i := range s {
		if f&1 == 1 {
			n, _ := strconv.Atoi(s[j : i+1])
			v += n
			j = i + 1
		}
		f >>= 1
	}
	n, _ := strconv.Atoi(s[j:])
	v += n
	return v
}


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

#define N 100001

using namespace std;

int n;
int a[N];
bool dp[N][2];
bool vis[N][2] = {0};

bool solve2(int k, int p)
{
	memset(dp, false, sizeof(dp));
	for (int i = 1; i <= k; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i - a[j] >= 0)
			{
				dp[i][0] = dp[i][0] || !dp[i - a[j]][1];
				dp[i][1] = dp[i][1] || !dp[i - a[j]][0];
			}
		}
	}
	return dp[k][p];
}

int main()
{
	int k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cout << (solve2(k, 0) ? "First" : "Second") << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  vector<char> vec_ans;
  char cur;
  for(int i=0; i<n; i++){
    if(cur!=s[i]) vec_ans.emplace_back(s[i]);
    cur = s[i];
  }
  
  int ans = vec_ans.size();
  cout << ans << "\n";
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;



int main() {
    int n,a;
    long long sum = 0;
    int max = 0;
    int min = 0;
    vector<int> numbers;
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> a;
        numbers.push_back(a);
        sum+=a;
        if (i == 0) {
            max = a;
            min = a;
        }else{
            if(a>max) max=a;
            if(a<min) min=a;
        }
    }
    cout << min << " " << max << " " << sum << endl;
    
    return 0;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

struct less_key {
    bool operator()(const std::pair<i64,i64> &left, const std::pair<i64,i64> &right) {
        return left.first < right.first;
    }
};

i64 gcd (i64 a, i64 b, i64 & x, i64 & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    i64 x1, y1;
    i64 d = gcd (b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

i64 rev(i64 a, i64 m) {
    i64 x, y;
    i64 g = gcd(a, m, x, y);
    if (g != 1) {
        throw g;
    }
    return (x % m + m) % m;
}

i64 binpow(i64 a, i64 p) {
    if (p == 0) {
        return 1;
    }
    if (p == 1) {
        return a;
    }
    i64 t = binpow(a, p / 2);
    t *= t;
    t %= mod;

    if (p % 2) {
        t *= a;
        t %= mod;
    }

    return t;
}

const i64 MAXN = 100005;

i64 n, k;
i64 a[MAXN];
i64 b[MAXN];


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n >> k;
    for (i64 i = 0; i < k; i++) {
        i64 j;
        string s;
        cin >> j >> s;
        if (a[j]) {
            continue;
        }
        if (s == "AC") {
            a[j] = 1;
        } else {
            b[j] += 1;
        }
    }

    i64 R1 = 0, R2 = 0;

    for (i64 i = 1; i <= n; i++) {
        R1 += a[i];
        if (a[i]) {
            R2 += b[i];
        }
    }

    cout << R1 << " " << R2 << endl;
    return 0;
}

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

using namespace std;

int main(){
  int a, b, c, d, e, f;
  double mx=0.0;
  cin >> a >> b >> c >> d >> e >> f;
  int mx_total=100*a, mx_sugar=0;
  for(int aa=0;aa*a*100<=f;aa++){
    for(int bb=0;(aa*a+bb*b)*100<=f;bb++){
      int water=(aa*a + bb*b)*100;
      for(int cc=0;water+cc*c<=f;cc++){
        if(e*water/100<c*cc)break;
        for(int dd=0;water+cc*c+dd*d<=f;dd++){
          int sugar=cc*c + dd*d;
          if(e*water/100<c*cc+d*dd)break;
          double d_sugar = (double)sugar;
          double d_water = (double)water;
          double value = (d_sugar)/(d_sugar+d_water);
          if(value>mx){
            mx=value;
            mx_total=sugar+water;
            mx_sugar=sugar;
          }
        }
      }
    }
  }
  cout << mx_total << ' ' << mx_sugar << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int dx[]={0,2,0,-2};
int dy[]={-2,0,2,0};
int h,w,sx,sy;
bool dp[1111][1111];
string s[1111];
int main(){
  while(cin>>h>>w>>sy>>sx,h){
    getline(cin,s[0]);
    r(i,h*2+1)getline(cin,s[i]);
    sy=sy*2-1;sx=sx*2-1;
    memset(dp,0,sizeof(dp));
    queue<P>q;
    for(int i=1;i<w*2;i+=2)q.push(P(1,i)),q.push(P(h*2-1,i));
    for(int i=1;i<h*2;i+=2)q.push(P(i,1)),q.push(P(i,w*2-1));
    r(i,4){
      int Y=sy+dy[i]/2;
      int X=sx+dx[i]/2;
      int YY=sy+dy[i];
      int XX=sx+dx[i];
      if(YY<0||XX<0||YY>=h*2||XX>=w*2){
        if(s[Y][X]=='0')dp[sy][sx]=1;
      }
    }
    while(!q.empty()){
      P p=q.front();q.pop();
      int y=p.first;
      int x=p.second;
      int used[2]={};
      if(dp[y][x]==1)continue;
      r(i,4){
        int Y=y+dy[i]/2;
        int X=x+dx[i]/2;
        int YY=y+dy[i];
        int XX=x+dx[i];
        if(YY<0||XX<0||YY>=h*2||XX>=w*2)used[s[Y][X]-'0']=1;
        else if(dp[YY][XX])used[s[Y][X]-'0']=1;
      }
      if(used[0]&&used[1]){
        dp[y][x]=1;
        r(i,4){
          int Y=y+dy[i];
          int X=x+dx[i];
          if(Y<0||X<0||Y>=h*2||X>=w*2)continue;
          if(!dp[Y][X])q.push(P(Y,X));
        }
      }
    }
    cout<<(dp[sy][sx]?"Yes":"No")<<endl;
  }
}


Measured memory_bytes: 5316
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	ans := 0
	for i := 1; i < n-1; i++ {
		if p[i] < p[i-1] && p[i] >= p[i+1] {
			ans++
			continue
		}
		if p[i] < p[i+1] && p[i] >= p[i-1] {
			ans++
			continue
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import Control.Applicative

main = do
    -- 整数の入力
    a <- getLine
    -- 出力
    if (a !! 0 == a !! 1 && a !! 0 == a !! 2) || (a !! 1 == a !! 2 && a !! 2 == a !! 3) then putStrLn "Yes" else putStrLn "No"



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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vec;
typedef vector<P> pvec;
typedef vector<vector<int>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<int> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<int,vector<int>,greater<int>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> DX = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> DY = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const ll INF = (1LL << 60); // 1152921504606846976
const double PI = (3.141592653589794);
const double EPS = (0.0000000001); // 10^(-10)

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }



//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec G(nmax);





void solve4ts()
{
    
    int n,m;
    cin>>n>>m;

    if(m==1){
        cout<<"1 2"<<endl;
        return;
    }

    int i1=1;
    int i2=m+2;

    for(int i=m;i>=1;i--){
        cout<<i1<<" "<<i1+i<<endl;
        i1++;
        swap(i1,i2);
    }
    
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}

Measured memory_bytes: 7828
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .split(config.newline, 4);

S = line[1].split(' ').map(Number);
T = line[3].split(' ').map(Number);

C = T.reduce(function (p, c) {
  return p + ((S.indexOf(c) !== -1) ? 1 : 0); }, 0);

console.log(C);

Measured memory_bytes: 30516
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

set<ll> setLun;

void addLun(string str){
    if(str.length()>= 11) return;
    setLun.insert(stoll(str));
    char ch = str.back();
    if(ch > '0') {
        string tmp = str;
        tmp.push_back((char)(ch-1));
        addLun(tmp);
    }
    if(ch < '9'){
        string tmp = str;
        tmp.push_back((char)(ch+1));
        addLun(tmp);
    }
    {
        string tmp = str;
        tmp.push_back((char)(ch));
        addLun(tmp);
    }
    return;
}

void solve(long long K){
    REP(i, 9){
        addLun(string(1, (char)('0'+i+1)));
    }
    for(auto it= setLun.begin(); it != setLun.end(); ++it){
        K--;
        if(K == 0) {
            cout<< *it<<endl;
            break;
        }
    }
}

int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


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

bool judge(string &s){
    int length=s.size();
    bool flag=true;
    for(int i=0,j=length-1;i<=j;i++,j--){
        if(s[i]!=s[j]){
            flag=false;
            break;
        }
    }
    return flag;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s,s1,s2;
    int length;
    cin>>s;
    length=s.size();
    s1=s.substr(0,(length-1)/2);
    s2=s.substr((length+1)/2,(length-1)/2);
    if(judge(s) && judge(s1) && judge(s2)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #ここにコード
    #input
    import numpy as np
    N, M, X = map(int, input().split())
    C = [0] * N
    A = np.zeros((N, M), int)
    for i in range(N):
        B = list(map(int, input().split()))
        C[i] = B[0]
        for j in range(1, M+1):
            A[i, j-1] = B[j]

    #output
    #参考書はN冊ある。各々の教科書について、購入するかしないかで2**N通り。
    answer = pow(10, 9)
    import itertools

    L = itertools.product([True, False], repeat = N)

    for l in L:
        skill = np.zeros(M, int)
        temp_answer = 0
        for i in range(N):
            if l[i]:
                skill += A[i]
                temp_answer += C[i]
        if np.all(skill >= X):
            answer = min(temp_answer, answer)
    if answer != pow(10, 9):
        print(answer)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 27352
S=input()

i=0
while i<len(S):
    if (i+1)%2==0:
        if S[i]=="L" or S[i]=="U" or S[i]=="D":
            pass
        else:
            print("No")
            quit()
    else:
        if S[i]=="R" or S[i]=="U" or S[i]=="D":
            pass
        else:
            print("No")
            quit()
    i+=1
    
print("Yes")



Measured memory_bytes: 38384
#include <iostream> 
 
using namespace std; 
 
int main(){ 
	int n;
	cin >> n;
	int odd = 0;
	int eve = 0;
	for(int i = 1; i <= n; i++){
		if(i % 2 == 0) eve++;
		else odd++;
	}
	cout << (double)(odd) / (double)(odd+eve) << endl;
} 


Measured memory_bytes: 3772
program main
  implicit none
  integer(8) i, N, ans, A1,B,C,x
  integer(8), allocatable :: a(:)
  !read(*, *) (L(i), i = 1,N)
  read(*, *) N
  allocate(a(N))
  read(*, *) (a(i), i = 1,N)
  ans = 0
  !すべて0
  if (sum(a) == 0) then
    ans = 1
  end if
  !その他
  if (mod(N,3) == 0) then
    call qsort(a)
    if (a(1)==a(N/3)) then
      if (a(N/3+1)==a(2*N/3)) then
        if (a(2*N/3+1)==a(N)) then
          A1 = a(1)
          B = a(N/3+1)
          C = a(2*N/3+1)
          x = ieor(A1,B)          
          x = ieor(x,C)
          if (x == 0) then
            ans = 1
          end if
        end if
      end if
    end if
  end if
  if (ans == 0) then
    write(*, *) 'No'
  else
    write(*, *) 'Yes'
  end if

contains
 
  recursive subroutine qsort(a)
    implicit none
    integer(8),intent(inout) :: a(:)
    integer(8)::i,j,toobig,toosmall,pv,n
    n = size(a)
    i = 1
    j = n
    pv = a((i+j)/2)
    do
       do
         if (a(i) < pv) then
           i = i+1
         else
           exit
         end if
       end do
       do
         if(a(j) > pv) then
           j = j-1
         else
           exit
         end if
       end do
       if (i>=j) then
         exit
       else
         toobig = a(j)
         toosmall = a(i)
         a(i) = toobig
         a(j) = toosmall
         i = i+1
         j = j-1
       end if
     end do
     if (i > 2) then
       call qsort(a(1:i-1))
     end if
     if (j < n-1) then
       call qsort(a(j+1:n))
     end if
  end subroutine qsort
end program main


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



    int m,n;
    string Common(string text1, string text2){
    	string ans= "";
    	m=text1.size();
		n=text2.size();
		
		if(m==0||n==0)
		return ans;
		
       vector<vector<int> > dp(m+1, vector<int>(n+1,0));
     
        for(int i=1; i<=m; i++){
            for(int j=1; j<=n; j++){
                if(text1[i-1]==text2[j-1])
                    dp[i][j]=dp[i-1][j-1]+1;
        		else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
        }
        int i=m, j=n;
         while(1){
         	 if(dp[i][j]==0)
                break;
            if(dp[i][j-1]==dp[i][j]){
                --j;
                continue;
            }
            else if(dp[i-1][j]==dp[i][j] ){ 
                --i;
                continue;
            }
            ans+=text1[i-1];
            --i;--j;
           
        }
        reverse(ans.begin(),ans.end());
        return ans;
    }
    
int main() {
		string s1,s2;
		cin>>s1>>s2;
		cout<<Common(s1,s2);
}

Measured memory_bytes: 35584
#include <stdio.h>

int main(){
    int x,y;
    while(1){
        scanf("%d %d", &x,&y);
        if(x == 0 && y == 0)break;
        if(x > y)printf("%d %d\n", y, x);
        else printf("%d %d\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    string s;
    cin >> s;
    int cnt = 0;
    bool judge = 0;
    rep(i, s.size()) {
        if (s[i] == 'R')
            cnt++, judge = 1;
        if (judge && s[i] != 'R')
            break;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int a[100000+5];
int b[100000+5];
int c[100000+5];

int main(int argc, char const *argv[])
{
	int N;
	while(cin >> N) {
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		memset(c, 0, sizeof(c));
		for(int i=1; i<=N; i++){
			cin >> a[i] >> b[i] >> c[i];
		}
		for(int i=2; i<=N; i++){
			int tempa = a[i - 1];
			int tempb = b[i - 1];
			int tempc = c[i - 1];
			a[i] = a[i] + max(tempb, tempc);
			b[i] = b[i] + max(tempa, tempc);
			c[i] = c[i] + max(tempa, tempb);
		}
	    cout << max(a[N], max(b[N], c[N])) << endl;
    }
	return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
  int n;cin>>n;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    if(a%2==0){
      if(a%3==0||a%5==0){

      }else{
        puts("DENIED");
        return 0;
      }
    }
  }
        puts("APPROVED");

  
  return 0;
}


Measured memory_bytes: 256
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, M = [ int(x) for x in input().split() ]
A = [ int(x) for x in input().split() ]
BC = []
for _i in range(M):
    BC.append([ int(x) for x in input().split() ])
A = sorted(A)
BC = sorted(BC, key = lambda x: x[1], reverse = True)

p = 0

def solve():
    global A, BC, p
    for bc in BC:
        for _i in range(bc[0]):
            if p >= len(A):
                return
            if A[p] < bc[1]:
                A[p] = bc[1]
                p += 1
            else:
                return

solve()
print(sum(A))



Measured memory_bytes: 38140
x,y = map(int,input().split())

for i in range(100):
    for j in range(100):
        if i+j == x and i*2+j*4==y:
            print('Yes')
            exit()

print('No')



# a = 2
# b = 4

# lista=[]
# listb=[]

# for i in range(101):
#     if i %2 == 0:
#         lista.append(i)

# for j in range(101):
#     if j % 4 == 0:
#         listb.append(j)


# if y == b*x:
#     print('Yes')
# elif y == a*x:
#     print('Yes')
# else:
#     print('No')

Measured memory_bytes: 9172
n = int(input())
err = False
word_list = []
for i in range(n):
    s = input()
    if i == 0:
        last_letter = s[-1]
        word_list.append(s)
        continue
    if s in word_list:
        err = True
    else:
        if last_letter != s[0]:
            err = True
        else:
            last_letter = s[-1]
            word_list.append(s)
if err:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3060
n,m=list(map(int,input().split()))
a=list()
for i in range(n):
    a.append(list(map(int,input().split())))
b=list()
for i in range(m):
    b.append(int(input()))
for i in range(n):
    s=0
    for j in range(m):
        s+=a[i][j]*b[j]
    print(s)
    


Measured memory_bytes: 6008
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
email.kishor.josephite@gmail.com
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int a,b;
   cin>>a>>b;
   if(a>b)
    cout<<  a*2-1<<endl;
   else if(b>a)
    cout<< b*2-1 <<endl;
   else
    cout<< a*2<<endl;

    return 0;
}



Measured memory_bytes: 256
from collections import deque
ca = ord('a')
while 1:
    N = int(input())
    if N == 0:
        break
    G = [[] for i in range(26)]
    S = [0]*26; T = [0]*26
    for i in range(N):
        word = input()
        s = ord(word[0]) - ca; t = ord(word[-1]) - ca
        S[s] += 1; T[t] += 1
        G[s].append(t)
    ok = 1
    for i in range(26):
        if S[i] != T[i]:
            ok = 0
    if ok:
        que = deque()
        U = [0]*26
        for i in range(26):
            if S[i]:
                que.append(i)
                U[i] = 1
                break
        while que:
            v = que.popleft()
            for w in G[v]:
                if U[w]:
                    continue
                U[w] = 1
                que.append(w)
        for i in range(26):
            if S[i] and not U[i]:
                ok = 0
    print("OK" if ok else "NG")


Measured memory_bytes: 6096
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#define endl "\n"
#define INT long long int
using namespace std;
pair<int,int> A[300100], B[300100];
set <pair<int, int> > S;
vector<int> V1, V2;

int main(){
    ios::sync_with_stdio(false);
    int h, w, n, i, a, b, j, m;
    cin >> h >> w >> n;
    for(i=1;i<=h;i++)A[i].second=i;
    for(i=1;i<=w;i++)B[i].second=i;
    for(i=0;i<n;i++){
        cin >> a >> b ;
        A[a].first++;
        B[b].first++;
        S.insert({a,b});
    }
    sort(A,A+h+1);
    sort(B,B+w+1);
    m = A[h].first + B[w].first;
    j=h;
    while(A[j].first==A[h].first){
        V1.push_back(A[j].second);
        j--;
    }
    j=w;
    while(B[j].first==B[w].first){
        V2.push_back(B[j].second);
        j--;
    }
    for(i=0;i<V1.size();i++){
        for(j=0;j<V2.size();j++){
            if(S.find({V1[i],V2[j]})==S.end()){
                cout << m <<endl;
                return 0;
            }
        }
    }
    cout << m-1 <<endl;
}


Measured memory_bytes: 26112
#include<stdio.h>
int main()
{
    int P,Q,R;
    int m=200;
    scanf("%d  %d  %d", &P,&Q,&R);
    if(m>P+Q)
        m=P+Q;
    if(m>Q+R)
        m=Q+R;
    if(m>R+P)
        m=R+P;

    printf("%d", m);
    return 0;
}


Measured memory_bytes: 128
A, B, C, X, Y = map(int, input().split())

if A + B < 2 * C:
    print(A*X + B*Y)

else:
    ans = 2*C*max(X, Y)

    C_num = min(X, Y)
    if X > Y:
        print(min(ans, C_num*2*C + A*(X-C_num)))
    else:
        print(min(ans, C_num*2*C + B*(Y-C_num)))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
    int A,B;
    cin >> A >> B;

    int M,m;

    if(A > B){
        M = A;
        m = B;
    }else if(B > A){
        M = B;
        m = A;
    }else{
        M = A;
        m = B;
    }

    int x = m + M;

    if(M-m <= (16 - x)/2){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
A = [[int(i) for i in readline().split()] for _ in range(3)]
n = int(readline())
b = [int(readline()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            A[i][j] = 0
        
if A[0][0]+A[1][1]+A[2][2] == 0 \
or A[0][2]+A[1][1]+A[2][0] == 0 \
or A[0][0]+A[0][1]+A[0][2] == 0 \
or A[1][0]+A[1][1]+A[1][2] == 0 \
or A[2][0]+A[2][1]+A[2][2] == 0 \
or A[0][0]+A[1][0]+A[2][0] == 0 \
or A[0][1]+A[1][1]+A[2][1] == 0 \
or A[0][2]+A[1][2]+A[2][2] == 0 :
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<ll>A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    cin>>B[i];
  }
  ll asum=accumulate(ALL(A),0ll),bsum=accumulate(ALL(B),0ll) ;
  ll acnt=0ll,bcnt=0ll;
  for(int i=0;i<N;i++){
    if(B[i]>A[i]){
      bcnt+=(B[i]-A[i]+1)/2;
    }else{
      acnt+=A[i]-B[i];
    }
  }
  if(acnt<=bsum-asum && bcnt<=bsum-asum){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>
#include <math.h>
#include <deque>
#include <stack>

using namespace std;

typedef long long ll;

int main(void){
    ll n;
    cin >> n;
    vector<ll> p(n),ans(n);
    for(ll i = 0;i < n;i++){
        cin >> p[i];
    }
    ans = p;
    ll sw = -1;
    ll idx;
    sort(ans.begin(), ans.end());
    for(ll i = 0;i < n; i++){
        if(ans[i] != p[i] && sw == -1){
            sw = p[i];
            idx = i;
        }else if(ans[i] != p[i] && sw != -1){
            ll tmp = p[i];
            p[i] = sw;
            p[idx] = tmp;
            for(ll i = 0;i < n; i++){
                if(ans[i] != p[i]){
                    cout << "NO" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  ll a,b,c,k; cin >> a >> b >> c >> k;
  ll ans = 0;
  if(a <= k){
    ans += a;
    k -= a;
  }else{
    cout << k << endl;
    return 0;
  }
  if(b <= k){
    k -= b;
  }else{
    cout << ans << endl;
    return 0;
  }
  ans += -1*k;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int rep[N] ;
int Find(int x){
    if ( rep[x] == x ) return x ;
    return rep[x] = Find(rep[x]) ;
}
void Union(int x, int y){
    int X = Find(x) ;
    int Y = Find(y) ;
    if ( X == Y ) return ;
    rep[X] = Y ;
}
signed main(){
    fastio
    int n , m ;
    cin >> n >> m ;
    for(int i = 0; i < n; i++){
        rep[i] = i ;
    }
    for(int i = 0; i < m; i++){
        int a , b ;
        cin >> a >> b ;
        a--, b--; 
        Union(a, b) ;
    }
    vector<int> cnt(n) ;
    for(int i = 0; i < n; i++){
        cnt[Find(i)]++;
    }
    sort(cnt.rbegin(), cnt.rend()) ;
    cout << cnt[0] << endl;
    return 0; 
}

Measured memory_bytes: 12592
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		int ans = b;

		if(a<13)ans/=2;
		if(a<6)ans=0;

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

#define pb push_back
#define fr first
#define sc second

int f(int x){
	if(x < 10)return x;
	return x%10+f(x/10);
}

int main(){
	int K;
	cin >> K;
	
	while(K%2 == 0)K /= 2;
	while(K%5 == 0)K /= 5;
	
	if(K == 1){
		printf("%d\n",1);
		return 0;
	}
	
	vector<int> R;
	int r = 1;
	do{
		r *= 10;
		while(r > K)r -= K;
		R.pb(r);
	}while(r != 1);
	sort(R.begin(),R.end());
	reverse(R.begin(),R.end());
	
	bool t = false;
	int used[100010];
	queue<P> que;
	for(int i = 0 ; i < 100010 ; i ++)used[i] = 1000000;
	que.push(P(0,K));
	used[K] = 0;
	while(!que.empty()){
		P p = que.front(); que.pop();
		if(used[K-p.sc] != 1000000)t = true;
		if(t)continue;
		for(int i = 0 ; i < R.size() ; i ++){
			int nex = p.sc+K-R[i];
			if(nex >= K)nex -= K;
			if(used[nex] == 1000000){
				used[nex] = p.fr+1;
				que.push(P(p.fr+1,nex));
			}
		}
	}
	
	int ret = 1000000;
	for(int i = 1 ; i <= K-i ; i ++){
		ret = min( ret , used[i]+used[K-i] );
	}
	cout << ret << endl;
}



Measured memory_bytes: 1528
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################
n = int(input())
arr = [0]*(10000+11)

for i in range(1,101):
	for j in range(1,101):
		for k in range(1,101):
			if i*i + j*j + k*k + i*j + j*k + k*i <= n:
				arr[i*i + j*j + k*k + i*j + j*k + k*i]+=1
for i in range(1,n+1):
	print(arr[i])




Measured memory_bytes: 69692
/*input
9 73
67597 52981 5828 66249 75177 64141 40773 79105 16076
*/
#include<bits/stdc++.h>
#define ull         unsigned long long
#define ll             long long
#define M             1000000007
#define pb             push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()    
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp             make_pair
#define lb             lower_bound
#define ub            upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)    for(ll int i=0;i<n;i++) a[i]=0;
#define F            first
#define S            second
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

bool DEBUG = 0;

ll n,m;
vi a(100005);
vi pre(100005);

bool val(ll mx)
{
    ll count = 0;
    rep(i,0,n)
    {
        int it = lower_bound(a.begin() , a.end() , max(mx - a[i] , 0ll)) - a.begin();
        // cout<<mx<<" "<<i<< " " << a[i] << " " <<max(mx - a[i] , 0ll)<<" "<<it<<"\n";
        count += ((n-it));
    }
    return count>=m;  
}

void solve()
{
    //initialize();
    cin>>n>>m;
    a.resize(n);
    rep(i,0,n)
        cin>>a[i];
    sort(all(a));
    pre[n-1] = a[n-1];
    rep(i,n-1,0)pre[i] = pre[i+1]+ a[i];
    ll l = 0 , h = 200005, mid;
    while((h-l) > 1)
    {
        mid = (h+l)/2;
        if (val(mid))
            l = mid;
        else
            h = mid-1;
    }
    ll x;
    if (val(max(h,l)))
        x = max(h,l);
    else
        x = min(h,l);
    ll ans = 0;
    ll count = 0;
    rep(i,0,n)
    {
        auto it = lower_bound(a.begin() , a.end() , max(x + 1 - a[i] , 0ll)) - a.begin();
        count += ((n-it));
        if (it == n)
            continue;
        ans += ((n-it) * a[i]) + (pre[it]);
    }
    ans += (m - count) * x;
    cout<<ans<<"\n";

}


int main(void)
{
    ios
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 4736
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
dif = abs(T - H[0] * 0.006 - A)
result = 1

for i in range(1, N):
    if abs(T - H[i] * 0.006 - A) < dif:
        dif = abs(T - H[i] * 0.006 - A)
        result = i + 1

print(result)


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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	string S;
	cin >> S;
	int num = 0, num_out = 0;
	for (int i = 0; i < N; i++) {
		int tmp = S.at(i);
		if (tmp == 'a') {
			if (num < (A + B)) {
				cout << "Yes" << endl;
				num++;
			} else {
				cout << "No" << endl;
			}
		} else if (tmp == 'b') {
			if (num < (A + B) && num_out < B) {
				cout << "Yes" << endl;
				num++;
				num_out++;
			} else {
				cout << "No" << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 4050005
#define m 2005
#define mod 1000000007
#define ll long long
using namespace std;
int n, k;
ll jc[maxn], bjc[maxn];
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
ll c(int a, int b) {
	if (a < b || b < 0) return 0;
	return 1ll * jc[a] * bjc[b] % mod * bjc[a - b] % mod;
}
ll dp[m][m];
int main() {
	bjc[0] = jc[0] = 1;
	for (int i = 1; i < maxn; i++)
		jc[i] = jc[i - 1] * i % mod;
	bjc[maxn - 1] = ksm(jc[maxn - 1], mod - 2);
	for (int i = maxn - 2; i >= 0; i--)
		bjc[i] = bjc[i + 1] * (i + 1) % mod;
//	cout << bjc[0] << endl;
	cin >> n >> k;
	if (k == 1) {
		cout << 1 << endl;
		return 0;
	}
//	cout << "!@#" << endl;
	k--;
	ll ans = jc[n];
	for (int i = n; i >= 0; i--)
		for (int j = i; j >= 0; j--) {
			if (j == n) dp[i][j] = 1;
			else {
				dp[i][j] = dp[i][j + 1];
				ll nx = dp[i + 1][j];
				int tot = k * i + j + (k - 1);
				nx = nx * c(tot, k - 1) % mod;
				dp[i][j] = (dp[i][j] + nx) % mod;
			}
	//		cout << i << ' ' << j << ' ' << dp[i][j] << endl;
		}
	ans = ans * dp[0][0] % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 93440