akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = (1LL << 31) - 1;
const int MOD = (int)(1e9 + 7);

class RangeMinimumQuery {
public:
	int n;
	vector<int> d;
	RangeMinimumQuery(int m) {
		for (n = 1; n < m; n *= 2);
		d.assign(n * 2, INF);
	}
	void update(int i, int x) {
		d[n + i] = x;
		for (int j = (n + i) / 2; j > 0; j >>= 1)
			d[j] = min(d[j * 2], d[j * 2 + 1]);
	}
	//[l, r)
	int query(int l, int r) {
		int mi = get(l);
		for (; l && l + (l&-l) <= r; l += l&-l)
			mi = min(mi, d[(n + l) / (l&-l)]);
		for (; l < r; r -= r&-r)
			mi = min(mi, d[(n + r) / (r&-r) - 1]);
		return mi;
	}
	int get(int i) { return d[n + i]; }
};

signed main() {
	int n, q; cin >> n >> q;
	RangeMinimumQuery RMQ(n);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com == 0)RMQ.update(x, y);
		else cout << RMQ.query(x, y + 1) << endl;
	}
	return 0;
}

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


int main() {

    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 0; i <= b; ++i) {
        if (a*i % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,t;
    cin>>n>>t;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll rightm=0;
    map<ll,ll> m;
    for(int i=n-1;i>=0;i--){
        if(rightm>=a[i])m[rightm-a[i]]++;
        if(rightm<a[i])rightm=a[i];
    }
    ll ma=0;
    ll ans=0;
    for(auto &&a:m){
        if(ma<a.first){
            ma=a.first;
            ans=a.second;
        }
    }

    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 7296
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

if N == 0:
	print(0)
	exit()

lim = 32
top = [0]*(lim+1)
bottom = [0]*(lim+1)

for i in range(1, lim+1):
	if i%2:
		t = (i+1)//2
		top[i] = (4**t-1)//3
		bottom[i] = bottom[i-1]
	else:
		b = i//2
		bottom[i] = (4**b-1)*2//3
		top[i] = top[i-1]

digit = [0]*(lim+1)
for i in range(1, lim+1):
	digit[i] = (-2)**(i-1)

if 0 <= N:
	idx = bisect_left(top, N)
else:
	idx = bisect_left(bottom, -N)

ans = ""
for i in range(idx, 0, -1):
	if -bottom[i-1] <= N <= top[i-1]:
		ans += "0"
	else:
		ans += "1"
		N -= digit[i]

print(ans)

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

int main() {
  int N, ans = 0;
  cin  >> N;

  vector<int> a(N);
  loop(i, N) {
    cin >> a.at(i) ;
  }

  sort(a.begin(), a.end(), greater<int>());

  loop(i, N) {
    i % 2 == 0 ? ans += a.at(i) : ans -= a.at(i);
  }

  cout << ans << endl;
}


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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  int n; cin>>n;
  vi a(n); rep(i,n) cin>>a[i];
  int i=1,cnt=0;
  while(i!=2){
    cnt++;
    i=a[i-1];
    if(cnt>n){
      out(-1);
      return;
    }
  }
  out(cnt);
}

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


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#define mprint(x) printf(FORMATCONVERSION(x),(x))
#define FORMATCONVERSION(x) _Generic((x),\
                                    int:"%d",unsigned int:"%u",\
                                    double:"%lf",long long int:"%lld",\
                                    unsigned long long int:"%llu",\
                                    char :"%c",char*:"%s")


int main(void){
    int n;
    scanf("%d",&n);
    char str[n][51];
    for(int i = 0;i < n;i++)scanf("%s",str[i]);
    unsigned char_buf[26][n];

    for(int i = 0;i < n;i++)for(int j = 0;j < 26;j++)char_buf[j][i] = 0;

    for(int index = 0;index < n;index++)
        for(int ch = 0;ch < 26;ch++)
            for(int buf_ptr = 0;buf_ptr < strlen(str[index]);buf_ptr++)
                if(str[index][buf_ptr] == 'a' + ch)char_buf[ch][index]++;

    unsigned min = 334;
    for(int ch = 0;ch < 26;ch++){
        for(int index = 0;index < n;index++)if(char_buf[ch][index] < min)min = char_buf[ch][index];
        for(int count = 0;count < min;count++)putchar('a' + ch);
        min = 334;
    }
    return 0;        
}


Measured memory_bytes: 128
n = int(input())
g = [[] for _ in range(n)]
ans = 0
for i in range(n):
    ans += (i + 1) * (n - i)
for i in range(n - 1):
    a, b = map(int, input().split())
    a, b = min(a, b), max(a, b)
    ans -= a * (n - b + 1)
print(ans)


Measured memory_bytes: 83068
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 600000


int table[NUM];

