akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi; 
typedef vector<pi> vpi;

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rsz resize
#define bk back()
#define pb push_back
#define ins insert
#define del erase
#define inf INT_MAX

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7;
const ld PI = acos((ld)-1);
mt19937 rng; // or mt19937_64
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1 ;
	while(t--)
	{
		double d,s,t;
		cin >> d >> t >> s ;
		if((d/s)>t)
		{
			cout << "No" ;
		}
		else
	    {
			cout << "Yes" ;
		}
	}	
}


Measured memory_bytes: 3728
a,b,c = map(int, input().split())
if a <= b <= c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
else:
    print(c, b, a)


Measured memory_bytes: 5596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
char str[1010];
stack<char>s;
int main()
{
    scanf("%s",str);
    int len=strlen(str);
    for(int i=0;i<len;i++)
    {
        if(str[i]!='B')
            s.push(str[i]);
        else if(!s.empty())
            s.pop();
    }
    string ss;
    while(!s.empty())
    {
        ss+=s.top();
        s.pop();
    }
    reverse(ss.begin(),ss.end());
    cout<<ss;
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split();
        var a = int.Parse(s[0]);
        var b = int.Parse(s[2]);

        if (s[1] == "+") Console.WriteLine(a + b);
        else Console.WriteLine(a - b);
    }
}


Measured memory_bytes: 11092
package main

import (
    "fmt"
)

func sumOfDegit(n int) int {
	var sum int
  for n > 0{
    sum += n %10
    n /=10
  }
  return sum
}

func main() {
  var(
    n,a,b,sum int
  )
  fmt.Scan(&n, &a, &b)
  for i := 0; i < n+1; i++{
    if v := sumOfDegit(i); a<= v && v <= b{
      sum += i
    }    
  }
  fmt.Println(sum)
}

Measured memory_bytes: 512
// @Problem https://atcoder.jp/contests/abc139/tasks/abc139_b
fn main() {
    let first_line_int :Vec<f32> = read_vec();
    let r = ((first_line_int[1] - 1.0) / (first_line_int[0] - 1.0)).ceil() as i32;
    println!("{}", r);

}

fn read_vec<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s)
        .expect("Failed to read line");
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 2704
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
using namespace std;
int main() {
	
	int N, M;
	int a, b;
	int cnt = 0;
	long long int ans = 0;
	cin >> N >> M;
	vector<pair<int, int>>p(N);
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		p.at(i) = make_pair(a, b);
	}
	
	sort(p.begin(), p.end());
	
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < p.at(i).second; j++) {
			if (cnt < M) {
				cnt++;
				ans += p.at(i).first;
			}
			else break;
		}
	}
		cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4016
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int x;
    cin >> x;
    cout << (1000 * (x / 500) + 5 * (x % 500 / 5));
}

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

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e9)

using namespace std;

