akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	ll n;
	ll m = LLONG_MAX;
	cin >> n;
	cu(i,0,5){
		ll x;
		cin >> x;	
		m = min(m, x);
	}
	cout << (n + m - 1)/m + 4 << '\n';
}


Measured memory_bytes: 256
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
an = 0
bn = 0
t = 0
for an in range(n):
  if t+a[an] <= k:
    t += a[an]
  else:
    an-=1
    break
an+=1
ans = an
while True:
  while bn < m:
    if t+b[bn] <= k:
      t += b[bn]
      bn += 1
    else:
      break
  ans = max(ans,an+bn)
  if an == 0 or bn == m:
    break
  else:
    an -= 1
    t -= a[an]
print(ans)

Measured memory_bytes: 40780
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int binpow(int a, int b) {
    if(b==0) return 1;
    int x=binpow(a,b/2);
    x=(x*x)%mod;
    if(b%2==0) return x;
    else return (x*a)%mod;
}
signed main() {
    int n;
    cin>>n;
    // run l from 1 to 1e7
    int l=1;
    int r=1;
    int cur=1;
    int ans=0;
    while(l<1e7) {
        if(cur==n) {
            //cout<<l<<" "<<r<<endl;
            ans=(ans+1)%mod;
        }
        if(cur<=n) {
            r++;
            cur+=(int)log10(r)+1; // digit of r
        }
        if(cur>n) {
            l++;
            cur-=((int)log10(l-1)+1);
        }
    }
    //cout<<"ans = "<<ans<<endl;
    for(int dig=8 ; dig<=n ; dig++) {
        if(n%dig==0) {
            // can use all dig-digit numbers
            int cnt=n/dig;
            int up=binpow(10,dig);
            int down=binpow(10,dig-1);
            int add=(up-cnt+1)-down;
            //cout<<"digit = "<<dig<<endl;
            //cout<<"add = "<<add<<endl;
            ans=(ans+add+mod)%mod;
        }
        // dig*a+(dig+1)*b=n
        // => (dig)(a+b)=n-b
        // b%(dig)==(n)%(dig)
        int rem=(n%dig);
        if(!rem) rem=dig;
        int low=rem*(dig+1);
        int hi=dig*(dig+1); // n>dig*a because b must >0
        if(low<n) ans=(ans+(n-low-1)/hi+1)%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 3952
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

typedef struct qq {
	string name;
	int time;
}p;

int main() {
	int n, q;
	cin >> n >> q;
	queue<p> que;
	string na;
	int ti;
	for (int i = 0; i < n; ++i) {
		cin >> na >> ti;
		que.push({ na,ti });
	}
	int sec = 0;
	while (!que.empty()) {
		int c = min(que.front().time, q);
		que.front().time -= c;
		sec += c;
		if (que.front().time > 0) que.push(que.front());
		else cout << que.front().name << " " << sec << endl;
		que.pop();
	}

	return 0;
}


Measured memory_bytes: 6240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll A,B,N;
    cin >> A >> B >> N;
    ll p1 = (A*N)/B;
    ll p2 = A*(N/B);
    ll ans = 0;
    ans = max(ans,p1-p2);
    ll q1 = (A*(N-1)/B);
    ll q2 = A*((N-1)/B);
    ans = max(ans,q1-q2);
    ll r1 = (A*N)%B;
    ll r2 = N%B;
    ll r3 = (A*r2)%B;
    if (r1 > r2) {
        ans = max((A*(N-r2-1))/B - A*((N-r2-1)/B),ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
def find_tanku(words, st)
  phrase_length = [5, 7, 5, 7, 7]

  st.upto(40) do |index|
    head = phrase_length.shift - words[index].length

    case head
    when 0 then return st + 1 if phrase_length.empty?
    when -Float::INFINITY..-1 then return false
    else phrase_length.unshift(head)
    end
  end
end

loop do
  n = gets.to_i
  break if n == 0
  words = Array.new(n) { gets.chomp }

  n.times do |st|
    res = find_tanku(words, st)

    if res
      puts res
      break
    end
  end
end

Measured memory_bytes: 8840
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  int s,w;
  cin >> s >> w;

  if(s<=w) {
    cout << "unsafe" << endl;
  }else {
    cout << "safe" << endl;
  }

  return 0;
}


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

int main() {
  int x;
  cin >> x;
  int num = x / 100, mod = x % 100;
  int a, b, c, d, e;
  a = mod / 5;
  b = mod % 5 / 4;
  c = mod % 5 % 4 / 3;
  d = mod % 5 % 4 % 3 / 2;
  e = mod % 5 % 4 % 3 % 2;
  if (a + b + c + d + e > num) cout << 0 << endl;
  else cout << 1 << endl;
}

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

ifstream fin("darb.in");
ofstream fout("darb.out");
int a, b, c, n;
int maxSum[100001][4];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a >> b >> c;

        maxSum[i][1] = max(maxSum[i - 1][2], maxSum[i - 1][3]) + a;
        maxSum[i][2] = max(maxSum[i - 1][1], maxSum[i - 1][3]) + b;
        maxSum[i][3] = max(maxSum[i - 1][1], maxSum[i - 1][2]) + c;
    }

    cout << max(max(maxSum[n][1], maxSum[n][2]), maxSum[n][3]);

    return 0;
}

Measured memory_bytes: 5140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;

class Program
{
    static void Main()
    {
        new Program().Solve();
    }

    void Solve()
    {
        var n = Console.ReadLine();
        var s = n[n.Length - 1];
        if (s == '2' || s == '4' || s == '5' || s == '7' || s == '9') Console.WriteLine( "hon");
        if (s == '0' || s == '1' || s == '6' || s == '8') Console.WriteLine( "pon");
        if (s == '3') Console.WriteLine( "bon");
    }

    #region Console.Read 関係
    long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    long ReadLong() => long.Parse(Console.ReadLine());
    #endregion
}

Measured memory_bytes: 25792
// *****************************************************************
// *****************************************************************
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <stack>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
// *****************************************************************
// *****************************************************************
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fr(i,n) for(llu i=0;i<n;i++)
#define fl(j,a,b) for(llu j=a;j<=b;j++)
#define pi 3.14159265
#define mod 1e9+7
#define MID(a,b) ((a + b) >> 1)
#define MAX(a,b) ((a) > (b) ? (a): (b))
#define MIN(a,b) ((a) < (b) ? (a) :(b))
// *****************************************************************
// *****************************************************************
typedef long long unsigned int llu;
typedef long long int ll;
// *****************************************************************
// *****************************************************************
using namespace std;
// *****************************************************************
// *****************************************************************

       // I have no special talent. I am only passionately curious.

                         // tannatsri //

              // Without tact you can learn nothing.

// *****************************************************************
// *****************************************************************
template< class Iterator,  class T>
// template<typename TT>
// *****************************************************************
// *****************************************************************
Iterator search(Iterator start, Iterator end, T key) {
    while(start != end) {
        if(*start == key){
            return start;
        }
        ++start;
    }
    return end;
}
bool rev(int a, int b) {
    return a > b;
}
// *****************************************************************
// *****************************************************************
int main() {
    IOS;
    string s;
  	cin >> s;
  	set<char> ss;
  	for(auto i = s.begin();i != s.end(); ++i){
          ss.insert(*i);
      }
    if(ss.size() == 2) cout << "Yes\n";
    else cout <<"No" << "\n";
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

ll mpow(ll x, ll n) {
    ll ans = 1; x %= mod;
    while (n != 0) {
        if (n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
public:
    ll cmb(ll a, ll b) {
        if (a == 0 && b == 0) return 1;
        if (a < b || a < 0 || b < 0) return 0;
        ll c = 1;
        for (int i = a,j=1; i > a - b; i--,j++) {
            c *= i;
            c /= j;
        }
        return c;
    }
};

int main() {
    ll n, p;
    cin >> n >> p;
    vector<ll> as(n);
    rep(i, n) cin >> as[i];
    ll even = 0, odd = 0;
    rep(i, n) {
        if (as[i] % 2 == 0) {
            even++;
        }
        else {
            odd++;
        }
    }
    Factorial f;
    ll eSum = 1;
    rep(i, even) {
        eSum *= 2;
    }
    ll rSum = 0;
    for (int i = 0; i <= odd; i++) {
        if (i % 2 == p) {
            rSum += f.cmb(odd, i);
        }
    }
    cout << eSum * rSum << endl;
    return 0;
}


Measured memory_bytes: 3648
#[allow(unused)]
use std::io::{stdin, stdout, Write};    
#[allow(unused)]
macro_rules! read {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty), *) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            read!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

fn main() {
    println!("{}", if read![i32] >= 30 { "Yes" } else { "No" });
}

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

#define VMAX (10000)

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


Measured memory_bytes: 2084
n=int(input())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
lpq=[]
for i in range(n):
  for j in range(n):
    if i==j:
      pass
    else:
      lpq.append([l[i][0]-l[j][0],l[i][1]-l[j][1]])
score=n-1
for i in lpq:
  s1=0
  for j in l:
    for k in l:
      if j==k:
        pass
      else:
        if j[0]-k[0]==i[0] and j[1]-k[1]==i[1]:
          s1+=1
  s=n-s1
  if s<score:
    score=s
if n==1:
  print(1)
else:
  print(score)


Measured memory_bytes: 3444
import itertools
N = int(input())
P = tuple(list(map(int,input().split())))
Q = tuple(list(map(int,input().split())))

p = 0
q = 0
for i,r in enumerate(itertools.permutations([i+1 for i in range(N)])):
    if P == r:
        p = i+1
    if Q == r:
        q = i+1
    if p and q:
        break

print(abs(p-q))

Measured memory_bytes: 3064
input = readlines()
n = input.shift.chomp.to_i
list = input.shift.chomp.split("\s").map{|x| x.to_i}

res = 0
tmp_sum = list[0]
list.each_with_index do |l, i|
  next if i == 0
  res += l * tmp_sum
  if res > 1000000007
    res = res % 1000000007
  end
  tmp_sum += l
end

puts res % 1000000007


Measured memory_bytes: 33820
K = int(input())
A = list(map(int, input().split()))

def solve():
    if A[K - 1] != 2:
        print(-1)
        return;
    M = 2
    m = 2
    for i in range(K - 1, 0, -1):
        nM = (M + A[i] - 1) - (M + A[i] - 1) % A[i - 1]
        if m % A[i - 1] == 0:
            nm = m
        else:
            nm = m + A[i - 1] - m % A[i - 1]
        #print("nM =", nM, "nm =", nm)
        if nM < m or nm >= M + A[i]:
            print(-1)
            return;
        #print("nM =", nM, "nm =", nm)
        M, m = nM, nm
    M = M + A[0] - 1
    # m = m
    print(m, M)
solve()


Measured memory_bytes: 14432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[2005][2005],mod=1e9+7;
int main(){
	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<=2002;i++){
		c[i][0]=c[i][i]=1;
		for(ll j=1;j<i;j++){
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
		}
	}
	for(ll i=1;i<=k;i++){
		if(n-k+1<i) cout<<0<<endl;
		else cout<<(c[n-k+1][i]%mod*c[k-1][i-1]%mod)%mod<<endl;
	}
}

Measured memory_bytes: 30208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  map<string, int> memo;
  int N;
  cin >> N;
  rep(i, N)
  {
    string s;
    cin >> s;
    memo[s] += 1;
  }

  int maxv = 0;
  // ? こぴぺ　mapでは昇順でソートされてるらしい
  for (const auto &x : memo)
  {
    int v = x.second;
    if (v > maxv)
      maxv = v;
  }
  for (auto it = memo.begin(); it != memo.end(); it++)
  {
    if (it->second == maxv)
    {
      cout << it->first << endl;
    }
  }
}

Measured memory_bytes: 25728
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

ans = defaultdict(int)

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            ans[x*x+y*y+z*z+x*y+y*z+z*x]+=1
for i in range(1, n+1):
    print(ans[i])


Measured memory_bytes: 75160
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);i++)