int main(){

	for(int i = 0; i < NUM; i++)table[i] = 0;

	int N;
	scanf("%d",&N);

	int head_0_pos = 1,under_0_num = 0,minus,tmp_pos,tmp;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&tmp);

		if(table[0] == 1){
			printf("No\n");
			continue;
		}

		if(tmp >= NUM){
			printf("Yes\n");
			continue;
		}

		if(tmp < head_0_pos){

			if(tmp < head_0_pos-1 || under_0_num > 0){
				printf("No\n");
			}else{
				printf("Yes\n");
				table[0] = 1;
			}

		}else if(tmp == head_0_pos){

			printf("Yes\n");

			table[head_0_pos] = 1;

			minus = 0;

			head_0_pos++;
			while(table[head_0_pos] == 1){
				minus++;
				head_0_pos++;
			}

			under_0_num -= minus;

		}else{

			printf("Yes\n");

			tmp_pos = tmp;
			table[tmp_pos]++;

			while(table[tmp_pos] == 2){
				table[tmp_pos] = 0;
				table[tmp_pos-1]++;
				tmp_pos -= 1;
			}

			if(tmp_pos == head_0_pos){

				head_0_pos += 1;
				under_0_num -= (tmp-tmp_pos);

			}else{

				under_0_num++;
				under_0_num -= (tmp-tmp_pos);
			}
		}
	}

	return 0;
}



Measured memory_bytes: 5496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define INF 1000000007
#define MOD 1000000007
#define SEP " "

