akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();
  let c = read::<i64>();
  let d = read::<i64>();

  println!("{}", min(a, b) + min(c, d));
}



Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */

long gcd(long m, long n);							/* 最大公約数 */
long lcm(long m, long n);							/* 最小公倍数 */

/* 最大公約数 */
long gcd(long m, long n) {
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

/* 最小公倍数 */
long lcm(long m, long n) {
	return m*n/gcd(m,n);
}
/* main *************************************************************/
int main()
{
	int		a,b;
	long    ans;

	
	scanf("%d",&a);
	scanf("%d",&b);
	
	ans = lcm( (long)a, (long)b);
	
	printf("%lld\n",ans);


	return 0;
}


Measured memory_bytes: 128
a = input()
a = list(a)
b = len(a)
c = int(b / 2)
d = []
for i in range(0,c):
    d.append(a[i])
e = a[::-1]
f = []
for g in range(0,c):
    f.append(e[g])
answer = 0
for h in range(0,c):
    if d[h] != f[h]:
        answer += 1
print(answer)


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


int main() {

	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if (r <= x&&x <= W - r&&r <= y &&y<= H - r) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> v(n);
    rep(i,n){
        int x;
        cin >> x;
        v[i]=make_pair(x,i);
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int id = v[0].second;
    int nex = v[1].first;
    rep(i,n){
        if(i!=id) cout<<v[0].first<<endl;
        else cout<<nex<<endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
using namespace std;
 
int main() {
	int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int p,q;
    p=a[0];
    q=a[1];
    int ans;
    while(1){
        if(q%p==0){
            ans=p;
            break;
        }else{
            int temp=q%p;
            q=p;
            p=temp;
        }
    }
    for(int i=2;i<n;i++){
        if(a[i]%ans!=0){
            p=a[i]%ans;
            q=ans;
            while(1){
                if(q%p==0){
                    ans=p;
                    break;
                }else{
                    int temp=q%p;
                    q=p;
                    p=temp;
            }
            }
        }
    }
    cout<<ans;
	return 0;
}


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

int main(){
    string s;
    cin >>s;
    int counter = 0;
    for(int i =0; i < 3; i++){
        if(s[i] == 'o'){
            counter ++;
        }
    }
    cout << 700 + 100*counter << endl;
    return 0;
}

Measured memory_bytes: 256
def t(a):
    b = [False] * len(a)
    c = 1
    for i, j in enumerate(a):
        if j == c:
            b[i] = True
            c += 1

    return b.count(False) if any(b) else -1


if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split()))
    print(t(a))


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

tree = [[] for _ in range(n+1)]

for _ in range(n-1):
    u, v, w = map(int, input().split())
    tree[u].append([v, w])
    tree[v].append([u, w])

color = [-1] * (n+1)
color[1] = 0
stack = [1]

while stack:
    node = stack.pop()
    for vertex, weight in tree[node]:
        if color[vertex] != -1:
            continue
        color[vertex] = (color[node] + weight) % 2
        stack.append(vertex)

print("\n".join(map(str, color[1:])))





Measured memory_bytes: 111416
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};
typedef struct node * Node;
Node root,t;
Node treeMinimum(Node x){
  while(x->l != NIL) x = x->l;
  return x;
}
  
Node treeMaximum(Node x){
  while(x->r != NIL) x = x->r;
  return x;
}
  
Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->l;
    else u = u->r;
  }
  return u;
}
  
Node treeSuccessor(Node x){
  Node y;
  if(x->r != NIL) return treeMinimum(x->r);
  y = x->p;
  while(y != NIL && x == y->r){
    x = y;
    x = y->p;
  }
  return y;
}
  
void treeDelete(Node z){
  Node x,y;
  if(z->l == NIL || z->r == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->l != NIL) x = y->l;
  else x = y->r;
  if(x != NIL) x->p = y->p;
  if(y->p == NIL) root = x;
  else if(y == y->p->l) y->p->l = x;
  else y->p->r = x;
  if(y != z) z->key = y->key;
  }
  
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->l;
    else  x = x->r;   
  }
  z->p = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->l = z;
  else y->r = z; 
}
  
void inorder(Node u){
  if(u == NIL) return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}
