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

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
    }
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(v.at(i) != i+1){
            cnt++;
        }
    }
    if(cnt <= 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

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

int main() {
  int64_t A, B, a, b, N;
  cin >> A >> B;
  a = A;
  b = B;
  while (a != 0 && b != 0) {
    if (a > b) {
      a = a % b;
    } else {
      b = b % a;
    } 
  }
  if (a == 0) {
      N = b;
    }
  if (b == 0) {
    N = a;
  }
  N = A* B/ N;
  cout << N << endl;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m + 1);
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m - a].push_back(b);
  }
  priority_queue<int> q;
  llong ans = 0;
  for (int i = m - 1; i >= 0; i--) {
    for (int j = 0; j < jobs[i].size(); j++) {
      q.push(jobs[i][j]);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll h, w;
  cin >> h >> w;
  if (h == 1 && w == 1) cout << 1 << endl;
  else if (h == 1 || w == 1) cout << max(h-2,(ll) 1) * max(w-2, (ll) 1) << endl;
  else cout << (h - 2) * (w - 2) << endl; 
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int A,B,C;
    cin >> A >> B >> C;
    if (A-C<=0){
        if (B-C>=0){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main () {
	string s;
	cin >> s;
	long long k;
	cin >> k;
	long long time = 5000000000000000;
	bool b = true;
	for (int i = 0; i < k; ++i)
	{
		if(s[i] != '1'){
			cout << s[i] << endl;
			b = false;
			break;
		}
	}
	if(b){
		cout << '1' << endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N-1);
  
  for( int i = 0; i<N; i++ ) cin >> a.at(i);
  for( int i = 0; i<N; i++ ) cin >> b.at(i);
  for( int i = 0; i<N-1; i++ ) cin >> c.at(i);
  
  int manzoku = 0;
  int bango = -10;
  for( int i = 0; i < N; i++ ){
    
    if( bango == a.at(i) - 2 ){
      manzoku += c.at(bango);
    }
      
    bango = a.at(i) -1;
    manzoku += b.at(bango);
  }
  cout << manzoku << endl;
    
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[105][105];
int main(){
	int n,m;cin>>n>>m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	for(int j=0;j<m;j++)
		for(int i=0;i<n;i++)
			a[n][j]+=a[i][j];
	for(int i=0;i<=n;i++)
		for(int j=0;j<m;j++)
			a[i][m]+=a[i][j];
	for(int i=0;i<=n;i++){
		for(int j=0;j<m;j++){
			cout<<a[i][j]<<' ';
		}cout<<a[i][m]<<endl;
	}	
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<string> arr(n, "");
  for(int i=0; i<n; ++i){
    cin>>arr[i];
  }
  cout<<"AC x "<<count(arr.begin(), arr.end(), "AC")<<endl;
  cout<<"WA x "<<count(arr.begin(), arr.end(), "WA")<<endl;
  cout<<"TLE x "<<count(arr.begin(), arr.end(), "TLE")<<endl;
  cout<<"RE x "<<count(arr.begin(), arr.end(), "RE")<<endl;
}

Measured memory_bytes: 6432
import heapq
from collections import deque


n, m = map(int, input().split())
a = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]
tree = [[] for i in range(n)]

for b, c in info:
    tree[b].append(c)
    tree[c].append(b)

visited = [False] * n
group = []
for i in range(n):
    if visited[i]:
        continue
    q = deque([i])
    visited[i] = True
    tmp = [a[i]]
    while q:
        pos = q.pop()
        for next_pos in tree[pos]:
            if visited[next_pos]:
                continue
            visited[next_pos] = True
            q.append(next_pos)
            tmp.append(a[next_pos])
    group.append(tmp)

for i in range(len(group)):
    group[i] = sorted(group[i])

ans = 0
cnt = len(group)*2 - 2

if cnt == 0:
    print(0)
    exit()
    
for i in range(len(group)):
    ans += group[i][0]
    cnt -= 1
    group[i][0] = 10**9 + 7

q = []
for i in range(len(group)):
    for num in group[i]:
        if num != 10**9 +7:
            heapq.heappush(q, num)

for i in range(cnt):
    if not q:
        print("Impossible")
        exit()
    ans += heapq.heappop(q)
print(ans)
    

Measured memory_bytes: 102840
let inp = readLine()!.split(separator: " ").map { Int($0)! }

let n = inp[0]
let k = inp[1]

let a = readLine()!.split(separator: " ").map { Int($0)! }

var cur = 1
for i in 0..<k {
  cur *= a[i]
}

for i in k..<n {
  if a[i] > a[i-k] {
    print("Yes")
  } else {
    print("No")
  }
}

Measured memory_bytes: 22256
w,h,n=map(int,input().split())
l=[[1 for _ in range(w)] for _ in range(h)]

for i in range(n):
  x,y,a=map(int,input().split())

  x1=x if a==1 else -1
  x2=x if a==2 else w+1
  y1=y if a==3 else -1
  y2=y if a==4 else h+1
  for k in range(w):
    for j in range(h):
     
      if k<x1:
        l[j][k]=0
      if k>=x2:
        l[j][k]=0
      if j<y1:
        l[j][k]=0
      if j>=y2:
        l[j][k]=0
print(sum([sum(v) for v in l]))
  

Measured memory_bytes: 9232
#include<bits/stdc++.h>
#define HohleFeuerwerke using namespace std
#define MAXN 105
HohleFeuerwerke;
int n;
int x[MAXN];
int l=INT_MAX,r=-INT_MAX;
int mincost=INT_MAX;
int main()
{
	ios::sync_with_stdio(false);
	cout.tie(0);cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>x[i],l=min(l,x[i]),r=max(r,x[i]);
	for(int i=l;i<=r;i++){
		int tmpcost=0;
		for(int j=1;j<=n;j++) tmpcost+=(x[j]-i)*(x[j]-i);
		mincost=min(tmpcost,mincost);
	}
	cout<<mincost<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,h,len,j,n,k;
    scanf("%d%d",&h,&n);
if((h<=9&&h>=1)&&(n>=1&&n<=9)){
    printf("%d\n",h*n);
}
      else{ printf("-1\n");}

    return 0;
}


Measured memory_bytes: 128
from functools import lru_cache

def main():
    a,b=map(lambda x: set(prime_factorize(int(x))),input().split())
    print(len(a&b)+1)

@lru_cache(maxsize=None)
def primes(n:int) -> list:
    '''n以下の全素数をlistで返す'''
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

# 素数判定（単純な素数判定なら十分早い。大量にやる場合はX in primesがよさそう）
@lru_cache(maxsize=None)
def is_prime(n: int) -> bool:
    '''引数nが素数であればTrue、そうでなければFalseを返す'''
    if n == 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    
    for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False
    return True

# 素因数分解
@lru_cache(maxsize=None)
def prime_factorize(n: int) -> list:
    '''引数nの素因数分解結果のlistを返す。'''
    arr = []
    # 2で割り続け奇数まで還元する
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    # sqrt(n)までの素数で試し割
    for f in primes(int(n**0.5)):
        while n % f == 0:
            arr.append(f)
            n //= f
    if n != 1:
        arr.append(n)
    return arr

#約数リスト
def make_divisors(n: int) -> list:
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 21768
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(Cal(n));
        }
        static Dictionary<int,long> memo = new Dictionary<int, long>();
        static long Cal(int val)
        {
            if (val == 0) return 2;
            if (val == 1) return 1;
            if (!memo.ContainsKey(val))
            {
                memo[val] = Cal(val - 1) + Cal(val - 2);
            }
            return memo[val];
        }
        
    }
}

Measured memory_bytes: 13152
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
//#include<unordered_map>
//#include<unordered_set>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cstring>
#include <functional>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1Int<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P; 
const int N = 100005;
//////////////////////////////

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

	Int n;
	cin >> n;

	vector<Int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	multiset<Int> s;
	for (int i = 0; i < n; i++) {
		Int now = a[i];
		auto itr = s.lower_bound(now);
		if (itr != s.begin()) {
			s.erase(--itr);
		}
		s.insert(now);
	}
	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 5760
from math import floor,ceil,sqrt
import fractions
import itertools
from collections import deque
import heapq
N,M=map(int,input().split())
tree=[[] for _ in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
prev=[-1]*N
d=[float("inf")]
prev[0]=0
d=deque()
d.append(0)
while len(d)>0:
    v=d.popleft()
    for i in tree[v]:
        if prev[i]==-1:
            prev[i]=v
            d.append(i)
print("Yes")
for i in range(1,N):
    print(prev[i]+1)




Measured memory_bytes: 99124
#include "bits/stdc++.h"
 
using namespace std;
 
int main() {
	cin.tie(); ios_base::sync_with_stdio(0);
	char a[6]; 
	for (int i = 0; i < 6; i++) cin >> a[i];
	
	int ans = 0;
	for (int i = 0; i < 3; i++) if (a[i] == a[i+3]) ans++;
	
	cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll X;
    cin >> X;
    ll ans = 0;
    vll fives(2000);
    unordered_map<ll, int> five2x;
    rep(i, 2000) {
        ll x = ll(i) - 1000;
        fives[i] = ll(x) * ll(x) * ll(x) * ll(x) * ll(x);
        five2x[fives[i]] = x;
    }
    ll A = 0, B = 0;
    rep(i, fives.size()) {
        rep(j, fives.size()) {
            if (fives[i] - fives[j] == X) {
                A = five2x[fives[i]];
                B = five2x[fives[j]];
            }
        }
    }

    cout << A << " " << B << endl;
    return 0;
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;
  vector<ll> h(N);
  REP(i, N) cin >> h[i];

  sort(h.begin(), h.end());

  ll ans = h[N-1] - h[0];
  FOR(i, 0, N-K+1){
    ans = min(ans, h[i+K-1] - h[i]);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int n;
vector<string>ans;
void func(string last){
	if(last.size()>n)return ;
	if(last.size()==n){
		ans.pb(last);
		return ;
	}
	char big='a';
	REP(i,last.size())big=max(big,last[i]);
	FORN(i,'a',big+2)func(last+(char)i);
}
int main(void){
	cin>>n;
	func("a");
	sort(ans.begin(),ans.end());
	REP(i,ans.size()){
		cout<<ans[i]<<endl;
	}
//	cout<<ans.size();
	return 0;
}

Measured memory_bytes: 9588
#include <iostream>
#include <malloc.h>
#include <string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	bool flag = false;
	for (auto i = s.begin(); i != s.end() - 1; ++i)
		if (*i == 'A'&&*(i + 1) == 'C')
			flag = true;
	if (flag)
		puts("Yes");
	else
		puts("No");
	//system("pause");
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

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 int MOD = 1e9 + 7;
const long long INF = 1LL << 60;

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    for (auto& x : h) {
        cin >> x;
    }

    ll dp[100010];
    for (auto& x : dp) {
        x = INF;
    }
    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        chmin(dp[i], dp[i-1]+abs(h[i-1] - h[i]));
        if (i > 1) {
            chmin(dp[i], dp[i-2]+abs(h[i-2] - h[i]));
        }
    }
    cout << dp[N-1] << endl;

    return 0;
}


Measured memory_bytes: 1408
function main(input) {
    var arr1 = input.split('\n')
    var n = arr1[0]
    var arr2 = arr1[1].split(' ')
    var s = arr2[0]
    var t = arr2[1]
    
    var acc = ''
    for(var i = 0; i < n; i++){
        acc += s[i]
        acc += t[i]
    }
    console.log(acc)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int BIG_INT = 1000000000;
const ll BIG_NUM = 1000000000000000000;



int main() {
	int n, m, p;
	cin >> n >> m >> p;

	vector<vector<pii>> g(n);
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		g[a].emplace_back(make_pair(b, -c + p));
	}

	vector<ll> d(n, BIG_NUM);
	d[0] = 0;

	for (int i = 0; i < 2 * n; i++) {
		for (int v = 0; v < n; v++) {
			if (d[v] != BIG_NUM) {
				for (pii e : g[v]) {
					if (d[e.first] > d[v] + e.second) {
							
						d[e.first] = d[v] + e.second;
						if (i >= n - 1) {
							d[e.first] = -BIG_NUM;
						}
					}
				}
			}
		}
	}


	d[n - 1] = min(d[n - 1], 0LL);
	if (d[n - 1] == -BIG_NUM) {
		d[n - 1] = 1;
	}
	cout << -d[n - 1] << endl;
}



Measured memory_bytes: 512
a, b, c = map(int, input().split())
k = int(input())

# red, green, blue

# green > red
# blue > green

while k:
    k = k - 1
    if a >= b:
        b = b*2
    elif b >= c:
        c = c*2
    else:
        break

if a < b < c:
    print('Yes')
else:
    print('No')

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

void init () {
	srand (time(0));
	int XOR[20] = {0};
	for (int n = 1; n <= 3; ++n) {
		for (int k = 1; k < (1<<n); ++k) {
			vector <int> a(1<<(n+1));
			for (int i = 0; i < (1<<n); ++i) a[i] = i, a[i+(1<<n)] = i;
			sort (a.begin(),a.end());
			cout << "n = " << n << ", k = " << k << endl;
			int times = 0;
			do {
				random_shuffle(a.begin(),a.end());
				int cnt = 0;
				vector <int> pos[1<<n];
				XOR[0] = 0;
				for (auto &x : a) ++cnt, XOR[cnt] = XOR[cnt-1] ^ x, pos[x].push_back(cnt);
				bool flag = true;
				for (int i = 0; i < (1<<n); ++i) {
					int pos1 = pos[i][0], pos2 = pos[i][1];
//					cout << "i = " << i << ", pos1 = " << pos1 << ", pos2 = " << pos2 << endl;
					if (pos1 > pos2) swap (pos1, pos2);
					int t = XOR[pos2] ^ XOR[pos1-1];
					if (t != k) flag = false;
				}
				/*
				for (auto &x : a) cout << x << " "; cout << endl;
				for (int i = 1; i <= cnt; ++i) cout << XOR[i] << " "; cout << endl;
				cout << endl;
				*/
				if (flag) {
					cout << "YES : " << n << " " << k << endl;
					for (auto &x : a) cout << x << " "; cout << endl;
					for (int i = 0; i < (1<<n); ++i) cout << pos[i][0] << " " << pos[i][1] << endl;
					break;
				}
			} while (++times < 12345678);
//			} while (next_permutation(a.begin(),a.end()));
		}
	}
}
int main () {
	//init();
	int n, k; cin >> n >> k;
	if (k >= (1<<n) || (n == 1 && k == 1)) puts("-1");
	else if (n == 1) puts("0 0 1 1");
	else {
		vector <int> ans;
		for (int i = 0; i < (1<<n); ++i) if (i != k) ans.push_back (i);
		ans.push_back (k);
		for (int i = (1<<n)-1; i >= 0; --i) if (i != k) ans.push_back (i);
		ans.push_back (k);
		for (auto &x : ans) cout << x << " "; cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2932
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int n;
int main() {
  while (cin >> n) {
	if (n < 1200) puts("ABC");
	else puts("ARC");
  }
}

/*
int n, m;
string A[110], B[110];
int main() {
  while (cin >> n >> m) {
	for (int i = 0; i < n; ++i) cin >> A[i];
	for (int i = 0; i < m; ++i) cin >> B[i];
	bool ok = false;
	for (int i = 0; i < n; ++i) {
	  if (i + m > n) continue;
	  for (int j = 0; j < n; ++j) {
		if (j + m > n) continue;
		bool tmp = true;
		for (int k = 0; k < m; ++k) {
		  for (int l = 0; l < m; ++l) {
			if (A[i+k][j+l] != B[k][l]) tmp = false;
		  }
		}
		if (tmp) ok = true;
	  }
	}
	if (ok) puts("Yes");
	else puts("No");
  }
}




*/






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

int main(){
  int dp[101][10001]={0},n,m,v[101],w[101];
  cin>>n>>m;
  for(int i=1;i<=n;i++){
    cin>>v[i]>>w[i];
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j<=m;j++){
      if(j-w[i]>=0)dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
      else dp[i][j]=dp[i-1][j];
    }
  }
  cout<<dp[n][m]<<endl;
  return 0;
}

Measured memory_bytes: 7048
#include <stdio.h>

int main(){

	int S;
	int h,m,s;

	scanf("%d", &S);

	h = S / (60*60);
	m = (S % (60*60)) / 60;
	s = S % 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

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

typedef long long ll;

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

    vector<ll> A(N);
    vector<ll> S(N);
    vector<ll> T(N);

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

    S[0] = A[0];
    S[1] = A[1];
    T[N-1] = A[N-1];
    T[N-2] = A[N-2];
    for(int i=2; i<N; i++){
        S[i] = S[i-2] + A[i];
    }
    for(int i=2; i<N; i++){
        T[N-1-i] = T[N+1-i] + A[N-1-i];
    }
    // デバッグ用
    // for(int i=0; i<N; i++){
    //     cout << "S[i]:" << S[i] << " T[i]:" << T[i] << endl;
    // }

    cout << T[0] - T[1] << " ";
    cout << T[1] + S[0] - T[2] << " ";
    for(int i=2; i<N-1; i++){
        cout << S[i-1] + T[i] - S[i-2] - T[i+1] << " ";
    }
    cout << S[N-2] - S[N-3] + T[N-1] << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll N;
    sll(N);
    vector<ll> as(N);
    ll total_xor = 0;
    rep(i, N){
        sll(as[i]);
        total_xor ^= as[i];
    }

    rep(i, N){
        printf("%lld", total_xor^as[i]);
        if(i!= N-1){
            printf(" ");
        }
    }
    printf("\n");

}

int main(){
    Main();
}

Measured memory_bytes: 4340
#include <cstdio>
#include <algorithm>

const int MAX_N = 10000;
int n;
int a[MAX_N];

void solve(){
	std::sort(a, a + n);
	for(int i = 0; i < 3; i ++){
		printf("%d\n", a[n - 1 - i]);
	}
}

int main(int argc, char const *argv[]){
//	freopen("in.txt", "r", stdin);

	for(n = 0; scanf("%d", &a[n]) != EOF; n ++);
	solve();

	return 0;
}

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

int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    cout << floor_sum(n, m, a, b) << "\n";
  }
}


Measured memory_bytes: 3628
n=int(input())
a=list(map(int,input().split()))
temp=[0,0,0,0,0,0,0,0]
r=0
for i in range(n):
  if a[i]>=3200:
    r=r+1
  elif a[i]>=2800:
    temp[7]=1
  elif a[i]>=2400:
    temp[6]=1
  elif a[i]>=2000:
    temp[5]=1
  elif a[i]>=1600:
    temp[4]=1
  elif a[i]>=1200:
    temp[3]=1
  elif a[i]>=800:
    temp[2]=1
  elif a[i]>=400:
    temp[1]=1
  else:
    temp[0]=1
if sum(temp)==0:
  print(1,r)
else:
  print(sum(temp),sum(temp)+r)  

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

using ull = unsigned long long;
using ll = long long;

int main()
{
    vector<int> a(3,0);

    for(auto&& x : a)
        cin >> x;

    int five = count(a.begin(),a.end(),5);
    int seven = count(a.begin(),a.end(),7);

    if(five == 2 && seven == 1)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


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

int main()

{
	string s;
	cin >> s;
long long	n = s.find('7'-0);
if (n <= s.size() && n >= 0)
{
	cout << "Yes";
}
else
{
	cout << "No";
}
//	system("pause");

}


Measured memory_bytes: 3620
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 999999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}

int main(){
	int r,i,V,E,s,t,e;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d%d",&V,&E,&r);
		Graph g(V);
		vector<Weight> dist;
		vector<int> prev;
		for(;E--;)scanf("%d%d%d",&s,&t,&e),g[s].push_back(Edge(s,t,e));
		shortestPath(g,r,dist,prev);
		for(i=0;i<V;i++){
			if(dist[i]==INF)puts("INF");
			else printf("%d\n",dist[i]);
		}
	//}
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  string ans = "No";
  rep(i,X + 1) {
    if(2 * i + 4 * (X - i) == Y) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define INF 2000000000
using namespace std;

typedef long long ll;


int main(){
    int N;
    int K;
    cin>>N;
    ll A[100005][3],dp[2][3];
    int prev = 1,now = 0;
    dp[now][0]=dp[now][1]=dp[now][2]=0;
    for(int i = 0;i < N;i++){
        cin>>A[i][0]>>A[i][1]>>A[i][2];
    }
    for(int i = 0;i < N;i++){
        prev = 1-prev,now = 1-now;
        dp[now][0]=max(dp[prev][1],dp[prev][2])+A[i][0];
        dp[now][1]=max(dp[prev][2],dp[prev][0])+A[i][1];
        dp[now][2]=max(dp[prev][0],dp[prev][1])+A[i][2];
    }
    cout<<max(dp[now][0],max(dp[now][1],dp[now][2]))<<endl;
}


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

ll l[87];

int main() {
    l[0]=2;
    l[1]=1;
    int n; cin >> n;
    rep2(i,n){
        l[i+1]=l[i]+l[i-1];
    }
    cout << l[n] << endl;
}

Measured memory_bytes: 256
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
if N % 2 == 0:
    j = N // 2
    i = j - 1
    med1_by_2 = A[i] + A[j]
    med2_by_2 = B[i] + B[j]
    ans = med2_by_2 - med1_by_2 + 1
else:
    i = N // 2
    med1 = A[i]
    med2 = B[i]
    ans = med2 - med1 + 1
print(ans)

Measured memory_bytes: 25552
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>

long long int MOD = 1e9+7;

int main(){

  std::string L;
  std::cin >> L;
  
  //std::cerr << "L: " << std::endl << L << std::endl << std::endl;

  std::vector<std::vector<long long int> > dp(2);
  for(long long int i = 0; i < L.length(); i++){
    dp[0].push_back(0);
    dp[1].push_back(0);
  }

  // initialize dp table
  dp[0][0] = 2; // highest bits are (0,1) or (1,0)
  dp[1][0] = 1; // highest bits are (0,0)

  for(long long int i = 1; i < L.length(); i++){
    if(L[i] == '0'){
      dp[0][i] = dp[0][i-1]; // (0,0)
      dp[1][i] = dp[1][i-1]*3; // (1,0), (0,1), (0,0)
      dp[0][i] = (dp[0][i]+MOD)%MOD;
      dp[1][i] = (dp[1][i]+MOD)%MOD;
    }
    else{ //if(L[i] == '1')
      dp[0][i] = dp[0][i-1]*2; // (0,1), (1,0)
      dp[1][i] = dp[1][i-1]*3 + dp[0][i-1];
    }
    dp[0][i] = (dp[0][i]+MOD)%MOD;
    dp[1][i] = (dp[1][i]+MOD)%MOD;
  }

  std::cerr << "Answer: " << std::endl;
  std::cout << (dp[0][L.length()-1] + dp[1][L.length()-1] + MOD)%MOD << std::endl;

  return 0;
  
}


Measured memory_bytes: 2164
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
	double hight,max,min;
	cin >> hight;
	max=min=hight;
	while(cin >> hight){
		if(hight>max) max=hight;
		if(hight<min) min=hight;
	};
	cout << fixed << setprecision(1);
	cout << max-min << '\n' ;
}

Measured memory_bytes: 1280
A, B, C, D, E, F = [int(_) for _ in input().split()]


def main(A, B, C, D, E, F):
    conc = -1
    ans = (1, 2)
    for na in range(F // (100 * A) + 1):
        for nb in range(F // (100 * B) + 1):
            if na == nb == 0:
                continue
            G = F - na * 100 * A - nb * 100 * B
            for nc in range(G // C + 1):
                for nd in range(G // D + 1):
                    W = na * 100 * A + nb * 100 * B + nc * C + nd * D
                    if 0 < W <= F and nc * C + nd * D <= E * (na * A + nb * B):
                        conc2 = 100 * (nc * C + nd * D) / W
                        if conc < conc2 <= 100 * E / (100 + E):
                            ans = (W, nc * C + nd * D)
                            conc = conc2
    return ans


print(*main(A, B, C, D, E, F))


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

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

Measured memory_bytes: 3572
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <unordered_map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main(){
    ll n, res = 0;
    cin >> n;
    map<string, int> m;
    REP(i, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        res += m[s];
        ++m[s];
    }
    cout << res << endl;
}


Measured memory_bytes: 11136
{-# LANGUAGE OverloadedStrings #-}
import Data.Maybe
import Data.Ratio
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main = do
  getLine
  ns <- getIntList
  print . foldl1' (((/2).).(+)) . map fromIntegral . sort $ ns

-- IO
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getIntVec :: Int -> IO (VU.Vector Int)
getIntVec n = VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

Measured memory_bytes: 508
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<string.h>
#include<bitset>
#include<set>
using namespace std;

int main(){
	int n, k, ruiseki[11][2001] = {}, dp[11][2001] ={};
	vector<int> books[11];
	cin >> n >> k;
	for(int i = 0; i < n;i++){
		int a, b;
		cin >> a >> b;
		books[b].push_back(-a);
	}
	for(int i = 1; i < 11; i++){
		sort(books[i].begin(), books[i].end());
		for(int j = 0; j < books[i].size(); j++){
			ruiseki[i][j + 1] = -books[i][j] + ruiseki[i][j] + j * 2;
		}
	}

	for(int i = 1; i < 11; i++){
		for(int j = 0; j <= k; j++){
			for(int l = 0; l + j <= k; l++){
				dp[i][l + j] = max(max(dp[i][l + j], dp[i - 1][l + j]), max(dp[i - 1][j] + ruiseki[i][l], dp[i - 1][l] + ruiseki[i][j]));
			}
		}
	}
	cout << dp[10][k] << endl;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b;
    if(a==1 && b==2 || b==1 && a==2){
        cout<<"3"<<endl;
    }
    else if(a==1 && b==3 ||a==3 && b==1){
        cout<<"2"<<endl;
    }
    else
    {
        cout<<"1"<<endl;
    }
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db(x) cout << (x) << '\n';
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pii;
typedef pair<double,ll> pdi;
typedef pair<ld,ld> pdd;
typedef pair<double,ll> pdi;
typedef pair<double,pii> pdp;
typedef pair<string,ll> psi;
typedef pair<ll,string> pls;
typedef pair<string,string> pss;
typedef pair<ll,pii> pip;
typedef pair<pii,pii> ppp;
typedef complex<ld> point;
#define mod (ll)(1e9+7)
#define eps (1e-9)
#define oo (ll)(0x3f3f3f3f)
#define pi acos(-1)
#define MAXN (ll)(2e5+5)

int a[2][MAXN];
int base[MAXN];

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

    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        cin >> base[i];
        if(i)
            a[0][i]=base[i]-base[i-1];
        else
            a[0][i]=base[i];
    }

    int cont=0;
    bool acc=0;
    while(cont<k)
    {
        int act=cont&1;
        int pp=1-act;
        bool stop=(a[act][0]==a[pp][0]);
        a[pp][0]=0;
        for(int i=1;i<n;i++)
        {
            a[act][i]+=a[act][i-1];
            stop&=(a[act][i]==a[pp][i]);
            a[pp][i]=0;
        }
        if(stop && cont)
        {
            acc=1;
            break;
        }
        for(int i=0;i<n;i++)
        {
            int ini=max(0,i-a[act][i]);
            int fin=min(n-1,i+a[act][i]);
            a[pp][ini]++;
            a[pp][fin+1]--;
        }

        cont++;
    }

    if(!acc)
        for(int i=1;i<n;i++)
            a[cont&1][i]+=a[cont&1][i-1];

    for(int i=0;i<n;i++)
        cout << a[cont&1][i] << ' ';
    cout << '\n';

    return 0;
}
/**
1 1
0
**/


Measured memory_bytes: 5976
n=int(input())
b=[int(_) for _ in input().split()]

ans=[]
for i in range(n):
  for j in range(n-i-1,-1,-1):
    if b[j]==j+1:
      b.pop(j)
      ans.append(j)
      break
  else:
      print(-1)
      exit()
      
for i in reversed(ans):
  print(i+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define PI 3.14159265358979323846
int main(void) {
    double A, B , H , M;
    double ans;
    cin >> A >> B >> H >> M;

    double ang_A,ang_B;

    if(H>6)      ang_A = 30.0*(H-12);
    else         ang_A = 30.0*(H);

    if(M>30){     ang_B = 6.0*(M-60);
                ang_A += 0.5 * (M);
              }
    else      {   ang_B = 6.0*(M);
      ang_A += 0.5*M;
    }

    if(H==0 && M==0) {
      cout << abs(A-B) << endl;
      return 0;
    }
    
    ans = sqrt(A*A + B*B - 2.0*A*B*cos((ang_A-ang_B)*  PI/180.0));


    //ans = sqrt(ans);
    //ans = pow(ans,0.5);
    printf("%.10lf\n",ans );

    return 0;
}


Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,h,hp=0,ans=0;
    cin >> N;
    for (int i=0;i<N;i++) {
        cin >> h;
        if (h>hp) ans += h - hp;
        hp = h;
    }
    cout << ans << '\n';
    return 0;
}

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

struct Bridge
{
  int a, b, cost;
};

int n, m, ans, parent[10001];
Bridge bridge[10001];

int bridge_comp(const void *a, const void *b)
{
  return ((Bridge *)a)->cost - ((Bridge *)b)->cost;
}

int root(int a)
{
  if (parent[a] == a) return a;
  else return (parent[a] = root(parent[a]));
}

int main()
{
  while((cin >> n >> m), n && m)
  {
    for (int i = 0; i < n; i++)
      parent[i] = i;
    for (int i = 0; i < m; i++)
      cin >> bridge[i].a >> bridge[i].b >> bridge[i].cost;
    qsort(bridge, m, sizeof(Bridge), bridge_comp);
    ans = 0;
    for (int i = 0; i < m; i++)
    {
      if ((n = root(bridge[i].a)) != root(bridge[i].b))
      {
	parent[root(bridge[i].b)] = n;
	ans += bridge[i].cost;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
X,K,D = list(map(int,input().split()))

import numpy as np

if np.abs(X) > K*D:
    print(np.abs(X)-K*D)
else:
    a = X // D
    b = a + 1
    if a % 2 != K % 2:
        print(np.abs(b*D - X))
    else:
        print(np.abs(X - a*D))


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

using namespace std;


using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 N, T;
  cin >> N >> T;
  ++T;

  // よく考えると a[i] が1以上のものしかないものは30個くらいしかできない気がしてきた
  using pi = pair< int64, int64 >;
  vector< pi > mx;
  vector< int64 > tap{0};

  for(int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    ++b;
    if(a == 0) tap.emplace_back(b);
    else mx.emplace_back(a, b);
  }
  sort(begin(tap), end(tap));
  for(int i = 1; i < tap.size(); i++) tap[i] += tap[i - 1];
  sort(mx.begin(), mx.end(), [](const pi &a, const pi &b) {
    return a.second * b.first < a.first * b.second;
  });
  auto dp = make_v< int64 >(101);
  fill_v(dp, infll);
  dp[0] = 1;
  for(auto &p : mx) {
    for(int k = 100; k > 0; k--) {
      if(dp[k - 1] > T) continue;
      chmin(dp[k], dp[k - 1] + dp[k - 1] * p.first + p.second);
    }
  }

  int ret = 0;
  for(int k = 100; k >= 0; k--) {
    if(dp[k] == infll) continue;
    for(int i = 0; i < tap.size(); i++) {
      if(tap[i] + dp[k] <= T) {
        chmax(ret, k + i);
      }
    }
  }
  cout << ret << endl;
}



Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
class UnionFind
{
public:
    vector<T> par;
    UnionFind(T n) : par(n, -1) {}
    void init(T n)
    {
        for (ll i = 0; i < n; i++)
        {
            par[i] = -1;
        }
    }

    ll root(T x)
    {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool same(T x, T y)
    {
        return root(x) == root(y);
    }

    bool merge(T x, T y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    ll size(T x)
    {
        return -par[root(x)];
    }
};

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n,m,k;
    cin >> n >> m >> k;
    UnionFind<ll> uft(n);
    vector<ll> friends(n);
    for(int i = 0; i < m; i++){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        uft.merge(a, b);
        friends[a]++;
        friends[b]++;
    }
    vector<ll> block(n);
    for(int i = 0; i < k; i++){
        ll c,d;
        cin >> c >> d;
        c--;
        d--;
        if(uft.same(c,d))
        {
            block[c]++;
            block[d]++;
        }
    }
    for(int i = 0; i < n; i++){
        cout << uft.size(i) - friends[i] -  block[i] - 1 << endl;
    }
}

Measured memory_bytes: 3200
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;


public  class Main 
{

	   
	   static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	       
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreTokens()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken();
	            
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        }

			public Character charAt(int i) {
				// TODO Auto-generated method stub
				return null;
			} 
	    } 

  

	  // Complete the hurdleRace function below.
//    public static void solve() {
//    	FastReader s=new FastReader();

   
    public static void main(String[] args) throws IOException {
    	FastReader s=new FastReader();
    	int n = s.nextInt();
    	int b = s.nextInt();
    	System.out.println(n*b);
		


		

    	
    }	
}



Measured memory_bytes: 32604
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(ll a=b;a<=c;a++)
#define PER(a,b,c) for(ll a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<ll,ll>
#define pii pair<pair<ll,ll>,ll>
using namespace std;
const double Pi=acos(-1.0);
const ll MAXN=1e6+5;
ll n,m,t,k;
ll mod=998244353ll;
ll qk(ll x,ll n){
    ll ans=1;
    while(n){
        if(n&1ll)ans=ans*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return ans;
}
void exgcd(ll a,ll b,ll &x,ll &y)
{
    if(!b){x=1ll;y=0ll;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll INV(ll a)
{
    ll x,y;
    exgcd(a,mod,x,y);
    return (x+mod)%mod;
}
int main(){
    cin>>n>>m>>k;
    if(m==1){
        if(k==n-1)cout<<1;
        else cout<<0;
        return 0;
    }
    ll ans=m*qk(m-1,n-1)%mod;
    ll now=ans;
    ll l=1,r=n-1;
    REP(i,1,k){
        now=now*r%mod*INV(l)%mod*INV(m-1)%mod;
        ans=(ans+now)%mod;
        l++,r--;
    }
    cout<<ans;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b, c, x; cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(500*i + 100*j + 50*k == x) ans++;
            }
        }
    }
    cout << ans << endl;
}

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


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

    if (N >= 10) cout << R << endl;
    else cout << R + 100 * (10 - N) << endl;
}

Measured memory_bytes: 3620