akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		HashSet<Integer> set = new HashSet<>();
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
		    set.add(sc.nextInt());
		}
		TreeSet<Integer> result = new TreeSet<>();
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
		    int x = sc.nextInt();
		    if (set.contains(x)) {
		        result.add(x);
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int x : result) {
		    sb.append(x).append("\n");
		}
		System.out.print(sb);
	}
}



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

int main(){
    vi a(2);
    int k;
    cin>>a[0]>>a[1]>>k;
    
    rep(i,k){
        if(a[i%2]%2)a[i%2]--;
        a[(i+1)%2] += a[i%2]/2;
        a[i%2] /= 2;
    }
    
    cout << a[0]<<" "<<a[1]<<endl;
    
    return 0;
}

Measured memory_bytes: 3612
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int t, n;

int main() {
	while (cin >> t&&t) {
		cin >> n;
		int sum = 0;
		REP(i, n) {
			int s, f;
			cin >> s >> f;
			sum += f - s;
		}
		if (sum < t) {
			cout << t-sum << endl;
		}
		else {
			cout << "OK" << endl;
		}
	}
}


Measured memory_bytes: 3088
import sys

input=sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
dic={}
for a in A:
    if a not in dic:
        dic[a]=0
    dic[a]+=1
S=sum(A)
Q=int(input())
for i in range(Q):
    b,c=map(int,input().split())
    if b in dic:
        val=dic[b]
        dic[b]=0
        if c not in dic:
            dic[c]=0
        dic[c]+=val
        S+=(c-b)*val
    #print("DEBUG")
    print(S)


Measured memory_bytes: 84264
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	int n,f[30],i,j,k,x,cnt,l,flg;
	char pat1[7],pat2[7];
	char a[30][6],buf[10],wk;
	while(1)	{
		scanf(" %d",&n);
		if(n==0)	break;
		for(i=0;i<n;i++)	{
			for(j=0;j<6;j++)	{
				scanf("%s",buf);
				a[i][j]=buf[0];
			}
		}
//		for(i=0;i<n;i++)	{
//			for(j=0;j<6;j++)	printf("%c",a[i][j]);
//			printf("\n");
//		}
		pat1[6]='\0';	pat2[6]='\0';
		for(i=0;i<n;i++)	f[i]=0;
		for(i=0;i<n-1;i++)	{
			for(j=i+1;j<n;j++)	{
				for(k=0;k<6;k++)	{
					pat1[k]=a[i][k];
					pat2[k]=a[j][k];
				}
				flg=0;
				for(k=0;k<4;k++)	{
					wk=pat1[0];
					pat1[0]=pat1[2];
					pat1[2]=pat1[5];
					pat1[5]=pat1[3];
					pat1[3]=wk;
					for(l=0;l<4;l++)	{
						wk=pat1[1];
						pat1[1]=pat1[3];
						pat1[3]=pat1[4];
						pat1[4]=pat1[2];
						pat1[2]=wk;
						if(strcmp(pat1,pat2)==0)	{
							flg=1;
						}
					}
				}
				for(k=0;k<4;k++)	{
					wk=pat1[0];
					pat1[0]=pat1[1];
					pat1[1]=pat1[5];
					pat1[5]=pat1[4];
					pat1[4]=wk;
					for(l=0;l<4;l++)	{
						wk=pat1[1];
						pat1[1]=pat1[3];
						pat1[3]=pat1[4];
						pat1[4]=pat1[2];
						pat1[2]=wk;
						if(strcmp(pat1,pat2)==0)	{
							flg=1;	
						}
					}
				}
				if(flg==1)	{
					f[j]=1;
				}
			}
		}
		cnt=0;
		for(i=0;i<n;i++)	cnt+=f[i];
		printf("%d\n",cnt);
	}
	return 0;
}


Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x,a,b;
  cin>>x>>a>>b;
  if(x+a<b){
    cout<<"dangerous"<<endl;
  }else if(a<b){
    cout<<"safe"<<endl;
  }else{
    cout<<"delicious"<<endl;
  }
}


Measured memory_bytes: 256
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))

b = len(set(a))
c = Counter(a)
c = list(sorted(c.values(), reverse = True))

if b <= k:
    print(0)
else:
    d = b - k
    print(sum(c[b-d:]))


Measured memory_bytes: 39100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll H, W;
    cin >> H >> W;
    vector<ll> A(H), B(H);
    rep(i, H){
        cin >> A.at(i) >> B.at(i);
        A.at(i)--;
    }
    map<ll, ll> from;
    multiset<ll> vals;
    rep(i, W){
      from[i] = i;
      vals.insert(0);
    }
    rep(i, H){
      auto it = from.lower_bound(A.at(i));
      ll mr = -1;
      while(it != from.end() && it->first <= B.at(i)){
        chmax(mr, it->second);
        ll x = it->first - it->second;
        vals.erase(vals.find(x));
        from.erase(it++);
      }
      if(mr != -1 && B.at(i) < W){
        vals.insert(B.at(i) - mr);
        from[B.at(i)] = mr;
      }
      ll ans = -1;
      if(sz(vals) > 0){
        ans = *vals.begin() + i + 1;
      }
      cout << ans << endl;
    }
}

