akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

typedef long long int64;

int n, l;
int a[100000];

int dp[100000];

int calc(int pos)
{
	int wait = 0;
	
	if(dp[pos] != 0)
		return dp[pos];
	
	if(0 < pos && a[pos] < a[pos - 1])
		wait = max(wait, calc(pos - 1));
	if(pos < n - 1 && a[pos] < a[pos + 1])
		wait = max(wait, calc(pos + 1));
		
	return dp[pos] = wait + l - a[pos];
}
	
int main()
{
	scanf("%d%d", &n, &l);
	for(int i = 0; i < n; ++i)
		scanf("%d", a + i);
		
	int ans = 0;
	
	for(int i = 0; i < n; ++i)
		ans = max(ans, calc(i));
		
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    string s; cin >> s;
    string t = "keyence";
    ll d = abs((ll)t.size() - (ll)s.size());
    bool chk = false;

    // i文字からd文字切り出し、7文字にした文字列s'をtと比較する。
    for(ll i=0; i<s.size()-d; i++){
        string sd = s.substr(0, i) + s.substr(i+d);
        if(sd == t){
            chk = true;
            break;
        }
    }
    chk ? YES() : NO();
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    int n, arr[100000];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    for (int i = 1; i < n; i++)
        if (arr[i] > arr[i - 1])
            arr[i]--;

    for (int i = 1; i < n; i++)
        if (arr[i] < arr[i - 1])
            return cout << "No\n", 0;
    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 1152
# To add a new cell, type '# %%'
# To add a new markdown cell, type '# %% [markdown]'

# %%
lst = input().split()

# %%
one = lst[0][0]
two = lst[0][1]
three = lst[0][2]


# %%
one_two = one != two
two_three = two != three
three_one = three != one


# %%
any([one_two, two_three, three_one])


# %%
if any([one_two, two_three, three_one]):
    print('Yes')
else:
    print('No')


# %%




Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            //入力読取。
            List<string> recordList = new List<string>();
            string strBreak = "-1 -1 -1";
            while (true)
            {
                string strRecord = Console.ReadLine();
                if (strRecord == strBreak)
                {
                    break;
                }
                string[] strRecordArray = strRecord.Split(' ');
                int intMidScore = int.Parse(strRecordArray[0]);
                int intTermScore = int.Parse(strRecordArray[1]);
                int intRetScore = int.Parse(strRecordArray[2]);
                Teacher insT = new Teacher(intMidScore, intTermScore, intRetScore);
                string strGrade = insT.GetGrade();
                recordList.Add(strGrade);
            }

            //出力
            foreach (string announce in recordList)
            {
                Console.WriteLine(announce);
            }
            
            Console.ReadKey();
        }
    }

    class Teacher
    {

        private int intMidScore;
        private int intTermScore;
        private int intRetScore;
        private string strGrade;

        public Teacher(int intMidScore, int intTermScore, int intRetScore)
        {
            this.intMidScore = intMidScore;
            this.intTermScore = intTermScore;
            this.intRetScore = intRetScore;
            Grading();
        }

        private void Grading()
        {
            int intSum = intMidScore + intTermScore;
            if (intMidScore == -1 || intTermScore == -1)
            {
                this.strGrade = "F";
            }
            else if (80 <= intSum)
            {
                this.strGrade = "A";
            }
            else if (65 <= intSum && intSum < 80)
            {
                this.strGrade = "B";
            }
            else if (50 <= intSum && intSum < 65)
            {
                this.strGrade = "C";
            }
            else if (30 <= intSum && intSum < 50)
            {
                if (50 <= intRetScore)
                {
                    this.strGrade = "C";
                }
                else
                {
                    this.strGrade = "D";
                }
            }
            else
            {
                this.strGrade = "F";
            }
        }

        public string GetGrade()
        {
            return strGrade;
        }

    }


}



Measured memory_bytes: 15896
double*q,s[99],*p=s+2,v,atof();short t[9];main(c){for(;~scanf("%s%c",t,&c);c-10||printf("%f\n",*--p))v=*--p,q=p-1,*q=*t-43?*t-45?*t-42?*t-47?p++,*p++=atof(t),*q:*q/v:*q*v:*q-v:*q+v;}

