akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int x;
    cin>>x;
    int a=100;
    int ans=0;
    while(a<x)a*=1.01,ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3668
n,k = map(int,input().split())
a = list(map(int,input().split()))
N =[0 for i in range(n)]
s = 1
cnt = 0
b = []
while True:
    if N[s-1]==1:
        rep = b.index(s)
        t = cnt-rep
        if k-rep <0:
          print(b[k])
          break
        else:
          num = (k-rep)%t
          print(b[rep+num])
          break
    else:
        b.append(s)
        N[s-1] = 1
        s = a[s-1] 
        cnt +=1


Measured memory_bytes: 32380
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]>i+1 and a[a[i]-1]==i+1)ans++;
    }
    cout<<ans<<endl;
 return 0;   
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w;
    cin>>h>>w;
    ll a[h+1][w+1];
    for(ll i=1;i<=h;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            cin>>a[i][j];
        }
    }
    vector<pair<ll,ll>>v1;
    for(ll i=1;i<=h;i++)
    {
        for(ll j=1;j<w;j++)
        {
            if(a[i][j]%2==1)
            {
                v1.push_back(make_pair(i,j));
                a[i][j]-=1;
                a[i][j+1]+=1;
            }
        }
    }
    vector<pair<ll,ll>>v2;
    for(ll i=1;i<h;i++)
    {
        //cout<<a[i][w]<<endl;
        if(a[i][w]%2==1)
        {
            a[i][w]-=1;
            a[i+1][w]+=1;
            v2.push_back(make_pair(i,w));
        }
    }
    cout<<v1.size()+v2.size()<<endl;
    for(pair<ll,ll>i:v1)
    {
        cout<<i.first<<" "<<i.second<<" "<<i.first<<" "<<i.second+1<<endl;
    }
    for(pair<ll,ll>i:v2)
    {
        cout<<i.first<<" "<<i.second<<" "<<i.first+1<<" "<<i.second<<endl;
    }
}

Measured memory_bytes: 6128
import sys
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
dif=[]
if m<=n:
  print(0)
  sys.exit()
else:
  for i in range(m-1):
    dif.append(x[i+1]-x[i])
  dif.sort(reverse=True)
  ans=x[m-1]-x[0]
  for j in range(n-1):
    ans-=dif[j]
  print(ans)
  


Measured memory_bytes: 13968
x=input()
l=[x[0]]
for i in range(1,len(x)):
    if l!=[]:
        if l[-1]=="S":
            h=1
        else:
            h=0
    l.append(x[i])
    if len(l)!=1:
        if l[-1]=="T":
            if h==1:
                l.pop(-1)
                l.pop(-1)
                if l!=[]:
                    h=(0 if l[-1]=="T" else 1)
                else:
                    h=0
            else:
                h=0
        else:
            h=0
print(len(l))

Measured memory_bytes: 4864
import scala.io.StdIn._
object Main extends App {

  def solve(n: Int, res: List[String]): List[String] = {
    if (n == 0) res
    else {
      n % 2 match {
        case 0 => solve(n / -2, "0" :: res)
        case _ => solve((n - 1) / -2, "1" :: res)
      }
    }
  }
  val ans = solve(readInt, Nil)

  println(if (ans.isEmpty) "0" else ans.mkString)
}