signed main()
{
    int A, B, X;
    cin >> A >> B >> X;
    if (X < A)
    {
        cout << "NO" << endl;
        return 0;
    }
    if (X > A + B)
    {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main(){
    int A;
    bool flag = false;
    cin >> A;
    REP(i,1,  10){
        REP(j,1, 10){
            if (A == i * j) {
                flag = true;
                break;
            }
        }
        if (flag){
            break;
        }
    }

    if (flag){
        cout << "Yes" << endl;
    } else {
        cout <<"No" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
//#include "sample.h"

using namespace std; //標準名前空間
 
int Com(int a, int b,int c);

int main() {
    int a, b, c, add;
    cin >> a >> b >> c;

    add = Com(a, b, c) + Com(b, c, a) + Com(c, a, b);
    if (add) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }
    return 0;
}

int Com(int a, int b, int c) {
    if (a == 7) {
        if (b == 5 && c == 5) {
            return 1;
        }
    }
    else {
        return 0;
    }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc121/tasks/abc121_d

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <regex>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define MOD (1000000007)
#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; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }
ull calc(ull n) {
    ull ans, ama = n % 4;
    if (ama == 0) {
        ans = n;
    } else if (ama == 1) {
        ans = 1;
    } else if (ama == 2) {
        ans = 1 ^ n;
    } else {
        ans = 0;
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ull a, b, ans;
    cin >> a >> b;

    // 0からNまでのXORを求める
    cout << (calc(a - 1) ^ calc(b)) << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
from collections import Counter
from itertools import accumulate, product

N, W = inpl()
A = []
for _ in range(N):
    A.append(inpl())
B = [[] for _ in range(4)]
w1 = A[0][0]

for w, v in A:
    B[w-w1].append(v)

B = [sorted(b, reverse=True) for b in B]
C = [[0] + list(accumulate(b)) for b in B]

res = 0

for a, b, c, d in product(range(len(C[0])),
                          range(len(C[1])),
                          range(len(C[2])),
                          range(len(C[3]))):
    if w1*a + (w1+1)*b + (w1+2)*c + (w1+3)*d <= W:
        res = max(res, C[0][a] + C[1][b] + C[2][c] + C[3][d])
print(res)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#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)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const int MAX = 30;

class node {
  public:
  int p, l, r;

  node(int p = -1, int l = -1, int r = -1): p(p), l(l), r(r) {}
};

node t[MAX];

void print(int id) {
  cout << " " << id;
}

void Preorder(int id) {
  if (id == -1) return;
  print(id);
  Preorder(t[id].l);
  Preorder(t[id].r);
}

void Inorder(int id) {
  if (id == -1) return;
  Inorder(t[id].l);
  print(id);
  Inorder(t[id].r);
}

void Postorder(int id) {
  if (id == -1) return;
  Postorder(t[id].l);
  Postorder(t[id].r);
  print(id);
}

int main() {
  int n, id, l, r, root = -1;
  cin >> n;
  rep(i, n) {
    cin >> id >> l >> r;
    t[id].l = l;
    t[id].r = r;
    if (l != -1) t[l].p = id;
    if (r != -1) t[r].p = id;
  }

  rep(i, n) {
    if (t[i].p == -1) {
      root = i;
      break;
    }
  }

  cout << "Preorder" << endl;
  Preorder(root);
  cout << endl;
  cout << "Inorder" << endl;
  Inorder(root);
  cout << endl;
  cout << "Postorder" << endl;
  Postorder(root);
  cout << endl;

  


  
  return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

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

int main() {
    int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    int k;
    cin >> k;
    cout << a[k - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
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,k;
  string s;
  cin >> n >> k;
  cin >> s;
  
if(s[k-1]=='A'){
  s[k-1]='a';
}else if(s[k-1]=='B'){
  s[k-1]='b';
}else{
  s[k-1]='c';
}




  cout << s << endl;

  
}

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

using namespace std;

bool pass_check(vector<bool> &passed) {
    for (int i = 0; i < passed.size(); i++) if (!passed[i]) return false;
    return true;
}

void dfs(vector<vector<int>> &graph, vector<bool> &passed, int vertex, int &cnt) {
    if (pass_check(passed)) {
        cnt++;
        return;
    }

    for (int x : graph[vertex]) {
        if (passed[x]) continue;
        passed[x] = true;
        dfs(graph, passed, x, cnt);
        passed[x] = false;
    }
}


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

    vector<vector<int>> graph(n);
    vector<bool> passed(n, false);
    
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int cnt = 0;
    passed[0] = true;
    dfs(graph, passed, 0, cnt);

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
num_query = int(input())

former = ""
latter = ""
is_rev = False

for _ in range(0, num_query):
    query = input()
    if query[0] == "1":
        is_rev = not is_rev
    else:
        pos = query[2]
        character = query[4]
        if pos == "1":
            if is_rev:
                latter += character
            else:
                former = character + former
        else:
            if is_rev:
                former = character + former
            else:
                latter += character

if is_rev:
    ans = latter[::-1] + s[::-1] + former[::-1]
else:
    ans = former + s + latter
print(ans)



Measured memory_bytes: 4436
#include <iostream>
#include <stack>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

string S;

int calc(int p, int q, int r) {
  stack<int> s;
  REP(i, 0, S.length()) {
    int n = -1;
    char c = S[i];
    if(c == '(') s.push('(');
    if(c == '*') s.push('*');
    if(c == '+') s.push('+');
    if(c == 'P') n = p;
    if(c == 'Q') n = q;
    if(c == 'R') n = r;
    if('0' <= c && c <= '2') n = c - '0';
    if(c == '-') s.push('-');
    if(c == ')') {
      int v1 = s.top(); s.pop();
      int op = s.top(); s.pop();
      int v2 = s.top(); s.pop();
      s.pop();
      if(op == '*') {
        if(v1 == 2 && v2 == 2) n = 2;
        else if(v1 == 0 || v2 == 0) n = 0;
        else n = 1;
      }
      if(op == '+') {
        if(v1 == 0 && v2 == 0) n = 0;
        else if(v1 == 2 || v2 == 2) n = 2;
        else n = 1;
      }
    }
    if(n != -1) {
      while(!s.empty() && s.top() == '-') {
        s.pop();
        n = 2 - n;
      }
      s.push(n);
    }
  }

  return s.top();
}

int main(void) {
  while(cin >> S, S != ".") {
    int ans = 0;
    REP(p, 0, 3) REP(q, 0, 3) REP(r, 0, 3) {
      if(calc(p, q, r) == 2) ans++;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3168
#include "bits/stdc++.h"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
using vint = std::vector<int>;
using vvint = std::vector<std::vector<int>>;
using namespace std;
ll mod = 1e9 + 7;

/*int <= 10^9*/


int main() {


	int N; cin >> N;
	string str = to_string(N);
	int digits = 0;
	rep(i, str.size()) {
		digits += (int)str[i] - '0';
	}

	if (N % digits == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	map<int,int> even,odd; //mapで各数列での要素の出現数を記録する
	for(int i = 0; i < n; i++){
		if(i%2==0) odd[v[i]]++;
		else even[v[i]]++;
	}

	int even_1=0,even_2=0,odd_1=0,odd_2=0;
	int e1=0,e2=0,o1=0,o2=0;
	int cnt = 0;
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			even_1 = itr->first;
		}
	}
	e1 = cnt;
	cnt = 0;
	for(auto itr = even.begin();  itr != even.end() ; ++itr){
		if(itr->second > cnt && itr->first != even_1){
			cnt = itr->second;
			even_2 = itr->first;
		}
	}
	e2 = cnt;

	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt){
			cnt = itr->second;
			odd_1 = itr->first;
		}
	}
	o1= cnt;
	cnt = 0;
	for(auto itr = odd.begin();  itr != odd.end() ; ++itr){
		if(itr->second > cnt && itr->first != odd_1){
			cnt = itr->second;
			odd_2 = itr->first;
		}
	}
	o2=cnt;

	if(even_1 == odd_1){
		cout << min(n-e1-o2, n-e2-o1) << endl;
	}else{
		cout << n-e1-o1 << endl;
	}

	return 0;
}

Measured memory_bytes: 5376
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

int m,n;
int k[101];
int data[101][101][2];
int s[101][101],cond[101][101],t[101][101];
int now[101];
int next[101];
bool used[101];

int main(void){
	scanf("%d %d",&m,&n);
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			data[i][j][0]=0;
			data[i][j][1]=101;
		}
	}
	for(int i=0;i<m;i++){
		scanf("%d",&k[i]);
		for(int j=0;j<k[i];j++){
			char d;
			scanf("%d %c%*c %d",&s[i][j],&d,&t[i][j]);
			if(d=='<')cond[i][j]=0;
			else cond[i][j]=1;
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<k[i];j++){
			if(cond[i][j]==0)data[i][s[i][j]][1]=min(t[i][j],data[i][s[i][j]][1]);
			if(cond[i][j]==1)data[i][s[i][j]][0]=max(t[i][j],data[i][s[i][j]][0]);
			if(data[i][s[i][j]][1]<data[i][s[i][j]][0]){
				printf("No\n");
				return 0;
			}
		}
	}
	memset(used,false,sizeof(used));
	for(int i=1;i<=n;i++)now[i]=100;
	int i;
	for(i=0;i<m;i++){
		int nec=-1;
		int j;
		for(j=0;j<m;j++){
			if(used[j])continue;
			for(int k=1;k<=n;k++){
				if(now[k]<data[j][k][0]){
					printf("No\n");
					return 0;
				}
				if(now[k]>data[j][k][1])next[k]=data[j][k][1];
				else next[k]=now[k];
			}
			bool flag=true;
			for(int k=0;k<m;k++){
				if(used[k])continue;
				for(int l=1;l<=n;l++){
					if(next[l]<data[k][l][0]){
						flag=false;
						break;
					}
				}
			}
			if(flag){
				nec=j;
				break;
			}
		}
		if(nec==-1)break;
		used[nec]=true;
		for(int j=1;j<=n;j++)now[j]=next[j];
	}
	printf("%s\n",i==m?"Yes":"No");
	return 0;
}

Measured memory_bytes: 1216
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    std::string S;
    std::cin >> S;

    std::sort(std::begin(S), std::end(S));

    if (S == "abc") {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] a = new int[n];
		StringTokenizer st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}
		int q = Integer.parseInt(reader.readLine());
		st = new StringTokenizer(reader.readLine());
		for (int i = 0; i < q; i++) {
			if (subsetSum(Integer.parseInt(st.nextToken()), a)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		reader.close();
	}

	private boolean subsetSum(int s, int[] a) {
		int n = a.length;
		int[][] dp = new int[n+1][s+1];
		for (int i = 0; i < n; i++) {
			int v = a[i];
			for (int j = 0; j <= s; j++) {
				if (v == j) {
					dp[i+1][j] = dp[i][j] + 1;
				} else if (v > j) {
					dp[i+1][j] = dp[i][j];
				} else {
					if (dp[i][j-v] > 0) {
						dp[i+1][j] = dp[i][j] + 1;
					} else {
						dp[i+1][j] = dp[i][j];
					}
				}
			}
		}
		return dp[n][s] > 0;
	}
}



Measured memory_bytes: 41600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  string s;cin >> s;
  int count = 0;
  rep(i,N-2){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int maxn = 200005;
int f[maxn];

inline void work() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> f[i];
    }
    sort(f, f + n);
    LL res = f[n - 1];
    int k = n - 2;
    n = n - 2;
    while (n >= 2) {
        res += f[k--] * 2;
        n -= 2;
    }
    if (n == 1) {
        res += f[k];
    }
    cout << res << endl;
}

int main() {
    // freopen(".txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
V<ll>fac,rfac;void setFac(int n, int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 2e3+1;
int n, m, s[N], t[N];
ll DP[N][N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n) cin >> s[i];
  FOR(i, 0, m) cin >> t[i];
  DP[0][0] = 1;
  FOR(i, 0, n+1) DP[i][0] = 1;
  FOR(i, 0, m+1) DP[0][i] = 1;
  FOR(i, 1, n+1)FOR(j, 1, m+1) DP[i][j] = (DP[i-1][j]+DP[i][j-1]-DP[i-1][j-1]*(s[i-1]!=t[j-1])) % MOD;
  cout << (DP[n][m]+MOD)%MOD << endl;
}

Measured memory_bytes: 31616
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

ll aa[205][205];
long  arr[10];

int main(int argc, char* argv[])
{
    long n,t;
    scanf("%ld%ld", &n, &t);
    printf("%ld\n", MAX(0,n-t));
  
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

namespace DPL_1_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            int[] vals;

            //入力
            line = Console.ReadLine().Trim();
            vals = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(e => int.Parse(e)).ToArray();
            var N = vals[0]; // Count
            var W = vals[1]; // Count

            var products = new Product[N];
            for (int i = 0; i < N; i++)
            {
                line = Console.ReadLine().Trim();
                vals = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(e => int.Parse(e)).ToArray();
                products[i] = new Product() { Value = vals[0], Weight = vals[1] };
            }

            int[,] dp = new int[N+1,W+1];
            for (int i = 0; i < N; ++i)
            {
                for (int w = 0; w <= W; ++w)
                {
                    if (w >= products[i].Weight) dp[i + 1,w] = Math.Max(dp[i, w - products[i].Weight] + products[i].Value, dp[i,w]);
                    else dp[i + 1,w] = dp[i,w];
                }
            }
            Console.WriteLine(dp[N, W]);
        }
    }

    class Product
    {
        public int Weight { get; set; }
        public int Value { get; set; }
    }
}



Measured memory_bytes: 21812
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val x = sc.nextLong()

    val d = x / 11
    val m = x % 11

    val tmp = if (m > 6) 2 else if (m != 0) 1 else 0

    println(d * 2 + tmp)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}


Measured memory_bytes: 27332
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 c = sc.nextInt();

        if (a < b) {
            if(b<c){
                System.out.printf("%d %d %d\n",a,b,c);
            }
                else if(a<c){
                    System.out.printf("%d %d %d\n",a,c,b);
                }
                else{
                    System.out.printf("%d %d %d\n",c,a,b);
                }
        }else if(a>b){
            if(c>a){
                System.out.printf("%d %d %d\n",b,a,c);
            }
                else if(b<c){
                    System.out.printf("%d %d %d\n",b,c,a);
            }
                else{
                    System.out.printf("%d %d %d\n",c,b,a);
                }
        }
        sc.close();
    }
}