Measured memory_bytes: 0
n,m,Q=map(int,input().split())
M=[[0]*n for _ in range(n)]
for i in range(m):
    l,r=map(int,input().split())
    M[r-1][l-1]+=1

for q in range(n):
    for p in reversed(range(1,n)):
        M[q][p-1]+=M[q][p]
for p in range(n):
    for q in range(n-1):
        M[q+1][p]+=M[q][p]        

for i in range(Q):
    p,q=map(int,input().split())
    print(M[q-1][p-1])

Measured memory_bytes: 57432
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
using std::cin; using std::cout;
using std::endl;
using std::bitset; using std::map;
using std::queue; using std::priority_queue;
using std::set; using std::string;
using std::stringstream; using std::vector;
using std::pair; using std::make_pair;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<ULL, ULL> puu;
#ifdef DEBUG
using std::cerr;
#define pass cerr << "[" << __FUNCTION__ << "] : line = " << __LINE__ << endl;
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)                      \
	{                                           \
		cerr << #a << " = {";                   \
		for (int qwq = (st); qwq <= (n); ++qwq) \
			if (qwq == (st))                    \
				cerr << a[qwq];                 \
			else                                \
				cerr << ", " << a[qwq];         \
		cerr << "}" << endl;                    \
	}
#define displayv(a) displaya(a, 0, (int)(a.size() - 1))
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#include <ctime>
class MyTimer {
	clock_t st;
public:
	MyTimer() { cerr << std::fixed << std::setprecision(0); reset(); }
	~MyTimer() { report(); }
	void reset() { st = clock_t(); }
	void report() {  cerr << "Time consumed: " << (clock() - st) * \
		1e3 / CLOCKS_PER_SEC << "ms" << endl; }
} myTimer;
#else
#define cerr if(false) std::cout
#define pass ;
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(a) ;
#define eprintf(...) if(0) fprintf(stderr, __VA_ARGS__)
class MyTimer {
public: void reset() {} void report() {}
} myTimer;
#endif

template<typename A, typename B>
std::ostream& operator << (std::ostream &cout, const pair<A, B> &x) {
	return cout << "(" << x.first << ", " << x.second << ")";
}
template<typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }

const int maxN = 200000 + 233;
const LL P = 1000000007;
int n, a[maxN];
set<int> S[maxN];
LL f[maxN];

int main() {
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	for(int i = 1; i <= n; ++i) S[a[i]].insert(i);
	memset(f, 0, sizeof(f));
	f[1] = 1;
	for(int i = 1; i < n; ++i) {
		auto p = S[a[i]].upper_bound(i);
		(f[i + 1] += f[i]) %= P;
		if(a[i] != a[i + 1] && p != S[i].end()) {
			(f[*p] += f[i]) %= P;
		}
	}
	cout << f[n] << endl;
	return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,y;
    cin >> n >> y;
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n-i; j++){
            if(10000*i + 5000*j + 1000 * (n-i-j) == y){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }






int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w,n,sr,sc;cin >> h >> w >> n >> sr >> sc;
	string s,t;cin >> s >> t;
	reverse(s.begin(),s.end());
	reverse(t.begin(),t.end());
	int l = 0, r = w + 1, u = 0, d = h + 1;
	bool ok = true;
	rep(i,n){
		if(t.at(i) == 'U'){
			if(d <= h) d++;
		}
		else if(t.at(i) == 'D'){
			if(u > 0) u--;
		}
		else if(t.at(i) == 'R'){
			if(l > 0) l--;
		}
		else{
			if(r <= w) r++;
		}
		if(s.at(i) == 'U'){
			u++;
		}
		else if(s.at(i) == 'D'){
			d--;
		}
		else if(s.at(i) == 'L'){
			l++;
		}
		else{
			r--;
		}
		if(r == 1 || l == w || u == h || d == 1 || l >= r || u >= d) ok = false;
	}
	if(sr <= u || sr >= d || sc <= l || sc >= r) ok = false;
	if(ok) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 920
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> ds(n, 0);
    for(int i = 0; i < n; ++i){
        cin >> ds.at(i);
    }
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        ll cost;
        cin >> cost;
        if(ds.at(i) > cost){
            ans += ds.at(i) - cost;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    bool is_zero = false;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 0) is_zero = true;
    }
    if (is_zero) {
        cout << 0 << '\n';
        return 0;
    }
    long long answer = 1;
    double g = 1;
    for (int i = 0; i < n; ++i) {
        g *= a[i];
        if (g > 2e18) {
            answer = -1;
            break;
        }
        answer *= a[i];
    }
    cout << (answer <= (long long) (1e18) ? answer : -1) << '\n';
    return 0;
}