Measured memory_bytes: 27312
#include <bits/stdc++.h>
using namespace std;
typedef struct node
{
	long long a[51][51];
	long long scale;
	struct node operator *(const struct node & tmp)
	{
		struct node ret;
		long long i,j,k;
		ret.scale=scale;
		memset(ret.a,0,sizeof(ret.a));
		for(k=1;k<=scale;k++)
			for(i=1;i<=scale;i++)
				for(j=1;j<=scale;j++)
					ret.a[i][j]=(ret.a[i][j]+a[i][k]*tmp.a[k][j])%1000000007;
		return ret;
	}
}NODE,*PNODE;
NODE g,ans;
long long p=0;
int main()
{
	long long n,i,j,k,flag=0;
	scanf("%lld %lld",&n,&k);
	g.scale=n;
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			scanf("%d",&g.a[i][j]);
	while(k)
	{
		if(k%2)
		{
			if(!flag)
			{
				ans=g;
				flag=1;
			}
			else
				ans=ans*g;
		}
		g=g*g;
		k/=2;
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(ans.a[i][j])
				p=(p+ans.a[i][j])%1000000007;
	printf("%lld",p);

}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int count5 = 0;
    int count7 = 0;
    for (int i = 0; i < 3; i++) {
        int x;
        cin >> x;
        if (x == 5) {
            count5++;
        } else if (x == 7) {
            count7++;
        }
    }
    if (count5 == 2 && count7 == 1) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

Measured memory_bytes: 256
def two(n):
  ans = 0
  while(n != 1):
    if n%2 == 0:
      ans += 1
      n = n//2
    else:
      return ans
  return ans
N = int(input())
a = [int(i) for i in input().split()] 
ans = 0
for i in a:
  ans += two(i)
print(ans)

Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
ll a[200003];
ll b[2003];
bool vis[1009][1009];
struct threeElements{
int f,s,t;
};
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   string s;
   cin>>s;
   if(s=="ABC")
    cout<<"ARC";
   else
    cout<<"ABC";
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define INF 1e9
#define MAXN 100010
using namespace std;
int v[MAXN],s1[MAXN],s2[MAXN];
int read()
{
	int s=0,fh=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')fh=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+(ch-'0');ch=getchar();}
	return s*fh;
}
int main()
{
	int n,i,z1,z2,ans,tot;
	n=read();
	for(i=1;i<=n;i++)v[i]=read();
	for(i=1;i<=n;i+=2)s1[v[i]]++;
	for(i=2;i<=n;i+=2)s2[v[i]]++;
	z1=0;z2=0;s2[0]=0;
	for(i=1;i<=100000;i++)
	{
		if(s2[i]>s2[z1])
		{
			z2=z1;z1=i;
		}
		else
		{
			if(s2[i]>s2[z2])z2=i;
		}
	}
	ans=INF;
	for(i=1;i<=100000;i++)
	{
		tot=0;tot+=((n/2)-s1[i]);
		if(i==z1)
		{
			tot+=((n/2)-s2[z2]);
		}
		else tot+=((n/2)-s2[z1]);
		ans=min(ans,tot);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1408
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0
for d in range(A+1):
  for e in range(B+1):
    for f in range(C+1):
      total = 500*d + 100*e +50*f
      if total == X:
      	count +=1

print(count)

Measured memory_bytes: 3060
// クイックソート
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100000
//const int INFTY = 2147483647;

typedef struct card
{
    char picture;
    int number;
}CARD;

int partition(CARD A[], int p, int r);
void quickSort(CARD A[], int p, int r);

int main(void)
{

    int n;
    CARD st_card[MAX_N], st_card_copy[MAX_N];

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> st_card[i].picture >> st_card[i].number;

        st_card_copy[i].picture = st_card[i].picture;
        st_card_copy[i].number = st_card[i].number;
    }

    quickSort(&st_card[0], 0, n - 1);

    // -----▼▼▼▼▼ 安定なソートなのかを確認 ▼▼▼▼▼-----

    int num_1, num_2;
    char stable[] = "Stable\n";
    char not_stable[] = "Not stable\n";
    char *str = &stable[0];

    for(int i = 0; i < n; i++)
    {
        if( st_card[i].number == st_card[i + 1].number )
        {
            for(int j = 0; j < n; j++)
            {
                if( ( st_card[i].picture == st_card_copy[j].picture )
                    && ( st_card[i].number == st_card_copy[j].number ) )
                {
                    num_1 = j;
                }

                if( ( st_card[i + 1].picture == st_card_copy[j].picture )
                    && ( st_card[i + 1].number == st_card_copy[j].number ) )
                {
                    num_2 = j;
                }
            }

            if( num_1 > num_2 )
            {
                str = &not_stable[0];
                // 処理終了
                break;
            }
        }
    }

    // -----▲▲▲▲▲ 安定なソートなのかを確認 ▲▲▲▲▲-----

    printf("%s", str);

    for(int i = 0; i < n; i++)
    {
        printf("%c %d\n", st_card[i].picture, st_card[i].number);
    }

    return 0;
}

// クイックソートを実施する関数
// p : 範囲の先頭
// q : 範囲の最後尾
void quickSort(CARD A[], int p, int r)
{
    int q;

    if( p < r )
    {
        // パーティション ソート で, インデックスを求める
        q = partition(A, p, r);
        // 前半の部分配列に対して, クイックソートする
        quickSort(A, p, q - 1);
        // 後半の部分配列に対して, クイックソートする
        quickSort(A, q + 1, r);
    }

    return;
}

// パーティション ソート の実施
// A[r]を基準として, 小さい要素は左側, 大きい要素は右側に並ぶ
// p : 範囲の先頭
// q : 範囲の最後尾
int partition(CARD A[], int p, int r)
{
    int i = 0;
    CARD x, tmp;

    x = A[r];
    i = p - 1;

    for(int j = p; j < r; j++)
    {
        if( A[j].number <= x.number )
        {
            i++;

            // A[i] と A[j]を交換
            tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }

    // A[i + 1] と A[r]を交換
    tmp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = tmp;

    return i + 1;
}



Measured memory_bytes: 4620
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	hs := make([]int, n)
	for i := range hs {
		fmt.Scan(&hs[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(hs)))
	var sum int
	for i := range hs {
		if i >= k {
			sum += hs[i]
		}
	}

	fmt.Println(sum)
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int m,d;
    cin >> m >> d;
    int ans = 0;
    if(m<4||d<21)ans = 0;
    else{
        for(int i=22;i<=d;i++){
            int num1 = i%10;
            int num10 = i/10;
            if(num1>=2&&num10>=2&&num1*num10<=m)ans++;
        }
    }
    COUT(ans);
    return 0;
}

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

int a[500+50];
int x[100000+50],l[100000+50];
vector <pair <int,int> > v;

// bool cmp(pair <int,int> v1, pair <int,int> v2){

// }
signed main(){
    ios::sync_with_stdio(false);
    
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i]>>l[i];
		v.push_back({x[i]-l[i],x[i]+l[i]});
	}
	sort(v.begin(),v.end());

	int rbnd=-1000000000000000;


	int cnt=0;

	for(int i=0;i<n;i++){
		if(v[i].first>=rbnd){
			cnt++;
			rbnd=max(rbnd,v[i].second);
		}
		else{
			rbnd=min(rbnd,v[i].second);
		}
	}

	cout<<cnt;

}
/*

Mistakes to take care of-

1. For string s, s+=a is similar to appending to s. s = s + a takes O|s| + O|a| time. 
Relevant problem where I made mistake - https://codeforces.com/contest/1326/problem/D2

2. Try using constant value of N to declare arrays, etc. Else you might get hacked / FST.
Relevant problem where I made a mistake - https://codeforces.com/contest/1307/problem/D

3. While exponentiation, avoid modding the exponent. Or mod with mod-1.
Relevant problem where I made a mistake - https://codeforces.com/contest/1332/problem/E

4. modulo operator (%) in c++ returns the sign of the divisor.
Eg. (-1%8) = -1
Relevant problem where I made a mistake - https://codeforces.com/contest/1345/submission/79809463
*/


Measured memory_bytes: 3568
#include <stdio.h>
int main()
{
	int a, b, c, di=0;
	scanf("%d %d %d", &a, &b, &c);
	int i;
    for(int i=a; i <= b; i++)
	{
		if(c % i == 0)
		{
			di++;
		} 
		
	}
    printf("%d\n", di);
	return 0;
} 


Measured memory_bytes: 2100
import fractions
import numpy as np

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= np.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True

a, b = map(int, input().split())

gcd = fractions.gcd(a, b)

yakusu = make_divisors(gcd)

num = 0
for i in yakusu:
    if i == 1:
        num += 1
    elif is_prime(i):
        num += 1

print(num)

Measured memory_bytes: 13772
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    ll n,k;
    cin >> n >> k;
    ll div = k;
    ll tmp = n,tmp2=0;
    int cnt = 0;

    while(tmp != 0){
        tmp2 = tmp % div;
        // cout << tmp2 << endl;
        div *= k;
        tmp -= tmp2;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
  if (ch == 'A')
    return 1;
  else if (ch == 'C')
    return 2;
  else if (ch == 'G')
    return 3;
  else if (ch == 'T')
    return 4;
  else
    return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {
  int i, n, h;
  char str[L], com[9];
  for (i = 0; i < M; i++) H[i][0] = '\0';
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s %s", com, str);

    if (com[0] == 'i') {
      insert(str);
    } else {
      if (find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 17060
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
a=b=c=0
if h%2and w%2:
    a=h//2*(w//2)
    c=1
    b=(h*w-a*4-c)//2
elif h%2or w%2:
    a=h//2*(w//2)
    b=(h*w-a*4)//2
else:
    a=h*w//4
l=[]
for i in set(s.replace('\n','')):
    l.append(s.count(i))
for i in l:
    if i>3:
        while i>3and a:
            i-=4
            a-=1
    if i>1:
        while i>1and b:
            i-=2
            b-=1
    if i and c:
        i-=1
        c-=1
if all(not t for t in(a,b,c)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {
            int n = Integer.parseInt(in.readLine());

            int[] fib = new int[50];
            fib[0] = 1;
            fib[1] = 1;
            for (int i = 2; i <= n; i++) {
                fib[i] = fib[i - 1] + fib[i - 2];
            }

            System.out.println(fib[n]);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll mod_pow(ll a,ll n){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll fac[500010],finv[500010];

ll comb(ll n,ll r){
  if(n<0||r<0||n<r)return 0;
  else return (fac[n]*finv[n-r]%mod)*finv[r]%mod;
}

ll N,A,B,C;

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

  fac[0]=1;
  rep(i,500000)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,500001)finv[i]=mod_pow(fac[i],mod-2);

  cin>>N>>A>>B>>C;
  ll pa=A*mod_pow(A+B,mod-2)%mod;
  ll pb=B*mod_pow(A+B,mod-2)%mod;
  ll pc=100*mod_pow(100-C,mod-2)%mod;

  ll res=0;
  repl(i,N,2*N){
    //ll w=(pa+pb)%mod;
    {
      ll twin=N-1;
      ll awin=i-twin-1;
      ll prob=(comb(i-1,N-1)*mod_pow(pa,twin+1)%mod)*mod_pow(pb,awin)%mod;
      res+=(prob*i%mod)%mod;
      res%=mod;
    }
    {
      ll awin=N-1;
      ll twin=i-awin-1;
      ll prob=(comb(i-1,N-1)*mod_pow(pb,awin+1)%mod)*mod_pow(pa,twin)%mod;
      res+=(prob*i%mod)%mod;
      res%=mod;
    }
  }
  res*=pc;
  res%=mod;
  cout<<res%mod<<endl;

  return 0;
}


Measured memory_bytes: 8064
#abc113b

n=int(raw_input())
t,a=map(int,raw_input().split())
h=map(int,raw_input().split())
m=[]
for i in xrange(n):
 m.append(abs(1.0*(t-a-h[i]*0.006)))
res=[i for i, x in enumerate(m) if x == min(m)]
print res[0]+1


Measured memory_bytes: 2820
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            y = 500*i + 100*j + 50*k
            if y == x:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int main(){
  	int a,b,h,m;
  	scanf("%d%d%d%d",&a,&b,&h,&m);
  	double ang = ((30.0 * h + 0.5 * m) - (6.0 * m)) * pi / 180.0;
  	double ans = 1.0 * a * a + 1.0 * b * b - 2.0 * a * b * cos(ang);
    printf("%.20lf\n",sqrt(ans));
  	return 0;
}

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

typedef long long ll;
#define Inf 1 << 20
#define MInf -(1 << 20)
 
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n - 1); i > -1;i--)
#define RRep(i,n,m) for(int i = (int)(n - 1); i > (int)(m);i--)
#define trav(a, x) for(auto& a : x)
 
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))
#define REVERSE(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REVERSE(V)
 
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;

int main()
{
    string s,t;
    cin >> s >> t;
    SORT(s);
    RSORT(t);
    if(s < t)
    {
        Yes(true);
    }
    else
    {
        Yes(false);
    }
}



Measured memory_bytes: 256
function main() {
  var
  i, j, w, h, t, l,
  line, cache, map, isLoop,
  len = input.length;
  for(i = 0; i < len; i++) {
    line = input[i].split(' ');
    h = parseInt(line[0], 10);
    w = parseInt(line[1], 10);
    if(w === 0 && h === 0) break;
    map = [];
    cache = {};
    for(j = 0; j < h; j++) map[j] = input[++i];
    t = 0;
    l = 0;
    isLoop = false;
    while(map[t].charAt(l) !== '.') {
      cache[[t, l]] = true;
      switch(map[t].charAt(l)) {
      case '>':
        l += 1;
        break;
      case '<':
        l -= 1;
        break;
      case 'v':
        t += 1;
        break;
      case '^':
        t -= 1;
        break;
      }
      if(cache[[t, l]]) {
        isLoop = true;
        break;
      }
    }
    console.log(isLoop ? 'LOOP' : [l, t].join(' '));
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 10092
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
"""

# import {{{
from collections import ChainMap
from collections import Counter
from collections import defaultdict
from collections import deque
from collections import namedtuple
import bisect
import copy
import decimal
import fractions
import functools
import heapq
import itertools
import math
import operator
import pdb
import pprint
import random
import re
import string
import sys
import time

try:
    import numpy as np
    import scipy as sp
except:
    pass
# }}}

# util {{{
def is_odd(x):
    return x % 2 == 1

def is_even(x):
    return x % 2 == 0

def cmp(x, y):
    return (x > y) - (x < y)

def sgn(x):
    return cmp(x, 0)

def clamp(x, lo, hi):
    assert lo <= hi
    if x < lo:
        return lo
    elif x > hi:
        return hi
    else:
        return x

def chmax(xmax, x):
    if x > xmax:
        return x, True
    else:
        return xmax, False

def chmin(xmin, x):
    if x < xmin:
        return x, True
    else:
        return xmin, False

def argmax(seq):
    return max(range(len(seq)), key=seq.__getitem__)

def argmin(seq):
    return min(range(len(seq)), key=seq.__getitem__)

def INPUT():
    return input().rstrip() # CRLF対策

sys.setrecursionlimit(100000)
# }}}

# 適宜調整
PINF = float("inf")
NINF = float("-inf")
EPS  = 1e-9



def main():
    S = input()
    cnt = Counter(S)

    ok = all(is_even(v) for v in cnt.values())
    print("Yes" if ok else "No")

if __name__ == "__main__": main()


Measured memory_bytes: 26056
#include <stdio.h>
#include <string.h>
#define Max 10000000
typedef struct  {
        char name[100];
        int t;

} P;
P Q[Max];
int head,tail,n;
int isFull(){
        return head==(tail+1)%Max;
}
void initialize(){
        head=0;
        tail=0;
}
int isEmpty(){
        if(head==tail) {
                return 1;
        }
        else return 0;
}
void enqueue(P x){
        if(isFull()) {
                fprintf(stderr,"Overflow\n");
        }
        Q[tail]=x;
        if(tail+1==Max) {
                tail=0;
        }
        else{
                tail++;
        }

}

P dequeue(){
        if(isEmpty()) {
                fprintf(stderr,"Underflow\n");

        }
        if(head+1==Max) {
                head=0;
        }
        else{
                head++;


        }
        P x=Q[head];

        return x;

}
int min(int a,int b){
        return a < b ? a : b;
}
int main(){
        int L=0,c;
        int i,q;
        P a;
        scanf("%d%d",&n,&q);
        for(i=0; i<n; i++) {
                scanf("%s",&Q[i+1].name);
                scanf("%d",&Q[i+1].t);
        }

        head=0;
        tail=n+1;
        while(head!=tail) {
                a=dequeue();
                c=min(q,a.t);
                a.t=a.t-c;
                L=L+c;
                if(a.t>0) enqueue(a);
                else{
                        if(head-tail!=0)
                                printf("%s %d\n",a.name,L);
                }
        }
        return 0;

}



Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
int i, n, m, k, ans;
ll x;
ll val;
int a[1000];

int main() {
    scanf(" %lld", &x);
    ans = 0;
    val = 100;
    while(val < x) {
        ans++;
        val = val * 1.01;
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 3760
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[200005];
int l[200005];
int sum[200005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m;
    int i;
    scanf("%d%d",&n,&m);
    for (i=0;i<n;i++)
    {
        l[i]=i+1;
        sum[i]=0;
    }
    int ans=0;
    for (i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        a[i]--;
        l[a[i]]--;
        if (l[a[i]]>=0)
        {
            if (sum[l[a[i]]]==0) ans++;
            sum[l[a[i]]]++;
        }
    }
    for (i=0;i<m;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        x--;
        y--;
        if (l[a[x]]>=0)
        {
            if (sum[l[a[x]]]==1) ans--;
            sum[l[a[x]]]--;
        }
        l[a[x]]++;
        a[x]=y;
        l[a[x]]--;
        if (l[a[x]]>=0)
        {
            if (sum[l[a[x]]]==0) ans++;
            sum[l[a[x]]]++;
        }
        printf("%d\n",n-ans);
    }
    return 0;
}


Measured memory_bytes: 3840
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int X;cin>>X;
	cout<<10-X/200<<endl;
	
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
using namespace std;
int main(){
    int n,a[100];
    cin>>n;
    a[0]=1;
    a[1]=1;
    for(int i=2;i<=n;i++){
        a[i]=a[i-1]+a[i-2];
    }
    cout<<a[n]<<endl;
    return 0;
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String str = sc.next();
        
        int n = sc.nextInt();
        
        for(int i = 0; i < n; i++){
            String q = sc.next();
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(q.equals("replace")){
                String p = sc.next();
                
                str = str.substring(0,a) + p + str.substring(b+1);
                
            }else if(q.equals("reverse")){
                
                String box = "";
                for(int i2 = b; i2 >= a; i2--){
                    box += str.substring(i2,i2+1);
                }
                str = str.substring(0,a) + box + str.substring(b+1);
            
            }else if(q.equals("print")){
                
                System.out.println(str.substring(a,b+1));
                
            }
        }
    }
}


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

int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  int z=a+c;
  if(2*b==z){
    printf("YES\n");
  }
  else{
    printf("NO\n");
  }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    string s; cin>>s;
    stack<char> st;
    rep(i,0,s.size()){
        if(s[i]=='S'){
            st.push(s[i]);
        }else{
            if(st.empty() or st.top()=='T'){
                st.push(s[i]);
            }else{
                st.pop();
            }
        }
    }
    cout<<st.size()<<endl;
}

Measured memory_bytes: 644
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		string s = Console.ReadLine();
		string t = Console.ReadLine();
		long L = Lcm(A,B);
		long M = A*B;
		long ans = L;
		for(var i=0;i<M/L;i++){
			int a1 = (int)(i*A/(M/L));
			int a2 = (int)(i*B/(M/L));
			if(s.Substring(a1,1) != t.Substring(a2,1)){
				ans = -1;
				break;
			}
		}
		Console.WriteLine(ans);
	}
	
	public static long Lcm(long a, long b) {
        return a * b / Gcd(a, b);
    }

	public static long Gcd(long a, long b) {
		if (a < b)
			return Gcd(b, a);
		while (b != 0) {
			var r = a % b;
			a = b;
			b = r;
		}
		return a;
	}
}

Measured memory_bytes: 11616
import sys
# python template for atcoder1
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def calcVolume(L, R, T, B, min_wall):
    '''
    池の体積を計算
    '''
    ret = 0
    for w in range(L, R+1):
        for h in range(B, T+1):
            ret += (min_wall-garden[h][w])
    return ret


def pondsVolume(L, R, T, B):
    '''
    池の体積をreturn
    池を作れないなら-1
    '''
    # 池の中で一番高い所
    max_in_pond = 0
    for w in range(L, R+1):
        for h in range(B, T+1):
            max_in_pond = max(max_in_pond, garden[h][w])
    # 周りの壁の一番低い所
    min_wall = float('inf')
    for w in range(L-1, R+2):
        min_wall = min(min_wall, garden[B-1][w], garden[T+1][w])
    for h in range(B-1, T+2):
        min_wall = min(min_wall, garden[h][L-1], garden[h][R+1])

    if min_wall <= max_in_pond:
        return -1
    else:
        return calcVolume(L, R, T, B, min_wall)


while True:
    d, w = map(int, input().split())
    if d == 0:
        break
    garden = [list(map(int, input().split())) for _ in range(d)]
    ans = 0
    wallMin = 0
    # 池の範囲を全探索
    for L in range(1, w-1):
        for B in range(1, d-1):
            for R in range(L, w-1):
                for T in range(B, d-1):
                    ans = max(ans, pondsVolume(L, R, T, B))
    print(ans)



Measured memory_bytes: 5652
/*
 * FileName:     allocation_fix_2
 * CreatedDate:  2020-07-07 14:54:36 +0900
 * LastModified: 2020-07-07 16:03:00 +0900
 */

#include <stdio.h>
#include <stdlib.h>
int check(long int *w, long int n, long int k, long int p){
    long int sum = 0;
    long int idx = 0;
    for(long int i=0;i<k;i++){
        sum = 0;
        while(w[idx]+sum <= p){
            sum += w[idx];
            idx++;
            if( idx==n )return 1;
        }
    }
    return 0;
}

int main(void){
    long int n, k;scanf("%ld%ld", &n, &k);
    long int *w = malloc(n*sizeof(long int));
    for(long int i=0;i<n;i++)scanf("%ld", w+i);
    long int left = 0, right = 100000*10000;
    while( left+1<right ){
        long int middle = (left+right)/2;
//        printf("left:%ld, middle:%ld, right:%ld\n", left, middle, right);
        if(check( w, n, k, middle)) right=middle;
        else left = middle;
    }
    printf("%ld\n", right);
    free(w);
    return 0;
}



Measured memory_bytes: 2344
use std::io::*;
use std::str::FromStr;

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let n:i32 = read();
    let s:String = read();
    if n%2 == 0 {
	let cs: Vec<char> = s.chars().collect();
	for i in 0.. n/2{
	    if cs[i as usize] != cs[(n/2 + i) as usize] {
		println!("No");
		return;
	    }
	}
    }else {
	println!("No");
	return;
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N%1000%111==0 || (N-N%10)%111==0) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline

N = int(input())
A = []
for _ in range(N):
    # 選手番号を0-indexにする
    line = list(map(lambda x: int(x) - 1, input().split()))
    A.append(line)

# cnt[i] = 選手iが現在までに何試合したか
cnt = [0] * N
# recent[i] = 選手iが最後に試合をした日
recent = [0] * N

# Qの初期値 = [0, 1, ..., N-1]
Q = deque(range(N))

while Q:
    # ある選手(p1)について
    p1 = Q.popleft()
    # p1がまだ全試合(N-1試合)を終えていない場合
    # p2 = p1が次に当たるべき選手
    if cnt[p1] < N - 1:
        p2 = A[p1][cnt[p1]]
        # p2もまだ全試合を終えていない場合
        if cnt[p2] < N - 1:
            # p2が次に当たるべき選手がp1の場合 -> (p1,p2)の試合を行うことが可能
            if A[p2][cnt[p2]] == p1:
                # day = (p1,p2)の試合を行う日
                day = max(recent[p1], recent[p2]) + 1
                recent[p1] = day
                recent[p2] = day
                cnt[p1] += 1
                cnt[p2] += 1
                Q.append(p1)
                Q.append(p2)

if min(cnt) != N - 1:
    print(-1)
else:
    print(max(recent))


Measured memory_bytes: 90780
use strict;
use warnings;

my @ABC = glob(<>);

@ABC = sort @ABC;

if ($ABC[0] == $ABC[1] && $ABC[0] != $ABC[2]) {
    print("Yes\n");
    exit();
}

if ($ABC[0] != $ABC[1] && $ABC[1] == $ABC[2]) {
    print("Yes\n");
    exit();
}

print("No\n");


Measured memory_bytes: 768
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
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;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

class SumSegTree {
private:

 ll _sum(ll a, ll b, ll k, ll l, ll r) {
  if (r <= a || b <= l)return 0;    // 交差しない
  if (a <= l && r <= b)return dat[k];   // a,l,r,bの順で完全に含まれる
  else {
   ll s1 = _sum(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
   ll s2 = _sum(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
   return s1 + s2;
  }
 }
public:
 ll n, height;
 vector<ll> dat;

 // 初期化（_nは最大要素数）
 SumSegTree(ll _n) {
  n = 1;
  height = 1;
  while (n < _n) {
   n *= 2;
   height++;
  }
  dat = vector<ll>(2 * n - 1, 0);
 }

 // 場所i(0-indexed)にxを足す
 void add(ll i, ll x) {
  i += n - 1; // i番目の葉ノードへ
  dat[i] += x;
  while (i > 0) { // 下から上がっていく
   i = (i - 1) / 2;
   dat[i] += x;
  }
 }

 // 区間[a,b)の総和。ノードk=[l,r)に着目している。
 ll sum(ll a, ll b) {
  return _sum(a, b, 0, 0, n);
 }
};

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

	ll n,k;
	cin>>n>>k;
	Array p(n,0);
	REP(i,n) cin>>p[i];
	
	Array con(n,0);
	REP(i,n-1){
		if(p[i+1]>=p[i]){
			con[i+1]+=con[i]+1;
		}
	}
	/*
	for(auto i:con){
		cout<<i<<" ";
	}
	cout<<endl;
	*/

	map<ll, ll> s;
	ll ans=1;
	REP(i,k) s[p[i]]++;
	
	bool flag_con=false;
	if(con[k-1]==k-1)flag_con=true;

	REP(i,n-k){
		auto it = s.begin();
		bool flag=true;
		if(it->first==p[i]){
			auto it2=s.end();
			it2--;
			if(it2->first<=p[i+k]){
				//cerr<<i<<endl;
				flag=false;
			}
		}
		s[p[i]]--;
		if(s[p[i]]==0) s.erase(p[i]);
		s[p[i+k]]++;
		if(flag){
			if(con[i+k]-con[i+1]==k-1){
				if(!flag_con){
					ans++;
					flag_con=true;
					//cout<<i<<endl;
				}
			}else{
				ans++;
			}
		}
		/*
		for(auto i:s){
			cout<<i.first<<" ";
		}
		cout<<endl;
		cout<<ans<<endl;
		*/
	}


	cout<<ans<<endl;

	return 0;
}

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

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    vector<vector<int> > dp(n + 1, vector<int>(h + 1, 1e9));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= h; j++) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            int nx = min(j + a[i], h);
            dp[i + 1][nx] = min(dp[i + 1][nx], dp[i + 1][j] + b[i]);
        }
    }
    cout << dp[n][h] << endl;
}

Measured memory_bytes: 39424
#include<stdio.h>

static inline void disp(short n, short *a)
{
    short i;

    printf("%hd", a[0]);
    for(i=1; i<n; ++i)printf(" %hd", a[i]);
    printf("\n");
}

int main(void)
{
    short n, i, j;
    short a[100], v;

    scanf("%hd", &n);
    for(i=0; i<n; ++i)scanf("%hd", a+i);

    disp(n,a);
    for(i=1; i<n; ++i){
        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            --j;
        }
        a[j+1] = v;
        disp(n,a);
    }

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using 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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int n;
  cin >> n;
  int t,a;
  cin >> t >> a;
  t*=1000;
  a*=1000;

  int ans;
  int d=(1<<30);
  REP(i,n){
    int h;
    cin >> h;
    int tmp = abs(a - (t - h*6));
    if(tmp < d){
      d = tmp;
      ans = i+1;
    }
  }
  cout << ans << endl;
}



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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)


ll next357(ll n)
{

    string s = to_string(n);
//    cout << "s[" << s << "] " ;
    int k = 1;
    for(int i = s.size()-1; i >= 0; i-- ) {
        if(k == 1 || (s[i] != '3' && s[i] != '5' && s[i] != '7')) {
            if(s[i] < '3') { s[i] = '3'; k = 0; continue;}
            if(s[i] < '5') { s[i] = '5'; k = 0; continue;}
            if(s[i] < '7') { s[i] = '7'; k = 0; continue;}
            if(s[i] >= '7') { s[i] = '3'; k = 1; continue;}
        }
    }
    if(k == 1) {
        s = "3" + s;
    }
//    cout << s << endl;
    return stol(s);
}

bool is357(ll n)
{
    string s = to_string(n);
    int c[10];
    c[3] = c[5] = c[7] = 0;
    REP(i, s.size()) {
        c[s[i] - '0'] ++;
    }
    return c[3] > 0 && c[5] > 0 && c[7] > 0;
}

int main(void)
{
    ll n;
    ll cnt = 0;
    cin >> n;
    for(ll i = 333; i <= n; i = next357(i)) {
        if(is357(i))cnt ++ ;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
n,x = map(int,input().split())
arr = list(map(int,input().split()))
ans = 0;
arr.sort();
flag = 0;

for i in range(n):

	if x < arr[i]:
		flag=1;
		break;
	else:
		ans+=1;
		x -= arr[i];

if x > 0 and ans > 0 and flag==0:
	ans-=1;

print(ans);

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    rep(i, h) cin >> s[i];

    vector<vector<int>> dp(h, vector<int>(w, 0));

    dp[0][0] = 0;

    rep(i, h) rep(j, w){
        if(i==0 && j==0) continue;
        if(i==0){
            dp[i][j] = dp[i][j-1] + (s[i][j] != s[i][j-1]);
        }
        else if(j==0) dp[i][j] = dp[i-1][j] + (s[i][j] != s[i-1][j]);
        else{
            dp[i][j] = min(dp[i-1][j] + (s[i-1][j] != s[i][j]), dp[i][j-1] + (s[i][j-1] != s[i][j]));
        }
    }

    // rep(i, h) {
    //     rep(j, w) cout << dp[i][j];
    //     cout << endl;
    // }
    cout << (dp[h-1][w-1]+1)/2 + (s[0][0]=='#' && s[h-1][w-1]=='#') << endl;
    
    return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s, t string
	fmt.Scanf("%s", &s)
	fmt.Scanf("%s", &t)
	ss := strings.Split(s, "")
	ts := strings.Split(t, "")

	var ret int
	for k, v := range ss {
		if v != ts[k] {
			ret++
		}
	}
	fmt.Printf("%d\n", ret)

}


Measured memory_bytes: 11104
n,time = map(int,input().split())
t = list(map(int,input().split()))
stoptime = 0
nagaretime = 0
for i in range(n):
         if nagaretime < t[i]:
                  stoptime += t[i] - nagaretime
         nagaretime = t[i] + time
print(nagaretime - stoptime)



Measured memory_bytes: 85328
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    long long int n,d,x,y;
    cin>>n>>d;
    int count=0;
    while(n--)
    {
        cin>>x>>y;
        x=abs(x);y=abs(y);
        if(x*x+y*y <=d*d)
        count++;
    }

    cout<<count<<"\n";
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin>>N;
    N=N%10;

    if(N==2||N==4||N==5||N==7||N==9)
    {
        cout<<"hon";
    }
    else if(N==0||N==1||N==6||N==8)
    {
        cout<<"pon";

    }
    else if(N==3)
    {

     cout<<"bon";}
     return 0;
}


Measured memory_bytes: 3588
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

#define M 1000000007

char a[100004];
int f[26];

int main() {
    int n = gi();
    scanf("%s", a);

    memset(f, 0, sizeof(f));
    for (int i = 0; i < n; i++)
        f[a[i]-'a']++;

    ll r = 1;
    for (int i = 0; i < 26; i++) {
        r *= (f[i] + 1);
        r %= M;
    }

    r = (r+M-1)%M;

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  int a;
  cin >> a;
  if (a == 7 || a == 5 || a == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

int main(){
    int n, x[100]; cin >> n;
    for(int i = 0; i < n; i++) cin >> x[i];

    int sum, ans = 1 << 30;
    for(int p = 1; p <= 100; p++){
        sum = 0;
        for(int i = 0; i < n; i++){
            sum += (x[i] - p)*(x[i] - p);
        }
        if(sum < ans) ans = sum;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;

struct lamp{
    int p;
    int k;
    int* s;
};

const long long mod = 1e9+7;

int main(){
	int n, m;
    lamp* lamps;
    cin >> n >> m;

    lamps = new lamp[m];

    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        lamps[i].k = k;
        lamps[i].s = new int[k];
        for(int j = 0; j < k; j++){
            cin >> lamps[i].s[j];
        }
    }

    for(int i = 0; i < m; i++){
        cin >> lamps[i].p;
    }

    int t = 1 << n;
    int count = 0;
    for(int i = 0; i < t; i++){
        bool flag = true;
        for(int j = 0; j < m; j++){
            int on = 0;
            for(int l = 0; l < lamps[j].k; l++){
                int check = 1 << lamps[j].s[l] - 1;
                if(i&check) on++;
            }
            if(lamps[j].p != on%2){
                flag = false;
                break;
            }
        }
        if(flag) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define INF 1000000


int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  string S;
  cin >> N;
  cin >> S;

  vector<int> vr, vg, vb;
  
  for (int i = 0; i < N; i++) {
    if (S[i] == 'R')      vr.push_back(i);
    else if (S[i] == 'G') vg.push_back(i);
    else if (S[i] == 'B') vb.push_back(i);
  }

  ll total = vr.size() * vg.size() * vb.size();

  for (int i = 0; i < vr.size(); i++) {
    for (int j = 0; j < vg.size(); j++) {

      int idx_r = vr[i];
      int idx_g = vg[j];
      int d = abs(idx_r - idx_g);
      
      if (idx_r - d >= 0) {
	if (S[idx_r - d] == 'B') total--;
      }
      
      if (idx_r + d < N) {
	if (S[idx_r + d] == 'B') total--;
      }
      
      if (idx_g - d >= 0) {
	if (S[idx_g - d] == 'B') total--;
      }

      if (idx_g + d < N) {
	if (S[idx_g + d] == 'B') total--;
      }

      if (d % 2 == 0) {
	if (S[(idx_r + idx_g)/2] == 'B') total--;
      }
      
    }
  }
  
  cout << total << endl;
  
  return 0;
  
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  ll x;cin>>x;
  cout<<x/11*2+(x%11>6?2:x%11>0?1:0);;
}

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

using namespace std;
using ll = long long;


int main()
{
	int k, t; cin >> k >> t;
	vector<int> a(t); for(int i = 0; i < t; i++)cin >> a[i];
	int nax = *max_element(a.begin(), a.end()); 

	if(nax <= k / 2) {
		cout << 0 << endl;
		return 0;
	}

	cout << (nax - 1) - (k - nax) << endl;

}

Measured memory_bytes: 256