using namespace std;

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;
}

string S;

int main() {
    cin >> S;
    if (S[0] == S[1] && S[1] == S[2]) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void) {
    int input1 = 0;
    int input2 = 0;
    scanf("%d", &input1);
    scanf("%d", &input2);
    // printf("%d\n", inputN);
    // printf("%d\n", inputM);
    int result = 0;
    if(input1%input2 == 0) {
        result = (int)(input1/(double)input2);
    }
    else {
        result = (int)(input1/(double)input2) + 1;
    }
    // for(int i=0; i<inputM; ++i) {
    //     scanf("%d", &inputPi);
    //     scanf("%s", inputS);
    //     if(strcmp("AC", inputS) == 0) {
    //         if(param[inputPi][1] == 0) {
    //             param[inputPi][1] = 1;
    //             resultAC++;
    //             resultWA+= param[inputPi][0];
    //         }
    //     } else if(strcmp("WA", inputS) == 0) {
    //         if(param[inputPi][1] == 0) {
    //             param[inputPi][0]++;
    //         }
    //     }
    // }
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  bool isok=false;
  for(ll a=1;a<10;a++) for(ll b=1;b<10;b++) if(a*b==n) isok=true;
  print(isok?"Yes":"No");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  
  if(a > b) {
    cout << "a > b" << endl;


  } else if(a < b) {
    cout << "a < b" << endl;

    
  } else if(a == b) {
    cout << "a == b" << endl;
  }
}



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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  int n = read(), ans = 0;
  vi time;
  REP(i, n) {
    time.PB(read());
    ans += time[i];
  }
  int m = read();
  int diffMax = 0;
  REP(i, m) {
    int p, x;
    std::cin >> p >> x;
    print(ans - time[p - 1] + x);
  }
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

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

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

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

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  std::string s,t;
  std::cin>>s>>t;
  bool flag=true;

  ll n=s.size(),m=t.size();

  std::vector<std::vector<ll>> itr(26);

  rep(i,0,26){
      rep(j,0,n)if((s[j]-'a')==i)itr[i].push_back(j);
  }
  
  rep(i,0,m)if(itr[t[i]-'a'].empty())flag=false;

  if(!flag){
    std::cout<<-1;
    return 0;
  }

  ll ans=itr[(ll)(t[0]-'a')][0]+1;


  ll now=ans-1;
  rep(i,1,m){
    ll next=t[i]-'a';
    auto len=std::upper_bound(all(itr[next]),now);
    if(len!=itr[next].end()){
    ans+=(*len-now);
    now=*len;
    }else{
      ans+=(n-now+itr[next][0]);
      now=itr[next][0];
    }

    //debug(now);
    //debug(ans);
  }

  std::cout<<ans;

  return 0;
}


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