Measured memory_bytes: 3976
/**
 *    author: apurba_debnath
**/
#include <bits/stdc++.h>


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    int n, o;
    cin >> n;
    o = n % 10;
    if (o == 2 || o == 4 || o == 5 || o == 7 || o == 9)
        cout << "hon";
    else if (o == 0 || o == 1 || o == 6 || o == 8)
        cout << "pon";
    else
        cout << "bon";

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

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

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

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


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  set<int> redflg;
  int n,m;
  cin>>n>>m;
  vector<int> c(n,1);
  redflg.insert(0);
  for(int i = 0; i < m; i++){
    int x,y;
    cin>>x>>y;
    x--;
    y--;
    c[x]--;
    c[y]++;
    if(redflg.find(x)!=redflg.end()){
      redflg.insert(y);
      if(c[x]==0) redflg.erase(x);
    }
    // cout<<c[x]<<endl;
    // for(auto a: redflg){
    //   if(x==a){
    //     redflg.insert(y);
    //     if(c[a]==0) redflg.erase(x);
        
    //   }
    // }
    // cout<<endl;
  }
  int ans=0;
  for(auto a: redflg){
    // cout<<a<<" ";
    if(c[a]>0){
      ans++;
    }
  }
  // cout<<endl;
  cout<<ans<<endl;
  return 0;
}



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

using namespace std;


int main(){

 string A,B,C;

  cin>>A>>B>>C;

  if(A[A.length()-1] == B[0] && B[B.length()-1] == C[0])
   cout<<"YES"<<endl;
   else cout<<"NO"<<endl;


return 0;
}









Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
que = deque()

blck = [1] * (w + 2)
data = [blck]
for ln in range(1, h+1):
    line = list(input().rstrip())
    lineN = [0] * (w+2)
    lineN[0] = 1
    lineN[-1] = 1
    for r, letter in zip(range(1, w+1), line):
        if letter == '#':
            lineN[r] = 1
            que.append((ln, r))
    data.append(lineN)
data.append(blck)


count = 0
next = deque()
while len(que) > 0:
    count += 1
    while len(que) > 0:
        r, c = que.popleft()

        r -= 1
        if data[r][c] == 0:
            next.append((r, c))
            data[r][c] = 1

        r += 2
        if data[r][c] == 0:
            next.append((r, c))
            data[r][c] = 1

        r-=1
        c-=1
        if data[r][c] == 0:
            next.append((r, c))
            data[r][c] = 1

        c+=2
        if data[r][c] == 0:
            next.append((r, c))
            data[r][c] = 1
    que, next = next, que

print(count - 1)

Measured memory_bytes: 101724
n,m=map(int,input().split())
info=[]
for i in range(n):
    info.append(list(map(int,input().split())))
    
info.sort()

sum_2=0
sum_3=0
index=0
for j in range(n):
    sum_2+=info[j][1]
    if sum_2<m:
        continue
    else:
        index=j
        break
        
for k in range(index):
    sum_3+=info[k][0]*info[k][1]
    
print(sum_3+info[index][0]*(m-(sum_2-info[index][1])))

Measured memory_bytes: 27760
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>; 
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;


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

  ll A,B,X; cin >> A>>B>>X;
  
  double ans = 0;
  if ((A*B/2.0)*A >= X) {
    ans = atan(A*B*B/2.0/X);
  } else {
    ans = atan(2.0*B/A - 2.0*X/A/A/A);
  }

  ans *= 180.0/M_PI;
  printf("%.10f\n", ans);

  return 0;
}

Measured memory_bytes: 256
import re

s = input()
s = s.replace('BC', 'D')
ss = [c for c in re.split('[BC]', s) if c != '']

