akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll N, K, Q;
  IN(N,K,Q);
  vll A(Q);
  vll ANS(N, 0);
  REP(i,Q){
    IN(A[i]);
    A[i]--;
    ANS[A[i]]++;
  }
  REP(i,N){
    if(ANS[i]+K-Q<=0){
      OUT("No");
    }else{
      OUT("Yes");
    }
  }

  return 0;
}

Measured memory_bytes: 2304
from bisect import bisect_right
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A_sum = [0]*(N+1)
for i in range(N):
    A_sum[i+1] = A[i]+A_sum[i]
B_sum = [0]*(M+1)
for i in range(M):
    B_sum[i+1] = B[i]+B_sum[i]

ans = 0
for i in range(N+1):
    if 0 <= K-A_sum[i]:
        j = bisect_right(B_sum,K-A_sum[i])
        ans = max(ans,i+j-1)

print(ans)

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

int dp[200][5][5];

int main()
{
  int n,k,a,b[108]={},ans=0;
  cin>>n>>k;
  for(int i=1;i<=k;i++){
    cin>>a;
    cin>>b[a];
  }
  if(b[1]==0){
    for(int j=1;j<=3;j++){
      dp[2][j][0]=1;
    }
  }else {
    dp[2][b[1]][0]=1;
  }
  for(int i=3;i<=n+1;i++){                 //今日の日数
    for(int j=0;j<=3;j++){              //１日前のパスタの種類
      for(int k=0;k<=3;k++){            //２日前のパスタの種類
        if(dp[i-1][j][k]!=0){           //昨日はパスタを食べたか
          if(b[i-1]!=0){                  //今日のパスタは決まっているか
            if(!(j==k && b[i-1]==j)){     //３日連続じゃないか
              dp[i][b[i-1]][j]+=dp[i-1][j][k];
              dp[i][b[i-1]][j]%=10000;
            }
          }else{                        //今日のパスタが決まってない場合
            for(int l=1;l<=3;l++){
              if(!(j==k && l==j)){      //３日連続じゃないか
                dp[i][l][j]+=dp[i-1][j][k];
                dp[i][l][j]%=10000;
              }
            }
          }
        }
      }
    }
  }
  for(int i=1;i<=3;i++){
    for(int j=1;j<=3;j++){
      ans+=dp[n+1][i][j];
      ans%=10000;
    }
  }
  ans%=10000;
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  string N;
  cin>>N;
  if(N.at(N.size()-1)=='2'||N.at(N.size()-1)=='4'||N.at(N.size()-1)=='5'||N.at(N.size()-1)=='7'||N.at(N.size()-1)=='9'){
    cout<<"hon"<<endl;
  }
  else if(N.at(N.size()-1)=='3'){
    cout<<"bon"<<endl;
  }
  else{
    cout<<"pon"<<endl;
  }
}

Measured memory_bytes: 3596
use proconio::{fastout, input};

#[fastout]
fn main() {
    const M: u64 = 998244353;
    input! {
        n: usize, s: usize,
        a: [usize; n],
    }
    let mut dp = vec![vec![0; s + 1]; n + 1];
    dp[0][0] = 1;
    for i in 0..n {
        for t in 0..=s {
            dp[i + 1][t] = (dp[i + 1][t] + dp[i][t] * 2) % M;
            if t + a[i] <= s {
                dp[i + 1][t + a[i]] = (dp[i + 1][t + a[i]] + dp[i][t]) % M;
            }
        }
    }
    println!("{}", dp[n][s]);
}


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

#define ll long long

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

    ll n, m;
    cin >> n >> m;

    vector<double> a(n);

    for(int i=0;i<n;i++) cin >> a[i];

    double sum = accumulate(a.begin(),a.end(),0);

    double off = ((double)sum/double(4.00*(double)m));

    ll c=0;
    for(int i=0;i<n;i++)
	{
		if(a[i]>=off) c++;
	}

	if(c>=m) cout << "Yes\n";
	else cout << "No\n";


    return 0;
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let mut aa = i::str();
    let mut bb = i::str();
    bb.push_str(&aa);
    println!("{}",bb);
}


#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn strv(n: usize) -> Vec<String> {
        (0..n).map(|_| str()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 2080
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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


    int N;  cin >> N;
    vi T(N), A(N); REP(i, N) cin >> T[i] >> A[i];

    ll nt = T[0], na = A[0];
    FOR(i,1,N) {
        if (T[i]>=nt && A[i]>=na) {
            nt = T[i];
            na = A[i];
        } else {
            ll m = max((nt+T[i]-1) / T[i], (na+A[i]-1) / A[i]);
            nt = T[i] * m;
            na = A[i] * m;
        }
    }

    ll ans = nt + na;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = str(input())

l = len(s)
ans = []

for i in range(l):
    if s[i] == str(0):
        ans.append(str(0))
    elif s[i] == str(1):
        ans.append(str(1))
    else:
        if ans == []:
          continue
        else:
          del ans[-1]
        
print(*ans, sep='')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b,x;
cin >> a >> b >> x;
if(a<=x&&x<=a+b) {
  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 a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), k = sc.nextInt();
		if(k <= a){
			System.out.println(k);
		} else if(k <= a+b){
			System.out.println(a);
		} else {
			System.out.println(a-(k-a-b));
		}
	}
}


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