void preorder(Node u){ 
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}
int main(){
  int n,m,i;
  char str[7];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", str);
    if ( str[0] == 'f' ){
      scanf("%d", &m);
      t = treeSearch(root, m);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( str[0] == 'i' ){
      scanf("%d", &m);
      insert(m);
    } else if ( str[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( str[0] == 'd' ){
      scanf("%d", &m);
      treeDelete(treeSearch(root, m));
    }
  }
  return 0;
}

Measured memory_bytes: 19364
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int nPerson = sc.nextInt();
		int mKind = sc.nextInt();
		boolean[] isAllLike = new boolean[mKind];
		for (int i = 0; i < mKind; i++) {
			isAllLike[i] = true;
		}

		for (int i = 0; i < nPerson; i++) {
			int kLikeFood = sc.nextInt();
			boolean[] nPersonLike = new boolean[mKind];
			for (int j = 0; j < kLikeFood; j++) {
				nPersonLike[sc.nextInt() - 1] = true;
			}
			for (int j = 0; j < mKind; j++) {
				if (!nPersonLike[j]) {
					isAllLike[j] = false;
				}
			}
		}
		
		int res = 0;
		for(int i=0;i<isAllLike.length;i++) {
			if(isAllLike[i]) {
				res++;
			}
		}

		System.out.println(res);
	}
}


Measured memory_bytes: 23636
#include<stdio.h>
#include<string.h>
 
#define M 1000000
#define NIL -1
#define L 14
 
char H[M][L]; /* Hash Table */
 
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}
 
/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }
 
int find(char str[]){
  long long key,i,h;
 
  key=getKey(str);
 
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
 
  }
  return 0;
}
 
int insert(char str[]){
  long long key,i,h;
 
  key=getKey(str);
 
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
   
  return 0;
}
 
int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
     
    scanf("%d", &n);
     
    for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
     
    if ( com[0] == 'i' ){
        insert(str);
    } else {
        if (find(str)){
        printf("yes\n");
        } else {
        printf("no\n");
        }
    }
    }
 
    return 0;
}

Measured memory_bytes: 14280
import java.io.*;
import java.util.*;

public class Main {
    private static final int MAX = 100000;
    private static int[] A = new int[MAX];

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        for(int i=0; i<n; i++) A[i] = sc.nextInt();
        int q = partition(0, n-1);
        StringBuilder builder = new StringBuilder();
        for(int i=0; i<n; i++){
            if(i == 0) builder.append(A[i]);
            else if( i == q ) builder.append(" [").append(A[i]).append("]");
            else builder.append(" ").append(A[i]);
        }
        System.out.println(builder.toString());

    }

    static int partition(int p, int r){
        int x = A[r];
        int i = p - 1;
        int t;
        for(int j=p; j<r; j++){
            if (A[j] <= x) {
                i++;
                // swap
                t = A[i];
                A[i] = A[j];
                A[j] = t;
            }
            // 大きかったらjを1進めるだけで良い
        }
        // swap
        t = A[i+1];
        A[i+1] = A[r];
        A[r] = t;
        return i+1;
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 41124
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    string A;
    cin >> A;
    ll N = A.size();
    unordered_map<char, ll> cnt;
    rep(i,0,N) {
        cnt[A[i]]++;
    }
    ll ans = N*(N-1)/2;
    for (const auto& kv : cnt) {
        ll M = kv.second;
        ans -= M*(M-1)/2;
    }
    ans += 1;
    cout << ans << endl;
}



Measured memory_bytes: 832
n, k = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0])
start = 1
end = 0
for i in range(n):
    a, b = ab[i]
    end += b
    if start <= k <= end:
        print(a)
        exit()
    start += b


Measured memory_bytes: 61528
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();
		
		int temp;
		
		if(a > b){
			temp = a;
			a = b;
			b = temp;
		}
		
		if(b > c){
			temp = b;
			b = c;
			c = temp;	
		}
		
		if(a > b){
			temp = a;
			a = b;
			b = temp;
		}
		
		System.out.println(a +" "+b+" "+c);
	}
}

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

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