int main() {
  int N, A, B, C, D ;
  cin >> N;
  A = N % 10;
  B = N / 10 % 10;
  C = N / 100 % 10;
  D = N / 1000 % 10;
  
  if (A==B && B==C) {
    cout << "Yes" <<endl;
  }
  else if (B==C && C==D) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3604
/*痛みを受け取れ，痛みを知れ*/
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1000007;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;
int a[N];
ll n, k;
bool check(int mid)
{
	ll num = 0;
	f(i, 1, n)
	{
		num += (int)ceil(a[i]*1.0 / mid)-1;
	}
	if (num <= k)return true;
	return false;
}
int main()
{
	//freopen("in.txt", "r", stdin);
	while (cin >> n >> k)
	{
		int mx = 0;
		f(i, 1, n)scanf("%d", &a[i]), mx = max(mx, a[i]);
		int l = 1, r = mx;
		int ans;
		if (k == 0) { cout << mx << endl;continue; }
		while (l <= r)
		{
			int mid = (l + r) / 2;
			if (check(mid))
			{
				ans = mid;
				r = mid - 1;
			}
			else l = mid + 1;

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


Measured memory_bytes: 4380
D, N = map(int, input().split())
i = 0
ans = 0
x = 100**D
c = 0
while True:
    if (i * x) % (x*100) != 0:
        ans += 1
        c += 1
        if c >= N:
            break
    i += 1
print(100**D*i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);

using namespace std;
const int N = 1e4;
set<int> way;
vector<int> gr[N], fway;
map<pii, pii> w;
int used[N], n;
ll totaltime = 0, totalamount = 0;
void dfs(int v)
{
    if(v == n)
    {
        for(auto e : way)fway.pb(e);
        return;
    }
    used[v] = 1;
    for(auto e : gr[v])
    {
        if(!used[e])
        {
            way.insert(e);
            dfs(e);
            way.erase(e);
        }
    }
}
int main()
{
    fast;
    int a, b, c; cin >> a >> b >> c;
    ll sum = a + b +c;
    if(a + b + c >= 22)cout << "bust";
    else cout << "win";
    return 0;
}


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

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

using namespace std;

long long A[2 * 100000];
long long dp[2 * 100000][2][3];

void setmax(long long &best, long long cand) {
  if (best < cand) best = cand;
}

int main() {
  int N;
  cin >> N;
  REP(i, N) cin >> A[i];

  const long long INF = 100000000000000000;
  REP(i, N) REP(j, 2) REP(k, 3) dp[i][j][k] = -INF;
  dp[0][0][1] = 0;
  dp[0][1][0] = A[0];
  int maxskip = N % 2 == 0 ? 1 : 2;
  for (int i = 1; i < N; ++i) {
    for (int skipped = 0; skipped <= maxskip; ++skipped) {
      // Previous one is taken, do not take.
      setmax(dp[i][0][skipped], dp[i - 1][1][skipped]);
      // Previous one is not taken, take.
      setmax(dp[i][1][skipped], dp[i - 1][0][skipped] + A[i]);
      if (skipped < maxskip) {
        // Previous one is not taken, do not take.
        setmax(dp[i][0][skipped+1], dp[i - 1][0][skipped]);
      }
    }
  }
  /*
  REP(i, N) {
    REP(j, 2) {
      REP(k, 3) cout << dp[i][j][k] << " ";
      cout << endl;
    }
    cout << endl;
  }
  */
  long long ans = -INF;
  for (int i = 0; i <= maxskip; ++i) {
    setmax(ans, dp[N - 1 - i][1][maxskip - i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 14564
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;

class Program {
  static void Main (string[] args) {
    string[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    int b = int.Parse(str[1]);
    b *= 2;
    if (a < b) 
    {
      Console.WriteLine(0);
    }
    else
    {
      Console.WriteLine(a - b);
    }
  }
}

Measured memory_bytes: 11220
import sys
input=sys.stdin.readline

n=int(input())
a=[int(input()) for _ in range(n)]
ans=0
s=0
for i in range(n):
    s+=a[i]
    if a[i]==0:
        ans+=(s//2)
        s=0
ans+=(s//2)
print(ans)


Measured memory_bytes: 7072
#include<bits/stdc++.h>
using namespace std;
typedef		vector<int>				 vi;
typedef 	vector<vi>				vii;
typedef		pair<int,int>			pii;
typedef		unsigned long long		ull;
typedef		long long				ll ;
#define MOD (int)(1e9+7)
#define INF (int)(1<<29) 
#define fori(i,a,b)		for(int i=a ; i <= b ; i++) 			
#define ford(i,a,b)  	for(int i=a ; i >= b ; i-- ) 
#define rep(i,n)   		for(int i=0; i < n ; i++ ) 
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;


int main()
{
	ios_base::sync_with_stdio(0);	
	int n ;
	cin >> n ;
	int a[n] ;
	for(int i = 0 ; i < n ; ++i ) 
	{
		cin >> a[i] ; 
	}
	ll ans = 1 ;
	int chk = 0 ; 
	sort ( a , a + n ) ;
	for(int i = n-1 ; i > 0 ; --i ) 
	{
		if ( a[i] == a[i-1] ) 
		{
			chk++ ;
			ans *= a[i];
			i--;
		}
		if ( chk == 2 ) 
			break ; 
	}
	if ( chk ) 
	{
		cout << ans << endl ; 
	}
	else
	{
		cout << "0\n";
	}

	return 0 ;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int inf=10000007;
int a[200007];
int main()
{
	int k,n,minn=inf;
	cin>>k>>n;
	for(int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		int tmp;
		if(i==1)tmp=a[n]-a[1];
		  else tmp=k-(a[i]-a[i-1]);
		if(tmp<minn)minn=tmp;
		if(i==n)tmp=a[n]-a[1];
		  else tmp=k-(a[i+1]-a[i]);
		if(tmp<minn)minn=tmp;
	}
	cout<<minn<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define maxn 200100
#define lowbit(x) x&(-x)
#define ll long long
using namespace std;
int n,a[maxn],bit[maxn];
ll m;
void add(int pos,int val)
{
    while(pos<maxn)
    {
        bit[pos]+=val;
        pos+=lowbit(pos);
    }
}
int cal(int pos)
{
    int ret=0;
    while(pos>0)
    {
        ret+=bit[pos];
        pos-=lowbit(pos);
    }
    return ret;
}
int ad=1e5+5;
bool judge(int x)
{
    memset(bit,0,sizeof(bit));
    ll ret=0,sum=0;
    add(ad,1);
    for(int i=1;i<=n;++i)
    {
        sum+=(a[i]>=x);
        int val=2*sum-i+ad;
        ret+=cal(val);
        add(val,1);
    }
    return ret>=m;
}
int main()
{
    scanf("%d",&n);
    m=((ll)n*(n+1)/2+1)/2;
    for(int i=1;i<=n;++i) scanf("%d",&a[i]);
    int lb=1,ub=1e9+1;
    while(ub>lb+1)
    {
        int mid=(lb+ub)>>1;
        if(judge(mid)) lb=mid;
        else ub=mid;
    }
    printf("%d\n",lb);
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

#define maxN 200010

int N;
ll A[maxN];
ll B[maxN];
ll a[maxN];
ll b[maxN];

int main(){
	
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
	for(int i=0;i<N;i++) cin >> B[i];
	
		
	int ans = 0;
	for(int p=0;p<29;p++){
		for(int i=0;i<N;i++){
			ll mask = (1L << (p + 1)) - 1;
			a[i] = A[i] & mask;
			b[i] = B[i] & mask;
		}
		sort(b, b + N);
		
		ll cnt = 0;
		ll l0 = 1L << p;
		ll r0 = l0 + (1L << p);
		ll l1 = r0 + (1L << p);
		ll r1 = l1 + (1L << p);
		
		ll na;
		for(int i=0;i<N;i++){
			na = a[i];
			
			int l = 0, r = N;
			int li0 = 0, ri0 = 0, li1 = 0, ri1 = 0;
			
			if(na + b[0] >= l0){
				li0 = -1;
			} else {
				l = 0; r = N;
				while(r - l > 1){
					int c = (l + r) / 2;
					if(na + b[c] < l0){
						l = c;
					} else {
						r = c;
					}
				}
				li0 = l;
			}
			
			if(na + b[0] >= r0){
				ri0 = -1;
			} else {
				l = 0; r = N;
				while(r - l > 1){
					int c = (l + r) / 2;
					if(na + b[c] < r0){
						l = c;
					} else {
						r = c;
					}
				}
				ri0 = l;
			}
			
			if(ri0 != -1 && ri0 > li0) cnt += ri0 - li0;
			
			if(na + b[0] >= l1){
				li1 = -1;
			} else {
				l = 0; r = N;
				while(r - l > 1){
					int c = (l + r) / 2;
					if(na + b[c] < l1){
						l = c;
					} else {
						r = c;
					}
				}
				li1 = l;
			}
			
			if(na + b[0] >= r1){
				ri1 = -1;
			} else {
				l = 0; r = N;
				while(r - l > 1){
					int c = (l + r) / 2;
					if(na + b[c] < r1){
						l = c;
					} else {
						r = c;
					}
				}
				ri1 = l;
			}
			
			if(ri1 != -1 && ri1 > li1) cnt += ri1 - li1;
			
		}
		
		if(cnt % 2 == 1) ans |= (1 << p);
		
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String ans = "No";
        for(int i = 1; i <= 9; i++) {
            for(int j = 1; j <= 9; j++) if(i * j == n) ans = "Yes";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import kotlin.math.max

fun main() {
    val n = readLine()!!.toInt()
    val t = Array(n) { IntArray(n - 1) }
    for (i in 0 until n) {
        val a = readLine()!!.split(' ').map { it.toInt() - 1 }
        for (j in a.indices) {
            t[i][j] = a[j]
        }
    }

    val id = Array(n) { IntArray(n) { -1 } }
    var size = 0
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            id[i][j] = size
            id[j][i] = size
            size++
        }
    }

    val graph = Array(size) { mutableListOf<Int>() }
    for (i in 0 until n) {
        for (j in 0 until n - 2) {
            val u = id[i][t[i][j]]
            val v = id[i][t[i][j + 1]]
            graph[u].add(v)
        }
    }

    val visited = BooleanArray(size)
    val computed = BooleanArray(size)
    val dp = IntArray(size)

    fun dfs(u: Int): Int {
        if (visited[u]) {
            return if (computed[u]) dp[u] else -1
        }
        visited[u] = true
        dp[u] = 1
        for (v in graph[u]) {
            val r = dfs(v)
            if (r == -1) return -1
            dp[u] = max(dp[u], r + 1)
        }
        computed[u] = true
        return dp[u]
    }

    var ans = 0
    for (i in 0 until size) {
        val r = dfs(i)
        if (r == -1) {
            ans = -1
            break
        }
        ans = max(ans, r)
    }

    println(ans)
}


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

int main(){
	bool flag = true;
	pair<char, int> C[36], E[36], D;
	int N, i, j, k, minj;
	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> C[i].first >> C[i].second;
		E[i] = C[i];
    }
	for (i = 0; i < N; i++){
		for (j = N - 1; j > i; j--){
			if (C[j].second < C[j - 1].second) {
				D = C[j - 1];
				C[j - 1] = C[j];
				C[j] = D;
			}
		}
	}
	for (i = 0; i < N; i++) {
		cout << C[i].first << C[i].second;
		if (i < N - 1) cout << " ";
		else cout << endl;
	}
	cout << "Stable" << endl;

	for (i = 0; i < N; i++) {
		minj = i;
		for (j = i; j < N; j++){
			if (E[j].second < E[minj].second)
				minj = j;
		}
		D = E[minj];
		E[minj] = E[i];
		E[i] = D;
	}
	for (i = 0; i < N; i++) {
		if (C[i].first != E[i].first) flag = false;
		cout << E[i].first << E[i].second;
		if (i < N - 1) cout << " ";
		else cout << endl;
	}
	if (flag)
		cout << "Stable" << endl;
	else
		cout << "Not stable" << endl;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b >> c;
    d = a * 100 + b * 10 + c;
    fp(!(d%4),"YES","NO");
    return 0;
}

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

int main() {
	int n, m, p, q, r;
	while (scanf("%d", &n), n) {
		scanf("%d%d%d%d", &m, &p, &q, &r);
		queue<P>que, que1, que2, que3;
		que.push(P(1, n));
		rep(i, m) {
			int x, y; scanf("%d%d", &x, &y);
			int cnt = 0;
			while (!que.empty()) {
				P p = que.front(); que.pop();
				int f = p.first, s = p.second;
				if (cnt + s - f + 1 <= x) {
					que1.push(p);
					goto g;
				}
				if (y <= cnt) {
					que3.push(p);
					goto g;
				}
				if (cnt < x) {
					que1.push(P(f, f + x - cnt - 1));
					p.first = f + x - cnt;
				}
				if (y < cnt + s - f + 1) {
					que3.push(P(f + y - cnt, s));
					p.second = f + y - cnt - 1;
				}
				que2.push(P(p.first, p.second));
			g:
				cnt += s - f + 1;
			}
			while (!que3.empty()) { que.push(que3.front()); que3.pop(); }
			while (!que2.empty()) { que.push(que2.front()); que2.pop(); }
			while (!que1.empty()) { que.push(que1.front()); que1.pop(); }
		}
		int cnt = 0, ans = 0;
		while (!que.empty()) {
			P pa = que.front(); que.pop();
			int f = pa.first, s = pa.second;
			if (cnt + s - f + 1 < p)goto e;
			if (r < f)goto e;
			if (cnt <= p)
				pa.first = f + p - cnt - 1;
			if (q < cnt + s - f + 1)
				pa.second = f + q - cnt - 1;
			if (pa.second <= r) {
				ans += pa.second - pa.first + 1;
				goto e;
			}
			ans += r - pa.first + 1;
		e:
			cnt += s - f + 1;
			if (q <= cnt)break;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
const long long int mod = 1e9 + 7;
int main()
{
    ll N, M, sum = 0;
    cin >> N >> M;
    priority_queue<double> Q;
    rep(i,0,N){
        ll temp;
        cin >> temp;
        Q.push(temp);
    }
    rep(i,0,M){
        double temp = Q.top();
        Q.pop();
        Q.push(temp/2);
    }
    rep(i,0,N){
        ll temp = (ll)Q.top();
        Q.pop();
        sum += temp;
    }
    cout << sum << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

ll gcd(ll m, ll n) {
    return n != 0 ? gcd(n, m % n) : m;
}

ll lcm(ll m, ll n) {
    // If both m and n are large numbers, the result is overflow without parentheses.
    return m * (n / gcd(m, n));
}

void solve() {
    int k, x;
    cin >> k >> x;
    cout << (x <= k * 500 ? "Yes" : "No") << EOL;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,i,j,cnt = 0;
  int S[10000],T[500];

  scanf("%d" ,&a);
  for(i = 0 ; i < a ; i++){
    scanf("%d" ,S+i);
  }

  scanf("%d" ,&b);
  for(i = 0 ; i < b ; i++){
    scanf("%d" ,T+i);
  }

  for(i = 0 ; i < a ; i++){
    for(j = 0 ; j < b ; j++){
      if(S[i] == T[j]){
	cnt++;
	T[j] = -1;
	break;
      }
    }
  }

  printf("%d\n" ,cnt);

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll f[20005];
ll h,n;
ll v[10005],c[10005];
ll rh,mxv;
inline void read(ll &x)
{
	ll f;char c;
	for (f=1,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for (x=0;c<='9'&&c>='0';c=getchar()) x=x*10+(c&15);x*=f;
}
inline ll mn(ll _x,ll _y)
{
	return _x<_y?_x:_y;
}
inline ll mx(ll _x,ll _y)
{
	return _x>_y?_x:_y;
}
int main()
{
	read(h);read(n);
	for(ll i=1;i<=n;i++)
	{
		read(v[i]);
		read(c[i]);
		mxv=mx(mxv,v[i]);
	}
	rh=h+mxv;
	for(ll j=1;j<=rh;j++)
		f[j]=1050000000;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=v[i];j<=rh;j++)
			f[j]=mn(f[j],f[j-v[i]]+c[i]);
	}
	ll ans=1050000000;
	for(ll i=h;i<=rh;i++)
		ans=mn(ans,f[i]);
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i,n) for(int i=n-1;i>=0;i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef pair<int,int> P;
//typedef long long int ll;

int ans; 
P m1[111111];
P m2[111111];
signed main(){
	
	int n,a[111111];
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	
	rep(i,110002){
		m1[i].second=i+1;
		m2[i].second=i+1;
	}

	rep(i,n){
		if(i%2==0){
			m1[a[i]].first++;
		}
		else{
			m2[a[i]].first++;
		}
	}
	sort(m1,m1+110002);
	sort(m2,m2+110002);


	if(m1[110001].second==m2[110001].second){
		cout<<min(n-m1[110001].first-m2[110000].first,n-m2[110001].first-m1[110000].first)<<endl;
	}
	else cout<<n-m1[110001].first-m2[110001].first<<endl;
	//DEB(m1[110001].first)END DEB(m2[110001].first)END
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


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

  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int res = 0;
  for (int i = 1; i < n-1; i++) {
    bool flag1 = (v[i] > v[i-1] && v[i] < v[i+1]);
    bool flag2 = (v[i] < v[i-1] && v[i] > v[i+1]);
    if(flag1 || flag2) res++;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a, b, ave;
    cin >> a >> b;
    ave = (a + b) / 2;
    if((a % 2 == 1 && b % 2 == 0) || (a % 2 == 0 && b % 2 == 1))
        ave += 1;
    cout << ave << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define Max 300
using namespace std;
int findp(int i)
{
	return i / 2;
}

int findl(int i)
{
	return 2 * i;
}

int findr(int i)
{
	return 2 * i + 1;
}

int main()
{
	int n;
	int A[Max];
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> A[i];
	}
	for (int i = 1; i <= n; i++)
	{
		cout << "node " << i << ": key = " << A[i];
		if (findp(i) != 0)
			cout << ", parent key = " << A[findp(i)];
		if (findl(i) <= n)
			cout << ", left key = " << A[findl(i)];
		if (findr(i) <= n)
			cout << ", right key = " << A[findr(i)];
		cout <<", "<< endl;
	}
	return 0;

}



Measured memory_bytes: 3112
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 文字列の入力
    _ <- getLine
    s <- getLine
    -- 出力
    putStrLn . show $ max 0 $ maximum $ scanl (\acc c -> if c == 'I' then succ acc else pred acc) 0 s


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

int n, m, q;
vector<int> a, b, c, d;
int ans;
void dfs(vector<int> A) {
   if (A.size() == n + 1) {
      int now = 0;
      rep(i, 0, q) {
         if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
      }
      ans = max(ans, now);
      return;
   }
   A.push_back(A.back());
   while (A.back() <= m) {
      dfs(A);
      A.back()++;
   }
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   cin >> n >> m >> q;
   a.resize(q), b.resize(q), c.resize(q), d.resize(q);
   rep(i, 0, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
   dfs(vector<int>(1, 1));
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3656
# coding: utf-8
# Your code here!

def count(train):
    s = set()
    for i in range(len(train)):
        head = train[0:i+1]
        tail = train[i+1:]
        s.add(head + tail)
        s.add(head + tail[::-1])
        s.add(head[::-1] + tail)
        s.add(head[::-1] + tail[::-1])
        s.add(tail + head)
        s.add(tail + head[::-1])
        s.add(tail[::-1] + head)
        s.add(tail[::-1] + head[::-1])
    return len(s)

def main():
    n = int(input())
    for _ in range(n):
        print(count(input()))

main()



Measured memory_bytes: 5644
#include<stdio.h>

int main(void)
{
  int i,j,n,m,a[1000],s,s1;

  while(1)
    {
      scanf("%d",&n);
      scanf("%d",&m);
      if(n==0&&m==0) break;
      for(i=0;i<=n-1;i++)
	{
	  scanf("%d",&a[i]);
	}
      s1=0;
      for(i=0;i<=n-1;i++)
	{
	  for(j=i+1;j<=n-1;j++)
	    {
	      s=a[i]+a[j];
	      if(s<=m && s1<s) s1=s;
	    }
	}
      if(s1==0) printf("NONE\n");
      else printf("%d\n",s1);
    }
  return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;

    string s[h];

    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    for (int i = 0; i < h; i++) {
        cout << s[i] << endl << s[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256