int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e - a > k)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;
}

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

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

    char c;
    for (auto i = 0; i < 3; i++)
    {
        if (i == 0)
        {
            c = s.at(i);
            continue;
        }

        if (c != s.at(i))
        {
            cout << "Yes" << endl;
            return 0;
        }
        c = s.at(i);
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int u,k,v,n,i,j,V[105][105]={0};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      V[u][v]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=n)printf("%d ",V[i][j]);
      else printf("%d\n",V[i][j]);
    }
  }
  return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define maxn 100010
typedef long long LL;
const LL mod = 998244353;
LL x[maxn], y[maxn], P[maxn];
int main() {
    LL n;
    scanf("%lld", &n);
    for (int i = 0; i < n; ++i) scanf("%lld%lld", &x[i], &y[i]);
    P[0] = 1;
    for (int i = 1; i <= n; ++i) (P[i] = P[i-1] << 1) %= mod;
    LL ans = P[n] - 1 - n - n*(n-1)/2;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            int cnt = 0;
            for (int k = j+1; k < n; ++k) {
                if ((x[j]-x[i]) * (y[k]-y[j]) == (x[k]-x[j]) * (y[j]-y[i])) ++cnt;
            }
            ((ans -= P[cnt]-1) += mod) %= mod;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
import math


def ncr(l, m):
    return math.factorial(l) // math.factorial(l - m) // math.factorial(m)


n = int(input())
map_l = []
info = []
for _ in range(n):
    map_l.append(list(map(int, input().split())))

for i in range(n):
    for j in range(n):
        if i > j:
            info.append(math.sqrt((map_l[i][0] - map_l[j][0])**2 + (map_l[i][1] - map_l[j][1])**2))
p = (math.factorial(n) * (n-1) / ncr(n, 2))
print(sum(info) * p / math.factorial(n))

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

long double A, B, H, M;

void solve() {
    cin >> A >> B >> H >> M;
    
    double pi = acos(-1.0);
    double ax = A * cos(2 * pi * (H * 60 + M) / 720);
    double ay = A * sin(2 * pi * (H * 60 + M) / 720);
	double bx = B * cos(2 * pi * M / 60);
	double by = B * sin(2 * pi * M / 60);
    cout << fixed << setprecision(20) << hypot(ax - bx, ay - by);
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 4184
#include<iostream>
using namespace std;
int main(){
	int r, c,a[100][100],sum;
	sum=0;
	int gou=0;


	cin>>r>>c;

	for(int i=0; i<r; i++ ){
		for(int j=0; j<c; j++){
			cin>>a[i][j];
			gou+=a[i][j];
		}
	}
	for(int i=0;i<r;++i){
		for(int j=0;j<c;++j){
			cout<<a[i][j]<<" ";
			sum+=a[i][j];
		}
		cout<<sum<<endl;
		sum=0;
	}
	for(int i=0;i<c;++i){
		for(int j=0;j<r;++j){
			sum+=a[j][i];
		}
		cout<<sum<<" ";
		sum=0;
	}
	cout<<gou<<endl;
	return 0;
}


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

// CAT ::= m[CAT]eCat
// eCat ::= e[CAT]w

template<typename T>
struct Parser {
	using itr = string::const_iterator;
	itr now;
	T ans;
	Parser(const string &s) {
		now = s.begin();
		ans = true;
		try {
			CAT(now);
			if(*now != '\0') throw "Rabbit";
		}
		catch(...) {
			ans = false;
		}
	}
	T CAT(itr &now) {
		next(now, 'm');
		if(*now == 'm') {
			CAT(now);
		}
		eCat(now);
	}
	T eCat(itr &now) {
		next(now, 'e');
		if(*now == 'm') {
			CAT(now);
		}
		next(now, 'w');
	}
	void next(itr &now, const char expected) {
		vector<char> req = {expected};
		next(now, req);
	}
	void next(itr &now, const vector<char> &expected) {
		// cerr << "now " << *now << "\n";
		for(char c : expected) {
			if(*now == c) {
				now++;
				return;
			}
		}
		throw "Rabbit";
		for(char c : expected) cerr << c << "\n";
	}
};

int main() {
	string s; cin >> s;
	Parser<bool> parse(s);
	cout << (parse.ans ? "Cat" : "Rabbit") << "\n";
	return 0;
}


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

string A,B,C;

int main() {
	int n,i;
	cin>>A>>B>>C;
	int a=A.size(); 
	int b=B.size();
	int c=C.size();
	
	if(A[a-1]==B[0]&&B[b-1]==C[0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
l = list(map(int, input().split()))
ans = 0
while (l[0] == l[1] == l[2]) == 0:
    l.sort()
    if (l[0] % 2 == l[1] % 2 == l[2] % 2) == 0:
        if (l[0] - l[1]) % 2 == 0:
            l[0] += 1
            l[1] += 1
        elif (l[1] - l[2]) % 2 == 0:
            l[1] += 1
            l[2] += 1
        else:
            l[0] += 1
            l[2] += 1
    elif l[1] - l[0] >= 2:
        l[0] += 2
    else:
        l[0] += 1
        l[1] += 1
    ans += 1
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int n,y;
    cin >>n>>y;
    int sum;
    bool aru=false;
    for(int a=0;a<=n;a++){
        for(int b=0;b+a<=n;b++){
            sum =10000*a+5000*b+(n-a-b)*1000;
            if(sum==y){
                cout << a <<" " <<b<<" "<<(n-a-b)<<endl;
                return 0;
            }
        }
    }
    cout <<"-1 -1 -1"<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

	class Main {
		public static void main(String[] args){
		 	Scanner sc = new Scanner(System.in);
		 	int r = sc.nextInt();
		 	int g = sc.nextInt();
		 	int b = sc.nextInt();
		 	int n = r * 100 + g * 10 + b;
		 if(n%4==0) {
			 System.out.println("YES");
		 }else {
			 System.out.println("NO");
		 }
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, m; cin >> n >> m;
    vector<int> c(m);
    for (int i = 0; i < m; i++)
        cin >> c[i];
    vector<int> dp(n+1, 50001);
    dp[0] = 0; dp[1] = 1;
    for (int i = 2; i <= n; i++)
        for (int j = 0; j < m; j++)
            if (c[j] <= i)
                dp[i] = min(dp[i-c[j]]+1, dp[i]);

    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,a[200002],count = 0;
    cin >> n;
    rep(i,n) cin >> a[i];
    
    llong mx=0;
    rep(i,n) mx = max(mx,a[i]);
    rep(i,n) if(a[i] == mx) count++;
    llong mx2=0;
    rep(i,n) if(a[i] != mx) mx2 = max(mx2,a[i]);
    
    if(count == 1){
        rep(i,n){
            if(a[i] == mx) cout << mx2 << endl;
            else cout << mx << endl;
        }
    }else{
        rep(i,n) cout << mx << endl;
    }
}

Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#define INF 2000000000
using namespace std;

int main(){
    int n,a[200] = {},max = -INF,min = INF;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(max <= a[i])
            max = a[i];
        if(min > a[i])
            min = a[i];
    }
    cout << abs(max - min) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void) {
 
  char s[100001];
  scanf("%s", s);
  int count = 0;
  for (int i = 1; i < strlen(s); i++) {
    if (s[i] != s[i-1]) {
      count++;
    }
  }
  printf("%d\n", count);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    FAST
    int k,a,b;
    cin>>k>>a>>b;
    if(((a+k-1)/k)*k<=b) cout<<"OK";
    else cout<<"NG";
    return 0;
}

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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;

    if(abs(x - a) < abs(x - b))
        cout << 'A' << endl;
    else
        cout << 'B' << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        Action abort = () => { Console.WriteLine("No"); Environment.Exit(0); };
     
        int n = int.Parse(Console.ReadLine());
        var x = Console.ReadLine().Split().Select(y => int.Parse(y) - 1).ToArray();
        Queue<int> remainItem = new Queue<int>();
        int[] res = new int[n * n];
        int ind = 0;
        foreach (var item in x.Select((Index, Item) => new { Item = Item + 1, Index }).OrderBy(y => y.Index))
        {
            for (int i = 0; i < item.Item - 1; i++)
            {
                while (res[ind] != 0) ind++;
                if (item.Index <= ind) abort();
                res[ind] = item.Item;
            }
            res[item.Index] = item.Item;
            for (int i = item.Item; i < n; i++)
                remainItem.Enqueue(item.Item);
        }
        while (remainItem.Count > 0)
        {
            while (res[ind] != 0) ind++;
            var item = remainItem.Dequeue();
            if (ind < x[item - 1]) abort();
            res[ind] = item;
        }
        Console.WriteLine("Yes");
        Console.WriteLine(string.Join(" ", res));
    }
}


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

int main(void){
    ll n, y;
    cin >> n >> y;

//    ll y_copy = y;
//    ll a_count, b_count, c_count;
//
//    a_count = y_copy / 10000;
//    y_copy %= 10000;
//
//    b_count = y_copy / 5000;
//    y_copy %= 5000;
//
//    c_count = y_copy / 1000;
//
//    while(a_count + b_count + c_count < n){
//        if(n - a_count - b_count - c_count >= 4){
//            b_count--;
//            c_count += 5;
//        }else{
//            a_count--;
//            b_count += 2;
//        }
//
//        if(b_count < 0){
//            a_count--;
//            b_count += 2;
//        }
//
//        if(a_count < 0){
//            cout << "-1 -1 -1" << endl;
//            return 0;
//        }
//    }
//
//    if(a_count + b_count + c_count != n || a_count * 10000 + b_count * 5000 + c_count * 1000 != y){
//        cout << "-1 -1 -1" << endl;
//        return 0;
//    }
//
//    cout << a_count << " " << b_count << " " << c_count << endl;
//    return 0;

    rep(i, n + 1){
        rep(j, n + 1){
            if(n - i - j < 0){
                continue;
            }
            ll sum = i * 10000 + j * 5000 + (n - i - j) * 1000;

            if(sum == y){
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,K;
	cin >> N >> K;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	const int index = lower_bound(A.begin(),A.end(),K) -A.begin();
	vector< vector<bool> > Left(N+1,vector<bool>(K+1,false));
	vector< vector<bool> > Right(N+1,vector<bool>(K+1,false));
	Left[0][0] = true;
	for(int i=0;i<index;++i){
		Left[i+1] = Left[i];
		for(int v=K;v>=0;--v){
			if( v-A[i] >= 0 ){
				(Left[i+1][v]) = (Left[i+1][v])|(Left[i][v-A[i]]);
			}
		}
	}
	Right[0][0] = true;
	for(int i=0;i<index;++i){
		int Aindex = index-1-i;
		Right[i+1] = Right[i];
		for(int v=K;v>=0;--v){
			if( v-A[Aindex] >= 0 ){
				(Right[i+1][v]) = (Right[i+1][v])|(Right[i][v-A[Aindex]]);
			}
		}
	}
	/*
	index個の数列
	Ai(0index)を使わない場合i[0,index)
	Left[i][*]+Right[index-1-i][*]
	*/
	int L,R,mid;
	LL sum = 0;
	for(int i=0;i<index;++i){
		sum += A[i];
	}
	if( sum < K ){
		cout << index << endl;
		return;
	}else{
		R = index;
	}
	L = -1;
	while(R-L>1){//二分探索
		mid = (L+R)/2;//A[mid]を使わない
		bool flag = false;
		for(int ter=K-A[mid];ter<K;++ter){//作る数
			for(int v=0;v<=ter;++v){//v:左で作る,ter-v:右で作る
				if( Left[mid][v] && Right[index-1-mid][ter-v]){
					flag = true;
					break;
				}
			}
			if( flag ) break;
		}
		if( flag ){
			R = mid;
		}else{
			L = mid;
		}
	}
	cout << R << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 6912
S = input()
D = {}
s = set()
for i in S:
    s.add(i)
    if i not in D:
        D[i] = 1
    else:
        D[i] += 1

s = list(s)
if len(D) == 2 and D[s[0]] == 2 and D[s[1]] == 2:
    print('Yes')
else:
    print('No')

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

int main()
{
    // 整数の入力
    int i,N,maxA,minA,a;
    int Count[9] = {0,0,0,0,0,0,0,0,0};
    minA = 0;
    cin >> N;
    for (i=0;i<N;i++){
        cin >> a;
        if (a < 400){
            Count[0] += 1;
        }else        if (a < 800){
            Count[1] += 1;
        }else        if (a < 1200){
            Count[2] += 1;
        }else        if (a < 1600){
            Count[3] += 1;
        }else        if (a < 2000){
            Count[4] += 1;
        }else        if (a < 2400){
            Count[5] += 1;
        }else        if (a < 2800){
            Count[6] += 1;
        }else        if (a < 3200){
            Count[7] += 1;
        }else{
            Count[8] += 1;
        }
    }
    for (i = 0; i<8;i++){
        if (Count[i] >0){
            minA += 1;
        }
    }
    if (minA == 0){
        cout << 1 << " "<< Count[8] <<endl;
    }else{
        cout << minA << " "<<  (minA + Count[8]) <<endl;
    }


    return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n, m;
    cin >> n >> m;
    int a[m] = {};
    int b[m] = {};
    rep(i, m) {
        {
            cin >> a[i] >> b[i];
            a[i]--;
            b[i]--;
        }
    }

    // 処理
    int cnt  = 0;
    int c[n] = {};
    rep(i, m) { c[a[i]]++; }
    rep(i, m) { c[b[i]]++; }

    // 出力
    rep(i, n) {
        { cout << c[i] << endl; }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[102];
	long long k,i;
	scanf("%s",s);
	scanf("%lld",&k);

	for (i=0;i<k;i++) {
		if (s[i]=='1') continue;
		i++;
		break;
	}
	i--;
	printf("%c\n",s[i]);
	
	return 0;
}


Measured memory_bytes: 128
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c, d := readInt(), readInt(), readInt(), readInt()

	ans := -1000000000000000000
	ac := a * c
	ad := a * d
	bc := b * c
	bd := b * d
	ans = max(ans, ac)
	ans = max(ans, ad)
	ans = max(ans, bc)
	ans = max(ans, bd)
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAXN=2e5+5;
const int MOD=1000000000;
const LL INF=(2e5)*(1e9)+5;
LL a[MAXN];
LL sum[MAXN];

int main()
{
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n)
    {
        LL tot=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            sum[i]=sum[i-1]+a[i];
            tot+=a[i];
        }
        LL Min=INF;
        for(int i=1;i<n;i++)
        {
                Min=min(Min,abs(2*sum[i]-tot));
        }
        cout<<Min<<endl;
    }

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;


int main(void) {

	int N, X;
	int Recipe[100] = { 0 };

	int tmp = 0;
	int cnt = 0;

	cin >> N;
	cin >> X;

	for (int i = 0; i < N; i++) {
		cin >> Recipe[i];
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (Recipe[i] < Recipe[j]) {
				tmp = Recipe[i];
				Recipe[i] = Recipe[j];
				Recipe[j] = tmp;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		if (X > Recipe[i]) {
			X -= Recipe[i];
			cnt++;
		}

	}

	while (X >= 0) {
		X -= Recipe[0];
		if(X >= 0)
			cnt++;
	}

	cout << cnt << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int64_t gcd(int64_t a,int64_t b){
  return a%b==0? b:gcd(b,a%b);
}

int64_t lcm(int64_t a,int64_t b){
  return a*b/gcd(a,b);
}

int main()
{
  int64_t n,m;
  cin>>n>>m;
  string s,t;
  cin>>s>>t;
  if(s.size()<t.size()) {
    swap(s,t);
    n=s.size();
    m=t.size();
  }
  int pos=0;
  /*if(gcd(m,n)==1) {
    cout<<lcm(n,m);
    return 0;
  }*/
  for (int i = 0; i < min(n,m); i+=lcm(n,m)/s.size())
  {
    if(s[pos]!=t[i]) {
      cout<<-1;
      return 0;
    }
    pos+=lcm(n,m)/t.size();
  }
  cout<<lcm(n,m);
  /*
  if(s[0]!=t[0]){
    cout<<-1;
    return 0;
  }
  vector<char> vec(lcm(n,m),'0'),x(lcm(n,m),'0');
  int64_t tmp=lcm(n,m)/n;
  for (int i = 0; i < lcm(n,m); i+=tmp)
  {
    vec[i]=s[i/tmp];
  }
  for(auto&& e: vec) {
    cout<<e<<" ";
  }cout<<endl;
  tmp=lcm(n,m)/m;

  for(int i=0;i<lcm(n,m);i+=tmp){
    x[i]=t[i/tmp];
  }
  for(auto&& e: x) {
    cout<<e<<" ";
  }cout<<endl;

  for (int i = 0; i < lcm(n,m); i+=tmp)
  {
    if(vec[i]=='0') continue;
    if(vec[i]==t[i/tmp]) continue;
    cout<<-1;
    return 0;
  }
  cout<<lcm(n,m);
  */
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int MOD = 1000000007;
int n, dp[2][N];
bool vis[N];
vector <int> son[N];

void dfs(int u)
{
	vis[u] = 1;
	dp[0][u] = dp[1][u] = 1;
	for (unsigned i=0;i<son[u].size(); i++)
	{
		int v=son[u][i];
		if (vis[v]) continue;
		dfs(v);
		dp[0][u] = (1LL*dp[0][u]*((dp[0][v]+dp[1][v])%MOD))%MOD;
		dp[1][u] = (1LL*dp[1][u]*dp[0][v])%MOD;
	}
}

int main()
{
	cin >> n;
	for (int i=1;i<n;i++)
	{
		int x,y;
		cin >> x >> y;
		son[x].push_back(y);
		son[y].push_back(x);
	}
	dfs(1);
	cout << (dp[0][1] + dp[1][1]) % MOD << endl;
	return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, m, c;
	scanf("%d%d%d", &n, &m, &c);
	vi b(m);
	for (int i = 0; i < m; i++) scanf("%d", &b[i]);
	int answer = 0;
	for (int i = 0; i < n; i++) {
		int tmp = c;
		for (int j = 0; j < m; j++) {
			int a;
			scanf("%d", &a);
			tmp += a * b[j];
		}
		if (tmp > 0) ++answer;
	}
	printf("%d\n", answer);
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		int x = 0, xi = 0;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		
		for(int i=0;N > i;i++){
			if('I'==S.charAt(i)){
				x++;
				if(x>xi){
					xi = x;
				}
			}else{
				x--;
			}
		}
		System.out.println(xi);
	}
}

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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define nl '\n'
#define all(x) (x).begin(), (x).end()
#define int_max numeric_limits<int>::max()
#define int_min numeric_limits<int>::min()
#define ll_max numeric_limits<ll>::max()
#define ll_min numeric_limits<ll>::min()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define im(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// custom sort example
//sort(all(a), [ ]( const auto& c, const auto& d) {
	//if (c.fi.se != d.fi.se) {
		//return c.fi.se < d.fi.se; // lower first
	//}
	//if (c.fi.fi != d.fi.fi) {
		//return c.fi.fi > d.fi.fi; // higher first
	//}
	//return c.se > d.se; // higher first
//});

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 998244353;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	ll n, x, m;
	cin >> n >> x >> m;
	ll res = 0;
	vector<lli> dp(m);
	for (int i = 0; i < m; i++) {
		dp[i] = {-1, -1};
	}
	for (ll i = 0; i < n; i++) {
		if (i == 0) {
			res = res + x;
			x = x * x;
		} else {
			res = res + x % m;
			if (dp[x % m].fi != -1) {
				ll pom = i - dp[x % m].se;
				ll pom2 = res - dp[x % m].fi;
				ll todo = n - i - 1;
				res = res + todo / pom * pom2;
				x = (x % m) * (x % m);
				for (int j = 0; j < todo % pom; j++) {
					res = res + x % m;
					x = (x % m) * (x % m);
				}
				break;
			}
			dp[x % m] = {res, i};
			x = (x % m) * (x % m);
		}
		if (x == 0) {
			break;
		}
	}
	cout << res << nl;
}


Measured memory_bytes: 4748
#include<cstdio>

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

using namespace std;

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

int h,w,B[10][10];

int n,x[36],y[36],id[10][10];

int cen,type;
void f(int x1,int y1,int &x2,int &y2){
	x1-=x[0];
	y1-=y[0];

	if(type>=4) y1*=-1; // 裏返し
	if     (type==0 || type==4) x2= x1, y2= y1; // そのまま
	else if(type==1 || type==5) x2=-y1, y2= x1; // 90 度回転
	else if(type==2 || type==6) x2=-x1, y2=-y1; // 180 度回転
	else if(type==3 || type==7) x2= y1, y2=-x1; // 270 度回転

	x2+=x[cen];
	y2+=y[cen];
}

// f の逆変換
void g(int x1,int y1,int &x2,int &y2){
	x1-=x[cen];
	y1-=y[cen];

	if     (type==0 || type==4) x2= x1, y2= y1; // そのまま
	else if(type==1 || type==5) x2= y1, y2=-x1; // 270 度回転
	else if(type==2 || type==6) x2=-x1, y2=-y1; // 180 度回転
	else if(type==3 || type==7) x2=-y1, y2= x1; // 90 度回転
	if(type>=4) y2*=-1; // 裏返し

	x2+=x[0];
	y2+=y[0];
}

int used[36]; // A に割り当てるなら 1, B に割り当てるなら 2, 未割り当てなら 0

bool is_connected(int tar){
	int cnt=0;
	bool vis[36]={};

	int Q[32],head=0,tail=0;
	rep(i,n) if(used[i]==tar) { vis[i]=true; Q[tail++]=i; break; }
	while(head<tail){
		int i=Q[head++],x1=x[i],y1=y[i];
		cnt++;
		rep(k,4){
			int x2=x1+dx[k],y2=y1+dy[k];
			if(0<=y2 && y2<h && 0<=x2 && x2<w && B[y2][x2]==1){
				int i2=id[y2][x2];
				if(used[i2]==tar && !vis[i2]){
					vis[i2]=true;
					Q[tail++]=i2;
				}
			}
		}
	}
	return cnt==n/2;
}

bool dfs(int i,int now){
	if(now==n/2) return is_connected(1) && is_connected(2);

	if(now+(n-i)<n/2) return false;

	if(used[i]!=0) return dfs(i+1,now);

	int xx,yy;
	// ブロック i を A に割り当てる
	f(x[i],y[i],xx,yy);
	if(0<=yy && yy<h && 0<=xx && xx<w && B[yy][xx]==1){
		int i2=id[yy][xx];
		if((x[i]!=xx || y[i]!=yy) && used[i2]==0){
			used[i]=1;
			used[i2]=2;
			if(dfs(i+1,now+1)) return true;
			used[i]=used[i2]=0;
		}
	}

	// ブロック i を B に割り当てる
	g(x[i],y[i],xx,yy);
	if(0<=yy && yy<h && 0<=xx && xx<w && B[yy][xx]==1){
		int i2=id[yy][xx];
		if((x[i]!=xx || y[i]!=yy) && used[i2]==0){
			used[i]=2;
			used[i2]=1;
			if(dfs(i+1,now+1)) return true;
			used[i]=used[i2]=0;
		}
	}

	return false;
}

int main(){
	for(;scanf("%d%d",&w,&h),w;){
		rep(i,h) rep(j,w) scanf("%d",B[i]+j);

		n=0;
		rep(i,h) rep(j,w) if(B[i][j]==1) {
			x[n]=j;
			y[n]=i;
			id[i][j]=n;
			n++;
		}

		if(n%2==1){ puts("NO"); continue; }

		rep(i,n) used[i]=0;
		for(cen=1;cen<n;cen++) for(type=0;type<8;type++) if(dfs(0,0)) goto FOUND;

		puts("NO");
		continue;

		FOUND:
		puts("YES");
	}

	return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
	int n, m , x;
	cin >> n >> m >> x;
	int cntL = 0, cntR = 0;
	rep(i, m) {
		int a; cin >> a;
		if (a < x) cntL++;
		else if (a > x) cntR++;
	}
	cout << min(cntL, cntR) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int N,M,Q;
int *a = new int[50];
int *b = new int[50];
int *c = new int[50];
int *d = new int[50];
int *A = new int[10];
int ans = 0;
int cnt = 0;

void solve(int j, int min){
    
    if(j == N-1){
        for(int i=min;i<M+1;i++){
            A[j] = i;
            // cout << j << "---------------------------------------" <<  A[j] << endl;
            int sum = 0;
            for(int k=0;k<Q;k++){

                if((A[b[k]-1] - A[a[k]-1]) == c[k]){
                    sum += d[k];
                    
                }
            }
            // cout << "sum is :" << sum << endl;
            if(ans < sum){
                ans = sum;
            }
            cnt++;
        }
        
    }else{
        for(int i=min;i<M+1;i++){
            A[j] = i;
            // cout << j << "---------------------------------------" <<  A[j] << endl;
            solve(j+1,i);
            
        }
        
    }
    
}

int main() {
    cin >> N;
    cin >> M;
    cin >> Q;
    
    for(int i=0;i<Q;i++){
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
        cin >> d[i];
    }
    // for(int i=0;i<Q;i++)
    //     cout << a[i] << b[i] << c[i] << d[i] << endl;
    solve(0,1);
    // cout << cnt << endl;
    cout << ans << endl;
	return 0;
}

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


int main()
{
    long long int n,mm[100005],fii=1,poo=1;
    mm[0]=0;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>mm[i];
    sort(mm,mm+n);
    long long int anst;
    double t=mm[n-1]/2.0,ans=10000000000;
    for(int i=0;i<n;i++)
    {
       double tmp=fabs(t-double(mm[i]));
       if(tmp<ans)
       {
           ans=tmp;
           anst=mm[i];
       }
    }
    cout<<mm[n-1]<<" "<<anst;
    return 0;
}

Measured memory_bytes: 1024
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '(L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int n,m;
std::multiset<LL> st;
LL d,t;
int main(){
 
   
    cin>>n;

    REP(i,n){
        cin>>d;
        st.insert(d);
    }
    cin>>m;
    REP(i,m){
        cin>>t;
       if(EXIST(st,t)){
           st.erase(st.find(t));
           goto NEXT;
       }
        cout<<"NO"<<endl;
        exit(0);
        NEXT:;
    }

    cout<<"YES"<<endl;

}


Measured memory_bytes: 9600
#include<stdio.h>

int main(){
    int a,n,m;
    a=1;
    n=0;
    m=1;
    while(m==1){
    scanf("%d",&n);
    if(n==0){
        break;
    }
    printf("Case %d: %d\n",a,n);
    a=1+a;
    }
    return 0;
}



Measured memory_bytes: 1972
#include <iostream>

using namespace std;

struct Node{
  int parent, left, right;
};

int n;
Node T[30];
int D[30], H[30];

void depth(int u, int d){
  if(u == -1) return;
  D[u] = d;
  depth(T[u].left, d+1);
  depth(T[u].right, d+1);
}

int height(int u){
  int ret1 = 0, ret2 = 0;
  if(T[u].left != -1) ret1 = height(T[u].left) + 1;
  if(T[u].right != -1) ret2 = height(T[u].right) + 1;
  return (H[u] = max(ret1, ret2));
}

signed main(){
  cin >> n;
  int u, l, r;

  for(int i = 0 ; i < 30 ; i++){
    T[i].parent = T[i].left = T[i].right = -1;
  }

  for(int i = 0 ; i < n ; i++){
    cin >> u >> l >> r;
    T[u].left = l;
    T[u].right = r;
    if(l != -1) T[l].parent = u;
    if(r != -1) T[r].parent = u;
  }

  int root;
  for(int i = 0 ; i < n ; i++){
    if(T[i].parent == -1) root = i;
  }
  
  depth(root, 0);
  height(root);
  
  for(int i = 0 ; i < n ; i++){
    cout << "node " << i << ": ";
    cout << "parent = " << T[i].parent << ", ";
    cout << "sibling = ";
    if(T[i].parent == -1){
      cout << -1 << ", ";
    }else if(T[T[i].parent].left != -1 && T[T[i].parent].left != i){
      cout << T[T[i].parent].left << ", ";
    }else if(T[T[i].parent].right != -1 && T[T[i].parent].right != i){
      cout << T[T[i].parent].right << ", ";
    }else{
      cout << -1 << ", ";
    }
    cout << "degree = " << (T[i].left!=-1?1:0)+(T[i].right!=-1?1:0) << ", ";
    cout << "depth = " << D[i] << ", ";
    cout << "height = " << H[i] << ", ";
    if(root == i) cout << "root" << endl;
    else if(T[i].left != -1 || T[i].right != -1) cout << "internal node" << endl;
    else cout << "leaf" << endl;
  }

}



Measured memory_bytes: 3088
#include <iostream>
#include <string>

int cal(const std::string S[], int i, int j, int W, int H) {
  int n_bombs = 0;
  if ( i-1 >= 0 && j-1 >=0 ) {
    if ( S[i-1][j-1] == '#' ) n_bombs++;
  }

  if ( i-1 >= 0 ) {
    if ( S[i-1][j] == '#' ) n_bombs++;
  }

  if ( i-1 >=0 && j+1 < W ) {
    if ( S[i-1][j+1] == '#' ) n_bombs++;
  }

  if ( j-1 >= 0 ) {
    if ( S[i][j-1] == '#' ) n_bombs++;
  }

  if ( j+1 < W ) {
    if ( S[i][j+1] == '#' ) n_bombs++;
  }

  if ( i+1 < H && j+1 < W ) {
    if ( S[i+1][j+1] == '#' ) n_bombs++;
  }

  if ( i+1 < H ) {
    if ( S[i+1][j] == '#' ) n_bombs++;
  }

  if ( i+1 < H && j-1 >= 0 ) {
    if ( S[i+1][j-1] == '#' ) n_bombs++;
  }
  return n_bombs;
}

int main()
{
  int H, W;
  std::cin >> H >> W;
  
  std::string S[H];
  for ( int i = 0; i < H; i++ ) std::cin >> S[i];
  std::string C[H];
  
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      if ( S[i][j] == '.' ) {
        int n_bombs = cal(S, i, j, W, H);
        // std::cerr << n_bombs << std::endl;
        C[i] += std::to_string(n_bombs);
      } else {
        C[i] += '#';
      }
    }
  }
  for ( int i = 0; i < H; i++ ) {
    for ( int j = 0; j < W; j++ ) {
      std::cout << C[i][j];
    }
    std::cout << std::endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans = 1;
        for (int i=0;i<n;i++) {
            if (i==0) {
                ans *= k;
            } else {
                ans *= k-1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

string s, t;

int dp[3010][3010];

int main() {
    cin >> s >> t;

    for (int i = 0; i <= s.size(); i++) {
        for (int j = 0; j <= t.size(); j++) dp[i][j] = 0;
    }

    for (int i = 0; i <= s.size(); i++) {
        for (int j = 0; j <= t.size(); j++) {
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]);
            if (i < s.size() && j < t.size()) {
                if (s[i] == t[j]) dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1);
            } 
        }
    }

    /*
    for (int i = 0; i <= s.size(); i++) {
        for (int j = 0; j <= t.size(); j++) {
            cout << dp[i][j] << " ";    
        }
        cout << endl;
    }
    */

    string ans = "";
    int i = s.size(), j = t.size();
    for (int k = dp[s.size()][t.size()]; k > 0; k--) {
        for (int l = i; dp[l][j] == k; l--) i = l;
        for (int l = j; dp[i][l] == k; l--) j = l;
        i--;
        j--;
        ans += s[i];
    }
    
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
a,b,c=[0,0],[0,0],[0,0]
a[0],b[0],c[0]=map(int,input().split())
hist=[[a[0],b[0],c[0]]]
i=1
while(1):
  if(a[(i+1)%2]%2==1 or b[(i+1)%2]%2==1 or c[(i+1)%2]%2==1):
    break
  a[i%2]=b[(i+1)%2]/2+c[(i+1)%2]/2
  b[i%2]=a[(i+1)%2]/2+c[(i+1)%2]/2
  c[i%2]=b[(i+1)%2]/2+a[(i+1)%2]/2
  ch=[a[i%2],b[i%2],c[i%2]]
  if(ch in hist):
    i=0
    break
  hist.append(ch)
  i+=1
print(i-1)

Measured memory_bytes: 3064
#include<stdio.h>
char *P[]={"No","Yes"}, p;
int n, m, k;
int a, b;
int main(void){
  scanf("%d%d%d", &n, &m, &k);
  for(a=0; a<=n; a++){
    for(b=0; b<=m; b++){
      if((m-b)*a+(n-a)*b==k){p=1; break;}
    }
  }
  puts(P[p]);
}


Measured memory_bytes: 128