sum = 0
for s in ss:
  na = 0
  for c in s:
    if c == 'A':
      na += 1
    else:
      sum += na

print(sum)


Measured memory_bytes: 6052
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
min = a
if b < min:
    min = b
if c < min:
    min = c
if d < min:
    min = d
if e < min:
    min = e
ans = n//min+5
if n%min == 0:
    ans = ans - 1
print (ans)


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n && n;){
		vs lines(n);
		rep(i,n) cin>>lines[i];
		
		vi prev(n,-1);
		rep(i,n) if(lines[i].back()=='v'){
			prev[i]=i+1;
			//lines[i].pop_back();
			lines[i].erase(end(lines[i])-1);
		}
		map<string,int> f;
		per(i,n) if(lines[i].size() && isdigit(lines[i].back()))
			rep(j,lines[i].size())
				if(isdigit(lines[i][j])){
					string tag=lines[i].substr(0,j);
					int x=stoi(lines[i].substr(j));
					if(x>1) prev[i]=f[tag];
					f[tag]=i;
				}
		
		vvi pathes;
		vi vis(n);
		rep(i,n) if(!vis[i]){
			vi path;
			for(int v=i;v!=-1;v=prev[v]){
				path.push_back(v);
				vis[v]=1;
			}
			reverse(all(path));
			pathes.push_back(path);
		}
		sort(all(pathes));
		
		rep(i,pathes.size()) rep(j,pathes[i].size())
			cout<<pathes[i][j]+1<<endl;
	}
}

Measured memory_bytes: 2956
import numpy as np
X, N = list(map(int,input().split()))
if N == 0:
  print(X)
else:
  p_arr = list(map(int,input().split()))
  for i in range(101):
    if i == 0:
      if not (X in p_arr):
        print(X)
        break
    else:

      lower = (X-i in p_arr)
      upper = (X+i in p_arr)
      if not lower:
        print(X-i)
        break
      else:
        if not upper:
          print(X+i)
          break


Measured memory_bytes: 26996
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 1e5 + 5, mod = (int) 0;
int a[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, res = 0;
    cin >> n;
    for (int j = 0; j < n; ++j) {
        cin >> a[j];
    }
    int g = 0;
    while (true) {
        int cur = 0;
        for (int i = 0; i < n; ++i) {
            cur ^= a[i] - 1;
            cur &= 1;
        }
        if (cur == 1) {
            cout << (g == 0? "First": "Second");
            return 0;
        }
        int cnt = 0;
        int flag = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] == 1) {
                cnt = 2;
                flag = 1;
            }
            cnt += a[i] & 1;
        }
        if (cnt != 1) {
            cout << (g == 1? "First": "Second");
            return 0;
        }
        int gc = 0;
        for (int j = 0; j < n; ++j) {
            if (a[j] & 1) a[j]--;
            gc = (gc == 0? a[j]: __gcd(gc, a[j]));
        }
        for (int j = 0; j < n; ++j)
            a[j] /= gc;
        g ^= 1;
    }
}

Measured memory_bytes: 640
#include <stdio.h>

int a(int n,int A[],int key)
{

  int left, right, mid;

  left = 0;
  right = n;
  while(left < right){
    mid = (left + right)/2;
    if(key == A[mid]){
      return mid;
    }
    if(key > A[mid]){
      left = mid + 1;
    }
    else if(key < A[mid]){
      right = mid;
    }
  }
  return -1;
}

int main()
{

  int count, n, q, i;

  count = 0;

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

  scanf("%d",&q);
  int T[q];
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    if(a(n,S,T[i]) != -1){
      count++;
    }
  }

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

  return 0;

}






Measured memory_bytes: 2284
n = int(input())
numbers = input()