int main() {
        int r = 0, n, m, a, A[100000];
        cin >> n;
        for(int i = 0; i < n; i++) {
                cin >> A[i];
        }
        cin >> m;
        for(int i = 0; i < m; i++) {
                cin >> a;
                if(binarySearch(A, n, a)) r++;
        }
        cout << r << endl;
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int X;
    cin >> X;
    if (X <= 99) cout << 0 << endl;
    else if (X >= 106 && X <= 199) cout << 0 << endl;
    else if (X >= 211 && X <= 299) cout << 0 << endl;
    else if (X >= 316 && X <= 399) cout << 0 << endl;
    else if (X >= 421 && X <= 499) cout << 0 << endl;
    else if (X >= 526 && X <= 599) cout << 0 << endl;
    else if (X >= 631 && X <= 699) cout << 0 << endl;
    else if (X >= 736 && X <= 799) cout << 0 << endl;
    else if (X >= 841 && X <= 899) cout << 0 << endl;
    else if (X >= 946 && X <= 999) cout << 0 << endl;
    else if (X >= 1051 && X <= 1099) cout << 0 << endl;
    else if (X >= 1156 && X <= 1199) cout << 0 << endl;
    else if (X >= 1261 && X <= 1299) cout << 0 << endl;
    else if (X >= 1366 && X <= 1399) cout << 0 << endl;
    else if (X >= 1471 && X <= 1499) cout << 0 << endl;
    else if (X >= 1576 && X <= 1579) cout << 0 << endl;
    else if (X >= 1681 && X <= 1699) cout << 0 << endl;
    else if (X >= 1786 && X <= 1799) cout << 0 << endl;
    else if (X >= 1891 && X <= 1899) cout << 0 << endl;
    else if (X >= 1996 && X <= 1999) cout << 0 << endl;
    else cout << 1 << endl;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int a;
        cin >> a;
        --a;
        if ((a == n - 1 || x[a] + 1 < x[a + 1]) && x[a] != 2019) ++x[a];
    }
    for (int i = 0; i < n; ++i) {
        cout << x[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>

using namespace std;

int main(){

	int N;

	cin >> N;

	string val = to_string(N);

	if(val.find("9") != string::npos){
		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 sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		int ans = a[0];
		for(int i = 1; i < n; i++){
			ans = gcd(ans, a[i]);
		}
		System.out.println(ans);
	}
	static int gcd(int a, int b){
		int max = Math.max(a, b);
		int min = Math.min(a, b);
		int next = max % min;
		if(next == 0){
			return min;
		}
		else{
			return gcd(min, next);
		}
	}
}


Measured memory_bytes: 50340
// She is Pretty pretty!
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

const int N = 1e6 + 100;
vector<ll> G[N], G1[N];
ll dp[N], dp1[N], mod, pre[N], suf[N], n;
void dfs(int u, int fa) {
    dp[u] = 1;
    for (auto v : G[u]) {
        if (v != fa) {
            dfs(v, u);
            G1[u].pb(v);
            dp[u] = dp[u] * (dp[v] + 1) % mod;
        }
    }
}
void dfs1(int u) {
    int si = (int)G1[u].size();
    pre[0] = 1;
    suf[si + 1] = 1;
    for (int i = 0; i < si; i++) {
        int v = G1[u][i];
        pre[i + 1] = pre[i] * (dp[v] + 1) % mod;
    }
    for (int i = si - 1; i >= 0; --i) {
        int v = G1[u][i];
        suf[i + 1] = suf[i + 2] * (dp[v] + 1) % mod;
    }
    for (int i = 0; i < si; i++) {
        int v = G1[u][i];
        dp1[v] = pre[i] * suf[i + 2] % mod * (dp1[u] + 1) % mod;
    }
    for (int i = 0; i < si; i++) {
        dfs1(G1[u][i]);
    }
}
int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> n >> mod;
    for (int i = 1; i < n; i++) {
        int x, y;
        cin >> x >> y;
        G[x].pb(y), G[y].pb(x);
    }
    dfs(1, 1);
    dfs1(1);
    for (int i = 1; i <= n; i++) {
        cout << dp[i] * (dp1[i] + 1) % mod << endl;
    }
    return 0;
}

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

int main(){
  int x; cin >> x;
  int y = x;
  int f = 0;
  while(x > 0){
    f += x % 10;
    x /= 10;
  }
  if(y % f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        sc.close();

        // 主処理
        String[] arr = w.split("");
        List<String> list = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            if (list.contains(arr[i])) {
                int index = list.indexOf(arr[i]);
                list.remove(index);
            } else {
                list.add(arr[i]);
            }
        }

        boolean judge = list.size() == 0;
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000



int main(){
	
	int K;
	cin>>K;
	
	string S;
	cin>>S;
	
	if(S.size()<=K)cout<<S<<endl;
	else{
		S = S.substr(0,K);
		S += "...";
		cout<<S<<endl;
	}
	
	
	return 0;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
#define INF 100000000

int main(){
    int K,A,B;
    bool flag = false;
    cin >> K >> A >> B;
    rep(i,A,B+1) if(i%K==0){flag = true;break;}
    if(flag) cout <<"OK" << endl;     
    else cout << "NG"<<endl;
}


Measured memory_bytes: 3624
void main()
{
    long n, m;
    rdVals(n, m);

    Bridge[] b = m.rdCol!Bridge;
    foreach (i; 0 .. m)
    {
        b[i].from -= 1, b[i].to -= 1;
    }

    long cnt;
    foreach (i; 0 .. m)
    {
        auto tree = new UnionFind(n);
        foreach (j; 0 .. m)
        {
            if (j == i) continue;
            tree.unite(b[j].from, b[j].to);
        }
        if (!tree.same(b[i].from, b[i].to)) ++cnt;
    }

    cnt.writeln;
}

struct Bridge
{
    long from, to;
}

struct UnionFind
{
    long[] par;

    this(long n)
    {
        par = new long[n];
        foreach (i; 0 .. n)
        {
            par[i] = i;
        }
    }

    long root(long x)
    {
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

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

    void unite(long x, long y)
    {
        x = root(x), y = root(y);
        if (x == y) return;
        par[x] = y;
    }
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

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

int main(){
  int s;
  cin >> s;
  
  int f = s/100;
  int l = s%100;
  
  bool flagf = true;
  bool flagl = true;
  
  if(f==0 || f>12){
  	flagf = false;
  }
  
  if(l==0 || l>12) {
  	flagl = false;
  }
  
  if(flagf && flagl){
  	cout << "AMBIGUOUS" << endl;
  }
  
  else if(flagf && !flagl) {
  	cout << "MMYY" << endl;
  }
  
  else if(!flagf && flagl){
  	cout << "YYMM" << endl;
  }
  
  else if(!flagf && !flagl){
  	cout << "NA" << endl;
  }
  
}


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

typedef complex<double> P;
typedef pair<P,P> L;

const double EPS = 1e-7;
const int MAX = 20000;

double dot(P a, P b){ return real(conj(a)*b);}
double cross(P a, P b){ return imag(conj(a)*b);}

int ccw(P a, P b, P c){
  b -= a;
  c -= a;
  if(cross(b,c) > EPS) return 1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

P crosspoint(L l, L m){
  double A = cross(l.second - l.first, m.second - m.first);
  double B = cross(l.second - l.first, l.second - m.first);
  if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
  else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

vector<P> convex_cut(vector<P> G, L l){
  vector<P> ans;
  for(int i=0;i<G.size();i++){
    P A = G[i];
    P B = G[(i+1)%G.size()];
    if(ccw(l.first, l.second, A) != -1) ans.push_back(A);
    if(ccw(l.first, l.second, A) * ccw(l.first, l.second, B) < 0) ans.push_back(crosspoint(L(A,B), l));
  }
  return ans;
}


int n;
vector<P> v;

void solve(){
  vector<P> v2;
  v2.push_back(P(MAX,MAX));
  v2.push_back(P(-MAX,MAX));
  v2.push_back(P(-MAX,-MAX));
  v2.push_back(P(MAX,-MAX));

  for(int i=0;i<n;i++){
    v2 = convex_cut(v2, L(v[i],v[(i+1)%n]));
    if(v2.size() < 3){
      cout << 0 << endl;
      return;
    }
  }

  cout << 1 << endl;
}

int main(){
  while(cin >> n && n){
    v.clear();
    for(int i=0;i<n;i++){
      int x,y;
      cin >> x >> y;
      v.push_back(P(x,y));
    }
    solve();
  }
}

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

int main(void) {
    int N,X;cin>>N>>X;
    int bounding = 1;
    int now = 0;
    for (int i = 1; i <= N; i++) {
        int L;cin>>L;
        now += L;
        if (now <= X) bounding++;
        else break;
    }
    cout << bounding << endl;
    return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int a[n];
  float sum=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum+=a[i];
  }
  int count=0;
  for(int i=0;i<n;i++)
  {
    if(a[i]>=(sum/(4*m)))
    {
      count++;
    }
    if(count==m)
    {
      break;
    }
  }
  if(count==m)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
  	cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())

A = [list(map(int, input().split())) for i in range(n)]

min =10**10

for i in range(2**n):
    ii=i
    rikai=[0]*m
    kane=0
    for j in reversed(range(n)):#j冊目はかう？

        if ii//(2**j)==1:
            ii-=(2**j)
            for k, a in enumerate(A[j]):
                if k==0:
                    kane+=a
                else:
                    rikai[k-1]+=a

    #判定
    hantei=True
    for i in rikai:
        if i<x:
            hantei=False

    if hantei==True:
        if min > kane:
            min=kane

if min==10**10:
    print(-1)
else:
    print(min)

Measured memory_bytes: 9236
using System;

namespace B
{
    class Program
    {
        static bool isTrue = true;

        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            judge(input);
            judge(input.Substring(0, (input.Length-1)/2));
            judge(input.Substring((input.Length+3)/2-1, (input.Length-1)/2));

            if(isTrue) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }

        static void judge(string s)
        {
                for(int i=0; i<s.Length/2; i++)
                {
                    if(s[i] != s[s.Length-1-i]) isTrue = false;
                }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;
struct Edge{
  ll to,id;
};
typedef vector<vector<ll>> Graph;
typedef vector<pii> vpii;


int main() {
  ll N; cin>>N;
  vi L(N*2); REP(i,N*2) cin>>L[i];
  sort(ALL(L));
  ll ans=0;
  for(ll i=0;i<N*2;i+=2) {
    ans+=L[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<int>> a(h,vector<int>(w));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>a.at(i).at(j);
  vector<vector<int>> s;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j<w-1&&a.at(i).at(j)%2==1){
        a.at(i).at(j)--;
        a.at(i).at(j+1)++;
        s.push_back({i+1,j+1,i+1,j+2});
      }else if(i<h-1&&a.at(i).at(j)%2==1){
        a.at(i).at(j)--;
        a.at(i+1).at(j)++;
        s.push_back({i+1,j+1,i+2,j+1});
      }
    }
  }
  cout<<s.size()<<endl;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<4;j++)
      cout<<s.at(i).at(j)<<(j<3?" ":"");
    cout<<endl;
  }
}

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

#define ll long long
#define pb push_back

const int maxn = (1 << 17) + 20;

int a[maxn] , b[maxn];

void solve(int n , int x)
{
	if(n == 1)
	{
		assert(x == 1);
		a[0] = 0 , a[1] = 1;
		return;
	}

	if(x & 1)
		solve(n - 1 , (x / 2) ^ 1);
	else
		solve(n - 1 , x >> 1);

	for(int i = 0; i < (1 << (n - 1)); i += 2)
	{
		b[i * 2] = a[i] * 2;
		b[i * 2 + 1] = a[i] * 2 + 1;
		b[i * 2 + 2] = a[i + 1] * 2 + 1;
		b[i * 2 + 3] = a[i + 1] * 2;
	}

	memcpy(a , b , sizeof b);

	if(x & 1)
	{
		for(int i = 0; i < (1 << n); i += 4)
		{
			assert(a[i] != x && a[i + 2] != x && a[i + 3] != x);
			if(a[i + 1] == x)
			{
				a[i + 1] = a[i + 3];
				for(int j = i + 3; j + 1 < (1 << n); j++)
					a[j] = a[j + 1]^1;
				a[(1 << n) - 1] = x;
				break;
			}
		}
	}
}

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

	int n , x , y;
	cin >> n >> x >> y;

	if(__builtin_popcount(x ^ y) % 2 == 0)
		return cout << "NO" << endl , 0;

	cout << "YES" << endl;
	solve(n , x ^ y);

	for(int i = 0; i < (1 << n); i++)
		cout << (a[i] ^ x) << " ";
	cout << endl;

	for(int i = 0; i + 1 < (1 << n); i++)
		assert(__builtin_popcount(a[i] ^ a[i + 1]) == 1);
}
















Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define w(x) int x; cin>>x; while(x--)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int dp[100001],a[100001];
int fun(int n)
{   //cout<<n<<endl;
    if(n==0)
    {
        return 0;
    }
    if(dp[n]!=-1)return dp[n];
    int x,y;
    if(n>=1)
    x=fun(n-1)+abs(a[n]-a[n-1]);
    else x=INT_MAX;
    if(n>=2)
    {
        y=fun(n-2)+abs(a[n]-a[n-2]);
    }else y=INT_MAX;
    return dp[n]=min(x,y);
}
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<fun(n-1)<<endl;
    return 0;
}


Measured memory_bytes: 9872
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	run()
}

func run() {
	setSpace()
	a, b := readN(), readN()
	s, l := 0, 0
	if a < b {
		s, l = a, b
	} else {
		s, l = b, a
	}
	for i := 0; i < l; i++ {
		fmt.Printf(strconv.Itoa(s))
	}
	fmt.Println("")
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main(){
    fast;
    int h,n;
   	cin>>h>>n;
   	int sum = 0;
   	for(int i=1;i<=n;i++){
   		int x;
   		cin>>x;
   		sum+=x;
   	}
   	if(sum>=h)
   		cout<<"Yes";
   	else cout<<"No";
}  

Measured memory_bytes: 256
use std::io::stdin;

fn read_line() -> Vec<i32> {
    let mut a_str = String::new();
    stdin().read_line(&mut a_str).expect("read error");
    a_str.split_whitespace()
        .map(|x| x.parse::<i32>().expect("parse error"))
        .collect::<Vec<i32>>()
}

fn main() {
    let v = read_line();
    let mut h = v[0];
    let a = v[1];
    let mut c = 0;
    while h > 0 {
        c += 1;
        h -= a;
    }

    println!("{}", c);
}

Measured memory_bytes: 4352
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
        	var intA = cin.ReadInt;
        	var intB = cin.ReadInt;
          	WriteLine(intA * intB % 2 == 0 ? "Even" : "Odd");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 27608
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt();
        int[][] red = new int[n][2];
        int[][] blue = new int[n][2];

        for (int i = 0; i < n; i++) {
            red[i][0] = sc.nextInt();
            red[i][1] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            blue[i][0] = sc.nextInt();
            blue[i][1] = sc.nextInt();
        }

        int count = 0;
        boolean[] r = new boolean[n];

        Arrays.sort(blue, Comparator.comparingInt(o1 -> o1[0])); // xが小さい順
        Arrays.sort(red, Comparator.comparingInt(o1 -> -o1[1])); // yが大きい順

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (!r[j] && blue[i][0] > red[j][0] && blue[i][1] > red[j][1]) {
                    count++;
                    r[j] = true;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 28884
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

long euclid(long c, long d)
{ // 最大公約数を求めるプログラム
  long mx = max(c, d);
  long mi = min(c, d);
  long tmp = 0;
  while (mi > 0)
  {
    tmp = mx % mi;
    if (tmp == 0)
    {
      return mi;
    }
    else
    {
      mx = mi;
      mi = tmp;
    }
  }
  return 1;
}

int main()
{
  ll N, x;
  cin >> N >> x;
  vector<ll> a(N);

  rep(i, N)
  {
    cin >> a[i];
  }

  ll ans = a[1] - a[0];
  sort(a.begin(), a.end());

  if (N == 1)
  {
    ans = abs(x - a[0]);
  }
  else
  {
    vector<ll> b;
    rep(i, N)
    {
      b.push_back(abs(x - a[i]));
    }

    // それぞれの最大公約数を求めていく
    ll tmp = euclid(b[0], b[1]);
    for(int i = 1; i < b.size(); i++)
    {
      tmp = euclid(tmp, b[i]);
    }
    ans = tmp;
  }

  cout << ans << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e5 + 7;

int n;
int m;
set<int> g[maxn];
int dp[maxn];
bool starter[maxn];
bool seen[maxn];


int solve(int u) {
    seen[u] = true;
    if (dp[u] > 0) return dp[u];

    for (int v: g[u]) {
        dp[u] = max(dp[u],solve(v)+1);
    }
    return dp[u];
}


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    cin >> n >> m;
    memset(starter, true, sizeof(starter));
    for (int i = 0; i < m; i++) {
        int u,v;
        cin >> u >> v;
        g[u].insert(v);
        starter[v] = false;
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!starter[i]) continue;
        if (seen[i]) continue;
        solve(i);
        ans = max(ans,dp[i]);
    }

    out(ans);

    
    return 0;
}


Measured memory_bytes: 14848
#!/usr/bin/env python3
import sys
import itertools

MOD = 1000000007  # type: int


def ok(s: str):
    ng = 'AGC'
    c = s.count(ng)
    for i in range(1, 4):
        s2 = s[:i-1] + s[i] + s[i-1] + s[i+1:]
        c += s2.count(ng)
    return c == 0
    

def solve(N: int):
    K = [''.join(t) for t in itertools.product('ACGT', repeat=3)]
    C = [{k: 0 for k in K} for i in range(N+2)] # C[-1 ~ N]
    C[0]['TTT'] = 1
    
    for i in range(1, N+1):
        for last3 in C[i-1].keys():
            for c in 'ACGT':
                if ok(last3 + c):
                    C[i][last3[1:] + c] = (C[i][last3[1:] + c] + C[i-1][last3]) % MOD
    print(sum([C[N][k] for k in K]) % MOD)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < 3; i++) a[i] = sc.nextInt();
        Arrays.sort(a);
        String ans = "NO";
        if (a[0] == 5 && a[1] == 5 && a[2] == 7) ans = "YES";
        System.out.println(ans);
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



int main(){
    int d,n;
    cin >> d >> n;
    if(n==100){
        cout<<101;
    }else{
        cout<<n;
    }
    
    for(int j=0; j<d; j++){
        cout<<"00";
    }
    cout<<endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = br.readLine().split(" ");
		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		long kobaisu = getKobaisu(a, b);
		System.out.println(kobaisu);
	}
	// 公約数の取得
	  private static long getKoyakusu(long a, long b) {
	    long candidate = a;
	    while (b % a != 0) {
	      candidate = b % a;
	      b = a;
	      a = candidate;
	    }
	    return candidate;
	  }

	  // 公倍数の取得
	  private static long getKobaisu(long a, long b) {
	    return (a * b) / getKoyakusu(a, b);
	  }
}


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

using namespace std;

template <typename T>
class WeightedUnionFind {
 private:
  std::vector<int> parent;
  std::vector<T> weight;

 public:
  WeightedUnionFind(int n) : parent(n, -1), weight(n, 0) {}

  int root(int x) {
    if (parent[x] < 0) return x;
    int rx = root(parent[x]);
    weight[x] += weight[parent[x]];
    return parent[x] = rx;
  }

  bool is_same(int x, int y) { return root(x) == root(y); }

  int size(int x) { return -parent[root(x)]; }

  T diff(int x, int y) {
    root(x), root(y);
    return weight[y] - weight[x];
  }

  bool unite(int x, int y, T w) {
    int rx = root(x), ry = root(y);
    w += weight[x] - weight[y];
    if (rx == ry) return false;
    if (parent[rx] > parent[ry]) std::swap(rx, ry), w *= -1;
    weight[ry] = w;
    parent[rx] += parent[ry];
    parent[ry] = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  WeightedUnionFind<int64_t> uf(N);
  for (int i = 0; i < M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (!uf.unite(l, r, d) && uf.diff(l, r) != d) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 4452
A,B,K=map(int,input().split())
if B-A < K :
  for i in range(A,B+1) :
    if i < A+K or B-K < i :
      print(i)
else :
  S=set()
  for i in range(K) :
    S.add(A+i)
    S.add(B-i)
  L=list(S)
  L.sort() 
  for i in L :
    print(i)


Measured memory_bytes: 3060
try:
    while True:
        a = sorted(map(int, raw_input().split(',')))
        if a.count(a[2]) == 4:
            print 'four card'
        elif a.count(a[1]) + a.count(a[-2]) == 5:
            print 'full house'
        elif a == range(a[0], a[0] + 5) or a == [1, 10, 11, 12, 13]:
            print 'straight'
        elif a.count(a[2]) == 3:
            print 'three card'
        elif a.count(a[1]) == 2 and a.count(a[-2]) == 2:
            print 'two pair'
        elif len(set(a)) == 4:
            print 'one pair'
        else:
            print 'null'
except EOFError:
    pass

Measured memory_bytes: 4228
N = int(input())
a = list(map(int, input().split()))
h = {}
for i in range(N):
    h[a[i]] = h.get(a[i], 0)
    h[a[i]] += 1

ans = 0
keys = list(h.keys())
for i in range(len(keys)):
    k = keys[i]
    if k < h[k]:
        ans += h[k] - k
    elif k > h[k]:
        ans += h[k]
print(ans)

Measured memory_bytes: 18168
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int n, mx;
vector<int> dp(100001, 1000000001);

int main()
{
    cin >> n >> mx;
    dp[0] = 0;
    int ans = 0;
    REP(k, n) {
        int wi;
        int vi;
        cin >> wi >> vi;
        // DD(wi, vi);
        // DA(dp, 10);
        for (int i = dp.size() - 1; i >= 0; --i) {
            if(dp[i] + wi <= mx) {
                dp[i + vi] = min(dp[i + vi], dp[i] + wi);
                ans = max(ans, i + vi);
                // D(i);
            }
        }
    }
    cout << ans << endl;
}


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

int main()
{
	int n, k, p;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> k >> p;
		if (k % p != 0){
			cout << k % p << endl;
		}
		else cout << p << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include<limits.h>  

int main(void) {    

int i, n, a;    

int min=INT_MAX, max=INT_MIN;    

long long sum=0;    

scanf("%d", &n);    

for(i=0; i<n; i++) {        

scanf("%d", &a);        

if(a<min) min=a;        

if(max<a) max=a;        

sum+=a;    

}    

printf("%d %d %lld\n", min, max, sum);    

return 0;

}  

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
#include<stdio.h>

using namespace std;

double a, b, c, d, e, f;
double x, y;

int main(){
	while (cin >> a >> b >> c >> d >> e >> f){
		double det = a * e - b * d;
		x = (c * e - b * f) / det;
		y = (a * f - c * d) / det;
		if (x == -0) x = 0; if (y == -0) y = 0;
		printf("%.3f %.3f\n", x, y);
	}
}

Measured memory_bytes: 1236
/*ITP1_3_D:How Many Divisors?*/
#include <iostream>
using namespace std;

int main() {

    int a,b,c,count=0;
    cin >> a >> b >> c;

    for (int i=a;i<= b;i++) {
        if ( c % i == 0 ) count++; 
    }   

    cout << count << endl;
    return 0;
}



Measured memory_bytes: 3092
#include<cstdio>
int main()
{
	int n,sum=0;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			if(a[i]%3!=0&&a[i]%5!=0)
			sum++;
		}
	}
	if(sum==0)
	printf("APPROVED\n");
	else
	printf("DENIED\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a + b > c + d)cout << "Left" << endl;
    else if(a + b < c + d)cout << "Right" << endl;
    else cout << "Balanced" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
		int n,k; cin>>n>>k;
		int a[n];
		for(int i=0;i<n;i++)
		{
			cin>>a[i];
		}
		sort(a,a+n);
		int sm=0;
		for(int i=0;i<k;i++)
		{
			sm+=a[i];
		}
		cout<<sm;

}

Measured memory_bytes: 3608
N, L = map(int, input().split())
all_flavor = (L - 1) * N + N * (N + 1) // 2

smallest_abs = 100000000000
elem = 0
for i in range(1, N + 1):
    if abs(L - 1 + i) < smallest_abs:
        smallest_abs = abs(L - 1 + i)
        elem = L - 1 + i

print(all_flavor - elem)

Measured memory_bytes: 3060
# bitDPやりたくなるけどあきらかにオーバーキル
# ふつうにDFSする
n = int(input())


def dfs(cur):
    ret = 0
    for m in ["3", "5", "7"]:
        nex = cur
        nex += m
        if int(nex) <= n:
            if "7" in nex and "5" in nex and "3" in nex:
                ret += 1
            ret += dfs(nex)
    return ret


print(dfs(""))


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

t = [0]
x = [0]
y = [0]
for i in range(n):
    tmp = input().split()
    tmp = list(map(int,tmp))
    t.append(tmp[0])
    x.append(tmp[1])
    y.append(tmp[2])

flag = True
for i in range(1,n+1):
    dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
    if t[i] - t[i-1] < dist or (t[i] - t[i-1])%2 != dist%2:
        flag = False

if flag == True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 12076
object Main {
  def main(args: Array[String]): Unit = {
    import collection._
    val n = io.StdIn.readLine().toInt
    val arr = for(i <- 0 until n) yield io.StdIn.readLine().toInt
    val ss = arr.sorted
    val sum = ss.foldLeft(0){_ + _}
    val ans = if (sum % 10 != 0){
      sum
    } else {
      ss.find(_ % 10 != 0) match {
        case None => 0
        case Some(x) => sum - x
      }
    }

    println(ans)
  }
}

Measured memory_bytes: 27180
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[100010];
int gcd(int x, int y) {
	if (x < y) gcd(y, x);
	if (y == 0) return x;
	return gcd(y, x % y);
}
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	int ans = A[0];
	for (int i = 1; i < N; i++) ans = gcd(ans, A[i]);
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < n; ++i)

int main() {
	int n;
	scanf("%d", &n);
	int l = 1;
	ll an = 0;
	f(i, 0, n) {
		int t;
		scanf("%d", &t);
		an += (t - 1) / l;
		if (l == t)++l;
		if (l == 1)++l;
	}
	printf("%lld\n", an);
}

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

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	string a,b;
	cin>>a>>b;
	for(int i = 0; i < n; i++){
		cout<<a[i]<<b[i];
	}
	return 0;
}

Measured memory_bytes: 256
N,A = map(int,input().split())
X = list(map(int,input().split()))
dp = [[[0 for _ in range(50*(N+2))] for _ in range(N+2)] for _ in range(N+2)]

dp[0][0][0] = 1
#kまでみた
for k in range(N):
    #used個使った
    for used in range(N):
        for i in range(50*N):
            #使う時
            dp[used+1][k+1][i+X[k]] += dp[used][k][i]
            dp[used][k+1][i] += dp[used][k][i]
ans = 0
for used in range(1,N+1):
    ans += dp[used][N][used*A]
print(ans)




Measured memory_bytes: 97756
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans = a-b;
    if(k&1)ans*=-1;

    cout<<ans;
}

    /*
        a b c
        b+c a+c a+b

        2*a+b+c a+2*b+c a+b+2*c

        2a+3b+3c 3a+2b+3c 3a+3b+2c

    |a-b|
*/


Measured memory_bytes: 256