akhauriyash/Code-Regression huggingface dataset:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

N,Y = na()
flag = 0
for x in range(N+1):
    for y in range(N+1):
        z = N - (x+y)
        if 10000*x + 5000*y + 1000*z == Y and x >= 0 and y >= 0 and z >= 0:
            flag = 1
            break
    if flag:
        break
    else:
        pass
if flag:
    print(x,y,z)
else:
    print(-1,-1,-1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long long n,a[100002],flag=1,ans;
void k(){
    flag=1;
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+n+1);
    k();
    for(int i=2;i<=n;i++){
        if(a[i]==a[i-1]) flag=(flag+1)%2;
        else{
            ans+=flag;
            k();
        } 
    }
    if(flag%2!=0) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int n,p,times=999999999;
	cin >> n;

	for (int i=0;i<n;i++) {
		cin >> p;
		p = log((p & -p))/log(2);
		//cout << p << endl;
		if (p < times) {
			times = p;
		}
	}
	cout << times << "\n";
	return 0;
}

Measured memory_bytes: 888
a=input()
b=a[::-1]
count=0
no=1
la=0
lb=0

while la+lb+2<=len(a):
#    print(a[la],b[lb])
    if a[la]==b[lb]:
        la=la+1
        lb=lb+1
    else:
        if a[la]=="x":
            count=count+1
            la=la+1
        elif b[lb]=="x":
            count=count+1
            lb=lb+1
        else:
            print(-1)
            no=0
            break
if no==1:
    print(count)




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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef vector<vector<int>> Matrix;

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

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

    while(N > 1000){
        N -= 1000;
    }

    cout << 1000 - N << endl;

}

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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(c,element) (c.find(element)!=c.end())
#define cpresent(c,element) (find(c,element)!=c.end())
typedef vector<int> vi;
typedef vector<ll> vll;
ll mod=1e9+7;


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

int test=1;
//cin>>test;
while(test--)
{
	int r;
	cin>>r;
  double pi=3.14159265358979323846;
  cout<<2*pi*r;


	
}
return 0;
}