Measured memory_bytes: 28312
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,t;
  cin >> n >> t;
  vector<int> c(n),d(n);
  rep(i,n) cin >> c.at(i) >> d.at(i);
  int ans = INF;
  rep(i,n){
    if(d.at(i)<=t){
      ans = min(ans,c.at(i));
    }
  }
  if(ans==INF){
    cout <<  "TLE" << endl;
  }else{
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define ll long long

ll Ssize;
vector<ll> d(10);
bool Plus[10];

void bit_change(ll);
void keisan();

ll ans=0;

int main() {

	string S;
	cin >> S;
	Ssize = S.size();

	for (ll i = 0; i < Ssize; i++) {
		char s = S[i];
		d[i] = atoi(&s);
		//cout << d[i] << " ";
	}

	bit_change(0);

	cout << ans << endl;

	return 0;
}

void bit_change(ll bit) {

	if (bit == Ssize-1) {
		keisan();
		return;
	}

	Plus[bit] = true;
	bit_change(bit + 1);

	Plus[bit] = false;
	bit_change(bit + 1);

	return;
}

void keisan() {

	ll pre = -1;
	for (ll i = 0; i < Ssize-1; i++) {
		if (Plus[i] == true) {
			
			for (ll j = i,cnt=1; j > pre; j--,cnt*=10) {
				ans += d[j] * cnt;
			}
			pre = i;

		}

	}

	for (ll j = Ssize-1, cnt = 1; j > pre; j--, cnt *= 10) {
		ans += d[j] * cnt;
	}

	return;
}

Measured memory_bytes: 256
var  al,bl,i,j,k:longint;
     a,b:ansistring;
begin
  readln(a);
  readln(b);
  al:=length(a);
  bl:=length(b);
  i:=1;  j:=1;
  while  (i<=al)or(j<=bl)  do
    begin
      if  i<=al  then
        begin
          write(a[i]);
          inc(i);
        end;
      if  j<=bl  then
        begin
          write(b[j]);
          inc(j);
        end;
    end;
  writeln;
end.


Measured memory_bytes: 128
import sys
from itertools import accumulate
from itertools import groupby
#from scipy.special import comb
#from scipy.misc import comb

#booltable=[0]+booltable
"""
6
1 3 -4 2 2 -2

3
"""

def resolve():
    #input = sys.stdin.readline
    N=int(input().rstrip())
    #A=list(map(int,input().rstrip().split()))
    A=[int(x)for x in input().split()]


    cumsum = sorted(list(accumulate(A)))
    ans=0
    for key, group in groupby(cumsum):
        groupsize=len(list(group))
        if groupsize>=2:
            #ans += comb(groupsize,2,1) # 組み合わせ列挙 5C3
            ans+=groupsize*(groupsize-1)//2
        if key==0:
            ans+=groupsize
    print(int(ans))        
    


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """6
1 3 -4 2 2 -2"""
        output = """3"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """7
1 -1 1 -1 1 -1 1"""
        output = """12"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5
1 -2 3 -4 5"""
        output = """0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 29844
#include<stdio.h>
int main()
{
	int Y,M,D,N,r,i;
	for(scanf("%d",&N);N--;)
	{
		scanf("%d%d%d",&Y,&M,&D);
		for(i=Y+1,r=0;i<1000;i++)
			r+=i%3?195:200;
		for(i=M+1;i<11;i++)
			r+=Y%3?(i%2?20:19):20;
		for(i=D;i<=(Y%3?(M%2?20:19):20);i++)
			r+=1;
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 596
//<editor-fold desc="I/O Templates">
private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readLong() = readLn().toLong()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map(String::toInt)
private fun readLongs() = readStrings().map(String::toLong)
//</editor-fold>

fun main() {
    val (n, k) = readInts()
    val a = readInts()
    for (i in k until n) {
        println(if (a[i] > a[i - k]) "Yes" else "No")
    }
}

Measured memory_bytes: 68156
n,k=map(int,input().split())
s=input()
if s[k-1]=='A':
    print(s[:k-1]+'a'+s[k:])
elif s[k-1]=='B':
    print(s[:k-1]+'b'+s[k:])
else:
    print(s[:k-1]+'c'+s[k:])

Measured memory_bytes: 9084
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//最小公倍数を返す関数
int mcd(int n) {
	return 0;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}

vi vecint(1);
int main() {
	int n;
	ll sum = 0;
	cin >> n;
	vi nums(n);
	repz(i, n) {
		cin >> nums[i];
		sum += nums[i];
	}
	vi::iterator ir = max_element(nums.begin(), nums.end());
	size_t index = distance(nums.begin(), ir);
	ll maxNum = nums[index];
	ir = min_element(nums.begin(), nums.end());
	index = distance(nums.begin(), ir);
	ll minNum = nums[index];

	cout << minNum << " " << maxNum << " " << sum << endl;
	//system("pause");
	return 0;
}


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

using std::cin;
using std::cout;
using std::endl;


void TorT()
{
  int n, a, b;

  cin >> n >> a >> b;
  if (n * a > b) cout << b << endl;
  else           cout << n * a << endl;
}


void cross9_9()
{
  int a, b;

  cin >> a >> b;
  if (a > 0 && a < 10 && b > 0 && b < 10) cout << a * b << endl;
  else cout << -1 << endl;
}


void calculate_circle()
{
  int r;

  cin >> r;
  cout << r * r << endl;
}


void SvsM()
{
  int hp, a;
  int atk_cnt, rest;

  cin >> hp >> a;
  atk_cnt = hp / a;
  if (hp % a) atk_cnt++;
  cout << atk_cnt << endl;
}


void Poor3()
{
  int a, b, c;

  cin >> a >> b >> c;
  if (a == b && b != c) cout << "Yes" << endl;
  else if (b == c && c != a) cout << "Yes" << endl;
  else if (c == a && a != b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


void Algae()
{
  int r, d, x;
  
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i++)
  {
    x = r * x - d;
    cout << x << endl;
  }
}


void cross81()
{
  int n;
  int flag = 0;

  cin >> n;
  for (int i = 1; i < 10; i++)
  {
    for (int j = 1; j < 10; j++)
    {
      if (n == i * j)
      {
        flag = 1;
        cout << "Yes" << endl;
        break;
      }
    }
    if (flag) break;
  }
  if(!flag) cout << "No" << endl;
}


void bite_eating()
{
  int n, l;
  std::vector<int> taste;
  int sum = 0;
  int diff = 100;

  cin >> n >> l;
  for (int i = 0; i < n; i++)
  {
    taste.push_back(l + i);
    sum += taste[i];
    if (std::abs(taste[i]) < std::abs(diff)) diff = taste[i];
  }
  cout << sum - diff << endl;
}


int main()
{
  //TorT();
  //cross9_9();
  //calculate_circle();
  //SvsM();
  //Poor3();
  //Algae();
  //cross81();
  bite_eating();
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	int a =	sc.nextInt();
	int b =	sc.nextInt();
	int c =	sc.nextInt();
	int ab = a+b;
	int bc = b+c;
	int ca = c+a;
	int ans	= Math.min(ab,bc);
	System.out.println(Math.min(ans,ca));
    }
}

Measured memory_bytes: 21204
n = int(input())
s = [input() for i in range(3)]
cnt = 0
for i in range(n):
    if s[0][i] != s[1][i]:
        cnt += 1
    if s[2][i] != s[0][i] and s[2][i] != s[1][i]:
        cnt += 1
print(cnt)


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


class Point {
public:
  double x, y;
  Point(double x=0, double y=0) : x(x), y(y) {}
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
};

typedef Point Vector;

double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; }


Point p1, p2, p3, k, s;

bool isInTry(Point p) {
  double c1 = cross(p2 - p1, p - p1);
  double c2 = cross(p3 - p2, p - p2);
  double c3 = cross(p1 - p3, p - p3);
  return c1 * c2 > 0.0 && c2 * c3 > 0.0;
}

void solve() {
  bool f1 = isInTry(k);
  bool f2 = isInTry(s);
  if((!f1 || !f2) && (f1 || f2)) cout << "OK" << endl;
  else                           cout << "NG" << endl;
}

main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y
	>> k.x >> k.y >> s.x >> s.y;
    solve();
  }
}