Measured memory_bytes: 26244
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[100010];
int main(){
	int l;
	
	cin>>s;
	
	l=strlen(s); 
	if (s[0]==s[l-1]){
		if (l%2==0) cout<<"First";
		else cout<<"Second";
	}
	else {
		if (l%2==0) cout<<"Second";
		else cout<<"First";
	}
	
	cout<<endl;
	
	
	return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
MAX = 10**18

ans = 1
for i in range(N):
    ans = ans*A[i]
    if ans > MAX:
        for j in range(i,N):
            if A[j]==0:
                ans = 0
                break
        if ans != 0:
            ans = -1
        break

print(ans)

Measured memory_bytes: 21644
#include <iostream>
typedef long long ll;
using namespace std;
int main(){
    string s;
    ll k;
    cin>>s>>k;

    int not_one = -1;
    for(int i=0;i<s.size();i++){
        if(s[i]!='1'){
            not_one = i;
            break;
        }
    }

    //not_oneは1でない数字が現れる最初の地点
    //これが-1であるということは1が存在しないことを意味する
    //条件①not_oneが-1かどうか
    //-1である→最初の1文字
    //-1でない→k次第でs[not_one]または1

    char ans;
    if(not_one == -1){
        ans = s[0];
    }else{
        if(k-1 < not_one){
            ans = '1';
        }else{
            ans = s[not_one];
        }
    }

    cout << ans << endl;
}


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

void solve()
{
	int p, q, r;
	cin >> p >> q >> r;
	
	auto ans = p + q + r - max(p, max(q, r));
	cout << ans << endl;
	
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
}

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

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

    int A[M], B[M];
    rep(i, M) cin>>A[i]>>B[i];

    vector<int> tree[N];

    rep(i, M){
        tree[A[i]-1].push_back(B[i]-1);
        tree[B[i]-1].push_back(A[i]-1);
    }

    queue<int> q;
    int is_search[N]={0};
    int sum[N]={0};
    rep(i, N){
        rep(j, tree[i].size()){
            if(is_search[tree[i][j]]==0){
                q.push(tree[i][j]);
                is_search[tree[i][j]]=1;
                sum[i]++;
            }
        }
        while(q.size()!=0){
            int num=q.front();
            q.pop();
            rep(k, tree[num].size()){
                if(is_search[tree[num][k]]==0){
                    q.push(tree[num][k]);
                    is_search[tree[num][k]]=1;
                    sum[i]++;
                }
            }
        }
    }

    int ans=0;
    if(ans==0) ans=1;
    rep(i, N) ans=fmax(ans, sum[i]);
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int A ;
  string op;
  cin >> A;
  
  if ( A % 1110 <= 9 || A % 1000 % 111 <= 9 ){
    cout << "Yes" <<endl;
  }
  
  else { cout << "No" <<endl;}
}

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

