akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
#include <map>
 
using namespace std;

typedef long long ll;

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

    vector<vector<pair<int, bool> > > A(3, vector<pair<int, bool> >(3));

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            int a;
            cin >> a;
            A[i][j] = make_pair(a, false);
        }
    }

    int N;

    cin >> N;

    for(int i = 0; i < N; i++) {
        int b;
        cin >> b;

        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(A[j][k].first == b) {
                    A[j][k].second = true;
                }
            }
        }
    }

    bool c = false;

    for(int i = 0; i < 3; i++) {
        if(A[i][0].second && A[i][1].second && A[i][2].second) {
            c = true;
        }
    }


    for(int i = 0; i < 3; i++) {
        if(A[0][i].second && A[1][i].second && A[2][i].second) {
            c = true;
        }
    }

    if(A[0][0].second && A[1][1].second && A[2][2].second) {
        c = true;
    }

    if(A[0][2].second && A[1][1].second && A[2][0].second) {
        c = true;
    }
    
    if(c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n,y=gets.chomp.split(" ").map(&:to_i)

y = y/1000
def search(n , y)
    (0..n).each do |i|
        (0..n-i).each do |j|
            k = n - i - j
            if 10*i + 5*j + k == y
                puts "#{i} #{j} #{k}"
                return true
            end 
        end
    end
    false
end

unless search(n , y) 
    puts "-1 -1 -1"
end


Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int a,b;
	cin >> a >> b;
	int c = a - b*2;
	if (c >0) {
		cout << c << endl;
		return 0;
	}
	cout << 0 << endl;
	return 0;
}


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

int main() {
    int N; cin >> N;
    int count = 0;
    for (int i = 1; i <= N; ++i) {
        int dcount = 0;
        bool flg = true;
        int a = i;
        while(flg){
            a /= 10;
            dcount++;
            if(a == 0) flg = false;
        }
        if((dcount) %2 ==1) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
	"strconv"
	"strings"
)

func resolve(num string) {
	var rep []int
	var temp2 []int
	var temptemp int

	temp := strings.Split(num, "")
	for i := 0; i < len(temp); i++ {
		temptemp, _ = strconv.Atoi(temp[i])
		temp2 = append(temp2, temptemp)
	}
	for i := 0; i < len(num)-2; i++ {
		temp_num := temp2[i]*100 + temp2[i+1]*10 + temp2[i+2]
		rep = append(rep, temp_num)
	}

	sort.Ints(rep)

	min := 999999
	for i := 0; i < len(rep); i++ {
		tempnum := math.Abs(float64(rep[i] - 753))
		if min > int(tempnum) {
			min = int(tempnum)
		}
	}
	fmt.Println(min)
}
func main() {
	var s string
	fmt.Scanf("%s\n", &s)

	resolve(s)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tc = 1;
    //cin >> tc;
    while(tc--)
    {
        int n;
        vector<int> v;
        cin >> n;
        while(n){
            v.push_back(n % 10);
            n /= 10;
        }
        int flag = 0;
        for(auto x: v){
            if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9){
                cout << "hon" << endl;
                break;
            }
            else if(x == 0 || x == 1 || x == 6 || x == 8){
                cout << "pon" << endl;
                break;
            }
            else if (x == 3){
                 cout << "bon" << endl;
                break;
            }
        }
    }
    return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  ll N;
  scanf("%lld", &N);

  ll max_h = -1;

  vector<tuple<ll, ll, ll>> list;
  for (ll i = 0; i < N; i++) {
    ll a, b, c;
    scanf("%lld %lld %lld", &a, &b, &c);
    list.emplace_back(make_tuple(a, b, c));
    // cout << get<0>(list[i]) << endl;
    max_h = max(max_h, c);
  }

  for (ll ch = max_h;; ch++) {
    // cout << (ch) << endl;
    for (ll cx = 0; cx <= 105; cx++) {
      for (ll cy = 0; cy <= 105; cy++) {
        // judge
        bool ok = true;
        for (ll i = 0; i < list.size(); i++) {
          auto v = list[i];
          ll x = get<0>(v);
          ll y = get<1>(v);
          ll h = get<2>(v);

          if (h != max(0LL, (ch - abs(x - cx) - abs(y - cy)))) {
            ok = false;
            break;
          }
        }
        if (ok) {
          cout << (cx) << " " << (cy) << " " << (ch) << endl;
          return 0;
        }
      }
    }
  }
}


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

int main(){
    long long X;
    long long ans = 0;
    cin>>X;

    long long cnt = X/11;
    ans += cnt*2;

    X -= cnt*11;

    int i=0;

    while(X > 0){
        if(i%2 == 0) X -= 6;
        else X -= 5;
        i++;
    }

    ans += i;
    
    cout<<ans<<endl;

    return 0;
}

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

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

#define MOD 1000000007LL

#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;
    cin >> N;
    if(N % 2) {
        cout << 0 << endl;
    } else {
        ll count = 0;
        for(ll i = 10;i <= N;i *= 5) count += N / i;
        cout << count << endl;
    }
    return 0;
}


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