int		main(void)
{
	int n, k;
	string s;
	cin >> n >> k >> s;
	int c = 1;
	for (int i = 1; i < n; i++)
	{
		if(s[i] != s[i-1])
			c++;
	}
	c -= k * 2;
	cout << n - max(1, c) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
int n,a[max_n];
ll sum[max_n];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
    ll ans=1e18;
    ll res=0,x=0;
    for(int i=1;i<=n;i++){
        if(i&1){
            ll t=max(0ll,1-(sum[i]+x));
            res+=t;
            x+=t;
        }
        else{
            ll t=max(0ll,sum[i]+x+1);
            res+=t,x-=t;
        }
    }
    ans=min(ans,res);
    res=0,x=0;
    for(int i=1;i<=n;i++){
        if(i%2==0){
            ll t=max(0ll,1-(sum[i]+x));
            res+=t;
            x+=t;
        }
        else{
            ll t=max(0ll,sum[i]+x+1);
            res+=t,x-=t;
        }
    }
    ans=min(ans,res);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int gcd(int a, int b) {
	if (b == 0) {
		return a;
	}
	int r = a % b;
	return gcd(b, r);
}
int main(){
	int x1, x2,y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx = x2 - x1;
	int dy = y2 - y1;
	cout << x2 - dy <<" "<< y2 + dx<<" ";
	cout << x1 - dy <<" "<< y1 + dx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, k, cnt = 0;
	cin>>a>>b>>c>>k;
	cnt += min(a, k);
	D(cnt);
	k -= a;
	if (k > 0) k -= b;
	D(cnt);
	if (k > 0) cnt -= k;
	D(cnt);
	cout<<cnt<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}

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

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

int main(){
  stack<int> nums;
  string s;

  int n1,n2;

  while(cin>>s){
    if(s == "+"){
      n1 = nums.top();
      nums.pop();
      n2 = nums.top();
      nums.pop();
      nums.push(n1 + n2);
    }
    else if(s == "-"){
      n1 = nums.top();
      nums.pop();
      n2 = nums.top();
      nums.pop();
      nums.push(n2-n1);
    }
    else if(s == "*"){
      n1 = nums.top();
      nums.pop();
      n2 = nums.top();
      nums.pop();
      nums.push(n1*n2);
    }
    else{
      nums.push(atoi(s.c_str()));
    }
  }

  cout << nums.top() << endl;
}



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
#define rep(i,m,n) for(int i=m;i<(int)n;i++)
int main(){
    int h,w;
    cin>>h>>w;
    char a[h+2][w+2];
    rep(i,0,w+2){
        a[0][i]='#';
        a[h+1][i]='#';
    }
    rep(i,0,h+2){
        a[i][0]='#';
        a[i][w+1]='#';
    }
    rep(i,1,h+1){
        rep(j,1,w+1){
            cin>>a[i][j];
        }
        cout<<endl;
    }
    rep(i,0,h+2){
        rep(j,0,w+2){
            cout<<a[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
}

Measured memory_bytes: 3644
#coding:utf-8

def diff_A_temperature(T, A, x):
    H_T = T - (x * 0.006)
    diff_A = abs(H_T - A)

    return diff_A

def main():
    N = input()
    T, A = map(int, input().split())
    H_list = [int(i) for i in input().split()]
    H_diff_list = [diff_A_temperature(T, A, H) for H in H_list]
    print(H_diff_list.index(min(H_diff_list)) + 1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int p;
int main()
{int n;
 
    cin >> n;
    for (int i = 1; i <= n; ++ i)
    {
        int a;
        cin >> a;
        if (a & 1) p ^= 1;
    }
    if (!p) puts("YES");
    else puts("NO");
}

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

string s;
int k, n;

int main() {
	cin>>k>>s;
	n = s.size();
	if(n <= k) cout<<s;
	else {
		for(int i = 0; i < k; i++)
			cout<<s[i];
		cout<<"...";
	}
	return 0;
}

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

namespace std {

template<class Fun>
class y_combinator_result {
  Fun fun_;
public:
  template<class T>
  explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}

  template<class ...Args>
  decltype(auto) operator()(Args &&...args) {
    return fun_(std::ref(*this), std::forward<Args>(args)...);
  }
};

template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
  return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}

} // namespace std

using namespace std;

#ifdef LOCAL
#include "/Users/thakchir/Desktop/CP/Library/Debug/Debug.cpp"
#else
#define debug(...) 42
#endif

template <uint32_t mod>
class Modular {
private:
    uint32_t n;

public:
    Modular(int64_t _n = 0) : n((_n >= 0 ? _n : mod - (-_n) % mod) % mod) {}

    uint32_t get() const {
        return n;
    }

    bool operator==(const Modular &o) const {
        return n == o.n;
    }

    bool operator!=(const Modular &o) const {
        return n != o.n;
    }

    Modular& operator+=(const Modular &o) {
        n += o.n;
        n = (n < mod ? n : n - mod);
        return *this; 
    }

    Modular& operator-=(const Modular &o) {
        n += mod - o.n;
        n = (n < mod ? n : n - mod);
        return *this;
    }

    Modular& operator*=(const Modular &o) {
        n = uint64_t(n) * o.n % mod;
        return *this;
    }

    Modular& operator/=(const Modular &o) {
        return (*this) *= o.inv();
    }

    Modular operator+(const Modular &o) const {
        return Modular(*this) += o;
    }

    Modular operator-(const Modular &o) const {
        return Modular(*this) -= o;
    }

    Modular operator*(const Modular &o) const {
        return Modular(*this) *= o;
    }

    Modular operator/(const Modular &o) const {
        return Modular(*this) /= o;
    }

    Modular pow(uint64_t b) const {
        Modular ans(1), m = Modular(*this);
        while (b) {
            if (b & 1) {
                ans *= m;
            }
            m *= m;
            b >>= 1;
        }
        return ans;
    }

    Modular inv() const {
        int32_t a = n, b = mod, u = 0, v = 1;
        while (a) {
            int32_t t = b / a;
            b -= t * a;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        assert(b == 1);
        return Modular(u);
    }

    friend string to_string(const Modular &m) {
        return to_string(m.get());
    }
};

using Mint = Modular<int(1e9) + 7>;

void RunTestCase() {
  int s;
  cin >> s;
  vector<Mint> dp(s + 1);
  vector<int> seen(s + 1);
  Mint answer = y_combinator([&](auto self, int left) -> Mint {
    if (left < 3) {
      return 0;
    } else if (left == 3) {
      return 1;
    }
    auto &ans = dp[left];
    auto &vis = seen[left];
    if (!vis) {
      vis = true;
      ans = 1;
      for (int take = 3; left - take >= 3; ++take) {
        ans += self(left - take);
      }
    }
    return ans;
  })(s);
  cout << answer.get() << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  RunTestCase();
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  vector<int> a(5);
  REP(i, 5) cin >> a[i];

  int d = 10;
  REP(i, 5){
    if(a[i] % 10) d = min(d, a[i] % 10);
  }
  
  int sum = 0;
  REP(i, 5){
    sum += (a[i] / 10 + (a[i] % 10 != 0)) * 10;
  }

  if(d == 10)
    cout << sum << endl;
  else 
    cout << sum - (10-d) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  int n = s.size();
  bool ok = true;
  if(s[0] != 'A') ok = false;
  int count = 0;
  int j = 0;
  FOR(i, 2, n-1) if(s[i] == 'C') count++, j=i;
  if(count != 1) ok = false;
  FOR(i, 1, n){
    if(i == j) continue;
    if('A' <= s[i] && s[i] <= 'Z') ok = false;
  }
  if(ok) cout << "AC" << endl;
  else cout << "WA" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x[10000], i;

	for (i = 1;; i++) {
		scanf("%d", &x[i]);
		if (x[i] == 0) {
			break;
		}
		printf("Case %d: %d\n", i, x[i]);
	}


	return 0;
}


Measured memory_bytes: 2056
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    //高橋君のモンスター
    int A = sc.nextInt(); //体力
    int B = sc.nextInt(); //攻撃力
    //青木君のモンスター
    int C = sc.nextInt(); //体力
    int D = sc.nextInt(); //攻撃力
    //高橋君→青木君→・・・と攻撃を繰り返す
    int count = 0;
    do{
      if (count % 2 == 0){
      	C = C - B;
        //System.out.println( "青木君の体力=" + C);
      }
      else{
        A = A - D;
        //System.out.println( "高橋君の体力=" + A);
      }
      count++ ;
    }while(A*C > 0);
    //高橋君が勝てばYes、青木君が勝てばNo.
    if (A <= 0)
      System.out.println("No");
    else{
     if (C <= 0) 
      System.out.println("Yes");
     else
       System.out.println("ERROR");
    }
    
  }
}

Measured memory_bytes: 35504
using System;
class Test{
 
  public static void Main(){
    
    var S = Console.ReadLine();
    var s3 = S.Substring(2,1);
    var s4 = S.Substring(3,1);
    var s5 = S.Substring(4,1);
    var s6 = S.Substring(5,1);
    var res ="Yes";
    
    if(!s3.Equals(s4)){
      res = "No";
    }
    
    if(!s5.Equals(s6)){
      res = "No";
    }
    
    Console.WriteLine(res);
  }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	int k,x;
	cin>>k>>x;
	for(int i=x-k+1;i<x+k;i++)
		cout<<i<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

int main() {
  ll N;
  cin >> N;

  set<string> st;
  for (ll i = 0; i < N; i++)
  {
    string s;
    cin >> s;
    st.insert(s);
  }

  cout << st.size() << endl;
  
}

Measured memory_bytes: 19224
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int a, b;
	int num1, num2;

	string s;

	cin >> a >> b;

	std::stringstream ss;
	ss << a;

	s = ss.str();

	ss.str(""); // バッファをクリアする。
	ss.clear(stringstream::goodbit);

	ss << b;

	s += ss.str();

	num1 = atoi(s.c_str());
	num2 = sqrt((double)atoi(s.c_str()));

	if (num2 * num2 == num1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int main(){
  int a,foo,hoge;
  while(1){
    cin >> a;
    if(a==-1){
      break;
    }else{
      if(a<=10){
	foo=4280-1150;
      }else if(a>10&&a<=20){
	hoge=a-10;
	foo=1150+hoge*125;
	foo=4280-foo;
      }else if(a>20&&a<=30){
	hoge=a-20;
	foo=1150+1250+hoge*140;
	foo=4280-foo;
      }else if(a>30){
	hoge=a-30;
	foo=1150+1250+1400+hoge*160;
	foo=4280-foo;
      }
      cout << foo << endl;
    }
  }
  return 0;
}
	 



Measured memory_bytes: 3012
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,y;

int main(){
	cin>>n>>y;
	
	for(int i=0;i<=n&&y>=i*10000;i++){
		for(int j=0;i+j<=n&&y>=i*10000+j*5000;j++){
			if(i*10000+j*5000+(n-i-j)*1000==y){
				cout<<i<<" "<<j<<" "<<(n-i-j)<<endl;
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < (n);++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)

const ll INF = 1e9+7;

// 各桁の和
template<typename T>T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

int main() {
  ll n,W;cin>>n>>W;
  vector<ll> w(n),v(n);rep(i,n)cin>>w[i]>>v[i];
  
  ll dp[110][1010*110];
  rep(i,110)rep(j,1010*110)dp[i][j] = INF;
  dp[0][0] = 0;
  
  rep(i,n){
    rep(j,1010*110){
      if(j >= v[i])
      	dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
      else
        dp[i+1][j] = dp[i][j];
    }
  }
  
  int ans = 0;
  rep(i,1010*110)if(W >= dp[n][i]){
    ans=i;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 95744
#include<iostream>
#include<algorithm>
using namespace std;
int main(){

    string s;
    int n;
    cin>>n;
    int cnt = 0;
    bool flg = true;
    while(n--){
        char p;
        int x;
        cin>>p>>x;
        if(p == '(')cnt += x;
        else cnt -= x;
        if(cnt < 0){flg = false;break;}
    }
    if(flg&!cnt)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
//const ll mod = 1000000007;
//const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;

int n;
int a[1000][1000];

vector<P> G[1000][1000];
int c[1000][1000];
bool used[1000][1000];

void solve() {
	cin >> n;
	rep(i, n) {
		rep(j, n - 1) {
			cin >> a[i][j]; a[i][j]--;
		}
	}
	rep(i, n) {
		rep(j, n - 2) {
			int frl = min(i, a[i][j]);
			int frr = max(i, a[i][j]);
			int tol = min(i, a[i][j + 1]);
			int tor = max(i, a[i][j + 1]);
			c[tol][tor]++;
			G[frl][frr].push_back({ tol,tor });
		}
	}
	queue<P> q;
	rep(i, n) {
		Rep(j,i+1, n) {
			if (c[i][j] == 0) {
				q.push({ i,j });
			}
		}
	}
	int tmp = 0;
	while (!q.empty()) {
		int len = q.size();
		rep(aa, len) {
			P id = q.front(); q.pop();
			used[id.first][id.second] = true;
			rep(j, G[id.first][id.second].size()) {
				P to = G[id.first][id.second][j];
				int l = to.first, r = to.second;
				c[l][r]--;
				if (c[l][r] == 0) {
					q.push({ l,r });
				}
			}
		}

		tmp++;
	}
	rep(i, n) {
		Rep(j,i+1, n) {
			if (!used[i][j]) {
				cout << -1 << endl; return;
			}
		}
	}
	cout << tmp << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	//init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 48128
# coding: utf-8
# Your code here!
import sys
input = sys.stdin.readline

A, B, C, X = [int(input()) for _ in range(4)]

cnt = 0
for i in range(A+1):
    X1 = X - 500 * i
    if X1 >= 0:
        for j in range(B+1):
            X2 = X1 - 100 * j
            if X2 >= 0 and X2 <= 50 * C:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;

int base = 0;

int N, W;
int w[105], v[105];

int dp[105][305][105]; //[i][j][k] i番目以降の荷物から重さがW - jになるように選ぶ

int rec(int i, int j, int k){
    if(dp[i][j][k] >= 0){
        return dp[i][j][k];
    }

    int res;
    if(i == N){
        res = 0;
    }else if(W - k * base - j < w[i] + base){
        res = rec(i + 1, j, k);
    }else{
        res = max(rec(i + 1, j, k), rec(i + 1, j + w[i], k + 1) + v[i]);
    }
    return dp[i][j][k] = res;
}

int main(){
    cin >> N >> W;

    rep(i,N){
        cin >> w[i] >> v[i];
        if(base == 0) base = w[i];
    }
    rep(i,N) w[i] -= base;

    memset(dp, -1, sizeof(dp));
    printf("%d\n", rec(0,0,0));
}


Measured memory_bytes: 13440
N=int(input())
A=list(map(int,input().split()))
d={}
for i in A:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
a=0
for i in range(30,0,-1):
    t=2**i
    if t//2 in d:
        a+=d[t//2]//2
        if d[t//2]%2:
            d[t//2]=1
        else:
            d.pop(t//2)
    for n,v in d.items():
        if n>=t//2:
            continue
        if t-n in d:
            w=d[t-n]
            if v>w:
                a+=w
                d[n]=v-w
                d[t-n]=0
            else:
                a+=v
                d[t-n]=w-v
                d[n]=0    
print(a)

Measured memory_bytes: 108116
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 2e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;
vector<int> g[MAX];
bool vis[MAX];

bool dfs(int u, int cnt) {
	vis[u] = true;
	if (cnt == 2) {
		return u == N;
	}
	for (int i = 0; i < g[u].size(); ++i) {
		int v = g[u][i];
		if (vis[v]) continue;
		if (dfs(v, cnt + 1)) return true;
	}
	return false;
}

int main()
{
	int i, j, k;
	scanf("%d%d", &N, &M);
	int u, v;
	for (i = 1; i <= M; ++i) {
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if (dfs(1, 0)) printf("POSSIBLE");
	else printf("IMPOSSIBLE");

}


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

int main() {
  int n; cin >> n;
  unordered_map<string, int> um;
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    ++um[s];
  }
  
  vector<pair<int, string> > v;
  for (auto itr = um.begin(); itr != um.end(); ++itr)
    v.push_back(make_pair(itr->second, itr->first));
  sort(v.begin(), v.end(), [](pair<int, string> p1, pair<int, string> p2) {
    return p1.first > p2.first || p1.first == p2.first && p1.second < p2.second;
  });
  
  auto itr = v.begin();
  int times = itr->first;
  while (itr->first == times) {
    cout << itr->second << endl;
    ++itr;
  }
}

Measured memory_bytes: 29252
#include <cstdio>
#include <iterator>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int MAXN = 234567;
int a[MAXN];

bool check(int N, int ans) {
     stack<pii> stk;
     for (int i = 1; i < N; i++) {
         if (a[i] > a[i - 1]) continue;
         if (ans == 1) return false;
         int cur = a[i], cnt = 1;
         while (!stk.empty() && stk.top().first > cur) stk.pop();
         while (!stk.empty() && (stk.top().first == cur && stk.top().second == ans)) {
               cur--;
               stk.pop();
         }
         if (cur == 0) return false;
         if (stk.empty() || stk.top().first < cur) stk.push(make_pair(cur, 2));
         else {
            cnt += stk.top().second;
            stk.pop();
            stk.push(make_pair(cur, cnt));
         }
     }
     return true;
}

int main() {
    int N;
    //freopen("in20.txt", "r", stdin);
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &a[i]);
    }
    int l = 1, r = (int)2e5 + 1;
    while (l < r) {
          int mid = (l + r) / 2;
          if (check(N, mid)) {
             r = mid;
          } else {
             l = mid + 1;
          }
    }
    printf("%d\n", l);
    return 0;
}
//in06 ans: 4
//in20 ans: 50


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define M 500010
ll ex(ll a,ll b){ll ans=1;while(b){if(b&1)ans=(ans*a)%md;a=(a*a)%md,b/=2;}return ans;} 
inline ll add(ll a,ll b){a=a%md+b%md;if(a>md)a%=md;return a;}
inline ll sub(ll a,ll b){a=a%md-b%md;if(a<0)a+=md;return a;}
inline ll mul(ll a,ll b){a%=md,b%=md;return (a*b)%md;}


ll f[M],iv[M];
ll C(ll n,ll r){
	if(n<r)return 0;
	return mul(f[n],mul(iv[r],iv[n-r]));
}

void prep_fac(){
	f[0]=1;
	rep(i,1,M)f[i]=mul(i,f[i-1]);
	iv[M-1]=ex(f[M-1],md-2);
	for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}

// common=x  C(m,x)C(m-x,n-x)C(m-x-(n-x),n-x)
// 12 13 23 21 31 32 
// n!-C(x,1)(n-1)!+C(x,2)(n-2)!-..
// n!-(x+1)(n-1)!/1!+(x+1)x(n-2)!/2!
// C(n,x)C(x,i)=n!/(n-x)!i!(x-i)! =C(n,i)C(n-i,n-x)
// C(m,n)n!sum x-0,n i>=0 (-1)^i C(n,x) C(m-n,n-x) C(x,i)(n-i)! =
//  C(n,i)  sum x-0,n C(m-n,n-x) C(n-i,x-i) (n-i)!^2 = C(n,i) C(m-i,n-i) (n-i)!
int main(){
    IOS;
 	
 	prep_fac();
 	ll n,m;cin>>n>>m;
 	ll ans=0,ok=1;
 	rep(i,0,n+1){
 		ans=(ans+ok*mul(C(n,i),mul(C(m-i,n-i),f[n-i])))%md;
 		(ans+=md)%=md;	ok*=-1;
 	}
 	ans=mul(ans,mul(C(m,n),f[n]));
 	cout<<ans;
 	
	
    return 0;
}

Measured memory_bytes: 11420
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int N;
    cin >> N;
    
    float bitcoin_price = 380000.0;
    float otoshidama_sum = 0;
    for ( int i = 0; i < N; i++ ) {
        float price;
        string currency_type;
        cin >> price >> currency_type;
        if (currency_type == "JPY") {
            otoshidama_sum += price;
        } else {
            // bitcoin
            otoshidama_sum += price * bitcoin_price;
        }
    }
    cout << otoshidama_sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x),end(x)
#define rall(x) (x).rbegin(),(x).rend()
#define REP(i,b,n) for(int i=(int)(b);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define repsz(i,v) rep(i,(v).size())
#define aur auto&
#define bit(n) (1LL<<(n))
#define eb emplace_back
#define mt make_tuple
#define fst first
#define snd second
using namespace std;
typedef long long ll;
//#define int long long
template<class C>int size(const C &c){ return c.size(); }
template<class T,class ...U>bool chmin(T&a, const U&...bs){const T b(bs...);if(a<=b)return false;a=b;return true;}
template<class T,class ...U>bool chmax(T&a, const U&...bs){const T b(bs...);if(a>=b)return false;a=b;return true;}

bool solve(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> black(n+1), white(n+1);
    rep(i, n) black[i+1] = black[i] + (s[i] == '#');
    rep(i, n) white[i+1] = white[i] + (s[i] == '.');
    int res = n;
    rep(i, n+1) chmin(res, black[i] + (white.back() - white[i]));
    cout << res << endl;
    return true;
}
signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}
// vim:set foldmethod=marker commentstring=//%s:


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

int main()
{
    int n;
    char s[105];
    cin >> s >> n;
    int len=strlen(s);
    int num1=0,num2=0;
    if(len==1){
        cout << 1ll*len*n/2 << endl;
        return 0;
    }
    int flag=0;
    for(int i=1;i<len;i++){
        if(s[i]!=s[i-1]){
            flag=1;
            break;
        }
    }
    if(flag==0){
        cout << 1ll*len*n/2 << endl;
        return 0;
    }
    for(int i=1;i<len;i++){

        if(s[i]==s[i-1]){
            num1++;
            i++;
        }
    }
    for(int i=1;i<2*len;i++){
        if(s[i%len]==s[(i-1)%len]){
            num2++;
            i++;
        }
    }
    num2-=num1;
    cout << 1ll*(n-1)*num2+num1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int D,G;
	cin>>D>>G;
	vector<int> p(D),c(D);
	rep(i,D)cin>>p[i]>>c[i];
	ll ans = INF;
	// 全探索 --- bit は {0, 1, ..., n-1} の 2^n 通りの部分集合全体を動きます。
	for (int bit = 0; bit < (1<<D); ++bit){
		/* bit で表される集合の処理を書く */
		ll sum = 0;
		ll cnt = 0;
		for (int i = 0; i < D; ++i){
			//100*(i+1)点問題をすべて解くことになっているならば
			if(bit & (1<<i)){
				sum += c[i] + 100*(i+1)*p[i];
				cnt += p[i];
			}
		}
		if(sum >=G){
			ans = min(ans, cnt);
		}
		else{
			for (int i = D-1; i >= 0; --i){
				if(bit & (1<<i))continue;
				for (int j = 0; j < p[i]; ++j){
					if(sum >= G)break;
					sum += 100*(i+1);
					cnt++;
				}
			}
			ans = min(ans, cnt);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int linear (int S[], int n, int key) {
  int i = 0; int f;
  S[n] = key;
  while (S[i] != key) {
    i++;
  }
  f = (i != n) ? 1 : 0;
  return f;
}

int main (void) {
  int n, q, i, key, cnt = 0;
  int S[10000];
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &S[i]);
  }
  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%d", &key);
    if (linear (S, n, key)) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
}



Measured memory_bytes: 2140
K=int(input())
N=3
pr=10**9+7
a=0
l=[None]*(K+1)
for i in range(K,0,-1):
    t=pow(K//i,N,pr)
    c=i*2
    while c<=K:
        t-=l[c]
        c+=i
    l[i]=t
    a=(a+t*i)%pr
print(a)

Measured memory_bytes: 61984
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;

ll func(ll x, ll y) {
	if (y - x >= 0) return y - x;
	return LINF;
}


int main()
{
	int i, j, k;
	ll x, y;
	scanf("%lld%lld", &x, &y);
	ll mini = LINF;
	mini = min(mini, func(x, y));
	mini = min(mini, func(-x, y) + 1LL);
	mini = min(mini, func(x, -y) + 1LL);
	mini = min(mini, func(-x, -y) + 2LL);
	printf("%lld", mini);

}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  tmp=input[1].split(" ");
  a = new Array(n).fill(0);
  b = new Array();
  var max=-Math.pow(10,6)-1;
  var min=Math.pow(10,6)+1;
  for(i=0;i<n;i++){
    a[i]=parseInt(tmp[i]);
    max=Math.max(a[i],max);
    min=Math.min(a[i],min);
  }
  if(max>=Math.abs(min)){
    for(i=0;i<n;i++){
      if(a.indexOf(max)!=i){
        bsub=[a.indexOf(max)+1,i+1];
        b.push(bsub);
        a[i]=a[i]+max;
      }
    }
    for(i=0;i<n;i++){
      if(i>0&&a[i]<a[i-1]){
        bsub=[i,i+1];
        b.push(bsub);
        a[i]=a[i-1]+a[i];
      }
    }
  }else if(Math.abs(min)>max){
    for(i=0;i<n;i++){
      if(a.indexOf(min)!=i){
        bsub=[a.indexOf(min)+1,i+1];
        b.push(bsub);
        a[i]=a[i]+min;
      }
    }
    for(i=n-1;i>=0;i--){
      if(i<n-1&&a[i]>a[i+1]){
        bsub=[i+2,i+1];
        b.push(bsub);
        a[i]=a[i+1]+a[i];
      }
    }
  }
  var ans =b.length;
  for(i=0;i<b.length;i++){
    ans+="\n"+b[i][0]+" "+b[i][1];
  }
  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define forn(n1,n2) for(ll i=n1;i<n2;i++)
#define w(t) ll t;cin>>t;while(t--)
#define en "\n"
#define mod 1e6+3
#define f first
# define s second
using namespace std;
ll i,n,m,x,y,z,j,k,l,mn=LLONG_MAX,mx=0,c,a[100005],r,cnt=0,sum=0;
string str;char ch;set<ll>s;map<ll,ll>mp;
vector<vector<ll>>g;
vector<ll>v;
void swap(int *xp, int *yp)  
{  
    int temp = *xp;  
    *xp = *yp;  
    *yp = temp;  
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,x,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t;
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	a[0]=-1;
	int ans[n]={0};
	for(int i=1;i<n;i++)
	{
		cin>>a[i];
		a[i]--;
		ans[a[i]]++;
	}
	for(int i=0;i<n;i++)
	{
		cout<<ans[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 5204
#include<iostream>
#include<algorithm>
using namespace std;
int a,b,c;
int main(void){
	cin>>a>>b>>c;
	cout<<min(min(abs(a-b)+abs(b-c),abs(a-c)+abs(c-b)),min(abs(a-b)+abs(c-a),abs(b-c)+abs(c-a)));
	return 0;
} 

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

int N;
vector<int> a;

int main()
{
  cin >> N;
  a.resize(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a[i];
  }

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int AliceSc = 0;
  int BobSc = 0;

  bool AliceTurn = true;

  for (int i = 0; i < N; i++)
  {
    if (AliceTurn)
    {
      AliceSc += a[i];
    }
    else
    {
      BobSc += a[i];
    }
    AliceTurn = !AliceTurn;
  }

  cout << AliceSc - BobSc << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int ihund = n-m;
		int kaitoums = m * 1900 + ihund * 100;
		for(;m>0;m--){
			kaitoums *= 2;
		}
		System.out.println(kaitoums);
    }
}


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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const int N = (int)1e5+77;
const ll inf = (ll) 1e15+77;
const int mod = (int) 1e9 + 7;
const ld pi = acos(-1);

int n, x;
double p[305][305][305], dp[305][305][305];

int main() {
    fast;
    cin >> n;
    vector<int> cnt(4, 0);
    forn(i, n) {
        cin >> x;
        ++cnt[x];
    }
    p[cnt[1]][cnt[2]][cnt[3]] = 1;
    ford(c, n, 0) {
        ford(b, n, 0) {
            ford(a, n, 0) {
                if (a == 0 and b == 0 and c == 0) continue;
                if (a + b + c > n) continue;
                double p_waste = (double) (n - (a + b + c)) / n;
                double dp_waste = p_waste / (1 - p_waste) + 1;
                dp[a][b][c] += dp_waste * p[a][b][c];

                if (a != 0) {
                    double p_go = (double) a / (a + b + c);
                    p[a - 1][b][c] += p[a][b][c] * p_go;
                    dp[a - 1][b][c] += dp[a][b][c] * p_go;
                }

                if (b != 0) {
                    double p_go = (double) b / (a + b + c);
                    p[a + 1][b - 1][c] += p[a][b][c] * p_go;
                    dp[a + 1][b - 1][c] += dp[a][b][c] * p_go;
                }

                if (c != 0) {
                    double p_go = (double) c / (a + b + c);
                    p[a][b + 1][c - 1] += p[a][b][c] * p_go;
                    dp[a][b + 1][c - 1] += dp[a][b][c] * p_go;
                }
            }
        }
    }
    printf("%.10lf\n", dp[0][0][0]);
    return 0;
}

Measured memory_bytes: 438528
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int ans = 0;
        int startWith = 0;
        int endWith = 0;
        int b_any_a = 0;
        int n = sc.nextInt();
        for(int i = 0;i < n;i++){
            String str = sc.next();
            for(int x = 0;x < str.length()-1;x++){
                if(str.substring(x,x+2).equals("AB")) ans++;
            }
            if(str.charAt(0) == 'B' & str.charAt(str.length()-1) == 'A'){
                b_any_a++;
            }else{
                if(str.charAt(0) == 'B') startWith++;

                if(str.charAt(str.length()-1) == 'A') endWith++;
            } 
        }

        if(b_any_a == 0){
            ans+=Math.min(startWith,endWith);
        }else if(startWith + endWith == 0){
            ans += b_any_a - 1;
        }else if(startWith + endWith > 0){
            ans += b_any_a + Math.min(startWith,endWith);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 33184
def check(hate, x)
  x.to_s.chars.each do |i|
    if hate.include?(i)
      return false
    end
  end
  return true
end

n, k = gets.split.map(&:to_i)
hate = gets.split.map


while !check(hate, n)
  n += 1
end

puts n


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
typedef pair<int, int> P;
typedef pair<pair<int, int>, int> PP;
typedef bitset<61> Bitset;
const ll INFL = 1LL << 60;
const ll MOD = 1000000007;
const int INF = INT_MAX;
const int MAX = 300000;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin>>n;
    vector<string>s(n);
    map<string,int> mp;
    int mx = 0;
    for(int i = 0; i < n; i++) {
        cin>>s[i];
        mp[s[i]]++;
        mx = max(mx,mp[s[i]]);
    }
    vector<string>str;
    for(int i = 0; i < n; i++) {
        if(mp[s[i]]==mx) {
            str.push_back(s[i]);
            mp[s[i]]--;
        } 
    }
    sort(str.begin(),str.end());
    for(auto t : str) cout<<t<<endl;

}


Measured memory_bytes: 27120
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long LL;

int main(){
    int n;
    int toint[256];
    for(int i = 0; i < 10; i++){
        toint[i + '0'] = i;
    }
    for(int i = 0; i < 26; i++){
        toint[i + 'A'] = 10 + i;
    }
    for(int i = 0; i < 26; i++){
        toint[i + 'a'] = 36 + i;
    }
    while(cin >> n){
        LL sum = 0;
        for(int i = 0; i < n; i++){
            LL x = 0;
            int p;
            char m[100];
            scanf("%d %s", &p, m);
            for(int idx = 0; m[idx]; idx++){
                x = x * p + toint[m[idx]];
            }
            sum = sum ^ x;
        }
        if(sum == 0){
            cout << "lose" << endl;
        }else{
            cout << "win" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1240