Measured memory_bytes: 952
#include<stdio.h>
int main()
{
	long long tc;
	scanf("%lld",&tc);
	long long sum = 0;
	for(int i = 1;i<=tc;i++)
	{
		if(i % 3 != 0 && i % 5 != 0)
		{
			sum += i;
		}
	}
	printf("%ld\n",sum);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  bool pos = false;
  rep(i, n) rep(j, n) {
    vector<int> q(n);
    rep(k, n) q[k] = p[k];
    swap(q[i], q[j]);
    bool now = true;
    rep(k, n-1) if (q[k] > q[k+1]) now = false;
    if (now) pos = true;
  }
  if (pos) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3508
n, x = map(int, input().split())

l = list(map(int, input().split()))

f = [0] * (n + 1)

f[0] = 0
f[1] = 0

ans = 1
for i in range(1, n + 1):
	f[i] = f[i - 1] + l[i - 1]
	if f[i] > x:
		break
	ans += 1

print(ans) 



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

const int MAX_N = 2e5 + 5, inf = 1e9 + 7;
int n, A, B, ans = inf;
int Arr[MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> Arr[i];
		A += Arr[i];
	}

	for (int i = 0; i < n; i++) {
		B += Arr[i];
		ans = min(ans, abs(B - (A - B)));
	}

	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C,X,count;
    count =0;
    cin >> A>>B>>C>>X;
    for (int i = 0; i < C+1; i++)
    {
        for (int j = 0; j < B+1; j++)
        {
            for (int k = 0; k < A+1; k++)
            {
                if (50*i+100*j+500*k==X)
                {
                    count++;
                }
                
            }
            
        }
        
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
# 参考 http://fluffyowl.hatenablog.com/entry/2019/01/08/114131

N = int(input())
s = input()

MOD = 10**9 + 7

# dp[i][j] : 左からi番目の数値まで確定していて、最後に置いた値が未使用の値のうちj番目に小さい値 である場合の数(0-indexed)
dp = [[0]*N for _ in range(N)]
for i in range(N):
    dp[0][i] = 1 # 一番左は0からN-1まで1通りずつ

for i in range(1,N):
    if s[i-1] == ">": # dp[i-1][j]をdp[i][j-1],...,dp[i][0] に足す
        x = dp[i-1][N-i]
        for j in reversed(range(N-i)): # jが大きい要素から順に累積和を足す
            dp[i][j] += x
            dp[i][j] %= MOD
            x += dp[i-1][j]
            x %= MOD
    else: # dp[i-1][j]をdp[i][j],...,dp[i][N-i-1] に足す。dp[i][j]が含まれる点に注意
        x = dp[i-1][0]
        for j in range(N-i): # jが小さい要素から順に累積和を足す
            dp[i][j] += x
            dp[i][j] %= MOD
            x += dp[i-1][j+1]
            x %= MOD

print(dp[N-1][0]) # 最後に置く値は必ず0番目に小さいのでdp[N-1][0]以外のdp[N-1]の要素は0

Measured memory_bytes: 113884
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
///-------------------------

int main()
{
    Phuong_; /// <3333
    int n,m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    vector<ll> b(m);
    for(int i=0; i<n; ++i) {
        cin >> a[i];
        if(i) a[i]+=a[i-1];
    }
    for(int i=0; i<m; ++i){
        cin >> b[i];
        if (i) b[i]+=b[i-1];
    }
    int ans=0;
    int head = m-1;
    for(int i=0; i<n; ++i){
        if (a[i]>k) break;
        while (head >=0 && (b[head]+ a[i]>k)) head--;
        ans = max(ans, head+i+2);
    }
    head = n-1;
    for(int i=0; i<m; ++i){
        if (b[i]>k) break;
        while (head>=0 && (a[head] + b[i]>k)) head--;
        ans = max(ans, head+i+2);
    }
    cout << ans;
    return 0;
}


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

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

bool check(int X){
    int N = X/100;
    REP(i, N+1){  // おにぎり
        REP(j, N-i+1){  // サンドイッチ
            REP(k, N-i-j+1){  // クッキー
                REP(l, N-i-j-k+1){  // ケーキ
                    REP(m, N-i-j-k-l+1){  // 飴
                        REP(n, N-i-j-k-l-m+1){  // パソコン
                            if( 100*i + 101*j + 102*k + 103*l + 104*m + 105*n == X) return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}


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

    if(check(X)) cout << 1 << endl;
    else cout << 0 << endl;    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int x[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << x[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

void selectionSort(vector<int> &a)
{
	int cnt = 0;
	for (int i = 0; i < a.size(); i++)
	{
		int mini = i;
		for (int j = i + 1; j < a.size(); j++)
		{
			if (a.at(j) < a.at(mini))
			{
				mini = j;
			}
		}

		if (a.at(i) > a.at(mini))
		{
			swap(a.at(i), a.at(mini));
			cnt++;
		}
	}

	for (int i = 0; i < a.size(); i++)
	{
		cout << a.at(i) << (i == a.size() - 1 ? "" : " ");
	}
	cout << endl;
	cout << cnt << endl;
}

int main()
{
	int n;

	vector<int> a;

	for (cin >> n; n--;)
	{
		int x;
		cin >> x;

		a.push_back(x);
	}

	selectionSort(a);
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1e9 + 7;
const int MAX = 510000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
ll COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  COMinit();
  for (int i = 1; i <= K; i++) {
    ll ans = COM(N - K + 1, i) * COM(K - 1, i - 1);
    ans %= MOD;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int main(){int i,n,s,e,k;
long long int sum=0;
cin>>n;
//sum=n;
int cnt[10][10];
memset(cnt,0,sizeof(cnt));
for(i=1;i<=n;i++){
    k=i;
    e=k%10;
    while(k>=10){k=k/10;}
    s=k;
    cnt[s][e]++;
    sum+=2*cnt[e][s];
    if(s==e){sum--;}
 //   cout<<cnt[e][s]<<" ";
}cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include<cmath>

using namespace std;

int main()
{
  int a,b;
  cin>>a>>b;
  if(a==b)
  cout<<a;
  if(a<b)
  cout<<a;
  if(a>b)
  cout<<a-1;
 
  
    return 0;
}

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

const int MAX_N = 5e6+10;
string s;
int le[MAX_N], ri[MAX_N];

void solve()
{
	const int n = s.length();
	for(int i=0;i<n;++i){
		if(s[i] == '<') le[i+1]=max(le[i+1], le[i]+1);
		else le[i+1] = 0;
	}
	for(int i=n-1;i>=0;--i){
		if(s[i] == '>') ri[i]=max(ri[i],ri[i+1]+1);
		else ri[i] = 0;
	}
	ll ans = 0;
	for(int i=0;i<=n;++i) ans+=max(le[i],ri[i]);
	cout<<ans;
}

int main()
{
	cin >> s;
	solve();
	return 0;
}

Measured memory_bytes: 7852
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,p=0;cin>>n>>m;
  vector<int>a(m);
  for(int i=0;i<n;i++){
    int k;cin>>k;
    for(int j=0;j<k;j++){
      int b;cin>>b;
      a.at(b-1)++;
    }
  }
  for(int i=0;i<m;i++){
    if(a.at(i)==n)p++;
  }
  cout<<p<<endl;
}
  
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
using namespace std;
int main(){
    string s;
    int w;
    cin>>s>>w;
    for(int i=0;i<=s.size()-1;i+=w){
        cout<<s.substr(i,w)[0];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//小さい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return aNum - bNum;}

long long _gcd(long long a,long long b){
    long long c;
    while(b!=0){c=a%b;a=b;b=c;}
    return a;
    
}
long long _lcm(long long a,long long b){long long c=_gcd(a,b);a/=c;return a*b;}

int main(void){
    long long N;
    long long min=10000000000000;
    scanf("%lld",&N);
    for(long long i=1;i<=sqrt(N);i++){
        long long temp=0;
        if(N%i==0){
            temp=i+N/i;
            if(temp<min){
                min =temp;
            }
        }
    }
    printf("%lld",min-2);
}
    


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int n,i,j,check=0;
  scanf("%d",&n);
  for(i=1;i<10;i++)
    for(j=i;j<10;j++)
      if(n==i*j)
        check=1;
  if(check==1)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = 1e9 + 7;

int d, t, s;

int main()
{
  ios::sync_with_stdio(0); cin.tie(0);
  cin >> d >> t >> s;
  if (t * s >= d) cout << "Yes\n";
  else cout << "No\n";
  //system("pause");
  return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long
#define ull unsigned long long

ll digitpower(ll a,ull b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  static int modmode=0;//%d9_7するのかどうか
  if(b%2==1){
    ll tmp = digitpower(a,(b-1)/2);
    if(modmode==1){
      tmp%=d9_7;
    }
    tmp*=tmp;
    if(modmode==1){
      tmp%=d9_7;
    }
    tmp*=a;
    if(modmode==1){
     return (tmp)%d9_7;
    }else{
      return tmp;
    }
  }else{
    ll tmp = digitpower(a,(b)/2);
    if(modmode==1){
      tmp%=d9_7;
    }
    tmp*=tmp;
    if(modmode==1){
      tmp%=d9_7;
    }
    if(modmode==1){
      return (tmp)%d9_7;
    }
    return tmp;
  }
}
template<class T>
class SegmentTree{
  public:
   int n;
   vector<T> nodes;
    //constructor
    SegmentTree(int size,T init){
      initialize(size,init);
    }
    //関数を定義(minなのかmaxなのかとか)
    T thisoperator(T a, T b){
      return a+b;
    }
    void update(int x,T a){//xがindex
      x+=n-1;
      nodes[x]+=a;
      while(x>0){
        x=(x-1)/2;
        nodes[x]=thisoperator(nodes[2*x+1],nodes[2*x+2]);
      }
    }
   void initialize(int inputn,T init){
      int k=0;
      while(inputn>digitpower(2,k)){
        k++;
      }
      n=digitpower(2,k);
      nodes=vector<T> (digitpower(2,k)*2-1,init);
   }
   T sec_get(int reql,int reqr,int nowindex=0,int nowl=0,int nowr=-1){
     // 最初に呼び出されたときの対象区間は [0, n)
    if(nowr < 0) nowr = n;

    // 要求区間と対象区間が交わらない -> 適当に返す
    if(nowr <= reql || reqr <= nowl) return 0;

    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    if(reql <= nowl && nowr <= reqr) return nodes[nowindex];
    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    T val1 = sec_get(reql, reqr, 2*nowindex+1, nowl, (nowl+nowr)/2);
    T val2 = sec_get(reql, reqr, 2*nowindex+2, (nowl+nowr)/2, nowr);
    return thisoperator(val1, val2);
   }
   void Printn(){
     cout<<"Printvector"<<endl;
     rep(i,n){
       cout<<nodes[i+n-1]<<" ";
     }
     cout<<endl;
   }
};

int main(void){
  int n,q;
  cin>>n>>q;
  SegmentTree<ll> seg(n,0);
  vl c1(q),c2(q),c3(q);
  rep(i,q){
    cin>>c1[i]>>c2[i]>>c3[i];
  }
  rep(i,q){
    ll com=c1[i],x=c2[i],y=c3[i];
    if(com==0){
     // x--;
      seg.update(x-1,y);
    }else{
      //x--;y--;
      cout<<seg.sec_get(x-1,y)<<endl;
    }
    //seg.Printn();
  }
  return 0;
}



Measured memory_bytes: 7100
N, T = list(map(int,input().split()))
L1 = [list(map(int,input().split())) for _ in range(N)]
L2 = []
for i in L1:
    if i[1] <= T:
        L2.append(i)
if len(L2) == 0:
    print('TLE')
else:
    cost = []
    for i in L2:
        cost.append(i[0])
    print(min(cost))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

bool judge_bigger(int x,int p,vint A,int m,int n,int v){
  if(x < p) return true;
  int key = A[x] + m;
  if(A[p-1] > key) return false;
  int sum = 0;
  sum += (p-1)*m;
  sum += (n-x)*m;
  rep(i,p-1,x){
    sum += min(m,key-A[i]);
  }
  return sum >= v*m;
}

signed main(){
  int n,m,v,p;
  cin >> n >> m >> v >> p;
  vint A(n);
  rep(i,0,n) cin >> A[i];
  sort(A.rbegin(),A.rend());
  int ok = -1;
  int ng = n;
  while(abs(ok - ng) > 1){
    int mid = (ok + ng)/2;
    if(judge_bigger(mid,p,A,m,n,v)){
      ok = mid;
    }
    else{
      ng = mid;
    }
  }
  cout << ok + 1 << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll max(ll a,ll b){
    if(a>b)
    return a;
    return b;
}
ll knapsack(vector<ll> v,vector<ll> w,ll n,ll wt){
  ll k[n+1][wt+1];
  for(ll i=0;i<=n;i++){
    for(ll j=0;j<=wt;j++){
      if(j==0||i==0)
      k[i][j]=0;
      else if(w[i-1]<=j){
        k[i][j]=max(k[i-1][j],v[i-1]+k[i-1][j-w[i-1]]);
      }
      else
      k[i][j]=k[i-1][j];
    }
  }
  return k[n][wt];
}
int main(){
  ll n,wt;
  cin>>n>>wt;
  vector<ll>v(n,0);
  vector<ll>w(n,0);
  for(int i=0;i<n;i++){
  cin>>w[i]>>v[i];
}

  ll ans=knapsack(v,w,n,wt);
  cout<<ans<<endl;
  return 0;
}


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

void solve(long long K, long long S){
  long long ans = 0;
        for ( long long i = 0; i <= K; i++ ) {
    for ( long long k = 0; k <= K; k++ ) {
      long long z = S - i - k;
      if ( 0 <= z && z <= K ) { ans++; }
    }
  }
  printf("%lld\n", ans);
}

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

Measured memory_bytes: 256
#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()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
int main(){
	int n,t;
	std::cin >> n>>t;
	std::vector<int> a(n);
	rep(i,n)std::cin >> a[i];
	std::set<int,greater<int>> s;
	rep(i,n)s.insert(a[i]);
	int max=0,counter=0;
	rep(i,n){
		int dum=*s.begin();
	//	std::cout << dum << std::endl;
	//	std::cout << dum-a[i] << std::endl;
		if(dum-a[i]>max){
			max=dum-a[i];
			counter=1;
		}else if(dum-a[i]==max)counter++;
		s.erase(a[i]);
	}
	std::cout << counter << std::endl;
}

Measured memory_bytes: 5376
#include <iostream>
#include <math.h>
#include <set>
using namespace std;
int main()
{
	int i,j,k,X,N;
	cin>>X>>N;
	set <int> check;
	
//	int A[N];
	for(i=0;i<N;i++)
	{
		cin>>j;
		check.insert(j);
	}
	int m=10000;
	int z=200000;
	for(i=0;i<=101;i++)
	{
		if(check.find(i)==check.end())
		{
		j=abs(i-X);
		if(m>j)
		{
			m=j;
			z=i;
		}
		}
	}
	cout<<z;
	return 0;
}

Measured memory_bytes: 3632
N,*A  =map(int,open(0).read().split())

L = [0 for i in range(int(1e5)+1)]

for a in A:
  L[a]+=1

ans = 0
for i in range(int(1e5)+1):
  S = sum(L[i:i+3])
  if ans < S:
    ans = S
  
print(ans)

Measured memory_bytes: 20212
#include <cstdio>
#include <deque>
using namespace std;
int len,ans;
char ch[200005];
deque<int>v;
int main(){
	scanf("%d%s",&len,ch);
	for(int i=0;i<len;++i){
		if(ch[i]=='R')v.push_back(i);
	}
	for(int i=0;i<len;++i){
		if(v.empty())break;
		if(v[0]<i)v.pop_front();
		if(v.empty())break;
		if(ch[i]=='W'){
			v.pop_back();
			++ans;
		}
		if(v.empty())break;
	}
	printf("%d\n",ans);
	return 0;
}

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

const int MOD = 1e9+7;
const int MAX = 2e5;

vector<long long> fac(MAX), finv(MAX), inv(MAX);

int main() {
  int n, k; cin >> n >> k;
  k--;
  string S;
  cin >> S;
  if(S.at(k) == 'A') S.at(k) = 'a';
  else if(S.at(k) == 'B') S.at(k) = 'b';
  else if(S.at(k) == 'C') S.at(k) = 'c';
  
  cout << S << endl;
}

Measured memory_bytes: 4992
A, B, C, K = map(int, input().split())
# A 1が書かれている
# B 0が書かれている
# C -1が書かれている
# K 枚選ぶ
if K <= A:
    print(K)
elif K <= A+B:
    print(A)
else:
    minus = K-A-B
    print(A-minus)


Measured memory_bytes: 9156
n = int(input())
s = input()
e = [0 for i in range(n)]
w = [0 for i in range(n)]
ee = 0
ww = 0
for i in range(n):
	w[i] = ww
	if s[i] == "E":
		ee += 1
	else:
		ww += 1
	e[i] = ee
ec = s.count("E")
wc = s.count("W")
ans = 10**6
c = 0
for i in range(n):
	c = ec - e[i] + w[i]
	ans = min(c,ans)
print (ans)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N; cin >>N;
    vector<int> L(N); cin >> L;

    int Lmax = *max_element(ALL(L));
    int Lsum = accumulate(ALL(L),0); //cout<<FMT2(Lmax,Lsum)<<endl;
    
    Yes(Lmax<Lsum-Lmax);
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    using namespace std;
    string a, b, c;
    cin >> a >> b >> c;
    
    uint32_t sa, sb, sc;
    sa = sb = sc = 0;
    
    uint32_t turn = 0;
    char winner;
    
    while (true)
    {
        char card;
        if (turn == 0) {
            if (a.length() > sa) {
                card = a[sa];
                sa += 1;
            } else {
                winner = 'A';
                break;
            }
        } else if (turn == 1) {
            if (b.length() > sb) {
                card = b[sb];
                sb += 1;
            } else {
                winner = 'B';
                break;
            }
        } else {
            if (c.length() > sc) {
                card = c[sc];
                sc += 1;
            } else {
                winner = 'C';
                break;
            }
        }
        
        if (card == 'a') {
            turn = 0;
        } else if (card == 'b') {
            turn = 1;
        } else {
            turn = 2;
        }
    }

    cout << winner << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

VI adj[101010];
int color[101010];
int color2[101010];

void depth(int i, int d) {
    if (color[i] != -1) return;
    color[i] = d;
    for (int a: adj[i]) {
        depth(a, d + 1);
    }
}

void depth2(int i, int d) {
    if (color2[i] != -1) return;
    color2[i] = d;
    for (int a: adj[i]) {
        depth2(a, d + 1);
    }
}


int initb, initw;

void c(int i, int v) {
    if (((i == 0 && v != initb) || (i == 1 && v != initw)) && color[v] != -1) return;
    color[v] = i;
    for (int a: adj[v]) {
        if (color[a] == -1) {
            c(i, a);
        }
    }
}

int main() {
    int n;
    cin >> n;
    
    REP(i,101010) color[i] = -1;
    REP(i,101010) color2[i] = -1;
    REP(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    
    depth(0,0);
    depth2(n-1,0);
    int d = color[n-1];
    REP(i,101010) {
        if (color[i] == d / 2 && color2[i] == d - d / 2) initb = i;
        if (color[i] == d / 2 + 1 && color2[i] == d - (d / 2 + 1)) initw = i;
    }
    
    REP(i,101010) color[i] = -1;
    color[initb] = 0;
    color[initw] = 1;
    c(0, initb);
    c(1, initw);
    
    int cntb = 0, cntw = 0;
    REP(i,101010) {
        if (color[i] == 0) cntb++;
        else if (color[i] == 1) cntw++;
    }
    
    if (cntb > cntw) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }
}


Measured memory_bytes: 9600
N = gets.to_i

# $stdout = File.open(File::NULL, "w")

def main
  max = 10 ** 9 + 7
  all = 1
  zero = 1
  nine = 1
  zn = 1
  N.times.each do
    all = all * 10 % max
    zero = zero * 9 % max
    nine = nine * 9 % max
    zn = zn * 8 % max
  end
  return (all - zero - nine + zn) % max
end

STDOUT.puts main


Measured memory_bytes: 14356
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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 a,b,c; cin>>a>>b>>c;
  if(a+b+c>=22) cout<<"bust"<<endl;
  else cout<<"win"<<endl;
  return 0;
}


Measured memory_bytes: 3604
from decimal import Decimal
import math

N = int(input())

T, A = map(Decimal, input().split())

for i in range(1, N):
    t, a = map(Decimal, input().split())
    td = math.ceil(T / t)
    ad = math.ceil(A / a)

    if td < ad:
        T = t * ad
        A = a * ad
    else:
        T = t * td
        A = a * td

print(T + A)

Measured memory_bytes: 84592
#include<stdio.h>
int main(void){
	int n;
	double w,t;
	while(scanf("%d,%lf,%lf",&n,&w,&t)!=EOF){
	
	
	
	double bmi=w/(t*t);
	if(bmi>=25)printf("%d\n",n);
	}
	return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << max({a*2-1, b*2-1, a+b}) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int ans = 0;
            for (int i = 1; i <= n; ++i) {
                int cur = i;
                int count = 0;
                for (int j = 1; j * j <= cur; ++j) {
                    if (cur % j == 0) {
                        ++count;
                        if (j != cur / j) ++count;
                    }
                }
                if (count == 8 && i % 2 == 1) ++ans;
            }
            out.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        private int pread() {
            if (pnumChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= pnumChars) {
                curChar = 0;
                try {
                    pnumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (pnumChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = pread();
            while (isSpaceChar(c))
                c = pread();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = pread();
            }
            int res = 0;
            do {
                if (c == ',') {
                    c = pread();
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = pread();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



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

void print(int *,int *,int,int);
int Calc(int,int,int,int *);

int main()
{
  int n1,*A,n2,*Q,i;
  
  scanf("%d",&n1);

  A = (int *)malloc(n1 * sizeof(int));

  for(i=0;i<n1;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&n2);

  Q = (int *)malloc(n2 * sizeof(int));

  for(i=0;i<n2;i++){
    scanf("%d",&Q[i]);
  }

  print(A,Q,n2,n1);
  
  free(A);
  free(Q);

  return 0;
}

void print(int *A,int *Q,int n2,int n1)
{
  int i;
  
  for(i=0;i<n2;i++){
    if(Calc(0,Q[i],n1,A)==0) printf("no\n");
    else printf("yes\n");
  }
}

  
int Calc(int i,int Q,int n1,int *A)
{
  int res;
  
  if(Q==0) return 1;
  if(i>=n1) return 0;

  res = Calc(i+1,Q,n1,A)+Calc(i+1,Q-A[i],n1,A);

  return res;
}



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

int main() {
  int A,P;
  int ans = 0;
  cin >> A >> P;
  if(!(A == 0 && (P == 1 || P == 0))){
    while(A > 0){
      A--;
      P += 3;
    }
    while(P > 1){
      P -= 2;
      ans++;
    }
  }
  cout << ans << endl;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

struct board{
  int b[16];
  int c;
  int m;
  int bl;
  int prev;
  board(int *v, int c, int m, int bl, int p): c(c), m(m), bl(bl), prev(p){ REP(i,16) b[i]=v[i]; }
};

bool operator< (board b1, board b2){
    return ((b1.c+b1.m > b2.c+b2.m) ? true : false);
}

int dist(int a, int b){
  return abs(a%4-b%4)+abs(a/4-b/4);
}

int main(){
  int org[16];
  int blank = 0;
  int cost = 0;
  priority_queue<board> pq;
  REP(i, 16) { cin >> org[i]; org[i]--; if(org[i]==-1) { org[i]=15; blank=i; } else cost+=dist(org[i],i); }
  pq.push(board(org, cost, 0, blank, 100));
  int res = 100;
  board target = pq.top();
  while(true){
    target = pq.top();
    pq.pop();
    if(target.c==0) {res = target.m+target.c; break;}
    REP(i, 4){
      if(abs(target.prev-i)==2) continue;
      int c_x = target.bl%4+dx[i]; int c_y = target.bl/4+dy[i];
      if(c_x<0 || c_x>3 || c_y<0 || c_y>3 ) continue;
      int cand = c_x+4*c_y;
      int d = dist(target.b[cand], target.bl) - dist(target.b[cand], cand);
      if(d>1) continue;
      if(target.c+d+target.m+1>45) continue;
      swap(target.b[cand], target.b[target.bl]);
      pq.push(board(target.b, target.c+d, target.m+1, cand, i));
      swap(target.b[cand], target.b[target.bl]);
    }
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 84776
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define lli long long int
#define test                lli t;cin>>t;while(t-->0)
#define ainput  int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define vec vector<lli>v;
vec
#define avinput  int n;cin>>n;int a[n];for(int i=0;i<n;i++){cin>>a[i];v.push_back(a[i]);}
#define vp  for(lli i=0;i<v.size();i++) {cout<<v[i]<<" ";}cout<<endl;
#define vp1  for(lli i=0;i<v1.size();i++) {cout<<v1[i]<<" ";}cout<<endl;
#define vp2  for(lli i=0;i<v2.size();i++) {cout<<v2[i]<<" ";}cout<<endl;
#define vp3  for(lli i=0;i<v3.size();i++) {cout<<v3[i]<<" ";}cout<<endl;
#define vp6  for(lli i=0;i<v6.size();i++) {cout<<v6[i].first<<" "<<v6[i].second<<endl;}
#define vp16  for(lli i=0;i<v16.size();i++) {cout<<v16[i].first<<" "<<v16[i].second<<endl;}
#define ln cout<<endl;
  //cout << fixed << setprecision(10) <<((double)((sum*1.0)/((n*1.0-k*1.0)+1.0))) << endl;
set<lli>s1;
set<lli>s2;
set<string>st2;
vector<lli>v1;
vector<lli>v2;
vector<lli>v3;
vector<lli>v4;
vector<lli>v5;
vector<pair<lli,lli> >v6;
vector<pair<lli,lli> >v16;
vector<string>v7;
vector<string>v8;
vector<char>v9;
vector<double>v11;
list<lli>l;
//****coding start****

int main()
{
    lli n;
 cin>>n;
    lli a[n];
    for(lli i=0;i<n;i++){
        cin>>a[i];
    }
    lli g=a[0];
    for(lli i=0;i<n;i++){
        g=__gcd(g,a[i]);
    }
    cout<<g<<endl;
    return 0;
}

Measured memory_bytes: 4360
#include<cstdio>
const int MAXN = 2e5 + 5;
int n, a[MAXN];
int main(){
    scanf("%d", &n);
    char c = getchar();
    while(c != 'W' && c != 'R')
        c = getchar();
    int sum = 0;
    for(int i = 1; i <= n; ++ i)
        a[i] = c == 'W' ? 1 : 2,
        sum += (a[i] == 2),
        c = getchar();
    int cnt = 0;
    for(int i = 1; i <= sum; ++ i)
        if(a[i] == 1)
            ++ cnt;
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 2496