akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	static int[][] c;

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			c = new int[4][4];
			boolean flg = false;

			for (int i = 1; i < 4; i++) {
				for (int j = 1; j < 4; j++) {
					c[i][j] = in.nextInt();
				}
			}
			int[][] a = new int[101][3];
			int[][] b = new int[101][3];

			for (int x = 0; x <= 100; x++) {
				a[x][0] = x;
				a[x][1] = c[2][1] - (c[1][1] - x);
				a[x][2] = c[3][1] - (c[1][1] - x);
				b[x][0] = c[1][1] - x;
				b[x][1] = c[1][2] - x;
				b[x][2] = c[1][3] - x;

				if (judge(a[x][0], a[x][1], a[x][2], b[x][0], b[x][1], b[x][2])) {
					flg = true;
					break;
				}
			}

			String str = flg ? "Yes" : "No";
			out.println(str);

		}
		static boolean judge(int a1,int a2, int a3, int b1, int b2, int b3) {
			boolean isSame = true;
			if (a1 + b1 != c[1][1]) {
				isSame = false;
			}
			if (a1 + b2 != c[1][2]) {
				isSame = false;
			}
			if (a1 + b3 != c[1][3]) {
				isSame = false;
			}
			if (a2 + b1 != c[2][1]) {
				isSame = false;
			}
			if (a2 + b2 != c[2][2]) {
				isSame = false;
			}
			if (a2 + b3 != c[2][3]) {
				isSame = false;
			}
			if (a3 + b1 != c[3][1]) {
				isSame = false;
			}
			if (a3 + b2 != c[3][2]) {
				isSame = false;
			}
			if (a3 + b3 != c[3][3]) {
				isSame = false;
			}
			return isSame;
		}

	}


	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21588
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int a,b,c,x,y,mi=1000000000;
    cin>>a>>b>>c>>x>>y;
    for(int i=0;i<=max(x,y);i++)mi=min(mi,(c*2*i)+(max(0,(x-i))*a)+(max(0,(y-i))*b));
    cout<<mi<<endl;
    return 0;
}


Measured memory_bytes: 256
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
N,K = map(int,input().split())
A = [1 for _ in range(N+1)]
for i in range(2,N+1):
    A[i] = (i*A[i-1])%p
B = [1 for _ in range(N+1)]
B[N] = pow(A[N],p-2)
for i in range(N-1,1,-1):
    B[i] = ((i+1)*B[i+1])%p
for i in range(1,K+1):
    if N-K<i-1:
        ans = 0
    else:
        a = A[K-1]
        a = (a*B[K-i])%p
        a = (a*B[i-1])%p
        b = A[N-K+1]
        b = (b*B[N-K+1-i])%p
        b = (b*B[i])%p
        ans = (a*b)%p
    print(ans)

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

int tb[60][30];