lst = set()
ans = []
for i in range(n):
  pin = ''
  if numbers[i] not in lst:
    pin += numbers[i]
    lst.add(pin)
    lst2 = set()
    for j in range(i+1, n):
      pin += numbers[j]
      if pin[1] not in lst2:
        lst2.add(pin[1])
        lst3 = set()
        for k in range(j+1, n):
          pin += numbers[k]
          if pin[2] not in lst3:
            lst3.add(pin[2])
            ans.append(pin)
          if ('0' in lst3) and ('1' in lst3) and ('2' in lst3) and ('3' in lst3) and ('4' in lst3) and ('5' in lst3) and ('6' in lst3) and ('7' in lst3) and ('8' in lst3) and ('9' in lst3):
            break
          pin = pin[0] + pin[1]
      if ('0' in lst2) and ('1' in lst2) and ('2' in lst2) and ('3' in lst2) and ('4' in lst2) and ('5' in lst2) and ('6' in lst2) and ('7' in lst2) and ('8' in lst2) and ('9' in lst2):
        break
      pin = pin[0]
    if ('0' in lst) and ('1' in lst) and ('2' in lst) and ('3' in lst) and ('4' in lst) and ('5' in lst) and ('6' in lst) and ('7' in lst) and ('8' in lst) and ('9' in lst):
      break
print(len(ans))


Measured memory_bytes: 9380
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll n;
	cin >> n;
	if (n % 10 == 1 || n % 10 == 0 || n % 10 == 6 || n % 10 == 8) {
		cout << "pon" << endl;
	}
	else {
		if (n % 10 == 3) {
			cout << "bon" << endl;
		}
		else cout << "hon" << endl;
	}
}

Measured memory_bytes: 3624
#include<cstdio>

int main() {
	int n; scanf("%d", &n);
	int ans = 0;
	for(int i=105;i<=n;i++) {
		int cnt = 0;
		for(int j=1;j<=i;j+=2)
			if (i%j==0) cnt++;
		if (cnt==8) ans++;
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
S = input()
if S[1] == S[0] and S[2] != S[0]:
	if S[2] == S[3]:
		print("Yes")
	else:
		print("No")
elif S[2] == S[0] and S[1] != S[0]:
	if S[1] == S[3]:
		print("Yes")
	else:
		print("No")
elif S[3] == S[0] and S[1] != S[0]:
	if S[1] == S[2]:
		print("Yes")
	else:
		print("No")
else:
	print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
#define INF 49

int main() {
  int K; cin >> K;
  vector<int> dist(K, INF);
  dist[1] = 0;
  deque<int> deq = {1};
  while (!deq.empty()) {
    int v = deq.front(); deq.pop_front();
    int u = (v * 10) % K, t = (v + 1) % K;
    if (dist[u] > dist[v]) {
      dist[u] = dist[v];
      deq.push_front(u);
    }
    if (dist[t] > dist[v] + 1) {
      dist[t] = dist[v] + 1;
      deq.push_back(t);
    }
  }
  cout << dist[0] + 1 << endl;
}

Measured memory_bytes: 896
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var A = one[1];
  var B = one[2];
  var list = nextIntArray();
  var output = 0;
  for(var i = 1; i < N; i++){
    var kyori = list[i] - list[i - 1];
    if(kyori * A > B){
      output += B;
    }else{
      output += kyori * A;
    }
  }
  myout(output);
}


Measured memory_bytes: 41528
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAXX 10005
#define PI 3.14159265358979323846264338327950
#define ll signed long long int
using namespace std;
ll t , n;
vector<ll> adj[MAXX];
bool used[MAXX];


signed main()
{
	FAST;
	ll a, b;
	cin >> a >> b;
	if(a >= 13){
		cout << b;
		return 0;
	}
	if(a >= 6){
		cout << b/2;
	}
	else{
		cout << 0;
	}
}

Measured memory_bytes: 512
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int x = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (Math.abs(x-a) >= Math.abs(x-b)){
      System.out.println("B");
    } else {
      System.out.println("A");
    }
  }
}

Measured memory_bytes: 21716
import java.util.*;

class Main{
    static int minc = 100000000;
    static int n;
    static int m;
    static int x;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        x = sc.nextInt();
        int[][] nm = new int[n][m];
        int[] c = new int[n];
        for(int i=0;i<n;i++){
            c[i] = sc.nextInt();
            for(int j=0;j<m;j++){
                nm[i][j] = sc.nextInt();
            }
        }

        int[] list = new int[n];
        search(nm, c, list, 0);