C = [[0]*W for _ in range(H)]
num = 80
for i in range(H):
    for j in range(W):
        C[i][j] = abs(A[i][j]-B[i][j])
        
dp = [[0]*W for _ in range(H)]
dp[0][0] |= (1<<num+C[0][0]) | (1<<num-C[0][0])

for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] |= (dp[i-1][j]<<num+C[i][j]) | (dp[i-1][j]<<num-C[i][j])
        if j > 0:
            dp[i][j] |= (dp[i][j-1]<<num+C[i][j]) | (dp[i][j-1]<<num-C[i][j])
            
b = list(bin(dp[-1][-1]))[::-1]
ans = 10**9
for i in range(len(b)):
    if b[i] == "1":
        ans = min(ans, abs(num*(H+W-1)-i))

print(ans)

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

using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<ll>;

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int a, b, c = 1, i = 0;
  cin >> a >> b;
  for (; c < b; i++) c += (a - 1);
  cout << i <<"\n";
}


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

using lli = long long int;

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

int main(void){
    int a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n;
    cin >> n;
    vint a(n),b(n);
    REP(i, n) { 
        cin >> a[i];
        b[i] = 0;
    }
    IREP(i,n){
        int now = i + 1, tot = i + 1, modval = 0;
        modval += a[tot - 1];
        tot += now;
        while (tot <= n)
        {
            modval += b[tot - 1];
            tot += now;
        }
        modval %= 2;
        b[i] = modval;
    }
    int num=0;
    vint c;
    REP(i, n)
    {
        if (b[i] == 1){
            num++;
            c.eb(i + 1);
        }
    }
    cout << num << endl;
    if (num > 0)
    {
        REP(i, num - 1)
        {
            cout << c[i] << " ";
        }
        cout << c[num - 1] << endl;
    }
}

Measured memory_bytes: 3192
import math


def eratosthenes(n):
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


q = int(input())
l, r = [], []
for _ in range(q):
    _lr = list(map(int, input().split()))
    l.append(_lr[0])
    r.append(_lr[1])
N = 10 ** 5 + 1

prime_list = eratosthenes(N)
prime_flag = [False for _ in range(10 ** 5 + 2)]
like_2017 = [0 for _ in range(10 ** 5 + 2)]
like_cnt = 0

for p in prime_list:
    prime_flag[p] = True

for i in range(10 ** 5 + 2):
    if prime_flag[(i + 1) // 2] and prime_flag[i]:
        like_cnt += 1
    like_2017[i] = like_cnt

for i in range(q):
    print(like_2017[r[i]] - like_2017[l[i] - 1])


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

#define NL '\n'
#define C char
#define D double
#define F float
#define S string
#define sz(x) x.size()
#define INF LONG_LONG_MAX
#define PI (2.0*acos(0.0))
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%d %d",&x,&y)
#define sfi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sfl(x) scanf("%lld",&x)
#define sfl2(x,y) scanf("%lld %lld",&x,&y)
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sfd(x) scanf("%lf",&x);
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(max3(a,b,c),d)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min3(b,c,d))
#define mem(ara,val) memset(ara,val,sizeof(ara))
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

/*LL gcd(LL a,LL b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
LL lcm(LL a,LL b)
{
    return a/gcd(a,b)*b;
}*/

/*bool pal (S s)
{
    bool flag = true;
    for(int i=0; i<sz(s); i++)
    {
        if(s[i]!=s[sz(s)-i-1])
        {
            flag = false;
            break;
        }
    }
    if(flag) return true;
    else return false;
}*/

int main()
{
    int n;
    cin>>n;
    int arr[n];
    vector <int> vec;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        if(arr[i]%2==0)
            vec.push_back(arr[i]);
    }
    int count=0;
    for(int i=0; i<sz(vec); i++)
    {
        if(vec[i]%3==0 || vec[i]%5==0) count++;
    }

    if(count==sz(vec)) cout<<"APPROVED"<<NL;
    else cout<<"DENIED"<<NL;



}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

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

int main() {
    int N, K; cin >> N >> K;
    int h[N]; rep(i, N) cin >> h[i];

    sort(h, h + N);

    int hd[N - K + 1];
    rep(i, N - K + 1) hd[i] = h[i + K - 1] - h[i];

    cout << *min_element(hd, hd + N - K + 1) << endl;

    return 0;
}

Measured memory_bytes: 1024
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto input = readLongs();
    writeln(input.sort().take(2).sum());

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



template <typename T> T gcd(T a, T b) {if(b == 0) return a;return gcd(b,a%b);}
template <typename T> T extgcd(T a, T b, T& x, T& y){
    T d = a;
    if(b != 0){d = extgcd(b,a%b,y,x); y-=(a/b)*x;}
    else x=1,y=0;
    return d;
}
template <typename T> T modpow(T x, T n, T m) {
    if(n==0) return 1;
    T resp = modpow(x*x%m,n/2,mod);
    if(n&1) resp = resp*x%m;
    return resp;
}
template <typename T> T modinverse(T a, T m) {
    T x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}