int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        for(int j=0;j<s.size();j++){
            tb[i][s[j]-'a']++;
        }
    }
    string ans="";
    for(int i=0;i<26;i++){
        int cnt=0;
        for(int j=0;j<N;j++){
            if(j==0)cnt=tb[j][i];
            else{
                if(tb[j][i]<cnt)cnt=tb[j][i];
            }
        }
        for(int j=0;j<cnt;j++){
            ans+=i+'a';
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<ll,ll>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define iof  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pi acos(-1)
const int mxn=1e9+5;
int main()
{
    fast;
    ll x,k,d;
    cin>>x>>k>>d;
    ll neg=0;
    if(x<0)
    {
        x=abs(x);
        neg=1;
    }
    ll tmp=x/d;
    if(tmp<=k) {
    k-=tmp;
    x%=d;
    }
    else
    {
        x-=k*d;
        k=0;
    }


    if(neg)x=-1*x;
    if(k&1)
    {
        if(x<0)
        {
            x+=d;
        }
        else x-=d;
    }
    cout<<abs(x)<<endl;
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n; cin >> n;
    rep(i,9){
        if (111 * (i+1) >= n){
            cout << 111 * (i+1) << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

    ll N;
    cin>>N;

    ll n = sqrt(N);
    ll h = 1;
    rep(i, n) {
        if (N % (i + 1) == 0) h = i + 1;
    }
    cout<<h - 1 + (N / h) - 1<<endl;
}

Measured memory_bytes: 384
import sys
cin = sys.stdin
def line2N():
    return map(int, cin.readline().split())
n, c = line2N()
x = [0]*n
v = [0]*n
for i in range(n):
    x0, v0 = line2N()
    x[i] = x0
    v[i] = v0
c1 = [0]*n
m1 = [0]*(n+1)
c1[0] = -(x[0]-0) + v[0]
m1[0] = max(0, c1[0])
for i in range(1,n):
    c1[i] = c1[i-1] - (x[i]-x[i-1]) + v[i]
    m1[i] = max(m1[i-1], c1[i])
c2 = [0]*n
c2[n-1] = -(c - x[n-1]) + v[n-1]
m2 = [0]*(n+1)
m2[n-1] = max(0, c2[n-1])
for i in range(n-2, -1, -1):
    c2[i] = c2[i+1] - (x[i+1]-x[i]) + v[i]
    m2[i] = max(m2[i+1], c2[i])
ans0 = 0
for i in range(0, n-1):
    ans0 = max(ans0, c1[i] - x[i] + m2[i+1])
for i in range(n-1, 0, -1):
    ans0 = max(ans0, c2[i] - (c-x[i]) + m1[i-1])
print(max(ans0, m1[n-1], m2[0]))

Measured memory_bytes: 21932
S = input()
cnt = 0
out = 0

for i in S:
  cnt += 1
  if out == 1:
    break
  if cnt % 2 == 0:
    if i == 'R':
      out = 1
  else:
    if i == 'L':
      out = 1

if out == 1:
  print('No')
else:
  print('Yes')

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
#define allsortg(v)sort(v.begin(),v.end(),greater<int>());
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	ll Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	N *= 100;
	ll ans = 0;
	if (N >= 200) {
		ans += min(min(Q * 8, H * 4), min(S * 2, D))*(N / 200);
		N %= 200;
	}
	if (N >= 100) {
		ans += min(min(Q * 4, H * 2), S)*(N / 100);
		N %= 100;
	}
	if (N >= 50) {
		ans += min(Q * 2, H)*(N / 50);
		N %= 50;
	}
	ans += Q*(N / 25);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
        int a,b,c;
        int x,y,z;

        scanf("%d %d %d",&a,&b,&c);

        x = b;
       y = a;
        x = c;
        z = b;

        printf("%d %d %d",x,y,z);                                                                                                                                                                                                               return 0;
}

Measured memory_bytes: 128
s=raw_input().split()
[N, A, B] = s
N = int(N)
A = int(A)
B = int(B)

def halfdist(x,y):
    return (y-x)/2

if ((B-A)%2 == 0):
    print halfdist(A,B)
else:
    print min(A-1+1+halfdist(1, B-(A-1)-1), N-B+1+halfdist(A+(N-B)+1, N))


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K; cin>>N>>K;
  
  int ans=0;
  for(int i=0; i<N; i++){
    int h; cin>>h;
    if(h>=K){
      ans++;
    }
  }

  cout<<ans<<endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  cin >> n;

  int c = (n + 110) / 111;
  re(i, 3) cout << c;
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> data(M,vector<int>(2));
  vector<vector<int>> answer(N+1,vector<int>(1, 0));
  for (int i = 0; i < M; i++) {
    for (int k = 0; k < 2; k++) {
      cin >> data.at(i).at(k);
    }
  }
  for (int m = 0; m < N; m++){
    for (int i = 0; i < M; i++) {
      for (int k = 0; k < 2; k++) {
        if (data.at(i).at(k) == m+1) {
          answer.at(m).at(0)++;
        }
        
      }
    }
  }
  for (int m = 0; m < N; m++){
    cout << answer.at(m).at(0) << endl;
  }
}

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

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

	if (S == "AAB" || S == "ABA" || S == "BAA" ||
		S == "ABB" || S == "BAB" || S == "BBA") {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

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

struct lambda{void operator() (int i) {printf(" %d",i);}};
int main(void){
    int i,n;
    array<int,9>v{1,2,3,4,5,6,7,8,9};

    scanf("%d",&n);
    do{
        printf("%d",v[0]);
        for_each(v.begin()+1,v.begin()+n,lambda());
        printf("\r\n");
    }while(next_permutation(v.begin(),v.begin()+n));

    return 0;
}


Measured memory_bytes: 2704
#include<stdio.h>
void InsertionSort(int A[],int length)
{
    int i,j,key,k;
    for(k=0; k<length-1; k++)
        printf("%d ",A[k]);
    printf("%d\n",A[k]);
    for(i=1; i<=length-1; i++)
    {
        key=A[i];
        j=i-1;
        while(j>=0&&A[j]>key)
        {
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=key;
        for(k=0; k<length-1; k++)
            printf("%d ",A[k]);
        printf("%d\n",A[k]);
    }
}
int main()
{
    int a[10000],i,n;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    InsertionSort(a,n);
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    float i;
    cin >> a >> b;
    for(i = 1;i <= 1250;i++)
        if(int(i*0.08)==a && int(i*0.1)==b)
            break;
    if(i > 1250)
        cout << "-1" << endl;
    else
        cout << int(i) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	ll a, b;
	cin >> a >> b;


	if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	}
	else if ((a <= 0 && b >= 0) || (a >= 0 && b <= 0)) {
		cout << "Zero" << endl;
	}
	else {
		 ll s = abs(b) - abs(a) + 1;
		 if (s % 2 == 0) {
			 cout << "Positive" << endl;
		 }
		 else {
			 cout << "Negative" << endl;
		 }
	}




}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] a = new char[H][W];
        for(int i = 0; i < H; i++){
            String s = sc.next();
            for(int j = 0; j < W; j++){
                a[i][j] = s.charAt(j);
            }
        }
        sc.close();
        int[] h = new int[H];
        int[] w = new int[W];
        for(int i = 0; i < H; i++){
            if(full_row(a[i]))
                h[i] = 1;
        }
        for(int i = 0; i < W; i++){
            if(full_col(a, i))
                w[i] = 1;
        }

        for(int i = 0; i < H; i++){
            if(h[i] == 0){
                for(int j = 0; j < W; j++){
                    if(w[j] == 0)
                        System.out.print(a[i][j]);
                }
                System.out.println();
            } 
        }
    }
    static boolean full_row(char[] a){
        for(int i = 0; i < a.length; i++){
            if(a[i] == '#')
                return false;
        }
        return true;
    }

    static boolean full_col(char[][] a, int n){
        for(int i = 0; i < a.length; i++){
            if(a[i][n] == '#')
                return false;
        }
        return true;
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define F first
#define S second
#define sz(x) (int)x.size()
#define db(x) cerr << #x << ": " << x << "\n";

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

    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if(A+B >= K)
        cout << min(A,K) << '\n';
    else
        cout << A-(K-A-B) << '\n';
}


Measured memory_bytes: 3608
def main():
    from sys import setrecursionlimit, stdin
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor, gcd
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**9+10

    N = II()
    args = defaultdict(lambda:defaultdict(lambda:[0]*2))
    zeros = 0
    for _ in range(N):
        x,y = map(int,input().split())
        if x == 0:
            if y == 0:
                zeros += 1
            else:
                args[0][0][0] += 1
            continue
        elif y == 0:
            args[0][0][1] += 1
            continue
        
        g = gcd(x,y)
        x2,y2 = abs(x//g),abs(y//g)
        if x*y < 0:
            args[x2][y2][1] += 1
        else:
            args[y2][x2][0] += 1

    ans = 1
    for y, a in args.items():
        for x, p in a.items():
            ans *= (pow(2,p[0],P) + pow(2,p[1],P) -1)
            ans %= P
    print((ans + zeros -1 + P)%P)

main()

Measured memory_bytes: 194956
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input!(n:usize,mut ds:[i64;n]);

    ds.sort();
    let mid = n / 2;
    let left = ds[mid - 1];
    let right = ds[mid];
    println!("{}", if right >= left { right - left } else { 0 });
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> vp(n);
  rep(i, n){
    int x, y;
    cin >> x >> y;
    vp.at(i) = make_pair(x, y);
  }
  sort(vp.begin(), vp.end());
  map<pair<int, int>, int> mp;
  rep(i, n){
    rep2(j, i+1, n){
      pair<int, int> add;
      add.first = vp.at(i).first - vp.at(j).first;
      add.second = vp.at(i).second - vp.at(j).second;
      mp[add]++;
    }
  }
  int mx = 0;
  for(auto p : mp){
    mx = max(mx, p.second);
  }
  cout << n - mx << endl;
  return 0;
}

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

int main(){
  ll a,v,b,w,t;


  std::cin >> a>>v>>b>>w>>t;

  if(abs(a-b)-(v-w)*t<=0)std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';



  return 0;
}


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

const int mx = 1e5+123;
long long dp[123][mx];
int n;
int mxCost;
int cost[123];
long long v[123];

long long solve ( int i, int currCost )
{
    if ( i > n ) return 0;
    if ( dp[i][currCost] != -1 ) return dp[i][currCost];

    long long ret1 = 0, ret2 = 0;
    if ( cost[i] + currCost <= mxCost ) ret1 = v[i] + solve ( i+1, currCost + cost[i] );
    ret2 = solve ( i+1, currCost );

    return dp[i][currCost] = max ( ret1, ret2 );
}


int main()
{
    cin >> n >> mxCost;
    for ( int i = 1; i <= n; i++ ) cin >> cost[i] >> v[i];

    memset ( dp, -1, sizeof (dp) );
    cout << solve ( 1, 0 ) << endl;
    
}

Measured memory_bytes: 99820
#include<bits/stdc++.h>
  using namespace std;
  int main()
  {
      string s;
      cin>>s;
     for(int i=0;i<s.length();i++)
      {
          if(s[i]!=',')
         {
             cout<<s[i];
         }
         else
         {
            cout<<" ";
			
			
			         }
     }
 }

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

using namespace std;

int main() {
	int n, cnt = 0;
	float m, x, y;
	
	cin >> n >> m;
	
	while(n--) {
		cin >> x >> y;
		
		if(sqrt(pow(x,2)+pow(y,2)) <= m) ++cnt;
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3820
package main

import (
	"fmt"
)

func main() {
	var maxNum int

	fmt.Scanf("%d", &maxNum)

	var cntOdds int

	for index := 1; index <= maxNum; index++ {
		if index%2 == 1 {
			cntOdds++
		}
	}

	fmt.Printf("%f\n", float64(cntOdds)/float64(maxNum))
}


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

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);

    string cs;
    cin >> cs;
    int rn = 0, bn = 0;
    for (int i = 0; i < n; i++)
    {
        if (cs[i] == 'R')
            rn++;
        else
            bn++;
    }
    printf("%s\n", rn > bn ? "Yes" : "No");

    return 0;
}


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

int main() {
	long long X;
	cin >> X;
	for (int i = 1; i <= 1000; i++) {
		if (i * 100 <= X && X <= i * 105) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
likes = [0]*M
for n in range(N):
    K = [int(i) for i in input().split()]
    A = K[1:]
    for a in A:
        likes[a-1]+=1
result=0
for like in likes:
    if like == N:
        result+=1
print(result)


Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> l(N);
	for (int i = 0; i < N; i++) { cin >> l[i]; }
	sort(l.begin(), l.end(), greater<int>());
	for (int i = 1; i < K; i++) { l[0] += l[i]; }
	cout << l[0] << endl;
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

int main(int argc, char *argv[])
{
  int n, a, b;
  while (cin >> n >> a >> b) {
    int cnt = n;
    for (int i = 0; i < n; ++i) {
      int t;
      cin >> t;
      cnt -= (a <= t && t < b);
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 256
A,B,C,D,E,F=map(int,input().split())
x = 1
y = -1
for i in range(0, F+1, 100*A):
    for j in range(0, F-i+1, 100*B):
        m = min(F - i - j, (i + j) * E // 100)
        if i + j == 0:
            continue
        for k in range(0, m+1, C):
            for l in range(0, m-k+1, D):
                if y / x < (k+l) / (i+j):
                    x = i + j
                    y = k + l
print(x+y, y)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int a[5],b[5],hit=0,brow=0;
    while(cin>>a[0]>>a[1]>>a[2]>>a[3]>>b[0]>>b[1]>>b[2]>>b[3]){
    hit=0,brow=0;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            if(a[i]==b[i]){
                hit++;
                break;
            }
            else if(a[i]==b[j])brow++;
        }
    }
    cout<<hit<<" "<<brow<<endl;
    }
return 0;
}

Measured memory_bytes: 1160
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> ret;
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main() {
    ll n, p;
    cin >> n >> p;
    auto mp = prime_factor(p);
    ll ans = 1;
    for (auto &itr : mp) {
        while (itr.second >= n) {
            itr.second -= n;
            ans *= itr.first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
S = list(input())
A_check = []
C_check = []
lower_check = []

for i in range(len(S)):
    if S[i] == 'A':
        A_check.append(i)
    
    if S[i] == 'C':
        C_check.append(i)
    
    if S[i].islower():
        lower_check.append(i)
        

if len(A_check) != 1 or len(C_check) != 1 or len(lower_check) != (len(S) - 2):
    print('WA')
elif A_check[0] != 0 or C_check[0] == len(S) - 1 or C_check[0] < 2:
    print('WA')
else:
    print('AC')


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<char> t(q), d(q);
    REP(i, q) cin >> t[i] >> d[i];

    ll a, b;
    {
        auto check = [&](ll mid) {
            ll idx = mid;
            REP(i, q) {
                if(s[idx] == t[i]) {
                    if(d[i]=='L') idx--;
                    else idx++;
                    if(idx < 0) return true;
                }
            }
            return false;
        };

        ll lb=-1, ub=n;
        while(ub-lb > 1) {
            ll mid = (lb+ub)/2;
            if(check(mid)) lb = mid;
            else ub = mid;
        }
        a = lb;
    }

    {
        auto check = [&](ll mid) {
            ll idx = mid;
            REP(i, q) {
                if(s[idx] == t[i]) {
                    if(d[i]=='L') idx--;
                    else idx++;
                    if(idx >= n) return true;
                }
            }
            return false;
        };

        ll lb=-1, ub=n;
        while(ub-lb > 1) {
            ll mid = (lb+ub)/2;
            if(check(mid)) ub = mid;
            else lb = mid;
        }
        b = ub;
    }

    // cout << a << " " << b << endl;
    if(b <= a) {
        cout << 0 << endl;
    } else {
        // cout << n - (a+1 + n-b) << endl;
        cout << b-a-1 << endl;
    }

    return 0;
}


Measured memory_bytes: 976
#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(){
    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    int k=0;
    if(x==(w/2) and y==(h/2) and w%2==0 and h%2==0){
        k=1;
    }

    double ans;
    ans=h*w/2.0;

    printf("%.10f ",ans);
    cout << k << endl;
    

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
n = int(input())
a = list(map(int, input().split()))
a.sort()
q = 1
f = 0
for i in a:
    q *= i
    if q > 10**18:
        f = 1
        break
if f == 1:
    print(-1)
else:
    print(q)

Measured memory_bytes: 22152
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")
rgb = r*g*b

count = 0
for i in range(n):
  for j in range(i+1, n-1):
    k = 2*j-i
    if k >= n or s[i] == s[j] or s[j] == s[k] or s[i] == s[k]:
      continue
    rgb -= 1
print(rgb)

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

int main() {
  int N,K,L=0;
  cin >> N >> K;


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

    if(x > K - x) //(i,K)から(i,x)のほうが近い
      L += (K - x) * 2;
    else
      L += x*2;
  }

  cout << L << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
 
#define pb emplace_back
#define fi first
#define se second
 
using namespace std;
 
using ld = long double;
using ll = long long int;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }
 
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
 
ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}
 
// head
 
using P = pair<int, int>;
 
int n, m;
 
int G[710][710];
 
int cnt[2];
int col[710];
 
bool dp[710][710];
 
void dfs(int x, int c){
  // cout << x << " " << c << endl;
  col[x] = c;
  cnt[c]++;
  REP(i, n){
    if(G[x][i] == 0){
      continue;
    }
    if(col[i] == -1){
      dfs(i, 1-c);
    } else if(col[i] == c){
      puts("-1");
      exit(0);
    }
  }
}
 
int main(){
 
  n = in();
  m = in();
  REP(i, n){
    REP(j, i){
      G[i][j] = G[j][i] = 1;
    }
  }
  REP(i, m){
    int a = in() - 1;
    int b = in() - 1;
    G[a][b] = G[b][a] = 0;
  }
 
  REP(i, n){
    col[i] = -1;
  }
 
  vector<P> cs(0);
  REP(i, n){
    if(col[i] == -1){
      cnt[0] = cnt[1] = 0;
      dfs(i, 0);
      cs.pb(cnt[0], cnt[1]);
      // cout << cs.back() << endl;
    }
  }
 
  dp[0][0] = true;
  REP(i, SZ(cs)){
    REP(j, n+1){
      if(dp[i][j]){
        dp[i+1][j+cs[i].fi] = true;
        dp[i+1][j+cs[i].se] = true;
      }
    }
  }
 
  ll ans = INFLL;
  REP(i, n+1){
    if(dp[SZ(cs)][i]){
      chmin(ans, i * (i-1) / 2 + (n-i) * (n-i-1) / 2);
    }
  }
 
  cout << ans << endl;
  
  return 0;
}

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

int n,t;
int main(void)
{
	cin>>n>>t;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin>>a[i];
	}
	int prev=0;
	ll ret=0;
	for(auto x:a){
		if(x-prev>=t)ret+=t;
		else ret+=x-prev;
		prev=x;
	}
	cout<<ret+ll(t)<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
using namespace std;
int N;
int a[105];
int main() {
    scanf("%d",&N);
    for(int i = 1 ; i <= N ; ++i) {
        scanf("%d",&a[i]);
    }
    int ans = 0;
    int cnt = 0;
    for(int i = 1 ; i <= N ; ++i) {
        if(a[i] != a[i - 1]) {
            ans += cnt / 2;
            cnt = 0;
        }
        ++cnt;
    }
    ans += cnt / 2;
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int num5 = 0,num7 = 0;

void f(int x){
    if(x == 5){
        num5++;
    }else if(x == 7){
        num7++;
    }else;
    return;
}

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    f(A);
    f(B);
    f(C);
    if(num5 == 2 && num7 == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

int main(){
    int H,A;
    cin >> H >> A;
    int i=0;
    while(1){
        H += -A;
        i++;
        
        if(H<=0) {
            cout << i;
            break;
        }
    }
    
}

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

using namespace std;
using ll = long long;
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

    string s;
    cin >> s;
    const ll n = s.size();

    bool flag = true;
    REP(i, n) {
        if(i%2==0 && s[i]=='L') flag = false;
        if(i%2==1 && s[i]=='R') flag = false;
    }
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if (a<=0 && 0<=b) {
        cout << "Zero" << endl;
        return 0;
    }

    bool p = true;
    if (b<0 && abs(b-a)%2==0) p = false;
    cout << (p? "Positive" : "Negative") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2e5 + 10;
int N;
LL a[MAX];
VI G[MAX];
int ans[MAX];
int dp[MAX];

void dfs(int cur, int prev) {

    const auto itr = lower_bound(dp, dp + MAX, a[cur]);
    const auto tmp = *itr;
    *itr = a[cur];
    ans[cur] = distance(dp, lower_bound(dp, dp + MAX, INF)) - 1;

    FORE(nxt, G[cur]) if (nxt != prev) {
        dfs(nxt, cur);
    }

    *itr = tmp;
}

int main(void) {
    cin >> N;
    REP(i, N) cin >> a[i];
    REP(i, N - 1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        G[u].EB(v);
        G[v].EB(u);
    }
    fill(dp, dp + MAX, INF);
    dp[0] = 0;
    dfs(0, -1);

    REP(i, N) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 29072
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double x, ll t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// ll dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];
vector<ll> g[114514], depth[114514];
ll dp[114514] = {};

ll rec(ll x) {
	ll ans = 0;
	for (int i = 0; i < g[x].size(); ++i) {
		int y = g[x][i];
		depth[x].push_back(rec(y));
	}
	sort(depth[x].begin(), depth[x].end(), greater<ll>());
	for (int i = 0; i < depth[x].size(); ++i) {
		ans = max(depth[x][i] + i, ans);
	}

	return ans + 1;
}

int main() {
	IOS();
	ll n;
	cin >> n;
	for (int i = 2; i <= n; ++i) {
		int a;
		cin >> a;
		g[a].push_back(i);
	}
	dump(rec(1) - 1);
}

Measured memory_bytes: 18176
#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){
        if (r <= y && y <= H-r){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main()
{
	int n1,n2,n3,n4,n5,n6,n7,n8,n9,Kei;
while(true){

	cin >> Kei;
	if (Kei==0)
		break;



	cin >> n1;
	cin >> n2;
	cin >> n3;
	cin >> n4;
	cin >> n5;
	cin >> n6;
	cin >> n7;
	cin >> n8;
	cin >> n9;
	cout << Kei-(n1+n2+n3+n4+n5+n6+n7+n8+n9) << endl;
}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
using ll = long long;

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

int main() {
	int A, B;
	cin >> A >> B;

	int C = A - 2 * B;

	if (C <= 0) { cout << 0 << endl; }
	else { cout << C << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll X,N;
    string S;
    cin >> X >> N;
    vector<ll> p(N);
    map<ll,ll> mp;
    rep(i,N){
        cin >> p[i];
        mp[p[i]]++;
    }
    ll m = 1e18;
    ll ans;
    for(ll i=101;i>=-101;i--){
        if(mp[i] > 0)continue;
        if(m >= abs(X-i)){
            ans = i;
            m = abs(X-i);
        }
    }
    cout << ans << endl;
}


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

char s[100100];

int main(void) {
	scanf("%s", s);
	int n = strlen(s), ans = strlen(s);
	for(int i = 0; i < n - 1; i++) {
		if(s[i] != s[i + 1]) 
			ans = min(ans, max(i + 1, n - i - 1));
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  
  int A, Z;
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) == 'A')
    {
      A = i;
      break;
    }
  }
  for (int i = N - 1; i >= 0; i--)
  {
    if (S.at(i) == 'Z')
    {
      Z = i;
      break;
    }
  }
  
  int ans = Z - A + 1;
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	int n, x, t;
	cin >> n >> x >> t;

	cout << t*((n + x - 1) / x) << endl;

	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };




ll tmp;

int main() {

	int n, m;

	cin >> n >> m;
	rep(i, m) {
		ll x;
		cin >> x;
		tmp += x;
	}

	if (n < tmp) {
		cout << -1 << endl;
	}
	else {
		cout << n - tmp << endl;
	}

	return 0;
}

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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define ri(n) scanf("%d",&n)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int MAXN = 1e5+200;
const int INF = 1e9;
int dp[MAXN];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n, w;
    cin>> n>> w;
    ii obj[n+1];
    for1(i,n){
        cin>> obj[i].fi >> obj[i].se;
    }
    ll dp[n+1][w+1];
    memset(dp, 0, sizeof dp);
    for1(i,n){
        for1(j, w){
            if(j-obj[i].fi>=0){
                dp[i][j] = max(dp[i][j], dp[i-1][j-obj[i].fi] + obj[i].se);
            }
            dp[i][j]= max(dp[i][j], dp[i-1][j]);
        }
    }
    cout<< dp[n][w]<<el;
}



Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,y,i,j,k,tmp,a,b,c,sum;
    cin>>n>>y;
    if(y%1000!=0)
    {
        printf("-1 -1 -1\n");
        return 0;
    }
    else{
        for(i=0;i<=n;i++)
        {
            for(j=0;j+i<=n;j++){
                k=n-i-j;
                tmp=(i*10000)+(j*5000)+(k*1000);
                if(tmp==y){
                    printf("%lld %lld %lld\n",i,j,k);
                    return 0;
                }
            }
        }
        printf("-1 -1 -1\n");
    }
}


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

int main(void) {
  int a, b, cou = 0;
  cin >> a >> b;
  int gr[a];
  cou = a;
  for (int i = 0; i < a; i++) {
    cin >> gr[i];
    b -= gr[i];
  }
  sort(gr, gr + a);
  cou += (b / gr[0]);
  cout << cou << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    ll res = 1;
    for(ll x = 2; x*x <= g; x++) {
        if (g%x==0) {
            res++;
            while(g%x==0) {
                g/=x;
            }
        }
    }
    if(g>1) {
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i];
    int mi=a[1],ans=1;
    for(int i=2;i<=n;++i){
        if(a[i]<mi)ans++;
        mi=min(mi,a[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024