akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 ll r,c;
 const int maxn=25;
 const int inf=1000;
 char grid[maxn][maxn];
 vector<vector<ll>> dist;
 int dx[]={1,-1,0,0};
 int dy[]={0,0,1,-1};
 bool valid(ll x,ll y)
{
	if(x<0 || x>r-1 || y<0 || y>c-1 || grid[x][y]=='#') return false;
	return true;
}
 void bfs(ll x,ll y)
{
	queue<pair<ll,ll>> q;
	q.push(mp(x,y));
	dist[x][y]=0ll;
	while(!q.empty())
	{
		auto a=q.front();
		q.pop();
		rep(i,4)
		{
			if(valid(a.fi+dx[i],a.se+dy[i]) && dist[a.fi+dx[i]][a.se+dy[i]]>1ll+dist[a.fi][a.se])
			{
				dist[a.fi+dx[i]][a.se+dy[i]]=1ll+dist[a.fi][a.se];	
				q.push(mp(a.fi+dx[i],a.se+dy[i])); 
			}
		}
	}
}
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	cin>>r>>c;
	rep(i,r)
	{
		rep(j,c)
		{
			cin>>grid[i][j];
		}
	}
	ll ans=0ll;
	rep(i,r)
	{
		rep(j,c)
		{
			if(grid[i][j]=='#') continue;
			dist=vector<vector<ll>>(maxn,vector<ll>(maxn,inf));
			bfs(i,j);
			rep(a,r)
			{
				rep(b,c)
				{
					if(grid[a][b]=='#') continue;
					ans=max(ans,dist[a][b]);
				}
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 3672
h, w, n = gets.chomp!.split(" ").map!(&:to_i)
s_r, s_c = gets.chomp!.split(" ").map!(&:to_i)
s_r -= 1
s_c -= 1
s = gets.chomp!.chars
t = gets.chomp!.chars

memo = {
  'L' => s_c,
  'R' => s_c,
  'U' => s_r,
  'D' => s_r,
}

inverse = {
  'L' => 'R',
  'R' => 'L',
  'U' => 'D',
  'D' => 'U',
}

is_no = false

n.times do |i|
  my = i * 2
  you = i * 2 + 1

  case s[i]
  when 'R'
    memo[s[i]] += 1
    if memo[s[i]] >= w
      is_no = true
      break
    end
  when 'D'
    memo[s[i]] += 1
    if memo[s[i]] >= h
      is_no = true
      break
    end
  when 'L', 'U'
    memo[s[i]] -= 1
    if memo[s[i]] < 0
      is_no = true
      break
    end
  end

  case t[i]
  when 'L'
    memo[inverse[t[i]]] = memo[inverse[t[i]]] > 0 ? memo[inverse[t[i]]] - 1 : 0
  when 'R'
    memo[inverse[t[i]]] = memo[inverse[t[i]]] + 1 < w ? memo[inverse[t[i]]] + 1 : memo[inverse[t[i]]]
  when 'U'
    memo[inverse[t[i]]] = memo[inverse[t[i]]] > 0 ? memo[inverse[t[i]]] - 1 : 0
  when 'D'
    memo[inverse[t[i]]] = memo[inverse[t[i]]] + 1 < h ? memo[inverse[t[i]]] + 1 : memo[inverse[t[i]]]
  end
end

puts is_no ? "NO" : "YES"


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

#define ll long long

ll dp[105][100005];
int weight[105];
ll price[105];
int n, w;

void initialize()
{
    for(int i=0;i<=100;i++)
    {
        for(int j=0;j<=100000;j++)
            dp[i][j] = -1;
    }
}

ll knapsack(int i, int j)
{
    if(i<=0 || j<=0) return 0;

    if(dp[i][j]!=-1) return dp[i][j];

    ll ret = knapsack(i-1, j);

    if(weight[i]<=j)
        ret = max(ret, knapsack(i-1, j-weight[i])+price[i]);

    dp[i][j] = ret;

    return ret;
}

int main()
{
    initialize();


    cin>>n>>w;
    for(int i=1;i<=n;i++)
        cin>>weight[i]>>price[i];


    ll retVal = knapsack(n, w);
    cout<<retVal<<endl;


    return 0;
}


Measured memory_bytes: 82548
N, Q = gets.split.map(&:to_i)
G = Array.new(N + 1){ [] }
V = Array.new(N + 1, 0)

(1 ... N).each do
  a,b = gets.split.map(&:to_i)
  G[a] << b
  G[b] << a
end

Q.times.each do
  u, x = gets.split.map(&:to_i)
  V[u] += x
end

q = [[1,0]]
used = Array.new(N + 1)
used[1] = true

until q.empty?
  u, x = q.shift
  V[u] += x
  
  G[u].each do |v|
    unless used[v]
      used[v] = true
      q << [v, V[u]]
    end
  end
end

V.shift
puts V * ' '

Measured memory_bytes: 36220
import java.util.Arrays;
import java.util.Scanner;

//Prime Number II
public class Main{

	public static void main(String[] args) {
		boolean[] p = new boolean[55000];
		Arrays.fill(p, true);
		p[0]=p[1]=false;
		for(int i=2;i<55000;i++)if(p[i])for(int j=i*2;j<55000;j+=i)p[j]=false;
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int d = n-1;
			int u = n+1;
			while(!p[d])d--;
			while(!p[u])u++;
			System.out.println(d+" "+u);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
//#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*
lli power(lli x,lli y)
{
    lli res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}
*/
int main()
{
//cout.precision(10);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   //freopen("input1.txt","r",stdin);
   //freopen("outputmid1.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
		lli n,m,i,a,z;
		cin>>n>>m;
		multiset<lli> ms;
		for(i=0;i<n;i++)
		{
			cin>>z;
			ms.insert(z);
		}
		for(i=0;i<m;i++)
		{
			auto itr=ms.end();
			itr--;
			a=(*itr/2);
			ms.erase(itr);
			ms.insert(a);
		}
		lli ans=0;
		for(auto itr=ms.begin();itr!=ms.end();itr++)
		{
			ans+=*itr;
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 4992
#include "cstring"
#include "iostream"

using namespace std;

int main()
{
	char S[16];
	char T[16] = { "o" };
	cin >> S;

	int t;
	int kane=700;

	for (t = 0; t < 3; t++) {
		if (S[t] == T[0]) {
			kane += 100;
		}
	}
	cout << kane ;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int counter1=0,counter2=0;
  if(a==5)counter1++;
  if(b==5)counter1++;
  if(c==5)counter1++;
  if(a==7)counter2++;
  if(b==7)counter2++;
  if(c==7)counter2++;
  if(counter1==2&&counter2==1)cout<<"YES";
  else cout<<"NO";
  return 0;
}
  

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;     
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int n, q;
        n = input.nextInt();
        Set<Integer> s = new HashSet<Integer>();
        for (int i = 0; i < n; ++i) {
            int x = input.nextInt();
            s.add(x);
        }
        q = input.nextInt();
        Set<Integer> t = new HashSet<Integer>();
        for (int i = 0; i < q; ++i) {
            int x = input.nextInt();
            t.add(x);
        }
        s.retainAll(t);
        System.out.println(s.size());
    }                
}

Measured memory_bytes: 31776
# listを並び替えてif-elseで条件分岐


N = int(input())
L = list(map(int, input().split()))

descending_L = sorted(L, reverse=True)
# print(descending_L)

other_side = sum(descending_L[1:])

if descending_L[0] < other_side:
    print('Yes')
else:
    print('No')


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

int A,B,X;

void solve(){
  if(A<=X && A+B>=X){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

int main(){
  cin >> A >> B >> X;
  solve();
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int a,b,c;cin>>a>>b>>c;
  cout << max(0,b+c-a) << endl;
}

Measured memory_bytes: 512
import itertools
import numpy as np
n, m, x = map(int, input().split())
flag = 0

cs = []
a = []
for i in range(n):
    inputs = [int(x) for x in input().split()]
    ci = inputs[0]
    ai = inputs[1:]
    cs.append(ci)
    a.append(ai)

res = 99999999999
for num in itertools.product('01', repeat=n):
    tmp = np.zeros(m)
    cost = 0
    for j in range(n):
        if num[j] == '0':
            continue
        else:
            cost += cs[j]
            tmp += np.array(a[j])
    if sum(tmp >= x) == m:
        flag = 1
        res = min(res, cost)

if flag:
    print(res)
else:
    print(-1)

Measured memory_bytes: 27276
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  var ta = Array(n) { readLine()!!.split(" ").map { it.toLong() } }
  var (nt, na) = ta[0]
  for (i in 1 until n) {
    val (t, a) = ta[i]
    val k = arrayOf((nt + t - 1) / t, (na + a - 1) / a).max()!!
    nt = k * t
    na = k * a
  }
  println(nt + na)
}


Measured memory_bytes: 37748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int p, n;
int ans[4];

void stern_brocot(int lnumer, int ldenom, int rnumer, int rdenom){
    // This node corresponds to the interval (lnumer / ldenom, rnumer / rdenom).
    int nnumer = (lnumer + rnumer), ndenom = (ldenom + rdenom);
    if(n < nnumer || n < ndenom) return;
    double pivot = (double)nnumer / ndenom;
    if(pivot < sqrt(p)){
        ans[0] = nnumer, ans[1] = ndenom;
        stern_brocot(nnumer, ndenom, rnumer, rdenom);
    }else{
        ans[2] = nnumer, ans[3] = ndenom;
        stern_brocot(lnumer, ldenom, nnumer, ndenom);
    }
}

int main(){
    while(1){
        cin >> p >> n;
        if(p==0) break;
        stern_brocot(0, 1, 1, 0);
        cout << ans[2] << "/" << ans[3] << " " << ans[0] << "/" << ans[1] << endl;
    }
    return 0;
}

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

typedef long long LL;
const int MAXN=2e5+5;
const int MAXM=1e5+5;
const int mod=1e9+7;

int n,m,x[MAXN],y[MAXN];

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&x[i]);
    }
    sort(x+1,x+n+1);
    int ans=0,num=0;
    x[0]=x[1]; y[0]=0;
    for(int i=1;i<=n;i++){
        if (x[i]!=x[i-1]){
            y[++y[0]]=num;
            num=1;
            continue;
        }
        num++;
    }
    y[++y[0]]=num;
    sort(y+1,y+y[0]+1);
    if (y[0]<=m) ans=0;
    else{
        for(int i=1;i<=y[0]-m;i++)
            ans+=y[i];
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	A := readInt()
	B := readInt()
	if A <= 5 {
		println(0)
	} else if A <= 12 {
		println(B/2)
	} else {
		println(B)
	}
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]


    H,W,N = LI()

    d = collections.Counter()
    for _ in range(N):
        x,y = LI()
        for dx in range(-1,2):
            for dy in range(-1,2):
                nx = x+dx
                ny = y+dy
                if 1 < nx < H and 1 < ny < W:
                    d[(nx,ny)] += 1
    ans = [0] * 10
    for x in d.values():
        ans[x] += 1
    ans[0] = (H-2) * (W-2) - sum(ans[1:])

    print(*ans,sep='\n')

if __name__ == '__main__':
    main()

Measured memory_bytes: 192636
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string s;
    cin >> s;
    if(sz(s) == 2) {
      print(s);
    }
    else{
      reverse(all(s));
      print(s);
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
  int N,count = 0,t;
  cin >> N;
  rep(i,N){
    cin >> t;
    if(!(i%2) && t%2)count++;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int dp[1000000]={0};
vector <int> adj[1000000];

int LongestPath(int node)
{
	if(dp[node])
		return dp[node];
	if(adj[node].empty())
	{
		dp[node]=1;
		return 1;
	}
	int mx=-1;
	for(auto x:adj[node])
		mx = max(mx,LongestPath(x));
	dp[node]=mx+1;
	return dp[node];
}

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
    	int t1,t2;
    	cin>>t1>>t2;
    	adj[t1].push_back(t2);
    }
    for(int i=1;i<=n;i++)
    	LongestPath(i);
    cout<<*max_element(dp+1,dp+n+1)-1<<endl;
}

Measured memory_bytes: 29952
import java.util.Scanner;


public class Main {
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            if(n==0) break;
            int[] s = new int[n];
            int sum=0;
            double ave=0,b=0;
            for(int i=0;i<n;i++){
                s[i] = sc.nextInt();
                sum += s[i];
            }
            ave = (double)sum/n;
            for(int i=0;i<n;i++){
                b += Math.pow(s[i]-ave,2);
            }   
            System.out.println(Math.sqrt(b/n));
        }
        sc.close();
    }
    
}


Measured memory_bytes: 31688
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    string s;
    ll dp[200001],dp2[200001];

    ll func(int i)
    {
        if(i==s.length())
            return 1;
        if(dp2[i]!=-1)
            return dp2[i];
        if(s[i]=='0')
            return dp2[i]=(func(i+1))%mod;
        else if(s[i]=='1')
            return dp2[i]=(2*func(i+1)+dp[s.length()-i-1])%mod;
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>s;
            dp2[0]=dp2[1]=-1;
            dp[1]=3;
            dp[0]=1;
            for(i=2;i<=200000;++i)
            {
                dp2[i]=-1;
                dp[i]=(dp[i-1]*3)%mod;
            }
            
            ll ans=(2*func(1)+dp[s.length()-1])%mod;
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

ll pow2(int t, int n) {
  ll ans = 1;
  for (int i = 0; i < n; i++)
    ans *= t;
  return ans;
}

ll P(int n, ll x) {
  if (n == 0)
    return 1;
  else {
    if (x == 1)
      return 0;
    else if (x <= pow2(2, n+1)-2)
      return P(n-1, x-1);
    else if (x == pow2(2, n+1)-1)
      return pow2(2,n);
    else
      return pow2(2,n) + P(n-1, x+1-pow2(2,n+1));
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, X; cin >> N >> X;
  ll ans = P(N,X);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;

//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int x, n; cin >> x >> n;
  set<int> s;
  rep(i,n) {
   int a; cin >> a;
   s.insert(a); 
  }
  int dif = INF;
  int ans = INF;
  rep(i,105) {
    if (s.find(i) != s.end()) continue;
    int foo = abs(x-i);
    if (dif > foo) {
      dif = foo;
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

int main() {
    int N;
    scanf("%d", &N);
    vector<pair<int, int> > A, B;
    for(int n=0; n<N; ++n) {
        int a;
        scanf("%d", &a);
        A.emplace_back(a, n);
    }
    for(int n=0; n<N; ++n) {
        int b;
        scanf("%d", &b);
        B.emplace_back(b, n);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    for(int n=0; n<N; ++n) {
        if(B[n].first<A[n].first) {
            printf("No\n");
            return 0;
        }
    }
    for(int n=1; n<N; ++n) {
        if(A[n].first<=B[n-1].first) {
            printf("Yes\n");
            return 0;
        }
    }
    vector<int> Ans(N), Now(N);
    for(int n=0; n<N; ++n) {
        Now[n] = n;
        Ans[B[n].second] = A[n].second;
    }
    for(int n=0; n<N-1; ++n) {
        if(Now[n]==Ans[n]) {
            printf("Yes\n");
            return 0;
        }
        int ans = Ans[n];
        for(int i=n+1; i<N; ++i) {
            if(ans==Now[i]) {
                swap(Now[n], Now[i]);
                break;
            }
        }
    }
    printf("No\n");
    return 0;
}


Measured memory_bytes: 2548
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String inputLine = sc.nextLine();
		long input = Long.parseLong(inputLine);
		long inputCopy = input;
		int div = 0;
		int digits = (int)Math.log(input);
		
		for(;digits >= 0;--digits) {
			div += inputCopy / Math.pow(10, digits);
			inputCopy = inputCopy % (long)Math.pow(10, digits);
		}
		
		sc.close();
		if(input % div == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    map<char, int>d;
    bool kotonaru = true;
    for (int i=0; i<S.size(); i++) {
        if (d.count(S[i]) > 0) {
            kotonaru = false;
            break;
        } else {
            d[S[i]] = 1;
        }
    }

    if (kotonaru) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<int> gr[N];
int comp[N];
int compNo;
bool vs[N];

void dfs(int node) {
    vs[node] = 1;
    comp[node] = compNo;
    for(int child : gr[node]) {
        if(vs[child]) continue;
        dfs(child);
    }
}


int main() {
    int n, m;
    cin>>n>>m;
    vector<int> ind(n + 1);
    for(int i = 1; i <= n; ++i) {
        int x;
        cin>>x;
        ind[x] = i;
    }

    for(int i = 0; i < m; ++i) {
        int x, y;
        cin>>x>>y;
        gr[x].push_back(y);
        gr[y].push_back(x);
    }
    for(int i = 1; i <= n; ++i) {
        if(!vs[i]) {;
            compNo++;
            dfs(i);
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        if(comp[ind[i]] == comp[i])
            ans++;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define nn 300008
#define int long long 
char str[nn];int dp[nn][3];int n;
int ha[nn];const int hp=19260817;int qp[nn];
#define mod 1000000033
int ask(int l,int r){
	return ((ha[r]-ha[l-1]*qp[r-l+1])%mod+mod)%mod;
}
signed main() {qp[0]=1;
	for(int i=1;i<nn;i++) qp[i]=qp[i-1]*hp%mod;
	scanf("%s",str+1);n=strlen(str+1);
	for(int i=1;i<=n;i++) ha[i]=ha[i-1]*hp+str[i],ha[i]%=mod;
	memset(dp,0x80,sizeof dp);dp[0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=max(i-2,0ll);j<i;j++){
			for(int k=0;k<=2;k++) 
				if(ask(j-k+1,j)!=ask(j+1,i)) dp[i][i-j]=max(dp[i][i-j],dp[j][k]+1);
		}
	}	
	printf("%lld\n",max(dp[n][2],dp[n][1]));
	return 0;
}



Measured memory_bytes: 12160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] params;
      Dice dice2 = new Dice(br.readLine().split(" "));
      int upper,front;
      int q = Integer.parseInt( br.readLine() );
      for ( ; q > 0; q--) {

        params = br.readLine().split(" ");

        upper = Integer.parseInt(params[0]);
        front = Integer.parseInt(params[1]);

        while(true){
          if( dice2.getFrontSide() == front){
            for (int i=0; i<3; i++)
              if(dice2.getUpperSide() == upper) break;
              dice2.rotate("W");
          }
          else {
            for(int i=0; i < 3; i++)
              if(dice2.getUpperSide() != front) dice2.rotate("N");
            for(int i=0; i < 3; i++)
              if(dice2.getUpperSide() != front) dice2.rotate("W");
            dice2.rotate("S");
          }
          if( (dice2.getUpperSide()==upper) && (dice2.getFrontSide()==front)) break;
        }
        System.out.println(dice2.getRightSide());
      }
    }
  }
}

class Dice {
  private int[] side;

  public Dice( int[] ia ) {
    side = Arrays.copyOf(ia, ia.length);
  }
  public Dice( String[] s ) {
    side = new int[s.length];
    for ( int i=0; i < 6; i++)
      side[i] = Integer.parseInt(s[i]);
  }

  public int getUpperSide() {
    return side[0];
  }
  public int getFrontSide() {
    return side[1];
  }
  public int getRightSide() {
    return side[2];
  }

  public int doRotate(String s) {
    for ( int i=0; i < s.length(); i++ ) {
      rotate(s.substring(i, i+1));
    }
    return side[0];
  }

  public void rotate(String o) {
    switch(o) {
      case "N" :
        rotateN();
        break;
      case "S" :
        rotateS();
        break;
      case "W" :
        rotateW();
        break;
      case "E":
        rotateE();
        break;
      default :
    }
  }

  private void rotateN() {
    int tmp = side[0];
    side[0] = side[1]; side[1] = side[5]; side[5] = side[4];
    side[4] = tmp;
  }
  private void rotateS() {
    int tmp = side[0];
    side[0] = side[4]; side[4] = side[5]; side[5] = side[1];
    side[1] = tmp;
  }
  private void rotateW() {
    int tmp = side[0];
    side[0] = side[2]; side[2] = side[5]; side[5] = side[3];
    side[3] = tmp;
  }
  private void rotateE() {
    int tmp = side[0];
    side[0] = side[3]; side[3] = side[5]; side[5] = side[2];
    side[2] = tmp;
  }
}


Measured memory_bytes: 24492
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[200000], b[300000][26];
Pll a[300000];
string str, ss;
bool f[200];
char c, ch[100][100];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v[26];
map<Pll,LL>ma;
multiset<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	rep(i, n) {
		cin >> str;
		a[i].first = str[0] - 'a', a[i].second = str[str.size() - 1] - 'a';
		v[a[i].first].push_back(i);
		if (i == 0) {
			first = str[0] - 'a';
		}
		if (i == n - 1) {
			last = str[0] - 'a';
		}
	}
	Mfor(i, n) {
		rep(j, 26) {
			b[i][j] = -1;
		}
	}
	Mfor(i, n - 1) {
		rep(j, 26) {
			if (a[i + 1].first == j && b[i+1][j] == -1)
				b[i][j] = i+1;
			else
				b[i][j] = max(b[i][j], b[i + 1][j]);
		}
	}
	priority_queue<Pll,vector<Pll>,greater<Pll>>qu;
	qu.push(Pll(0, 0));
	rep(i, n+1) {
		dp[i] = INF;
	}
	dp[0] = 0;
	while (!qu.empty()) {
		Pll cur = qu.top();
		qu.pop();
		LL num = cur.first, u = cur.second;
		if (num > dp[u]||u==n)continue;

		for (auto i = lower_bound(v[a[u].first].begin(), v[a[u].first].end(), u + 1); i != v[a[u].first].end(); i++) {
				if (dp[*i] > dp[u]) {
					dp[*i] = dp[u];
					qu.push(Pll(dp[*i], *i));
				}
				else {
					break;
				}
		}

		if (dp[u + 1] > dp[u] + 1) {
			dp[u + 1] = dp[u] + 1;
			qu.push(Pll(dp[u + 1], u + 1));
		}
	}
	cout << dp[n] << endl;
	return 0;
}



Measured memory_bytes: 33908
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

ll ans = 0;
int N;

bool check(ll n){
  if(n > N) return false;
  int three = 0, five = 0, seven = 0;
  while(n > 0){
    if(n%10 == 3) three++;
    else if(n%10 == 5) five++;
    else if(n%10 == 7) seven++;
    n /= 10;
  }
  if(three * five * seven) return true;
  else return false;
}

void dfs(ll n){
  if(check(n)) ans++;
  if(n*10 < N){
    dfs(n*10+3);
    dfs(n*10+5);
    dfs(n*10+7);
  }
}

int main(){
  cin >> N;
  dfs(0);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



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


int main(){
    string s;cin>>s;
    int len=s.size();
    set<char> t;
    for(int i=0;i<=len-1;i++)t.insert(s[i]);
    int ans=1;
    if(t.size()==2)ans=-1;
    else{
        if(len%2==0)ans*=-1;
        if(s[0]==s[len-1])ans*=-1;
    }
    if(ans==1)cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 512
(let* ((n (read))
    (ti (read))
    (tn (make-array n))
    (ans 0))
    (loop for i below n do
        (setf (aref tn i) (read))
    )
    (loop for i from 1 to (- n 1) do
        (if (<= ti (- (aref tn i) (aref tn (- i 1))))
            (incf ans ti)
            (incf ans (- (aref tn i) (aref tn (- i 1))))
        )
    )
    (incf ans ti)
    (format t "~D~%" ans)
)

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

int main() {
    //
    string s, t;
    long long cnt = 0;
    cin >> s >> t;

    for (long long i = 0; i < s.size(); i++){
        //
        if (s.at(i) != t.at(i)) cnt++;
    }
    
    cout << cnt;
    //
}

Measured memory_bytes: 3916
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    cs = "CODEFESTIVAL2016"
    cnt = 0
    for i in range(len(cs)):
        if s[i] != cs[i]:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path;
//***********//
ll gcd(ll x, ll y) {
	ll r;
	if (x < y) {
		swap(x, y);
	}
	while (y > 0) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
int main() {
	cin >> X;
	co(lcm(X, 360) / X);
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

char A[1001][1001];
ll DP[1001][1001];
ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
        cin>>A[i][j];

    DP[1][0]=1;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            if(A[i][j]!='#')
            DP[i][j]=(DP[i-1][j]+DP[i][j-1])%mod;

    cout<<DP[n][m];
}


Measured memory_bytes: 9088
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()

  println(abc159a(n, m))
}

private fun abc159a(n: Int, m: Int): Int {
  var ans = n * (n - 1) / 2

  ans += m * (m - 1) / 2

  return ans
}


Measured memory_bytes: 31392
//148 B - Strings with the Same Length 2019/12/22

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    string s , t;
    cin >> s >> t;
    for(int i=0;i<n;++i){
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

char str1[2][10000];
char str2[2][10000];
char stres[2][100000001];

int check(int num) {
    if(('0' <= num && num <= '9') ||( 'A' <= num && num <= 'Z') ||( 'a' <= num && num <= 'z') ) {
        return 1 ;
    }   else {
        return 0; 
    }
}

void setup_def(int n) {
    int i, tmp;
    for(i = 0; i < n; i++ ) {
        while(1) {
            scanf("%c",&str1[0][i]);
            tmp = check(str1[0][i]);
            if(tmp) {
                break;
            }
        }
        while(1) {
            scanf("%c",&str2[0][i]);
            tmp = check(str2[0][i]);
            if(tmp) {
                break;
            }
        }
    }
}

void output(int n, long long int m) {
    int i, j, flag = 0;
    char tmp[2] = {0};
    for(i = 0; i < m; i++ ) {
        while(1) {
            scanf("%c",&tmp[0]);
            flag = check(tmp[0]);
            if(flag) {
                break;
            }
        }
        flag = 0;
        for(j = 0; j < n; j++ ) {
            if(str1[0][j] == tmp[0]) {
                flag = 1;
                printf("%c",str2[0][j]);
                break;
            }
        }
        if(flag == 0) {
            printf("%c",tmp[0]);
        }
    }
}

int main(void) {
    int n;
    long long int m;
    scanf("%d",&n);
    while(n) {
        setup_def(n);
        scanf("%lld",&m);
        output(n,m);
        puts("");
        scanf("%d",&n);
    }
    return 0;
}

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


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

    if(N >= 10){
        cout << R << endl;
    }

    else{
        cout << R + 100*(10 - N) << endl;
    }


    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

// x の n 乗 を m で余りをとったもの
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while ( n > 0) {
        if (n & 1) { res = res * x % mod; } // 最下位ビットが立っているときに x^(2^i) を掛ける
        x = x * x % mod;                    // x を順次 2 乗していく
        n >>= 1;
    }
    return res;
}

string S;
ll dp[MAX_N][20];

// 右から k 番目を見ていて、現在のあまりが mod のときのパターン数
ll dfs(ll k, ll mod) {
    if(k < 0) {
        return (mod == 5) ? 1 : 0;
    }

    ll x = (S[k] == '?') ? -1 : (S[k] - '0');  // 今見ている数字

    ll& res = dp[k][mod];
    if(~res) { return res; }
    res = 0;

    ll k_inv = S.length() - k - 1;

    if(x == -1) {
        for(ll i = 0; i <= 9; ++i) {
            ll tmp = i * mod_pow(10, k_inv, 13);
            tmp %= 13;
            tmp += mod;
            tmp %= 13;
            res += dfs(k-1, tmp);
            res %= MOD;
        }
    }
    else {
        ll tmp = x * mod_pow(10, k_inv, 13);
        tmp %= 13;
        tmp += mod;
        tmp %= 13;
        res += dfs(k-1, tmp);
        res %= MOD;
    }
    return res;
}

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

    cin >> S;

    MINUS(dp);
    ll ans = dfs(S.length()-1, 0);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 22352
#include <stdio.h>

int main() {

  int n,m;
  int hiyou[1001];
  int vote[1001] = {0};
  int i,j,k,s,max = -1,no1;
  scanf("%d %d",&n,&m);

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

  //  printf("end hiyou input;\n");

  max = -1;
  for(i=0;i<m;i++) {

    scanf("%d",&s);

    for(j=0;j<n;j++) {
      if(hiyou[j] <= s) {
	//	printf("vote[%d] = %d\n",j,vote[j]);
	vote[j]++;
	if(max < vote[j]){
	  max = vote[j];
	  no1 = j+1;
	  break;
	  
	} else if(max == vote[j] && no1 > j+1){
	  no1 = j+1;
	  break;
	}
	break;
      }
    }
    
  }
  
  printf("%d\n",no1);

  return 0;

}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace _10_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            if (n < 2)
            {
                Console.WriteLine(1);
            }
            else
            {
                int[] x = new int[n + 1];
                x[0] = 1;
                x[1] = 1;
                for (int i = 2; i <= n; i++)
                {
                    x[i] = x[i - 1] + x[i - 2];
                }
                Console.WriteLine(x[n]);
            }
        }
    }
}

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

int main()
{
  string s;
  cin >> s;
  int ans = 0;
  string a, b;
  for(int i = s.size() - 2; i > 0; i -= 2){
    a = s.substr(0, i / 2);
    b = s.substr(i / 2, i / 2);
    if(a == b){
      ans = i;
      break;
    }
  }
  
    
  

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
bool table[10001][1261];

int main () {
	int N, M;
	while (cin >> N >> M, N || M) {
		int lastin[N + 1];
		int r;
		memset(table, 0, sizeof(table));
		cin >> r;
		for (int i = 0; i < r; i++) {
			int t, n, m, s;
			cin >> t >> n >> m >> s;
			if (s) {
				lastin[n] = t;
			}
			else {
				fill(table[m] + lastin[n], table[m] + t, true);
			}
		}
		int q;
		cin >> q;
		for (int i = 0; i < q; i++) {
			int s, e, m;
			cin >> s >> e >> m;
			cout << count(table[m] + s, table[m] + e, true) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 13484
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, a;
  cin >> n >> k;
  a=1;
  for(i=0;i<n;i++) {
    if(a * 2 < a + k) {
      a *= 2;
    }
    else {
      a += k;
    }
  }
  cout << a << endl;
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A, B; cin >> A >> B;
	for (int i = 0; i <= 1000; i++) {
		if (i * 8 / 100 == A && i / 10 == B) {
			cout << i << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';
	return 0;
}

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

using namespace std;

int main(void) {
    int a, b, t;
    cin >> a >> b >> t;
    auto c = 0;
    auto time = a;
    while(time < t + 0.5){
        c++;
        time += a;
    }
    cout << c * b;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class EYutori {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k, c; cin >> n >> k >> c;
      string s; cin >> s;
      string rs = s;
      reverse(all(rs));

      vector<int> r(n);
      int before = INT_MIN;
      rep(i, n) {
        if (i>0) r[i] = r[i-1];
        if (rs[i] == 'o' && i > before+c) {
          before = i;
          r[i]++;
        }
      }
      reverse(all(r));
      /*rep(i, n) {
        debug(i, r[i]);
      }*/

      int cnt = 0;
      int right = -1;
      rep(i, n) {
        if (s[i] != 'o') continue;
        int tmp1 = cnt-1;
        if (i+1<n) tmp1 += r[i+1];
        int tmp2 = cnt;
        debug(i, right);
        if (max(i+1,right+1)<n) tmp2 += r[max(i+1,right+1)];
        debug(tmp1, tmp2);
        if (tmp1 < k && tmp2 < k) {
          cout << i+1 << '\n';
        }
        if (i > right) {
          cnt++;
          right = i+c;
        }
      }
    }
};

signed main() {
  EYutori solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 2836
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> p;
    int elem;
    set<int> se;
    F0R(i,n)
    {
        cin >> elem;
        p.pb(elem);
    }
    int count=0;
    int prev=-1;
    int mid;
    FOR(i,1,n-1)
    {
        mid=-1;
        if(p[i]<p[i+1] && p[i]>p[i-1])
            mid=p[i];
        if(p[i]>p[i+1] && p[i]<p[i-1])
            mid=p[i];
        // cout << mid << endl;
        if(mid==p[i])
            count++;
        // se.insert(mid);
    }
    cout << count;// se.size();

    return 0;
}


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

int main() {
    int k; cin >> k;
    vector<long long> a;
    for (int i = 1; i <= 9; i++) a.push_back(i);
    while (1) {
        if (k <= a.size()) {
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();
        vector<long long> old;
        swap(a, old);
        for (long long x : old) {
            for (int i = -1; i <= 1; i++) {
                int d = x % 10 + i;
                if (d == -1 || d == 10) continue;
                long long nextx = x * 10 + d;
                a.push_back(nextx);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1712