        if(minc==100000000){
            System.out.println(-1);
        }
        else{
            System.out.println(minc);
        }

    }

    private static void search(int[][] nm, int[] c, int[] list, int now) {
        if(now!=n){
            list[now] = 1;
            search(nm, c, list, now+1);
            list[now] = 0;
            search(nm, c, list, now+1);
        }
        else{
            int sumc = 0;
            int[] check = new int[m];
            for(int i=0;i<n;i++){
                if(list[i]==0)continue;
                sumc += c[i];
                for(int j=0;j<m;j++){
                    check[j] += nm[i][j];
                }
            }
            boolean flag = true;
            for(int i=0;i<m;i++){
                if(check[i]<x)flag=false;
            }
            if(flag)minc = Math.min(minc, sumc);
        }
        
    }
}


Measured memory_bytes: 29472
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
    string S; cin >> S;
    if (S == "Sunny")
        cout << "Cloudy" << endl;
    if (S == "Cloudy")
        cout << "Rainy" << endl;
    if (S == "Rainy")
        cout << "Sunny" << endl;
}

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

int main()
{
    int N;
    long long K;
    static int A[200001] = { 0 };
    static int check[200001] = { 0 };
    int ans, count;

    cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    ans = 1;
    for (int i = 1; i <= K; i++) {
        check[ans] = i;
        ans = A[ans];
        if (check[ans] != 0) {
            count = (K- (long long)check[ans] + 1) % ((long long)i - (long long)check[ans] + 1);

            for (int j = 0; j < count; j++) {
                ans = A[ans];
            }
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5140
n = int(input())

dic = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

for i in range(n):
  s = input()
  dic[s] += 1
  
print('AC x ' + str(dic['AC']))
print('WA x ' + str(dic['WA']))
print('TLE x ' + str(dic['TLE']))
print('RE x ' + str(dic['RE']))

Measured memory_bytes: 69948
a = int(input())
hp_list = map(int, input().split())

hp_list = sorted(hp_list)
while (True):
    if hp_list[0] == 1 or len(hp_list) == 1:
        break
    for i in range(1, len(hp_list)):
        if hp_list[i] > hp_list[0]:
            hp_list[i] = hp_list[i] % hp_list[0]
        else:
            hp_list[i] = 0
    hp_list = [u for u in hp_list if u > 0]
    hp_list = sorted(hp_list)
print(hp_list[0])

Measured memory_bytes: 14252
#131　

#入力（1次元）
N, L = list(map(int, input().split()))

min = 2000000

#出力
ans = 0

#最適に食べる林檎No.を算出
for i in range(1,N+1):
    if (min > abs(L + i - 1)) :
        min = abs(L + i - 1)
        N_min = i

for j in range(1,N+1 ):
    if(j != N_min):  
        ans += L + j - 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n;
int A[10100];
double ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	sort(A+1,A+1+n);
	ans=(A[1]+A[2])*1.0/2;
	for(int i=3;i<=n;i++){
		ans=(ans+A[i]*1.0)/2;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
x,y,z,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))

ans1=[]
ans2=[]

for i in range(x):
    for j in range(y):
        ans1.append(a[i]+b[j])
ans1.sort()
ans1.reverse()

if len(ans1)>=k:
    del ans1[k:]
    
for i in range(len(ans1)):
    for j in range(z):
        ans2.append(ans1[i]+c[j])
ans2.sort()
ans2.reverse()

for i in range(k):
    print(ans2[i])


            
            
    

        

    
    


        
    

Measured memory_bytes: 139792
from heapq import heapify, heappush, heappop
N = int(input())
Alist = list(map(int, input().split()))
heapify(Alist)
while len(Alist)>1:
    Alist = [a for a in Alist if a > 0]
    min_num = heappop(Alist)
    for i in range(len(Alist)):
        Alist[i] %= min_num
    heappush(Alist, min_num)
print(Alist[0])

Measured memory_bytes: 83992
const main = (input) => {
  const inputs = input.trim().split('\n');
  const N = Number.parseInt(inputs[0].split(" ")[0]);
  const M = Number.parseInt(inputs[0].split(" ")[1]);
  const C = Number.parseInt(inputs[0].split(" ")[2]);

  var BMap = inputs[1].split(" ");
  var ans = 0;
  for(var i=0;i<N;i++){
    var AMap = inputs[i+2].split(" ");
    if(calc(AMap, BMap)+C>0){
      ans++
    }
  }

  console.log(ans);
}
function calc(amap, bmap){
  var ans = 0;
  for(var i=0;i<amap.length;i++){
    ans += amap[i]*bmap[i];
  }
  return ans;
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 7372
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

struct dish {
  i64 A_i;
  i64 B_i;
  i64 gain;
  dish(const i64& A_i, const i64& B_i, const i64& gain) :
    A_i(A_i), B_i(B_i), gain(gain) {
  }
};

int main() {
  i64 N;
  std::cin >> N;
  std::vector<dish> dishes;
  dishes.reserve(N);
  for (i64 i = 0; i < N; ++i) {
    i64 A_i, B_i;
    std::cin >> A_i >> B_i;
    dishes.emplace_back(A_i, B_i, A_i + B_i);
  }

  std::sort(dishes.begin(), dishes.end(), [](const dish& x, const dish& y) { return x.gain > y.gain; });
  i64 takahashi = 0;
  i64 aoki = 0;
  for (i64 i = 0; i < N; ++i) {
    if (i % 2 == 0) takahashi += dishes[i].A_i;
    else aoki += dishes[i].B_i;
  }

  std::cout << takahashi - aoki << std::endl;
  return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            char[] s = sc.next().toCharArray();
            int x = 0;
            int maxX = 0;

            for (int i = 0; i < n; i++) {
                if ( s[i] == 'I' ) {
                    x++;
                } else {
                    x--;
                }
                maxX = Math.max(maxX, x);
            }

            System.out.println(maxX);
        }
    }
}


Measured memory_bytes: 21204
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
int fpw(int a,int b,int mod){
	int r = 1;
	for(;b;b>>=1,a=a*a%mod)if(b&1) r = r*a %mod;
	return r;
}
int get_rem(string &S, int mod){
	if(mod <= 0) return -1;
	int r = 0;
	for(char c: S){
		r = r * 2 + c- '0';
	    r %= mod;
	}
	return r;
}
int cal(int n){
	if(!n) return 0;
	return 1+cal(n%__builtin_popcount(n));
}
int32_t main()
{
 string s; int n; cin >> n >> s;
 int tot = count(all(s),'1');
 if(!tot) {
 	fr(i,sz(s)) cout << "1\n";
 	return 0;
 }
 int mdn = get_rem(s,tot-1);
 int mdp = get_rem(s,tot+1);
 fr(i,sz(s)){
 	int ad = (s[i] == '1'?-1:1);
 	tot += ad;
 	if(!tot) {
 		cout << "0\n";
 		tot -= ad;
 		continue;
 	}
 	int tw = fpw(2,sz(s)-i-1,tot);
 	if(s[i] -'0'){
 		
 		int temp = mdn - tw;
 		if(temp < 0) temp += tot;
 		 cout << 1 + cal(temp) << "\n";
 	}
 	else {
 		int temp = mdp + tw;
 		temp %= tot;
 		 cout << 1 + cal(temp) << "\n";
 	}
 	tot -= ad;
 }
}

Measured memory_bytes: 3660
N=int(input())
abc=[list(map(int,input().split()))for i in range(N)]
A=[0]
B=[0]
C=[0]
for i in range(N):
    a=abc[i][0]+max(B[-1],C[-1])
    b=abc[i][1]+max(A[-1],C[-1])
    c=abc[i][2]+max(A[-1],B[-1])
    A+=[a]
    B+=[b]
    C+=[c]
print(max(A[-1],B[-1],C[-1]))

Measured memory_bytes: 42556
#include <stdio.h>

int main()
{

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


    int i;
    int b, c;
    int sum=0;
    for (i = 1; i < n; i++)
    {
        sum += (n - 1) / i;
        
    }

    printf("%d",sum);
   

    printf("\n");
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;

vector<int> G[100005];
bool usegraph[100005] = {false};
vector<int> path;

void dfs(int end_point){
    
    for(int i=0;i<G[end_point].size();i++){
        if(!usegraph[G[end_point][i]]){
            path.push_back(G[end_point][i]);
            usegraph[G[end_point][i]] = true;
            dfs(G[end_point][i]);
            return;
        }
    }
}

int main(void){
    int N, M;

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

    int a, b;
    for(int i=0;i<M;i++){
        scanf("%d%d", &a, &b);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int start_point, end_point;
    start_point = a;
    end_point = b;
    
    usegraph[start_point] = true;
    usegraph[end_point] = true;
    path.push_back(start_point);
    path.push_back(end_point);

    dfs(end_point);
    reverse(path.begin(), path.end());
    dfs(start_point);
    cout << path.size() << endl;
    cout << path[0];
    for(int i=1;i<path.size();i++){
        cout << ' ' << path[i];
        
    }
    cout << endl;
    return 0;
}

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "YES" : "NO") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

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

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

  CIN(r, g, b);
  int sum = r * 100 + g * 10 + b;
  OK(sum % 4 == 0);

  return 0;
}



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

#define int long long
#define fi first
#define se second
#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 repo(i,o,n) for(int i=o;i<(int)(n);i++)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,m,a,b,ans;
vector<pair<int,int>> v;

main() {
    cin >> n >> m;
    rep(i,n) cin >> a >> b,v.pb(make_pair(a,b))
    sort(all(v));
    rep(i,n) {
        if (m > v[i].se) m-=v[i].se,ans+=v[i].fi*v[i].se;
        else {
            ans += v[i].fi*m;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

bool check(string s1, string s2)
{
    for (int i = 0; i < s1.size(); i++)
    {
        if (s1[i] != '?' && s1[i] != s2[i])
        {
            return false;
        }
    }
    return true;
}

string solve(string s, string t)
{
    string ret(s);

    if (s.size() < t.size())
    {
        return "UNRESTORABLE";
    }
    bool success = false;
    for (int i = s.size() - t.size(); i >= 0; i--)
    {
        if (check(s.substr(i, t.size()), t))
        {
            success = true;
            for (int j = i; j < i + t.size(); j++)
            {
                ret[j] = t[j - i];
            }
            break;
        }
    }
    if (!success)
    {
        return "UNRESTORABLE";
    }
    else
    {
        for (int i = 0; i < ret.size(); i++)
        {
            if (ret[i] == '?')
            {
                ret[i] = 'a';
            }
        }
        return ret;
    }
}

int main()
{
    string s, t;
    cin >> s >> t;

    cout << solve(s, t) << endl;
}


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

int main(void){
    int n;
    cin>>n;
    int odd=0,two=0,four=0;
    rep(i,n){
        int a;
        cin>>a;
        if(a&1) odd++;
        else if(a%4==0) four++;
        else two++;
    }
    if(two>0) odd++;
    if(four+1<odd) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];


  ll sum = 0;
  for (int i = 0; i < n; i++){
    sum += a[i];
  }
  sum /= 2;
  ll ret = 0;
  ll x;
  for (int i = 1; i < n; i += 2){
    ret += a[i % n];
  }
  x = sum - ret;
  cout << 2*x << " ";
  for (int i = 1; i < n; i++){
    x = a[i - 1] - x;
    cout << 2*x << " ";
  }

  cout << endl;


  return 0;
}


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 2048
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    REP(i, n){
        cin >> x[i] >> y[i];
    }
    vector<int> kumi(n);
    iota(kumi.begin(), kumi.end(), 0);
    vector<int> orig(kumi);
    double ans = 0;
    do{
        double d = 0;
        FOR(i, 1, n){
            d += sqrt((x[kumi[i]] - x[kumi[i-1]]) * (x[kumi[i]] - x[kumi[i-1]]) + (y[kumi[i]] - y[kumi[i-1]]) * (y[kumi[i]] - y[kumi[i-1]]));
        }
        ans += d;
        next_permutation(kumi.begin(), kumi.end());
    } while(kumi != orig);
    IFOR(i, 1, n)
        ans /= i;

    printf("%.14f\n", ans);
    return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())
a = A
b = B

ans = []
for i in range(K):
    if A not in ans:
        ans.append(A)

    if B not in ans:
        ans.append(B)

    if A + 1 <= b:
        A += 1
    if B - 1 >= a:
        B -= 1

ans.sort()
for i in ans:
    print(i)


Measured memory_bytes: 3060