struct combination {
    ll M = mod;
    vector<ll> fact;vector<ll> ifact;
    combination(ll n):fact(n+1),ifact(n+1){
        fact[0]=1;ifact[0]=1;
        for (ll i = 0; i<n; i++) {fact[i+1] = fact[i]*(i+1) % M;ifact[i+1] = ifact[i]*modpow(i+1, M-2, M) % M;}
    }
    ll com(ll a, ll b){
        if(a == 0 && b == 0)return 1;if(a < b || a < 0)return 0;
        ll tmp = ifact[a-b]* ifact[b] % M;
        return tmp * fact[a] % M;
    }
};



int main()
{
    int N;
    cin >> N;
    vl x(N);
    in(N,x);
    
    combination C((ll)N);
    
    vl AA(N);
    AA[0] = 0;
    reps(i,1,N) AA[i] = AA[i-1]+C.fact[N-1]*modinverse((ll)i, mod)%mod,AA[i]%=mod;
    
    
    ll ans = 0;
    rep(i,N-1){
        ans += (x[i+1]-x[i])*AA[i+1]%mod;
    }
    out(ans%mod);
    //outve(AA);
    

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, K, A;
map<ll, ll> s;
int main() {
    cin >> N >> K;
    for(int i{}; i < N; ++i) {
        cin >> A;
        s[A]++;
    }
    vector<ll> a;
    a.reserve(200001);
    for(auto& x : s)
        a.emplace_back(x.second);
    sort(a.begin(), a.end());
    int ans{}, n = a.size();
    for(auto& x : a) {
        if(n <= K) break;
        ans += x;
        --n;
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef long double ld;

const ll INF = 1000000000000000000LL;

ll minw[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, w;
    cin >> n >> w;
    for(int i=1; i<=1000*n; i++) minw[i] = INF;
    for(int i=1; i<=n; i++){
        int a, b;
        cin >> a >> b;
        for(int j=1000*n; j>=b; j--){
            minw[j] = min(minw[j], minw[j-b] + a);
        }
    }
    ll res = 0;
    for(int i=1; i<=1000*n; i++){
        if(minw[i] <= w) res = i;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
int i,j,l,t,a[200000],k,p=0,x,n=0;
string s;
 cin>>i>>j;
 if((i==1||i==3||i==5||i==7||i==8||i==10||i==12)&&(j==1||j==3||j==5||j==7||j==8||j==10||j==12)){cout<<"Yes\n";}
 else if((i==4||i==6||i==9||i==11)&&(j==4||j==6||j==9||j==11)){cout<<"Yes\n";}
 else{cout<<"No\n";}





}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    Deque<String> dque=new ArrayDeque<>();
    String s=sc.next();
    for(int i=0;i<s.length();i++) dque.addLast(s.substring(i, i+1));
    String c="";
    int q=sc.nextInt(),count=0;
    boolean flag=true;
    for(int i=0;i<q;i++) {
    	int t=sc.nextInt();
    	if(t==1) {
    		flag=!flag;
    		count++;
    	}else {
    		int f=sc.nextInt();
    		c=sc.next();
    		if(f==1) {
    			if(flag) {
    				dque.addFirst(c);
    			}else {
    				dque.addLast(c);
    			}
    		}else {
    			if(flag) {
    				dque.addLast(c);
    			}else {
    				dque.addFirst(c);
    			}
    		}
    	}
    	//System.out.println(dque);
    }
    int n=dque.size();
    if(count%2==0) {
    	for(int i=0;i<n;i++) {
    		System.out.print(dque.removeFirst());
    	}
    }else {
    	for(int i=0;i<n;i++) {
    		System.out.print(dque.removeLast());
    	}
    }
    System.out.println();
  }
}


Measured memory_bytes: 174660
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  int m;
  if(n%2==0){
    m = (n-2)*n/2;
    cout<<m<<endl;
    REP(i, n){
      for(int j=i; j<n; ++j){
        if(j==i) continue;
        if(i+j==n-1) continue;
        cout<<i+1<<" "<<j+1<<endl;
      }
    }
  }
  if(n%2==1){
    m = (n-1)*(n-3)/2+n-1;
    cout<<m<<endl;
    REP(i, n-1){
      for(int j=i; j<n-1; ++j){
        if(j==i) continue;
        if(i+j==n-2) continue;
        cout<<i+1<<" "<<j+1<<endl;
      }
    }
    REP(i, n-1) cout<<i+1<<" "<<n<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NK = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        var (N, K) = (NK[0], NK[1]);

        var r = N % K;
        var ans = Math.Min(r, K - r);

        WriteLine(ans);
    }
}


Measured memory_bytes: 28224
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(n) n.begin(),n.end()
using namespace std;

int main()
{
    const int N = 10;
    vector<int> h;
    int hnum = 0;
    rep(i,N) 
    {
        cin >> hnum;
        h.push_back(hnum);
    }

    sort(all(h));

    cout << h[9] << endl;
    cout << h[8] << endl;
    cout << h[7] << endl;



    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int x,y;
  cin>>x>>y;
  int ans=0;
  if(x==3) ans++;
  if(y==3) ans++;
  if(x==2)ans+=2;
  if(y==2) ans+=2;
  if(x==1) ans+=3;
  if(y==1) ans+=3;
  if(x==1&&y==1) ans+=4;

  cout<<ans*100000<<endl;


}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <functional>

using namespace std;

int INF = 10000000;

int n;

char table[10][7] = 
{
	{'\\'},
	{'.',',','!','?',' ','-'},
	{'a','b','c','-'},
	{'d','e','f','-'},
	{'g','h','i','-'},
	{'j','k','l','-'},
	{'m','n','o','-'},
	{'p','q','r','s','-'},
	{'t','u','v','-'},
	{'w','x','y','z','-'},


};

int main()
{
	cin >> n;

	for(int i = 0;i < n;i++)
	{
		char str[80];
		int cmax = 0;

		string input;

		cin >> input;

		int a,b = -1,c = 0;

		for(int j = 0;j < input.length();j++)
		{
			a = input[j] - '0';
			

			if(a == 0)
			{
				if(b != -1 && b != 0){str[cmax++] = table[b][c];str[cmax] = '\0';}
				b = -1;c = 0;
			}

			if(b == a)
			{
				c++;
				if(table[b][c] == '-')c = 0;
			}

			b = a;

		}

		cout << str << endl;

	}

  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n];for(int i=0;i<n;i++)cin>>a[i];
  ll dp[n][2];
  dp[0][0]=a[0];
  dp[0][1]=-a[0];
  for(int i=1;i<n;i++){
    dp[i][0]=max(dp[i-1][0]+a[i],dp[i-1][1]-a[i]);
    dp[i][1]=max(dp[i-1][0]-a[i],dp[i-1][1]+a[i]);
  }
  cout<<dp[n-1][0]<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7,N=2e5+5;
int n,k,ans[N];
int main()
{
    scanf("%d",&n);
    for(int i=2;i<=n;i++)
    {
        int x;scanf("%d",&x);
        ans[x]++;
    }
    for(int i=1;i<=n;i++)
        printf("%d\n",ans[i]);
}


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

const int sup = 2*pow(10,8);

int main() {
	
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	for(int i=0; i<n; i++) cin >> a.at(i) >> b.at(i);
	
	int m = *max_element(a.begin(), a.end());
	vector<int> dp(h+1+m,sup);
	dp.at(0) = 0;
	for(int i=0; i<h+m; i++){
		for(int j=0; j<n; j++){
			if(i+a.at(j)>h+m) continue;
			dp.at(i+a.at(j)) = min(dp.at(i+a.at(j)), dp.at(i)+b.at(j));
		}
	}
	
	cout << *min_element(dp.begin()+h,dp.end()) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#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++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 200005

const int INF = 1e9+7;


struct SegmentTree{

    int N;
    vector<int> node;

    void init(int siz){
        N = 1;
        while(N < siz){
            N *= 2;
        }
        node.resize(2*N-1,INF);
    }

    void build(vector<int>& dat){
        for(int i = 0;i < dat.size();i++){
            node[i+N-1] = dat[i];
        }
        for(int i = N-2;i >= 0;i--){
            node[i] = node[2*i+1] + node[2*i+2];
        }
    }

    void update(int k,int x){
        k += N-1;
        node[k] = x;
        while(k > 0){
            k = (k-1)/2;//親
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    int getsum(int a,int b,int k,int l,int r){
        if(r <= a || b <= l){
            return 0;
        }
        if(a <= l && r <= b){
            return node[k];
        }
        int vl = getsum(a,b,k*2+1,l,(l+r)/2);
        int vr = getsum(a,b,k*2+2,(l+r)/2,r);
        return vl + vr;
    }

    int getsum(int a,int b){
        return getsum(a,b,0,0,N);
    }
};


int main(){

    string s;
    int k,n;
    cin >> s >> k;
    n = s.size();
    SegmentTree rsq;
    rsq.init(n);

    vector<int> v(n,1),alpha[26];
    rsq.build(v);

    for(int i = 0;i < n;i++){
        alpha[s[i]-'a'].push_back(i);
    }

    for(int i = 0;i < 26;i++){
        reverse(alpha[i].begin(),alpha[i].end());
    }

    string ans;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 26;j++){
            if(alpha[j].size() > 0 && rsq.getsum(0,alpha[j].back()) <= k){
                ans.push_back('a'+ j);
                k -= rsq.getsum(0,alpha[j].back());
                rsq.update(alpha[j].back(),0);
                alpha[j].pop_back();
                break;
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 7148
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;
vector<vector<int>> d;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  d.resize(h, vector<int>(w, -1));

  d[0][0] = 0;
  queue<P> q;
  q.push(P(0, 0));
  while (!q.empty()) {
    P p = q.front(); q.pop();
    rep(i, 4) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if(0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == -1 && s[nx][ny] == '.') {
        d[nx][ny] = d[p.first][p.second] + 1;
        q.push(P(nx, ny));
      }
    }
  }
  if(d[h - 1][w - 1] == -1) {
    cout << -1 << endl;
    return 0;
  }
  int cnt = 0;
  rep(i, h)rep(j, w) {
    if(s[i][j] == '.') cnt++;
  }
  int ans = cnt - d[h - 1][w - 1] - 1;
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

/// The definitions in this library are as below.
#define rI readInt
#define rL readLong
#define rC readChar
#define rC2 readChar2
#define rS readString

#define pb push_back

#define acc accumulate

#define FOR(i, a, b) for(int i=(a); i<=(b); i++)
#define FOR0(i, a, b) for(int i=(a); i<(b); i++)
namespace __library_79brue{
    /// This is a C++ library which improves the programming speed by \
        defining frequently used data structures or algorithms.       \
        This library can be freely used without any copyrights,       \
        but I recommend not to change the name of this library.       \
        Made by 79brue                                                \
        2019

    /// The functions or structures in this library are as below.
    /// quit()
    /// readInt() readLong() readChar() readChar2() readString()

    /// terminates the program
    inline void quit(){
        exit(0);
    }

    /// reads an integer
    inline void readInt(int& _x){
        scanf("%d", &_x);
    }

    /// reads a long-long integer
    inline void readLong(ll& _x){
        scanf("%lld", &_x);
    }

    /// reads a character
    inline void readChar(char& _x){
        scanf(" %c", &_x);
    }

    /// reads a character, the character may be space or line-break, etc...
    inline void readChar2(char &_x){
        scanf("%c", &_x);
    }

    inline void readString(char* _x){
        scanf("%s", _x);
    }

    inline int readLine(char* _x, int limit){
        if(!fgets(_x, limit, stdin)) quit();
        int _y = strlen(_x);
        while(_x[_y-1] == '\n' or _x[_y-1] == '\r') _y--;
        return _y;
    }
}
using namespace __library_79brue;

int n, m;
ll l;
ll dist[302][302];
int q;
int s, t;

int main(){
    scanf("%d %d %lld", &n, &m, &l);
    for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) if(i!=j) dist[i][j] = 1e13;
    for(int i=1; i<=m; i++){
        int x, y; ll z;
        scanf("%d %d %lld", &x, &y, &z);
        dist[x][y] = dist[y][x] = z;
    }
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
    for(int i=1; i<=n; i++) for(int j=1; j<=n; j++){
        if(dist[i][j] <= l) dist[i][j] = 1;
        else dist[i][j] = 1e13;
    }
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    scanf("%d", &q);
    for(int i=1; i<=q; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        printf("%lld\n", dist[x][y] > 500LL ? -1 : dist[x][y]-1);
    }
}


Measured memory_bytes: 1280
#include<iostream>
#include<math.h>
using namespace std;

int main()
{	

  long long A,B,N;  
  cin>> A >> B >> N;
  
  long long tmp =0;
  long long max_score = 0;
  
  long long maxC = floor(1.0*N/B);
//  cout << maxC << endl;

  
if(B-1<=N){  
  N = B-1;
}
  
  tmp = floor(1.0*A*N/B) - A * floor(N/B);
    if(tmp > max_score)
    {
     max_score = tmp; 
    } 
  
  
  cout << max_score;  
  
  return 0;
  
}


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

//ツつアツづ個偲ィツづ個姪「ツ妥ィツづ? ツ連ツ想ツ配ツ療アツづーツ使ツつ、ツづ?氾アツ湘ュツづ可嘉ーツつォツづ「ツつキツつ「ツづ?つキ
map<string,vector<int> > pages;

int main(){
  string s;
  int p;

  while(cin >> s >> p){
    pages[s].push_back(p);
  }

  map<string,vector<int> >::iterator iter;

  //ツマツッツプツづ個イツテツδ?ツタツづ? ツ篠ォツ渉堕篠ョツ渉?づ?要ツ素ツづーツ偲ヲツ督セツつオツづ?つュツづェツづゥツづ個づ?つサツづ個づ慊づ慊δ?ツプツつキツづェツづ篠つ「ツつ「
  for(iter = pages.begin(); iter != pages.end(); iter++){
    string name = iter->first;
    vector<int> v = iter->second;
    sort(v.begin(), v.end());

    cout << name << endl;

    for(int i = 0; i < v.size(); i++){
      if(i != 0) cout << " ";
      cout << v[i];
    }

    cout << endl;
  }
}

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

int main(){

    int a,b,c,d,e,f;

    cin >> a >> b >> c >> d >>e >>f;

    int rmt = f*e/100;
    a*=100;
    b*=100;

    int cm=rmt/c;
    int dm=rmt/d;
    int su[cm+1][dm+1];

    for(int i=0;i<=cm;i++){
        for(int j=0;j<=dm;j++){
            su[i][j]=c*i+d*j;
        }
    }

    int am=f/a;
    int bm=f/b;
    int wa[am+1][bm+1];

    for(int i=0;i<=am;i++){
        for(int j=0;j<=bm;j++){
            wa[i][j]=a*i+b*j;
        }
    }

    int ans[4]={0,0,1,0};
    double ma=0.0;

    for(int i=0;i<=cm;i++){
        for(int j=0;j<=dm;j++){
            for(int k=0;k<=am;k++){
                for(int l=0;l<=bm;l++){
                    if(su[i][j]+wa[k][l]<=f&&su[i][j]+wa[k][l]>0){
                        if(su[i][j]<=wa[k][l]*e/100){
                            if(ma<su[i][j]*100.0/(su[i][j]+wa[k][l])){
                                ans[0]=i;
                                ans[1]=j;
                                ans[2]=k;
                                ans[3]=l;
                                ma=su[i][j]*100.0/(su[i][j]+wa[k][l]);
                            }
                        }
                    }
                }
            }
        }
    }

    cout << su[ans[0]][ans[1]]+wa[ans[2]][ans[3]] << " " << su[ans[0]][ans[1]] << endl;

    return 0;
}

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


n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
l = [[] for i in range(29)]
for i in range(29):
    mod = 2**(i+1)
    for j in b:
        l[i].append(j%mod)
    l[i].sort()

ans = 0
for i in range(29):
    al = []
    count = 0
    mod = 2**i
    for j in a:
        al.append(j%(2*mod))
    al.sort(reverse = True)
    r1 = r2 = r3 = 0
    for j in al:
        while r1 < n and l[i][r1]+j < mod:
            r1 += 1
        while r2 < n and l[i][r2]+j < 2*mod:
            r2 += 1
        while r3 < n and l[i][r3]+j < 3*mod:
            r3 += 1
        count += n-r3+r2-r1
    ans += (count%2) << i
print(ans)



Measured memory_bytes: 211112
#include <stdio.h>

int main(void)
{
	int m, f, r, t;

	for (;;) {
		scanf("%d %d %d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1) break;
		if (m == -1 || f == -1) {
			puts("F");
			continue;
		}
		t = m + f;
		if (t >= 80) {
			puts("A");
			continue;
		}
		if (t >= 65 && t < 80) {
			puts("B");
			continue;
		}
		if (t >= 50 && t < 65) {
			puts("C");
			continue;
		}
		if (t >= 30 && t < 50) {
			if (r >= 50) puts("C");
			else puts("D");
			continue;
		}
		if (t < 30) {
			puts("F");
			continue;
		}
	}
	return 0;
}



Measured memory_bytes: 2044
#include<stdio.h>
#include<stdbool.h>

int main(void){
        char s[10];
        int l = 0, i, cnt = 0;
        bool ok = true;
        while((s[l]=getchar())!='\n') l++;
        for(i=0; i<l; i++){
                if('a'<=s[i] && s[i]<='z') cnt++;
                else if(s[i]=='C') ok &= (1<i && i<l-1);
                else if(s[i]=='A') ok &= (i==0);
                else ok = false;
        }
        if(ok && cnt==l-2) puts("AC");
        else puts("WA");
        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

class removeingarray
{
    vector<int> *_s;
    vector<pair<int, int>> _list;
    public:
        removeingarray(vector<int> &s)
        {
            _s = &s;
            int index = 0;
            _list.resize(s.size());
            while( index < s.size() )
            {
                int c = s[index];
                int i = 1;
                while(c == s[index + i]) 
                {
                    _list[index + i].first = index;
                    _list[index + i].second = -1;
                    i++;
                }
                _list[index].first = index + i;
                if( _list[index].first >= s.size() ) _list[index].first = -1;
                _list[index].second = i;
                index += i;
            }
        }

        int removenext(int index)
        {
            if( _list[index].second < 0 ) index = _list[index].first;
            auto ret = getnextsub(_list[index].first);
            _list[index].first = ret.second;
            return ret.first;
        }

        int removeat(int index)
        {
            auto ret = getnextsub(index);
            return ret.first;
        }

        pair<int, int> getnextsub(int index)
        {
            if( index >= _s->size() || index < 0 ) return make_pair(-1, -1);
            if( _list[index].second == 0 )
            {
                auto ret = getnextsub(_list[index].first);
                _list[index].first = ret.second;
                return ret;
            }
            else
            {
                _list[index].second--;
                if( _list[index].second == 0 ) return make_pair( index, _list[index].first );
                return make_pair(index, index);
            }
        }
};

bool getans()
{
    int n; cin >> n;
    int n2 = (1 << n);
    vector<int> s(n2);
    rep(i, n2) cin >> s[i];
    sort(s.begin(), s.end(), greater<int>());
    removeingarray ra(s);
    vector<int> slime;
    slime.push_back(ra.removeat(0));
    rep(i, n)
    {
        int num = slime.size();
        rep(j, num)
        {
            int ret = ra.removenext(slime[j]);
            if( ret < 0 ) return false;
            slime.push_back(ret);
        }
    }
    return true;
}

int main()
{
    if(getans())
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;    
}

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

int main()
{
  ll N,K;cin>>N>>K;
  vector<int> A(N);
  for (int i=0;i<N;i++)
  {
    cin>>A[i];
    A[i]--;
  }
  
  int now=0;
  vector<int> first(N,0);
  first[0]++;
  for (ll i=0;i<K;i++)
  {
    now=A[now];
    first[now]++;
    if (first[now]==3)
    {
       break;
    }
  }
  
  ll s=0;
  ll t=0;
  for (int i=0;i<N;i++)
  {
     if (first[i]==1)
       s++;
     else if (first[i]>=2)
       t++;
  } 
  //cout<<s<<" "<<t<<endl;
  
  if (K<=s)
  {
    now=0;
    for (ll i=0;i<K;i++)
     now=A[now];
    cout<<now+1<<endl;
    //cout<<"---"<<endl;
    return 0;
  }
  
  if (K<=N)
  {
    now=0;
    for (ll i=0;i<K;i++)
     now=A[now];
    cout<<now+1<<endl;
    //cout<<"===="<<endl;
    return 0;
  }
  
  ll p = (K-s) % t;
  
  now=0;
  for (int i=0;i<s;i++)
    now=A[now];
  
  for (int i=0;i<p;i++)
  {
    now=A[now];
  }
  cout<<now+1<<endl;
}

Measured memory_bytes: 4692
#include<bits/stdc++.h>
using namespace std;
const int MAX_N=1e6;
int seg_tree[2*MAX_N+5],n;
void build()
{
for(int i=n-1; i>0; --i)
seg_tree[i]=__gcd(seg_tree[i<<1],seg_tree[i<<1|1]);
}
void modify(int pos,int val)
{
for(seg_tree[pos+=n]=val; pos>1; pos>>=1)
seg_tree[pos>>1]=__gcd(seg_tree[pos],seg_tree[pos^1]);
}
int query(int l,int r)
{
int ans(1);
for(l+=n,r+=n; l<r; l>>=1,r>>=1)
{
if(l&1)
ans=__gcd(ans,seg_tree[l++]);
if(r&1)
ans=__gcd(ans,seg_tree[--r]);
}
return ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
int sum(0);
long long int arr[n];
for(int i=0; i<n; ++i)
{
cin>>arr[i];
sum+=arr[i];
}
int sum1(0),as(10000);
for(int i=0; i<n; ++i)
{
sum1+=arr[i];
as=min(as,abs(sum1-(sum-sum1)));
}
cout<<as;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NX = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, X) = (NX[0], NX[1]);
        var L = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var d = 0;
        var ans = 0;

        for (int i = 0; i < N; i++)
        {
            if (d <= X)
                ans++;

            d += L[i];
        }

        if (d <= X)
            ans++;

        WriteLine(ans);
    }
}


Measured memory_bytes: 28244
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const double PI=3.14159265358979323846;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double R;
    cin >> R;
    cout << fixed << setprecision(10) << 2 * PI * R << endl;
    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}
	
int main(){
	int n,a,b,c,x,y;
	string s;
	cin >> x >> y;
	int ans=0;
	if(x==3)ans=100000;
	if(x==2)ans=200000;
	if(x==1)ans=300000;
	
	if(y==3)ans+=100000;
	if(y==2)ans+=200000;
	if(y==1)ans+=300000;
	if(ans==600000){
		cout << 1000000 << endl;
	}else{
		cout << ans << endl;
	}
}

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

main()
{
  int f;
  int s=0,n=0;
  int w=0,e=0;
  string str;
  cin >> str;
  for(int i=0;i<str.size();i++){
    if(str[i]=='N')
      n++;
    if(str[i]=='S')
      s++;
    if(str[i]=='W')
      w++;
    if(str[i]=='E')
      e++;
  }

  if((n>0&&s==0)||(s>0&&n==0)||(w>0&&e==0)||(e>0&&w==0))
    cout << "No" << endl;
  else
    cout << "Yes" <<  endl;
  
  return (0);
}

Measured memory_bytes: 384
(n,m),*abs=$<.read.split.map(&:to_i).each_slice(2).to_a
ans=[0]
neis=[]
abs.each{|(a,b)|
  (neis[a-1]||=[]).push(b-1)
  (neis[b-1]||=[]).push(a-1)
}
q=[0]
c=1
until q.empty?
  qnext=[]
  q.each{|i|
    neis[i].each{|j|
      next if ans[j]
      ans[j]=i+1
      c+=1
      qnext.push(j)
    }
  }
  q=qnext
end
if c<n
  puts 'No'
else
  puts 'Yes',ans[1..-1]
end

Measured memory_bytes: 66900
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int a[maxn], k, n, m, sum, p;
double c, r;
string s, t;


int main(){
    ios_base::sync_with_stdio(0);
    cin>>n>>k;
    while(k--){
        cin>>m;
        while(m--){
            cin>>p;
            a[p]++;
        }
    }
    for(int i = 1; i <=n; i++){
        if(!a[i])sum++;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String result = sc.next();
        int n = result.length(), win=0;
        for(int i=0;i<n;i++){
            if(result.charAt(i) == 'o'){
                win++;
            }
        }
        if(8 - win <= 15 - n){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<class T>//ex) auto dp = make_vec(4,4,4,INF);
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, Ma, Mb;
	cin >> N >> Ma >> Mb;

	vector<Int> A(N);
	vector<Int> B(N);
	vector<Int> C(N);

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

	auto dp = make_vec(N + 1, 500, 500, INF);//[i+1][a][b]:i番目までの商品でAの重さがa、Bの重さがbとなる最小コスト
	dp[0][0][0] = 0;

	for (Int i = 0; i < N; i++) {//i番目の商品について考える
		for (Int a = 0; a < 450; a++) {
			for (Int b = 0; b < 450; b++) {
				//i番目の商品を選ぶ場合
				if (a + A[i] < 460 && b + B[i] < 460) {
					dp[i + 1][a + A[i]][b + B[i]] = min(dp[i + 1][a + A[i]][b + B[i]], dp[i][a][b] + C[i]);
				}

				//i番目の商品を選ばない場合
				dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b]);
			}
		}
	}

	Int ans = INF;
	for (Int i = 1; i < 800; i++) {
		if (Ma * i < 460 && Mb * i < 460) {
			ans = min(ans, dp[N][Ma * i][Mb * i]);
		}
	}

	if (ans==INF) {
		cout << -1 << "\n";
		return 0;
	}
	cout << ans << "\n";
}


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

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int k;
	string s;
	cin >> k >> s;
	if(s.length() <= k)
		cout << s;
	else{
		cout << s.substr(0,k) << "...";
	}


	
	

	return 0;
}

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

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

    ll n;
    cin >> n;
    vector<ll> x(n);
    for (ll i = 0;i < n;i++){
        cin >> x[i];
    }
    deque<ll> a;
    deque<ll> b;
    for (ll i = 0; i < n; i++){
        if (i%2 == 0){
            a.push_back(x[i]);
        }
        else{
            b.push_back(x[i]);
        }
    }

    if (n%2 == 0){
        reverse(b.begin(),b.end());
        for (ll i = 0; i < b.size(); i++){
            cout << b[i] << " ";
        }
        for (ll i = 0; i < a.size(); i++){
            cout << a[i] << " ";
        }
    }
    else{
        reverse(a.begin(),a.end());
        for (ll i = 0; i < a.size(); i++){
            cout << a[i] << " ";
        }
        for (ll i = 0; i < b.size(); i++){
            cout << b[i] << " ";
        }
    }

    cout << endl;

}

Measured memory_bytes: 6344
#include<stdio.h>

int main(){

  int i,j=0,l,n,status ,v=0;
  int A[100];

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

  for(i=0;i<n;i++){
    v=A[i];
    j=i-1;
    while (j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] =v;

    for(l=0;l<n-1;l++){
      printf("%d ",A[l]);
    }
    printf("%d",A[n-1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    ll a,b;cin>>a>>b;
    if(a==b){
        cout<<a<<endl;
        return 0;
    }
    if(b==a+1){
        cout<<(a^b)<<endl;
        return 0;
    }
    ll ans;
    //(2n)^(2n+1)=1
    if(a%2&&b%2){
        if((b-a)/2%2)ans=a^(ll)1;
        else ans=a^(ll)0;
    }
    else if(a%2==0&&b%2){
        if((b-a+1)/2%2)ans=1;
        else ans=0;
    }
    else if(a%2&&b%2==0){
        if((b-a-1)/2%2)ans=a^(ll)1;
        else ans=a^(ll)0;
        ans^=b;
    }
    else{
        if((b-a)/2%2)ans=b^(ll)1;
        else ans=b^(ll)0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,a,i,j;
    int arr[1000];
    scanf("%d",&n);
    for(i = 0; i < n ;i++){
        scanf("%d",&a);
        arr[i] = a;
    }
    for(j = 0 ; j < n/2 ; j++) {
        int t = arr[j];
        arr[j] = arr[n - j - 1];
        arr[n - j - 1] = t;
    }
    for(int k = 1;k <= n; k++){
        printf("%d",arr[k-1]);
        if(k == n) {
            printf("\n");
        }else {
            printf(" ");
        }
    }
    return 0;
}


Measured memory_bytes: 2052
from operator import itemgetter

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))

A.sort(reverse=True)
BC.sort(key=itemgetter(1), reverse=True)

n = 0
ans = 0
while True:
    if not BC:
        ans += sum(A[: N - n])
        break
    tgt = BC[0][1]
    a = A[0]
    if a >= tgt:
        ans += A.pop(0)
        n += 1
        if n == N:
            break
    else:
        tgt_n = BC[0][0]
        if n + tgt_n < N:
            ans += tgt * tgt_n
            n += tgt_n
            _ = BC.pop(0)
        else:
            ans += tgt * (N - n)
            break

print(ans)

Measured memory_bytes: 23780