int main() {
  int n, a;
  cin >> n >> a;
  
  if (n % 500 <= a) {
    cout << "Yes" << endl;
  }
  // ここにプログラムを追記
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N, K = MI()
    a = N % K
    b = K - a
    print(min(a, b))
if __name__ == "__main__":
    main()

Measured memory_bytes: 74596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
vector<vector<ll>> kn(10, vector<ll>());

void dfs(int keta) {
    for (auto e : kn[keta - 1]) {
        if (e % 10 == 0) {
            kn[keta].push_back(e * 10 + 0);
            kn[keta].push_back(e * 10 + 1);
        } else if (e % 10 == 1) {
            kn[keta].push_back(e * 10 + 0);
            kn[keta].push_back(e * 10 + 1);
            kn[keta].push_back(e * 10 + 2);
        } else if (e % 10 == 2) {
            kn[keta].push_back(e * 10 + 1);
            kn[keta].push_back(e * 10 + 2);
            kn[keta].push_back(e * 10 + 3);
        } else if (e % 10 == 3) {
            kn[keta].push_back(e * 10 + 2);
            kn[keta].push_back(e * 10 + 3);
            kn[keta].push_back(e * 10 + 4);
        } else if (e % 10 == 4) {
            kn[keta].push_back(e * 10 + 3);
            kn[keta].push_back(e * 10 + 4);
            kn[keta].push_back(e * 10 + 5);
        } else if (e % 10 == 5) {
            kn[keta].push_back(e * 10 + 4);
            kn[keta].push_back(e * 10 + 5);
            kn[keta].push_back(e * 10 + 6);
        } else if (e % 10 == 6) {
            kn[keta].push_back(e * 10 + 5);
            kn[keta].push_back(e * 10 + 6);
            kn[keta].push_back(e * 10 + 7);
        } else if (e % 10 == 7) {
            kn[keta].push_back(e * 10 + 6);
            kn[keta].push_back(e * 10 + 7);
            kn[keta].push_back(e * 10 + 8);
        } else if (e % 10 == 8) {
            kn[keta].push_back(e * 10 + 7);
            kn[keta].push_back(e * 10 + 8);
            kn[keta].push_back(e * 10 + 9);
        } else if (e % 10 == 9) {
            kn[keta].push_back(e * 10 + 8);
            kn[keta].push_back(e * 10 + 9);
        }
    }
}

int main() {
    int K;
    cin >> K;
    kn[0] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
    for (int i = 1; i <= 9; i++) {
        dfs(i);
    }
    vector<int> cnt(10);
    rep(i,10) cnt[i] = kn[i].size();
    rep(i,10) {
        if(K > cnt[i]){
            K-=cnt[i];
        } else {
            cout << kn[i][K-1] << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1976
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
//#define int long long
int32_t main()
{
  int n,m,k; cin >> n >> m >> k;
  vector< string> gr(n);
  fr(i,n) cin >> gr[i];
  int ans = 0;
  for(int rmask = 0; rmask < (1<<n); rmask++){
  	for(int cmask = 0; cmask < (1<<m); cmask++){
  		vector<string> temp = gr;
  		int cnt = 0;
  		fr(i,n)fr(j,m){
  			if( ((rmask>>i)&1) or ((cmask>>j)&1)) {
  				temp[i][j] = '*';
  			}
  			cnt += temp[i][j] == '#';
  		}
  		// fr(i,n) cout << temp[i] << " \n" ;nl;
  		ans += cnt == k;
  	}
  }
  cout <<  ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n;
    cin >> n;
    
    int mx = 0;
    int ans = 1;
    for(int i = 1; i <= n; i++) {
        int cnt = 0;
        int t = i;
        while(t % 2 == 0) {
            t /= 2;
            cnt++;
        }
        if(cnt > mx) {
            mx = cnt;
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll n;
    cin>>n;
    vl a(n);
    forr(i, n)
    {
    	cin>>a[i];
    }
    vl pref(n);
    pref[n-1]=a[n-1]%MOD;
    for(ll i=n-2; i>=0; i--)
    {
    	pref[i]=pref[i+1]+a[i];
    	pref[i]%=MOD;
    }
    ll ans=0;
    for(ll i=0; i<n-1; i++)
    {
    	ans+=((a[i]*pref[i+1])%MOD);
    	ans%=MOD;
    }
    cout<<ans<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define VEC(TYPE, A, NAME, INIT) vector<TYPE> NAME(A, INIT)
#define VEC2(TYPE, A, B, NAME, INIT) vector<vector<TYPE>> NAME(A, vector<TYPE>(B, (INIT)))

int main()
{
    int n;
    cin >> n;
    struct Node{
        int idx = -1;
        ull cost = 1;
        ull costSum = 0;
    };
    map<ull, Node> mp;
    REP(i, n) 
    {
        ull a;
        cin >> a;
        mp[a].idx = i;
    }

    struct Edge{
        int i;
        int j;
    };
    VEC(Edge, 0, edgeAry, Edge());
    for( auto it = mp.rbegin(); it != mp.rend(); ++it )
    {
        const ull d = it->first;
        Node& node = it->second;

        if( d == mp.begin()->first ) break;
        ull sub = n - 2*node.cost;

        auto& nextNode = mp[d-sub];
        if( nextNode.idx == -1 )
        {
            cout << -1 << endl;
            return 0;
        }
        nextNode.cost += node.cost;
        nextNode.costSum += node.cost + node.costSum;

        Edge edge;
        edge.i = node.idx;
        edge.j = nextNode.idx;
        edgeAry.push_back( edge );
    }
    
    {
        const ull d = mp.begin()->first;
        Node& node = mp.begin()->second;
        
        if( node.costSum != d )
        {
            cout << -1 << endl;
            return 0;
        }
    }

    for( auto& e : edgeAry )
    {
        cout << e.i + 1 << " " << e.j + 1 << endl;
    }

    return 0;
}

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

#define REP(i,j,k) for( int i = j; i < k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;

typedef vector<int> VI;

int main(){
	
	int N,M,C;
	
	VI B(20);
	vector< VI > A( 20, VI(20) );
	
	cin >> N >> M >> C;
	
	rep(j,M) cin >> B[j];
	rep(i,N) rep(j,M) cin >> A[i][j];
	
	int cnt = 0;
	
	rep(i,N){
		
		int tmp = C;
		rep(j,M) tmp += A[i][j] * B[j];
		if(tmp>0) cnt++;
		
	}
	
	cout << cnt << endl;
	
	return 0;
	
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string N; cin >> N;
    string P; // 1の位から
    bool carry = false;
    ll res = 0;
    for (auto itr = N.rbegin(); itr != N.rend(); itr++) {
        if (*itr + (carry == true) - '5' < 0) {
            P.push_back(*itr + (carry == true));
            res += *itr + (carry == true) - '0';//釣りは発生しない　支払い分
            carry = false;
        }
        else if (*itr + (carry == true) - '5' == 0)
        {
            if (itr != N.rend() && *(itr+1) - '5' >= 0) {
                P.push_back('0');
                res += (10 - (*itr + (carry == true) - '0')) % 10; //支払いは発生しない 釣り分
                carry = true;    
            }
            else {
                P.push_back(*itr + (carry == true));
                res += *itr + (carry == true) - '0';//釣りは発生しない　支払い分
               carry = false;
            }
        }
        else {
            P.push_back('0');
            res += (10 - (*itr + (carry == true) - '0')) % 10; //支払いは発生しない 釣り分
            carry = true;
        }
    }
    if (carry) {
        P.push_back('1');
        res += 1;
    }
    reverse(P.begin(), P.end());
    // ll shiharai = 0;
    // for (auto x: P) {
    //     shiharai += x - '0';
    // }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3228
def main():
	K, S = map(int, input().split())
	cnt = 0

	for i in range(K + 1):
		for j in range(K + 1):
			k = S - i - j
			if 0 <= k and k <= K:
				cnt += 1

	print(cnt)

  
if __name__ == "__main__":
  	main()

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

arr = list(map(int, input().split()))
arr.sort()
arr.reverse()

a_point = 0
b_point = 0
for i in range(len(arr)):
    if i % 2 == 0:
        a_point += arr[i]
    else:
        b_point += arr[i]

print(a_point - b_point)

Measured memory_bytes: 3060
from sys import stdin
L = int(stdin.readline())

tmp = 1
i = 0
while tmp <= L:
    tmp *= 2
    i += 1
N = i

i = N-1
M = 0
path = []
for i in range(1, N):
    path.append([i, i+1, 0])
    path.append([i, i+1, 2**(i-1)])
    M += 2

while i != 0:
    if L-2**(i-1) >= 2**(N-1):
        path.append([i, N, L-2**(i-1)])
        L -= 2**(i-1)
        M += 1
        continue
    i -= 1

print('%d %d' % (N, M))
for elem in path:
    print(' '.join(map(str, elem)))


Measured memory_bytes: 3188
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  n = n%10;
  if(n==2||n==4||n==5||n==7||n==9)cout<<"hon"<<endl;
  else if(n==3)cout<<"bon"<<endl;
  else cout<<"pon"<<endl;
  return 0;
}

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

int main()
{
	const int INF = 1e9;
	int N, T;
	cin >> N >> T;
	int res = INF;
	for (int i = 0; i < N; i++) {
		int c, t;
		cin >> c >> t;
		if (t <= T) {
			res = min(res, c);
		}
	}
	if (res == INF) {
		cout << "TLE" << endl;
	}
	else {
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

ll lcm (ll x, ll y)
{
    return x*(y/__gcd(x,y));
}

main()
{
    fast;
    ll n,h,w,p,f=0;
    cin>>n;
    for (h=1;h<=3500;h++)
    {
        for (w=1;w<=3500;w++)
        {
            p=lcm(n,lcm(h,w));
            ll num=4*(p/n)-(p/h)-(p/w);
            if (num<=0)
                continue;
            else if (__gcd(num,p)==num)
            {
                f=1;
                cout<<h<<" "<<p/num<<" "<<w<<endl;
                break;
            }
        }
        if (f)
            break;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  ll n,x;
  cin >> n >> x;
  ll ans = 0;
  vll A(n);
  rep(i,n) cin >> A[i];
  rep1(i,n){
    if(A[i-1] + A[i] > x){
      ans += A[i-1] + A[i] - x;
      if(x- A[i-1] > 0){
        A[i] = x - A[i-1];
      }
      else{
        A[i] = 0;
      }
    }
    //rep(j,n) cout << A[j] << " ";
    //cout << endl;
    //cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
fun main() {
    val (a, b, c, x, y) = readLine()!!.split(" ").map { it.toInt() }

    var answer = a * x + b * y

    val r = if (x > y) 2 * x else 2 * y


    var i = 2
    while (i <= r) {
        val aCount = if ( x > i / 2)  x - i / 2 else 0
        val bCount = if ( y > i / 2)  y - i / 2 else 0
        val sum = a * aCount + b * bCount + c * i
        if (sum < answer) {
            answer = sum
        }
        i += 2
    }
    print(answer)
}


Measured memory_bytes: 36280
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    T = [ tuple( map( int, input().split())) for _ in range(N)]
    T = sorted(T,key=lambda x:x[1])
    time = 0
    ans = "Yes"
    for i in range(N):
        time += T[i][0]
        if time > T[i][1]:
            ans = "No"
            break
    print(ans)
if __name__ == '__main__':
    main()


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    string s;cin >> s;
    int k = s.size();
    int cnt = 0;
    inc(i, 0, k){
        if(s[i] == 'o') cnt++;
    }
    if(15-k+cnt >= 8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int area = a * b;
        int perimeter = 2 * (a + b);
        System.out.println(area + " " + perimeter);
    }
}


Measured memory_bytes: 26212