Measured memory_bytes: 3792
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class UnionFindTree
{
private:
    typedef int T1;
    typedef int T2;

    static const T1 INIT_DATA;
    T1 updateData(T1 prev, T2 x){
        return prev + x;
    }
    T1 uniteData(T1 v1, T1 v2){
        return v1 + v2;
    }

    int n;
    vector<int> parent; // 親ノード
    vector<int> rank;   // 木の高さの上限
    vector<int> num;    // グループの要素数
    vector<T1> data;    // グループが持つ値

    int find(int x){
        if(parent[x] == x)
            return x;
        else
            return parent[x] = find(parent[x]);
    }
public:
    UnionFindTree(int n){ // コンストラクタ
        this->n = n;
        parent.resize(n);
        for(int i=0; i<n; ++i)
            parent[i] = i;
        rank.assign(n, 0);
        data.assign(n, INIT_DATA);
        num.assign(n, 1);
    }
    void unite(int a, int b){ // aとbのグループを併合
        if((a = find(a)) != (b = find(b))){
            if(rank[a] < rank[b]){
                parent[a] = b;
                data[b] = uniteData(data[b], data[a]);
                num[b] += num[a];
            }else{
                parent[b] = a;
                if(rank[a] == rank[b])
                    ++ rank[a];
                data[a] = uniteData(data[a], data[b]);
                num[a] += num[b];
            }
            -- n;
        }
    }
    bool same(int a, int b){ // aとbのグループが同じかを調べる
        return find(a) == find(b);
    }
    void update(int a, T2 x){ // ノードの値を更新する
        a = find(a);
        data[a] = updateData(data[a], x);
    }
    T1 getData(int a){ // グループが持つ値を返す
        a = find(a);
        return data[a];
    }
    int getNum(){ // グループの数を返す
        return n;
    }
    int getNum(int a){ // aのグループの要素数を返す
        return num[find(a)];
    }
};
const UnionFindTree::T1 UnionFindTree::INIT_DATA = 0;

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

    vector<tuple<int, int, int> > v(n);
    for(int i=0; i<n; ++i){
        int y, x, a;
        cin >> y >> x >> a;
        -- y;
        -- x;
        v[i] = make_tuple(a, y, x);
    }
    sort(v.rbegin(), v.rend());

    UnionFindTree uft(h+w);
    long long ans = 0;
    for(int i=0; i<n; ++i){
        int a, y, x;
        tie(a, y, x) = v[i];
        uft.unite(y, h+x);
        if(uft.getData(y) < uft.getNum(y)){
            ans += a;
            uft.update(y, 1);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4608
n = int(input())
A = [[int(i) for i in input().split()] for j in range(n)]
C = [[int(i) for i in input().split()] for j in range(n)]


ans = []

for bits in range(1, 2**4):
    cnt = 0
    used = [False] * n
    A.sort(key=lambda x:x[bits & 1], reverse=bits >> 1 & 1)
    C.sort(key=lambda x:x[bits >> 2 & 1], reverse=bits >> 3 & 1)

    for a, b in A:
        i = 0
        while i < n and (used[i] or a >= C[i][0] or b >= C[i][1]):
            i += 1
        if i >= n:
            continue
        cnt += 1
        used[i] = True
        i += 1
        

    ans.append(cnt)

print(max(ans))


Measured memory_bytes: 3064
N = int(input())
p = list(map(int, input().split()))
ans = 0
i = 0
while i < N - 1:
  if i < N - 4 and p[i] == i + 1 and p[i + 1] == i + 2 and p[i + 2] == i + 3 and p[i + 3] == i + 4:
    temp = p[i]
    p[i] = p[i + 1]
    p[i + 1] = temp
    temp = p[i + 2]
    p[i + 2] = p[i + 3]
    p[i + 3] = temp
    i += 3
    ans += 2
    continue
  if p[i] == i + 1:
    temp = p[i]
    p[i] = p[i + 1]
    p[i + 1] = temp
    ans += 1
  i += 1
if p[N - 1] == N:
  ans += 1
print(ans)

Measured memory_bytes: 14008
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n,m;
	static multiset<int> D;
	static int t[200010];
	
	scanf("%d",&n);
	rep(i,n){
		int d;
		scanf("%d",&d);
		D.insert(d);
	}
	scanf("%d",&m);
	rep(i,m){
		scanf("%d",&t[i]);
	}
	
	rep(i,m){
		if(D.find(t[i]) == D.end()){
			puts("NO");
			return 0;
		}
		D.erase(D.find(t[i]));
	}
	puts("YES");
}
	


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

long long calc(int x){
  if(not x) return 3;
  long long ret = 0, t = 1;
  while(x > 0){
    long long c;
    if(x%3 == 0) c = 3;
    else if(x%3 == 1) c = 5;
    else c = 7;
    ret += c*t;
    t *= 10;
    x /= 3;
    if(ret > 1e9) break;
  }
  return ret;
}

int main(){
  long long N;
  cin >> N;
  long long ng = 0, ok = N;
  while(ok-ng > 1){
    long long m = (ok+ng)/2;
    long long t = calc(m);
    if(t <= N) ng = m;
    else ok = m;
  }
  int ans = 0;
  for(int i = 0; i <= ng; ++i){
    int t = i;
    long long u = calc(t);
    int c = 0;
    while(t > 0){
      c |= (1<<(t%3));
      t /= 3;
    }
    long long s = 1;
    while(s < u) s *= 10;
    ans += (c==7);
    while(u+s*3 <= N){
      u += s*3;
      s *= 10;
      c |= 1;
      //if(c == 7) cerr << u << endl;
      ans += (c==7);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    string r = s;
    REVERSE(r);
    int ans = 0;
    rep(i,s.size()) if(s[i] != r[i]) ans++;
    OUT(ans/2);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n; cin >> n;
	vvb a(n, vb(n, false));
	{
		ll cnt = 0;
		REP(i, n) REP(j, n) {
			char c; cin >> c;
			if (c == '#') cnt++;
			if (c == '#') a[i][j] = true;
		}
		if (cnt == 0) {
			cout << -1 << endl;
			return 0;
		}
	}


	ll mi = TEN(10);
	REP(i, n) {
		vl white;
		REP(j, n) if (!a[i][j]) white.push_back(j);
		if (
			white.empty() || [&] {
				REP(_, n) if (a[_][i]) return true;
				return false;
			}()
		) {
			mi = min<ll>(mi, white.size());
		} else {
			mi = min<ll>(mi, white.size() + 1);
		}
	}
	ll cnt = 0;
	REP(j, n) {
		if ([&]() {
			REP(i, n) if (!a[i][j]) return false;
			return true;
		}()) {
			cnt++;
		}
	}
	cout << mi + n - cnt << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	string ans = "";
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	sort(S.begin(), S.end());
	for (int j = 0; j < N; j++) {
		ans += S[j];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(10 ** 9)



INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



x, y = LI()


n = max(x, y)
fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = fac[j-1] * j % mod


inv[n] = pow(fac[n], mod-2, mod)
for j in range(n-1, -1, -1):
    inv[j] = inv[j+1] * (j+1) % mod


if (x + y) % 3 or y * 2 < x or x * 2 < y:
    print(0)
else:
    a = x - (x + y) // 3
    b = y - (x + y) // 3
    print(fac[a + b] * inv[a] % mod * inv[b] % mod)



Measured memory_bytes: 57836
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
int main()
{
    char a[5][5];
    int i,j,k=0,l=0;
    for(i=0;i<2;i++)
        scanf("%s",&a[i]);
    for(i=0;i<2;i++)
    {
        for(j=0;j<3;j++)
        {
            if(l==1)
                break;
            if(a[i][j]==a[2-i-1][3-j-1])
            {
                k++;
                if(k==3)
                {
                    printf("YES\n");
                }
                continue;
            }
            else
            {
                printf("NO\n");
                l++;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int count = 0;
        
        while ((A-1)*count+1 < B ){
            count++;
        }
        System.out.println(count);
    }
}

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

typedef long long ll;

ll n,a,b;

int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	if((b-a) %2 == 1){
		ll kiri = a-1;
		ll kanan = n-b;
		ll ans = min(kiri + 1 + ((b-kiri-1)-1)/2 , kanan + 1 + (n-(a+kanan+1))/2);
		printf("%lld\n",ans);
	} else {
		printf("%lld\n",(b-a)/2);
	}
	return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc131/tasks/abc131_c

from fractions import gcd


A, B, C, D = map(int, input().split())

C_ = B // C
D_ = B // D

C_a = (A-1) // C
D_a = (A-1) // D

# 最小公倍数
CD = (C * D) // gcd(C, D)    # C*D / (最大公約数)

CD_ = (B // CD)
CD_a = ((A-1) // CD)

ans = B - (A-1) - (C_ - C_a) - (D_ - D_a) + (CD_ - CD_a)

print(int(ans))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
//#define int long long

signed main(){
    int n; cin >> n;
    int ans = 0;
    reps(i,1,n){
        if(to_string(i).length() % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::cmp::{self, Ordering};
use std::collections::*;
use std::io::{self, Read};

const MOD: usize = 1000000007;

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let n: usize = sc.read().unwrap();

    let mut t = vec![false; n + 1];
    for i in 0..n + 1 {
        if i == 4 {
            t[4] = true;
            continue;
        }
        if n == 7 {
            t[7] = true;
            continue;
        }

        if i > 7 {
            t[i] = t[i - 4] || t[i - 7];
        }
    }
    // println!("{:?}", t);

    if t[n] {
        println!("Yes");
    } else {
        println!("No");
    }
}

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


Measured memory_bytes: 4352
function main(input) {
    var input = input.split(' ')
    var n =parseInt(input[0],10)
    var a = parseInt(input[1],10)
    var b = parseInt(input[2],10)
    var array = new Array(parseInt(n,10))
    var sum = 0
    var result_array =[]
    var fin_sum=0

    for(var i=0; i<n;i++){
        array[i] = i+1
    }
    for(var j=0;j<n;j++){
        var tmp = array[j]
        while(tmp >0){
            sum += tmp%10
            tmp = Math.floor(tmp/10)
        }
        if(a<=sum && sum<=b){
            result_array.push(j)
        }
        sum = 0
    }
    for(var k=0; k<result_array.length; k++){
        fin_sum += array[result_array[k]]
    }
    console.log(fin_sum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

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

using namespace std;
using ll = long long;
int dp[1001][4097];

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M + 1);
	vector<int> C(M + 1);

	rep(i, M) {
		int a, b;
		cin >> a >> b;
		A[i + 1] = a;
		
		int n = 0;
		rep(j, b) {
			int c;
			cin >> c;

			n = n + (1 << --c);
		}
		C[i + 1] = n;
	}

	rep(j, 1 << N + 1) {
		dp[0][j] = INF;
	}

	dp[0][0] = 0;

	for (int i = 1; i < M+1; i++) {
		rep(j, 1 << N) {
			dp[i][j] = dp[i - 1][j];
		}
		rep(j, 1 << N) {
			dp[i][j | C[i]] = min(dp[i][j | C[i]], dp[i-1][j] + A[i]);
		}
	}

	ll ans = dp[M][(1 << N) - 1];
	if (ans == INF) ans = -1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 16256
import collections 
n,cc = int(raw_input()), collections.Counter(map(int,raw_input().split()))
m,s = max(cc.keys()),{ai:True for ai in cc}
for a in cc:
	c = a if cc[a] > 1 else 2 * a
	while(c <= m):
		if a in s: s[c] = False
		c += a
count = 0
for v in s.values():
	if v: count +=1
print count

Measured memory_bytes: 228784
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector <int> ans(N + 1);
  for (int i = 1; i <= N; i++) {
	  int A;
	  cin >> A;
	  ans[A] = i;
	}
  for (int i = 1; i <= N - 1; i++) {
	  cout << ans[i] << " ";
	}
  cout << ans[N] << endl;
  return 0;
}


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

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    string s,t,u;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    cin>>u;
    if(u==s)
        a--;
    else
    {
        b--;
    }
    cout<<a<<" "<<b;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;


int main() {
	ll n,m;
    cin>>n>>m;
    vector<ll>a(n),b(m),c(m);
    vector<pair<ll,ll>>cmp;
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    rep(i,m){
        cin>>b[i]>>c[i];
        cmp.eb(c[i],b[i]);
        }
    sort(cmp.begin(),cmp.end(),greater<pair<ll,ll>>());
    sort(a.begin(),a.end());
    int k=0;
    rep(i,m){
        rep(j,cmp[i].se){
            if(k==n)break;
            if(a[k]<=cmp[i].fi)sum+=cmp[i].fi-a[k];       
            k++;
             }
    }
    cout<<sum<<endl;
}

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

using namespace std;

int main() {
	long long x;
	scanf("%lld", &x);
	
	long long cur = 100;
	int cnt = 0;
	
	while (cur < x) {
		cur = cur + cur / 100;
		cnt++;
	}
	
	printf("%d\n", cnt);
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int main() {
  int n, k, score, count;
  double ans = 0;
  cin >> n >> k;
  REP(i, n) {
    score = i+1; count = 0;
    while(score < k) {
      score *= 2; count++;
    }
    ans += pow(0.5, count);
  }
  cout << setprecision(10) << ans / n << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <stack>
#include <limits>
#include <climits>
#include <cassert>
#include <fstream>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <ciso646>
#include <set>
#include <array>
#include <unordered_map>

using namespace std;

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

#define inf 0x3f3f3f3f
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define VS vector<string>
#define VI vector<ll>
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define ll long long
#define ull unsigned long long
#define pii pair<ll,ll>
#define pcc pair<char,char>
#define pic pair<ll,char>
#define pci pair<char,ll>
#define eps 1e-14
#define FST first
#define SEC second
#define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15)

namespace {
	struct input_returnner {
		ll N; input_returnner(ll N_ = 0) :N(N_) {}
		template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); }
		template<typename T> operator T() const { T res; cin >> res; return res; }
		template<typename T> T operator - (T right) { return T(input_returnner()) - right; }
		template<typename T> T operator + (T right) { return T(input_returnner()) + right; }
		template<typename T> T operator * (T right) { return T(input_returnner()) * right; }
		template<typename T> T operator / (T right) { return T(input_returnner()) / right; }
		template<typename T> T operator << (T right) { return T(input_returnner()) << right; }
		template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; }
	};
	template<typename T> input_returnner in() { return in<T>(); }
	input_returnner in() { return input_returnner(); }
	input_returnner in(ll N) { return std::move(input_returnner(N)); }
}

const ll MOD = 1e9 + 7;

void solve();

signed main() {
	SETUP;
	solve();
#ifdef _DEBUG
	system("pause");
#endif
	return 0;
}

#define int ll

void solve() {
	int N; cin >> N;
	vector<pii> v;
	REP(i, N) {
		int a; cin >> a;
		v.push_back(MP(a, i));
	}
	sort(ALL(v));
	vector<int> out(N);
	int A = v[N / 2 - 1].first;
	int B = v[N / 2].first;
	REP(i, N) {
		if (i < N / 2) {
			out[v[i].second] = B;
		}
		else {
			out[v[i].second] = A;
		}
	}
	for (auto &a : out) {
		cout << a << endl;
	}
}


Measured memory_bytes: 7788
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
	int h,w;
	char s,t;
	cin >> h >> w >> s >> t;
	vector<int> x(26), y(26);
	vector<vector<char> > field(h, vector<char>(w));
	vector<int> vlist(26, false);
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin >> field[i][j];
			if('A' <= field[i][j] && field[i][j] <='Z'){
				vlist[field[i][j] -'A'] = true;
				x[field[i][j]-'A'] = j;
				y[field[i][j]-'A'] = i;
			}
		}
	}
	
	vector<vector<int> > adj(26, vector<int>(26, inf));
	for(int i=0; i<26; i++){
		for(int j=i+1; j<26; j++){
			if(!vlist[i] || !vlist[j]) continue;
			if(x[i] == x[j]){
				bool connect = true;
				int yi=y[i], yj=y[j];
				if(yi>yj) swap(yi, yj);
				for(int k=yi+1; k<yj-1; k++){
					if(field[k][x[i]]!='o' && field[k][x[i]]!='|'){
						connect = false;
					}
				}
				if(connect) adj[i][j] = adj[j][i] = 1;
			}
			if(y[i] == y[j]){
				bool connect = true;
				int xi=x[i], xj=x[j];
				if(xi>xj) swap(xi, xj);
				for(int k=xi+1; k<xj-1; k++){
					if(field[y[i]][k]!='o' && field[y[i]][k]!='-'){
						connect = false;
					}
				}
				if(connect) adj[i][j] = adj[j][i] = 1;
			}
		}
	}
	
	
	
	for(int k=0; k<26; k++){
		for(int i=0; i<26; i++){
			for(int j=0; j<26; j++){
				adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
			}
		}
	}
	cout << adj[s-'A'][t-'A'] << endl;
	return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define lli long long int
#define INF LLONG_MAX

using namespace std;
int main(){
	int n;
	cin>>n;
	lli input[n][3];
	lli dp[n][3];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < 3; j++) cin>>input[i][j];
	for(int i = 0; i < n; i++) fill(dp[i], dp[i] + 3, 0);
	for(int i = 0; i < 3; i++) dp[0][i] = input[0][i];
	for(int i = 1; i < n; i++) {
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++) {
				if( k!= j){
					dp[i][j] = max(dp[i][j], dp[i - 1][k] + input[i][j]);
				}
			}
		}
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	return 0;
}
	
	


Measured memory_bytes: 4992
n, k = map(int, input().split())

mod = 10**9+7

def power(a, n, mod):
  bi=str(format(n,"b")) #2進数
  res=1
  for i in range(len(bi)):
    res=(res*res) %mod
    if bi[i]=="1":
      res=(res*a) %mod
  return res


X = [0]*(k+1)
ans = 0
for i in reversed(range(1, k+1)):
    temp = power(k//i, n, mod)
    j = i+i
    while j <= k:
        temp -= X[j]
        j += i
    X[i] = temp
    ans += (temp*i)%mod
print(ans%mod)


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

struct Team {
  int id, ac, penalty;
  vector<int> wa;
  Team(int id, int p) : id(id), ac(0), penalty(0), wa(p + 1) {}
  void wrong(int pid, int t){
    wa[pid]++;
  }
  void correct(int pid, int t){
    ac++;
    penalty += wa[pid] * 1200 + t;
  }
  bool operator<(const Team& t) const {
    if (ac != t.ac) return ac > t.ac;
    if (penalty != t.penalty) return penalty < t.penalty;
    return id < t.id;
  }
};

int main()
{
  int T, P, R;
  while (T = in(), P = in(), R = in(), T || P || R){
    vector<Team> teams;
    for (int i = 1; i <= T; i++) teams.emplace_back(i, P);
    while (R--){
      int tid, pid, t;
      string msg;
      cin >> tid >> pid >> t >> msg;
      if (msg == "WRONG") teams[tid - 1].wrong(pid, t);
      else teams[tid - 1].correct(pid, t);
    }
    sort(teams);
    for (auto& team : teams){
      printf("%d %d %d\n", team.id, team.ac, team.penalty);
    }
  }
  return 0;
}

Measured memory_bytes: 1272
#include<stdio.h>

int main()
{
	int a, b, c, d;

	scanf("%d %d %d %d", &a, &b, &c, &d);
	while (1) {
		c = c - b;
		if (c <= 0) {
			printf("Yes");
			return 0;
		}
		a = a - d;
		if (a <= 0) {
			printf("No");
			return 0;
		}
	}
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
 
using namespace std;
int n;
string s;
bool check(string s,int n)
{
    for (int i=0;i<n/2;i++)
        if (s[i]!=s[i+n/2])
        {
            return false;
        }
    return true;
}
int main()
{
    cin>>n;
    cin>>s;
    if (n%2==1)
    {
        cout<<"No";
        return 0;
    }
    if (check(s,n)==true) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
k = []
l = []
r = []

for i in range(m):
  k = list(map(int, input().split()))
  l.append(k[0])
  r.append(k[1])

if max(l) <= min(r):
  ans = min(r) - max(l) + 1
else:
  ans = 0
print(ans)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    list<ll> b;
    vector<ll> trace;
    cin >> N;
    rep(i, N) {
        ll temp;
        cin >> temp;
        b.push_back(temp);
    }
    rep(i, N) {
        per(j, b.size()) {
            auto iter = next(b.begin(), j);
            if(j + 1 == *iter) {
                b.erase(iter);
                trace.push_back(j);
                break;
            }
        }
    }
    if(b.empty()) {
        reverse(trace.begin(), trace.end());
        iter(i, trace) cout << i + 1 << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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() {
   ll ans = 0;
   int N,M;
   cin >> N >> M;
   vector<ll> vec(N+1);
   set<int> a;
   rep(i,M){int p; cin >> p; a.insert(p);}
   rep(i,N+1)
   {

      if(a.count(i)>0){ vec.at(i) = 0; continue;}
      else
      {
         if(i<2){vec.at(i) = 1; continue;}
         vec.at(i) = vec.at(i-1) + vec.at(i-2);
         vec.at(i) = vec.at(i) % MOD;
      }
      

   }
   ans = vec.at(N);
   cout << ans << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define ll          long long
#define pll         vector< pair<ll ,ll> >
#define vll         vector<ll>
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb          push_back
#define F           first
#define S           second
#define mp          make_pair
#define all(v)      v.begin(), v.end()
#define lb          lower_bound  //value not less than(>=)
#define ub          upper_bound  //value greater than(>)
#define bs          binary_search
#define pcont(v)    for(auto it:v) cout<<it<<" ";cout<<endl
#define ret(x)      return cout << x,0;
#define pi          pair<ll,pair<ll,ll> >

ll const MAX = 1e5+5;
using namespace std;

ll a[MAX],dp[MAX];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

    ll n;
    cin >> n;
    rep(i,0,n) cin >> a[i];

    dp[n-1]=0;
    for(ll i=n-2;i>=0;i--) {
        ll x=hell,y=hell;
        if(i+1<n) {
            x=dp[i+1]+abs(a[i]-a[i+1]);
        }
        if(i+2<n) {
            y=dp[i+2]+abs(a[i]-a[i+2]);
        }
        dp[i]=min(x,y);
    }
    cout << dp[0] << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
struct polk
{
    int seat;
    char suit;
    char value;
};
void check_stable(polk a[],int n)
{
    int i;
    for(i=0;i<n-1;i++)
    {
        if(a[i].value==a[i+1].value)
            if(a[i].seat>a[i+1].seat)
        {
            printf("Not stable\n");
            return;
        }
    }
    printf("Stable\n");
}
void change(polk* p1,polk* p2)
{
    int s;
    char temp;
    char v;
    temp=p1->suit;
    p1->suit=p2->suit;
    p2->suit=temp;
    v=p1->value;
    p1->value=p2->value;
    p2->value=v;
    s=p1->seat;
    p1->seat=p2->seat;
    p2->seat=s;
}
void bubble_sort(int n,polk a[])
{
    int i,h,flag=1;
    while(flag)
    {
        flag=0;
        for(i=n-1;i>0;i--)
        {
            if(a[i].value<a[i-1].value)
            {
                flag=1;
                change(&a[i],&a[i-1]);
            }
        }
    }
        for(h=0;h<n;h++)
        {
            if(h>0)
                printf(" ");
            printf("%c%c",a[h].suit,a[h].value);
        }
        printf("\n");
        check_stable(a,n);
}
void selection_sort(int n,polk a[])
{
    int i,j,mins,h;
    for(i=0;i<=n-1;i++)
    {
        mins=i;
        for(j=i;j<=n-1;j++)
        {
            if(a[j].value<a[mins].value)
            {
                mins=j;
            }
        }
        if(a[i].value!=a[mins].value)
        {
            change(&a[i],&a[mins]);
        }
    }
     for(h=0;h<n;h++)
        {
            if(h>0)
                printf(" ");
           printf("%c%c",a[h].suit,a[h].value);
        }
        printf("\n");
        check_stable(a,n);
}
int main()
{
    int i,n;
    polk a[37],b[37];
    scanf("%d",&n);
    getchar();
    for(i=0;i<n;i++)
    {
        b[i].suit=a[i].suit=getchar();
        b[i].value=a[i].value=getchar();
        b[i].seat=a[i].seat=i;
        getchar();
    }
    bubble_sort(n,b);
        selection_sort(n,a);
        return 0;
}



Measured memory_bytes: 2704
#include <iostream>
#include <string>
#include <algorithm>
#define ll long long int

using namespace std;


int main(int argc, char const* argv[])
{
	int n, m;
	cin >> n >> m;
	ll *x = new ll[n];
	ll *y = new ll[n];
	ll *z = new ll[n];
	ll *sum[8];
	for(int i = 0; i < 8; i++){
			sum[i] = new ll[n];
	}
	for(int i = 0; i < n; i++){
			cin >> x[i] >> y[i] >> z[i];
			for(int j = 0; j < 8; j++){
					sum[j][i] = (2 * (j & 1) - 1) * x[i] + (2 * ((j & 2) >> 1) - 1) * y[i] + (2 * ((j & 4) >> 2) - 1) * z[i];
			}
	}
	ll max = -1;
	for(int i = 0; i < 8; i++){
			sort(sum[i], sum[i] + n);
			ll thissum = 0;
			for(int j = 0; j < m; j++){
					thissum += sum[i][n - j - 1];
			}
			if(max < thissum)max = thissum;
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3

n = int(input())
mod = 10**9+7

is_prime = [True for _ in range(1100)]
is_prime[0] = is_prime[1] = False
for i in range(2, 1100):
    if not is_prime[i]: continue
    for j in range(i*i, 1100, i): 
        is_prime[j] = False

ind = []

for p in range(2, 1100):
    if is_prime[p]:
        cnt = 0 
        for m in range(2, n+1):
            while m%p == 0:
                m //= p
                cnt += 1
        if cnt != 0:
            ind.append(cnt)

#print('ind =', ind)
ans = 1 
for i in range(len(ind)):
    ans *= (ind[i]+1)

print(ans%mod)


Measured memory_bytes: 9224
N = int(input())
x = input().split()
avg = 0

for i in range (N) :
    x[i] = int(x[i])
    avg += x[i]

avg1 = avg // N
avg2 = avg // N + 1

ans1 = 0
ans2 = 0

for i in range (N) :
    ans1 += (x[i] - avg1) ** 2
    ans2 += (x[i] - avg2) ** 2

print (int(min(ans1 , ans2)))

Measured memory_bytes: 3064
//package bigneer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub

		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
//		int t=Integer.parseInt(br.readLine());
//		while(t-->0) {
//			int n=Integer.parseInt(br.readLine());
			String q[]=br.readLine().split(" ");
			int a=Integer.parseInt(q[0]);
			int b=Integer.parseInt(q[1]);
			System.out.println(a*b);
//			int a[]=new int[n];
//			for(int i=0;i<n;i++)
//				a[i]=Integer.parseInt(q[0]);
//			System.out.println();
//		}
	}

}


Measured memory_bytes: 32760
using System;
using System.Collections.Generic;
using System.Linq;

class AIZU0025{
   public static void Translate(string s, out List<int> b) {
      b=new List<int>();
      string[] ss=s.Split(' ');
      foreach (string s1 in ss) b.Add(int.Parse(s1));
   }
   public static void Main(string[] args) {
      List<int> Target=new List<int>(), Query=new List<int>();
      Queue<string> G=new Queue<string>();
      string s;int hit, blow;
      string[] ss;
      while(true) { 
         s = Console.ReadLine();
         if (string.IsNullOrEmpty(s)) break;
         ss=s.Split(' ');
         for (int I = 0; I<4; I++) Target.Add(int.Parse(ss[I]));
         s = Console.ReadLine();
         ss=s.Split(' ');
         for (int I = 0; I<4; I++) Query.Add(int.Parse(ss[I]));
         hit = Hit(Target,Query);
         blow = Target.Intersect(Query).Count()-hit;
         G.Enqueue(string.Format("{0} {1}",hit,blow));
         Target.Clear();Query.Clear();
      }
      while (G.Count>0) Console.WriteLine(G.Dequeue());
   }
   public static int Hit(List<int> Target,List<int> Query) {
      int res = 0;
      for (int i = 0; i<4; i++)
         if (Target[i]==Query[i]) 
            res++;
      return res;
   }
}

Measured memory_bytes: 10896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcm(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcm(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcm(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    int n;
    cin >> n;
    rep1(i, 50000) {
        if(floor(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	ll N,D; cin >> N >> D;
	int a = 0;
	while(N--){
		ll x,y; cin >> x >> y;
		ll v = x*x+y*y;
		if(D*D >= v) a++;
	}
	cout << a << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;
//8c:1a:bf:89:66:b6
struct threeElements{
int _1st,_2nd,_3rd;
};
vector<vector<int>>adj(10);
ll solve(int a,int b)
{
    int f=0,s=0;
    while(a)
    {
        a/=10;
        f++;
    }
    while(b)
    {
        b/=10;
        s++;
    }
    return max(f,s);
}
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   //18:52
   ll n;
   cin>>n;
   ll ans=oo;
   for(ll i=1;i*i<=n;i++)
   {
       if(n%i==0)
       {
           ans=min(ans,solve(i,n/i));
       }
   }
   cout<<ans;
}


Measured memory_bytes: 3584
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

constexpr int fairfield(int y, int m, const int &d) {
  if (m == 1 || m == 2) y--, m += 12;
  return 365 * y + y / 4 - y / 100 + y / 400 + 306 * (m + 1) / 10 + d - 428;
}

void solve() {
  int y1, m1, d1, y2, m2, d2;
  while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2, y1 != -1) {
    cout << fairfield(y2, m2, d2) - fairfield(y1, m1, d1) << endl;
  }
}

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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        if(a % 2 + i % 2 == 2) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, X = ZZ()
    N -= X
    ans = 0
    while True:
        ans += (N//X) * 3 * X
        #割り切れない
        if N%X: N, X = X, N%X
        #割り切れる
        else: break
    print(ans)

    return

if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	vector<int>H(N);
	for (int i = 0; i < N; i++){
		cin >> H[i];
	}
	if (N == 1) {
		cout << "Yes" << endl;
		return 0;
	}

	for (int i = 1; i < N; i++){
		if (H[i - 1] < H[i] && H[i] >= 0) {
			H[i]--;
		}
		else if (H[i] < H[i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"sort"
	"strings"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	as := strings.Split(s, "")
	at := strings.Split(t, "")
	sort.Strings(as)
	sort.Sort(sort.Reverse(sort.StringSlice(at)))
	s = strings.Join(as, "")
	t = strings.Join(at, "")
	for i := 0; i < max(len(s), len(t)); i++ {
		if i >= len(s) {
			fmt.Println("Yes")
			return
		}
		if i >= len(t) {
			fmt.Println("No")
			return
		}
		if s[i] < t[i] {
			fmt.Println("Yes")
			return
		}
		if s[i] > t[i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 640