akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
//区間加算・区間和クエリ
struct LasySegmentTree {
    int n;
    vector<ll> node, lazy;
    
    LasySegmentTree(vector<ll> v) {
        int sz=sz(v);
        n=1;
        while(n<sz) n*=2;
        node.resize(2*n-1);
        lazy.resize(2*n-1);
        
        rep(i,sz) node[i+n-1]=v[i];
        rrep(i,n-2) node[i]=node[i*2+1]+node[i*2+2];
    }
    
    void eval(int k,int l,int r) {
        if(lazy[k]!=0) {
            node[k]+=lazy[k];
            if(r-l>1) {
                lazy[2*k+1]+=lazy[k]/2;
                lazy[2*k+2]+=lazy[k]/2;
            }
        }
        lazy[k]=0;
    }
    
    void add(int a,int b,ll x,int k=0,int l=0,int r=-1) {
        if(r<0) r=n;
        eval(k,l,r);
        if(b<=l || r<=a) return;
        
        if(a<=l && r<=b) {
            lazy[k]+=(r-l)*x;
            eval(k,l,r);
        }
        else {
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            node[k]=node[2*k+1]+node[2*k+2];
        }
    }
    
    ll getsum(int a,int b,int k=0,int l=0,int r=-1) {
        if(r<0) r=n;
        if(b<=l || r<=a) return 0;
        
        eval(k,l,r);
        if(a<=l && r<=b) return node[k];
        ll vl=getsum(a,b,2*k+1,l,(l+r)/2);
        ll vr=getsum(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }
};

int main() {
    int n,k,q;
    cin>>n>>k>>q;
    vector<ll> v(n,k);
    LasySegmentTree segt(v);
    
    while(q--) {
        int a;
        cin>>a;
        a--;
        segt.add(0,a,-1);
        segt.add(a+1,n,-1);
    }
    rep(i,n) {
        if(segt.getsum(i,i+1)<=0) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  string s;
  cin >> s;

  map<char, int> m;

  REP(i, s.size()) m[s[i]]++;

  for(char i = 'a'; i <= 'z'; i++){
    if(m[i] == 0){
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
 int n,k;cin>>n>>k;
 vector<int> v(n);
 for(int i=0;i<n;i++)cin>>v[i];
 vector<bool> dp(k+1,0);
 for(int i=0;i<=k;i++){
     for(int a:v){
         if(i-a>=0&&!dp[i-a])dp[i]=1;
     }
 } 
if(dp[k])cout<<"First";
else cout<<"Second";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)    //repeat from n to 0
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
typedef long long ll;
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(ll *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(ll *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int MOD = 1000000007;
const int INF = 1000000000;
 
int pascalTri(int n,int r){
	int tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]%MOD+tri[i-1][j]%MOD)%MOD;}
		}
	}
	return tri[n][r];
}
 
const int DX4[4]= {-1,0,0,1};
const int DY4[4]= {0,-1,1,0};
 
int main(){
	int n;
	int i,j,k;
 
	SCAN(&n);
	ll a[n],b[n],c[n];
	SCAN(a,n);SCAN(b,n);SCAN(c,n);
	SORTA(a);SORTA(b);SORTA(c);

	ll compab[n];
	ll compbc[n];
	fill(compab,compab+n,0);
	fill(compbc,compbc+n,0);
	
	REP(i,n){
		compab[i]=lower_bound(a,a+n,b[i])-a;
		compbc[i]=(c+n)-upper_bound(c,c+n,b[i]);
	}

	ll cnt=0;
	REP(i,n){
		cnt+=compab[i]*compbc[i];
	}
 
	printf("%lld\n",cnt);
 
	return 0;
}


Measured memory_bytes: 4096
# Enter your code here. Read input from STDIN. Print output to STDOUT

import numpy as np
from sys import stdin


def get_result(data):
    H, N = data[0]
    A = sorted(data[1])
    return 'No' if sum(A[:N]) < H else 'Yes'

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


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

int main() {
  long long int n;
  cin >> n;
  int sn = (int)sqrt(n);
  //cout << sn << endl;
  int maxDigits = 10;
  for (int i=1; i<=sn; i++) {
    int rem = n % i;
    if (rem == 0) {
      //      cout << "cand = " << i << ", " << n / i << endl;
      int digits = 1;
      long long int checki = n / i;
      while (checki / 10 > 0) {
	checki /= 10;
	digits++;
      }
      maxDigits = min(digits, maxDigits);
    }
  }
  cout << maxDigits << endl;
}

    


Measured memory_bytes: 256
#include<stdio.h>

int linearSearch(int a[],int n,int key){
  int i=0;
  a[n]=key;
  while(a[i]!=key)i++;
  if(i==n){return 0;}
  else{return 1;}
}

int main(){
  int i,ary[10001],judge=0,n,key,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ary[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(linearSearch(ary,n,key))judge++;
  }
  printf("%d\n",judge);
  return 0;
}

  



Measured memory_bytes: 2068
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    switch (N)
    {
    case 1:
    {
        cout << "Hello World" << endl;
    }
    break;
    case 2:
    {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }
    break;
    default:
    {
        assert(false);
    }
    break;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,tot1,tot2;
int a[105],b[105];
int main()
{
    scanf("%d%d%d%d",&n,&m,&x,&y);
    for(register int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(register int i=1;i<=m;i++)
        scanf("%d",&b[i]);
    sort(a+1,a+n+1);
    sort(b+1,b+m+1);
    tot1=a[n];
    tot2=b[1];
    if(tot1>=tot2||tot1>=y||tot2<=x)
        printf("War\n");
    else printf("No War\n");
    return 0;
}

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

#define ll long long

inline ll read() {
    ll x = 0, f = 1; char ch = getchar();
    for(; ch < '0' || ch>'9'; ch = getchar())
        if(ch == '-') f = -f;
    for(; ch >= '0' && ch <= '9'; ch = getchar())
        x = x * 10 + ch - '0';
    return x * f;
}

inline void chkmin( int &a, int b ) { if(a > b) a = b; }

inline void chkmax( int &a, int b ) { if(a < b) a = b; }

#define _ read()

#define ln endl

int main()
{
	int n = _;
	for( int i = 1; i <= n; i++ ) 
	{
		int x = 1.08 * i;
		if(x == n )
			return printf("%d\n", i), 0;
	}
	puts(":(");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

int N,M;
unordered_set<int> a;


int main()
{

	cin >> N;
	cin >> M;


	for (int i = 0; i < M; i++) {
		int tmp;
		cin >> tmp;
		a.insert(tmp);
	}

	int fn1 = 1;
	int fn2 = 0;
	for (int i = 1; i <= N; i++) {
		if (a.find(i) == a.end()) {
			int tmp = (fn1 + fn2) % 1000000007;
			fn2 = fn1;
			fn1 = tmp;
		}
		else {
			if (fn1 == 0) {
				break;
			}
			else {
				fn2 = fn1;
				fn1 = 0; 
			}
		}
	}

	int ans = fn1;

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 4388
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#define int long long
using namespace std;

signed main() {
	int a; cin >> a;
	int sum = 0;
	for (int b = 0; b < a; b++) {
		int c; scanf("%d", &c);
		sum += c;
	}
	if (sum & 1) {
		puts("NO");
	}
	else {
		puts("YES");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	VLL X(N), sorted(N);
	for(int i = 0 ; i < N ; i++){
		cin >> X[i];
		sorted[i] = X[i];
	}

	sort(ALL(sorted));
	int med = (sorted[(N - 1) / 2] + sorted[(N - 1) / 2 + 1]) / 2;
	for(int i = 0 ; i < N ; i++){
		if(X[i] <= med)   cout << sorted[(N - 1) / 2 + 1] << endl;
		else              cout << sorted[(N - 1) / 2]     << endl;
	}

	return 0;
}


Measured memory_bytes: 5376
n=input()
s=[]
n=int(n)
i=0
while n!=0:
  if n%2**(i+1)==0:
    s.append("0")
  else:
    s.append("1")
    n-=(-2)**i
  i+=1
s.reverse()
if s==[]:
  s=["0"]
print("".join(s))

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

#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  int m,k; cin>>m>>k;

  if ((1LL<<m)<=k) {
    cout << -1 << endl;
    return;
  }
  if (m==1 && k==1) {
    cout << -1 << endl;
    return;
  }
  if (m==1 && k==0) {
    cout << "0 0 1 1" << endl;
    return;
  }

  for (int i=0; i<(1<<m); i++) {
    if (i!=k) cout << i << " ";
  }
  cout << k << " ";
  for (int i=(1<<m)-1; i>=0; i--) {
    if (i!=k) cout << i << " ";
  }
  cout << k << endl;
}

int main()
{
  solve();
  return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll A;
char S[20];
int main(){
    scanf("%lld%s", &A,S);
    if(A>=3200){
        printf("%s", S);
    }else{
        printf("red");
    }
    return 0;
}

Measured memory_bytes: 256
using System;
class P{
    static void Main(){
        char[] n = Console.ReadLine().ToCharArray();
        foreach (var c in n){
            if (c == '1') {
                Console.Write(9); continue;
            }
            if (c == '9'){
                Console.Write(1); continue;
            }
            Console.Write(c);
        }
        Console.WriteLine();
    }
}

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

int main(){
    int A, B, C, K, a = 1, b = 0, c = -1, res = 0;
    scanf("%d %d %d %d", &A, &B, &C, &K);
    K -= A;
    if (K < 0){
        A -= abs(K);
        res += A*a;
        cout << res << endl;
        return 0;
    }
    else if (K == 0){
        res += A*a;
        cout << res << endl;
        return 0;
    }
    else res += A*a;
    K -= B;
    if (K < 0){
        B -= abs(K);
        res += B*b;
        cout << res << endl;
        return 0;
    }
    else if (K == 0){
        res += B*b;
        cout << res << endl;
        return 0;
    }
    else res += B*b;
    K -= C;
    if (K < 0){
        C -= abs(K);
        int q = C*c;
        if (q > 0) q = abs(q);
        res += q;
        cout << res << endl;
        return 0;
    }
    else if (K == 0){
        int q = C*c;
        if (q > 0) q = abs(q);
        res += q;
        cout << res << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3804
n = int(input())
a = list(map(int, input().split()))
A = list(set(a))
A.sort()
ans = "No"
if len(A) == 1:
    if A[0] == 0:
        ans = "Yes"
elif len(A) == 2:
    if A[0] == 0:
        if a.count(A[1]) == 2* (n // 3) :
            ans = "Yes"
elif len(A) == 3:
    if A[0]^A[1]^A[2] == 0:
        if a.count(A[0]) == n//3:
            if a.count(A[1]) == n//3:
                if a.count(A[2]) == n//3:
                    ans = "Yes"
print(ans)

Measured memory_bytes: 14116
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
              Scanner sc = new Scanner(System.in);
              int i = 0;
              while(true){
                i++;
                int a = sc.nextInt();
                if(a == 0) break;
                else System.out.printf("Case %d: %d\n", i, a);
               
            }
            
             sc.close();
        }
}


Measured memory_bytes: 66568
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
typedef long long int64;

int W, H;
int f, m, o;
int c[10][10];

int64 dp[10][10][51][1 << 10];
int64 rec(int x, int y, int air, int dig)
{
  if(x < 0 || x >= W || air <= 0) return(INF);
  if(y + 1 == H) return(max(0, -c[y][x]));
  air = min(m, air + max(0, c[y][x]) * (1 - ((dig >> x) & 1)));
  if(~dp[x][y][air][dig]) return(dp[x][y][air][dig]);
  int64 ret = INF;
  ret = min(ret, rec(x - 1, y, air - 1, dig|(1 << x)));
  ret = min(ret, rec(x + 1, y, air - 1, dig|(1 << x)));
  ret = min(ret, rec(x, y + 1, air - 1, 0));
  return(dp[x][y][air][dig] = min< long long >(INF, ret + (1 - ((dig >> x) & 1)) * max(0, -c[y][x])));
}
main()
{
  while(cin >> W >> H, W) {
    fill_n(***dp, 10 * 10 * 51 * (1 << 10), -1);
    cin >> f >> m >> o;
    for(int i = 0; i < H; i++) {
      for(int j = 0; j < W; j++) {
        cin >> c[i][j];
      }
    }
    int64 ret = INF;
    for(int i = 0; i < W; i++) {
      ret = min(ret, rec(i, 0, o - 1, 0));
    }
    if(ret > f) cout << "NA" << endl;
    else cout << ret << endl;
  }
}

Measured memory_bytes: 41996
N_string = input()
l = len(N_string)
N = int(N_string)
K = int(input())

n = int(N_string[0])
dp0 = [[n - 1, 0, 0]]
dp1 = [[1, 0, 0]]

for i in range(l - 1):
    n = int(N_string[i + 1])
    if n == 0:
        dp0.append([9 + dp0[i][0],
                    dp0[i][0] * 9 + dp0[i][1],
                    dp0[i][1] * 9 + dp0[i][2]])
        dp1.append([dp1[i][0], dp1[i][1], dp1[i][2]])
    else:
        dp0.append([9 + dp0[i][0] + dp1[i][0],
                    dp0[i][0] * 9 + dp0[i][1] + dp1[i][0] * (n - 1) + dp1[i][1],
                    dp0[i][1] * 9 + dp0[i][2] + dp1[i][1] * (n - 1) + dp1[i][2]])
        dp1.append([0, dp1[i][0], dp1[i][1]])
print(dp0[-1][K - 1] + dp1[-1][K - 1])

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static boolean[] isPrime = new boolean[10001];

	public static void main(String[] args) {
		for (int i = 2; i <= 10000; ++i) {
			isPrime[i] = isPrime(i);
		}
		while (sc.hasNext()) {
			int N = sc.nextInt();
			int ans = 0;
			for (int i = 1; i <= N; ++i) {
				if (isPrime[i] && isPrime[N - i + 1]) ++ans;
			}
			System.out.println(ans);
		}
	}

	static boolean isPrime(int v) {
		for (int i = 2; i * i <= v; ++i) {
			if (v % i == 0) return false;
		}
		return true;
	}
}

Measured memory_bytes: 12000
import sys
from collections import Counter

N = int(input())
D = [int(x) for x in input().split()]
D_counter = Counter(D)
ans = 1

if D_counter[0] != 1 or D[0] != 0:
    print(0)
    sys.exit()

for d in D_counter:
    if d - 1 in D_counter:
        ans *= (D_counter[d - 1] ** D_counter[d]) % 998244353
        ans = ans % 998244353
    else:
        if not d == 0:
            print(0)
            sys.exit()
print(ans)


Measured memory_bytes: 19936
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	int k = 0, n = 0, m = 0;
	string a;
	cin >> a;
	if (a[0] == 'A')k++;
	for (int i = 2; i < a.size() - 1; i++) {
		if (a[i] == 'C')n++;
	}
	for (int j = 0; j < a.size(); j++) {
		if (a[j] >= 'a')m++;
	}
	if (k == 1 && n == 1 && m == a.size() - 2)cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll>A(N);
  for (int i = 0; i < N; i ++) cin >> A[i];
  ll mi = 1;
  ll ma = 1e9;
  while (mi != ma) {
    ll mu = (mi + ma) / 2;
    ll kj = 0;
    for (int i = 0; i < N; i ++) {
      kj += ((A[i] - 1) / mu);
    }
    if (kj <= K) ma = mu;
    else mi = mu + 1;
  }
  cout << mi << endl;
}


Measured memory_bytes: 4756
N, L = [int(i) for i in input().split()]
taste = [L + i - 1 for i in range(1, N + 1)]
absolute = float('inf')
ans = float('inf')
total = sum(taste)
for i in range(N):
    total_b = sum(taste[:i] + taste[i + 1:])
    if abs(total - total_b) < absolute:
        ans = total_b
        absolute = abs(total - total_b)
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		var N = G[0];
		var A = G;
		WriteLine(FirstBinary(1, N, p => Check(A, p)));
	}
	int FirstBinary(int min, int max, Predicate<int> pred)
	{
		while (min < max)
		{
			var mid = (min + max) / 2;
			if (pred(mid)) max = mid;
			else min = mid + 1;
		}
		return min;
	}
	bool Check(int[] A, int P)
	{
		var S = new Integer(A[0], P);
		foreach (var a in A.Skip(1))
			if (a > S.Length) S.Add(a - S.Length);
			else
			{
				S.Take(a);
				if (!S.Increment()) return false;
			}
		return true;
	}
}
struct Block
{
	public readonly int Num, Count;
	public Block(int n, int c) { Num = n; Count = c; }
}
class Integer
{
	readonly Stack<Block> blocks;
	readonly Stack<int> sum; // sum[n] = Sum(i in [0,n), blocks[i].Count)
	public int Length => sum.Peek();
	public readonly int P;
	public Integer(int n, int p) { blocks = new Stack<Block>(); blocks.Push(new Block(0, n)); sum = new Stack<int>(); sum.Push(0); sum.Push(n); P = p; }
	public void Add(int c) => Push(new Block(0, c));
	Block Pop()
	{
		var x = blocks.Pop();
		sum.Pop();
		return x;
	}
	void Push(Block b)
	{
		if (b.Count == 0) return;
		Block p = b;
		if (Length > 0 && blocks.Peek().Num == b.Num) p = new Block(b.Num, b.Count + Pop().Count);
		blocks.Push(p);
		sum.Push(Length + p.Count);
	}
	public void Take(int c)
	{
		var b = new Block();
		while (Length > c) b = Pop();
		if (Length < c) Push(new Block(b.Num, c - Length));
	}
	public bool Increment()
	{
		var b = Pop();
		var x = b.Num;
		var n = b.Count;
		if (x == P - 1 && Length == 0) return false;
		// y*m x*n => y*(m-1) (y+1)*1 0*n
		if (x == P - 1)
		{
			b = Pop();
			var y = b.Num;
			var m = b.Count;
			Push(new Block(y, m - 1));
			Push(new Block(y + 1, 1));
			Push(new Block(0, n));
		}
		// x*n => x*(n-1) (x+1)*1
		else
		{
			Push(new Block(x, n - 1));
			Push(new Block(x + 1, 1));
		}
		return true;
	}
}


Measured memory_bytes: 34140
import java.util.Scanner;

public class Main
{

    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();

        if (a == b && c == d || b == c && a == d || a == c && b == d) {
            System.out.println("yes");

        } else {
            System.out.println("no");
        }

    }

}



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

struct action {
	int type, val;
	action(){type = 0; val = 0;}
	action(int t, int v) {
		type = t; val = v;
	}
};

action cell[128];
double prob[128][5010][2];

int main() {
	int X, Y, Z;
	while(cin >> X >> Y >> Z, X || Y || Z) {
		vector<int> roulette;
		for(int i = 0; i < 128; i++) {
			cell[i] = action();
			for(int j = 0; j < 5010; j++) {
				prob[i][j][0] = prob[i][j][1] = 0;
			}
		}
		prob[0][0][0] = 1;
		for(int i = 0; i < X; i++) {
			int tmp;
			cin >> tmp;
			roulette.push_back(tmp);
		}
		for(int i = 0; i < 128; i++)
			cell[i] = action();
		for(int i = 0; i < Z; i++) {
			int N, E, A;
			cin >> N >> E >> A;
			cell[N] = action(E,A);
		}

		for(int i = 0; i <= Y; i++) {
			if(cell[i].type == 1) for(int j = 0; j < 5010; j++) {
				prob[i+cell[i].val][j][1] += prob[i][j][0];
			}
			for(int j = 0; j < roulette.size(); j++) {
				int add = 0;
				if(cell[i+roulette[j]].type == 2)
					add = cell[i+roulette[j]].val;
				else if(cell[i+roulette[j]].type == 3)
					add = -cell[i+roulette[j]].val;
				for(int k = 0; k < 5010; k++) {
					if(cell[i].type != 1)
						prob[i+roulette[j]][max(k+add,0)][0]
							+= prob[i][k][0] / (double)roulette.size();
					prob[i+roulette[j]][max(k+add,0)][0]
						+= prob[i][k][1] / (double)roulette.size();
				}
			}
		}

		double res = 0;
		for(int i = Y+1; i < Y+16; i++) {
			for(int j = 0; j < 5010; j++) {
				res += j * (prob[i][j][0] + prob[i][j][1]);
			}
		}
		res += 1e-9;
		cout << (int)res << endl;
	}
}

Measured memory_bytes: 11236
import sys

n, m = map(int, input().split(" "))
ab = [[int(m) for m in input().split(" ")] for i in range(m)]

roads_count = [0 for i in range(n)]
for a_i, b_i in ab:
    if a_i != b_i:
        roads_count[a_i-1] += 1
        roads_count[b_i-1] += 1
[print(num) for num in roads_count]

Measured memory_bytes: 3064
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
void rsort_d32(void *base, const int count);

int32_t v[50];
int32_t h[50];

int bs(int x, int l, int r){
	while(l<=r){
		int m=(l+r)/2;
		if(h[m]>=x) r=m-1; else l=m+1;
	}
	return l;
}

int main(void){
	uint32_t n=nextint();
	uint32_t k=nextint();
	uint32_t m=n>k?k:n;
	for(uint32_t i=0; i<n; i++){
		v[i]=nextint();
	}
	int64_t ans=INT64_MIN;
	for(int32_t i=m; i>=0; i--){
		for(int32_t j=m-i; j>=0; j--){
			int32_t l=k-i-j;
			memcpy(h, v, i*sizeof(int32_t));
			memcpy(h+i, v+(n-j), j*sizeof(int32_t));
			rsort_d32(h, i+j);
			int32_t K=bs(0, 0, i+j-1);
			if(K>l) K=l;
			int64_t now=0;
			for(int s=i+j-1; s>=K; s--) now+=h[s];
			if(now>ans) ans=now;
			//printf("%d %d: %ld: ", i, j, now);
			//for(int s=0; s<i+j; s++){printf("%d ", h[s]);} putchar(10);
		}
	}
	printf("%"PRId64"\n", ans);
}

void rsort_d32(void *base, const int count){
	int32_t *a=base;
	int32_t *b=malloc(count*sizeof(int32_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))+0x80]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))+0x80]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}


Measured memory_bytes: 128
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static int N;
    public static HashSet<Integer> hs;
    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        N = sc.nextInt();
        double[] ps = new double[N+1];
        double[][] dp = new double[N+1][N+1];

        for(int i=1; i<=N; ++i) {
            ps[i] = sc.nextDouble();
        }

//        for(int ij=0; ij<=N; ++ij) {
//            dp[0][ij] = 1;
//            dp[ij][0] = 1;
//        }

        dp[0][0] = 1;

        // i동전까지 고려 했을 때, Head가 j번 나올 확률
        for(int i=1; i<=N; ++i) {
            for(int j=0; j<=i; ++j) {
                if(j-1>=0)
                    dp[i][j] += dp[i-1][j-1] * ps[i];
                dp[i][j] += dp[i-1][j] * (1-ps[i]);
            }
        }

//        d0(dp);

        int k = (N>>1) + 1;
        double p = 0;
        for(int j=k; j<=N; ++j) {
            p += dp[N][j];
        }

        pw.printf("%1.10f\n", p);
        pw.close();
    }

    public static void d0(double[][] dp) {
        System.out.print("    ");

        for(int j=0; j<dp[0].length; ++j){
            System.out.printf("%3d ", j);
        }
        System.out.println();

        for(int i=0; i<dp.length; ++i){
            System.out.printf("%d|", i);
            for(int j=0; j<dp[0].length; ++j){
                System.out.printf("%f ", dp[i][j]);
            }
            System.out.println();
        }
    }
}


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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
     int n; cin >> n;
     vector<int> lis(n);
     REP(i, 0, n){cin >> lis[i];}
     sort(ALL(lis));
     ll ans = 0;
     for(int i = n-1; i >= 2; i--){
         for(int l = i - 1; l >= 1; l--){
             int a = lis[i], b = lis[l];
             int rr = lis[0], ll = lis[l-1];
             //cout << rr << ll << endl;
             while(ll - rr != 0){
                 int c = (ll + rr) / 2;
                 if(a < b + c){
                     if(ll == c){break;}
                     ll = c;
                 }else{
                     if(rr == c){break;}
                     rr = c;
                 }
                 if(rr > ll){
                     int x = rr; rr = ll; ll = x;
                 }
             }
             //cout << ll << rr << endl;
             int check;
             if(a < b + ll){
                 check = ll;
             }else{
                 check = rr;
             }
             if(!(a < b + check)){continue;}
             //cout << check << endl;
            auto it = lower_bound(ALL(lis), check);
            //cout << a << b << "check" <<  check << "num" << it - lis.begin()<< endl;
            ans += l -  (it - lis.begin());
         }
     }
     cout << ans << endl;
}

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

int mod = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<char>> A(N, vector<char>(N));
    vector<vector<char>> B(M, vector<char>(M));
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < M; i++)
    {
        for (int j = 0; j < M; j++)
        {
            cin >> B[i][j];
        }
    }

    bool ans = false;
    for (int i = 0; i < N - M + 1; i++)
    {
        for (int j = 0; j < N - M + 1; j++)
        {
            bool x = false;//違う画素があるか
            for (int k = 0; k < M ; k++)
            {
                for (int l = 0; l < M ; l++)
                {
                    if (A[i + k][j + l] != B[k][l])
                        x = true;
                }
            }
            if(!x)
                ans = true;
            if (ans)
                break;
        }
        if(ans)
            break;
    }
    cout << (ans ? "Yes" : "No");
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
words = np.array([input() for _ in range(N)])
if len(set(words))<N:
    print('No')
else:
    count=0
    for i in range(N-1):
        if words[i][-1] == words[i+1][0]:
            count+=1
    if count==N-1:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 12508
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int32_t main()
{
	IOS
	int N,W;cin>>N>>W;
	vector<int>dp(W+1);
	for(int i=0;i<N;i++)
	{
		int w,v;cin>>w>>v;
		for(int j=W-w;j>=0;j--)
		{
			dp[j+w]=max(dp[j+w],dp[j]+v);
		}
	}
	cout << dp[W] << endl;
	
	
}


Measured memory_bytes: 1024
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

P = 0
for i in range(m):
    if p[i] == 1:
        P += 2**(m-i-1)
    
sum = 0
isAffectedSwitch=[[False for _ in range(n)] for _ in range(m)]
for i in range(m):
    for j in range(1,s[i][0]+1):
        isAffectedSwitch[i][s[i][j]-1]=True

C = []
for i in range(n):
    B = 0
    for j in range(m):
        if isAffectedSwitch[j][i] == True:
            B += 2**(m-j-1)
    C.append(B)

for i in range(2**n):
    A = 0
    for j in range(n):
        if ((i >> j)&1):
            A = A ^ C[j]
           
    if A == P:
        sum += 1
        
print(sum)

Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int a[100005],x,ans;
int main(){
	int n;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> x;
		a[x]++;
	}
	for(int i = 1;i <= 100003;i++){
		if(a[i]>1)ans+=(a[i]-1);
		}
	if(ans%2)ans+=1;
	cout << n - ans <<endl;
	return 0;
	}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn=1e5+10;
struct Node{
	int l,r;
	int a[50];
	bool operator <(const Node &other)const{
	    return (l*other.r<r*other.l);
	}
}q[maxn];
int n,m;
bool check(int x,int y){
	double k=0;
	for(int i=0;i<m;i++){
		k+=(q[x].a[i]-q[y].a[i])*(q[x].a[i]-q[y].a[i]);
	}
	k=sqrt(k);
	int t=(int) k;
	if(k-t<=1e-9) return 1;
	return 0;
}
int main(){
	
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>q[i].a[j];
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(i,j)) ans++;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn solve(a: usize, b: usize, c: usize, d: usize) -> bool {
    if a < b || b > d {
        return false;
    }
    if b <= c {
        return true;
    }

    let g = gcd(b, d);
    return b + a % g - g <= c;
}


fn main() {
    let t: usize = read();
    for _ in 0..t {
        let a: usize = read();
        let b: usize = read();
        let c: usize = read();
        let d: usize = read();

        println!("{}", if solve(a, b, c, d) {"Yes"} else {"No"})
    }
}

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


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

using namespace std;

int main(void){
    vector<int> v;
    int i,j;
    v.push_back(2);
    for(i = 3;i < 1000000;i++){
        for(j = 0;j < v.size();j++){
            if(i%v[j] == 0) break;
            if(v[j]*v[j] > i){
                v.push_back(i);
                break;
            }
        }
    }
    while(true){
        int a,d,n;
        cin >> a >> d >> n;
        if(!a) break;
        for(i = 0;i < v.size();i++){
            if((v[i]-a)%d == 0 && v[i] >= a){
                n--;
                if(!n){
                    cout << v[i] << endl;
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 1588
package main

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

/*-----------Main-----------*/

func main() {
	s := readS()
	if s == "ABC" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


Measured memory_bytes: 1780
#include<cstdio>
#include<cstring>
using namespace std;
int x,y,ans;
char s[100001];
int main(){
    scanf("%s",s);
    for(int i=0;i<strlen(s);i++){
    	if(x==y){
			x++;
			if(s[i]=='p') ans--;
		}
    	else{
			y++;
			if(s[i]=='g') ans++;
		}
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
n,m=map(int,input().split())
par=[i for i in range(n+1)]
size=[1]*(n+1)
def find(x):
  if par[x]==x:
    return x
  else:
    par[x]=find(par[x])
    return par[x]
def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return 0
  if size[x]<size[y]:
    size[y]+=size[x]
    par[x]=y
  else:
    size[x]+=size[y]
    par[y]=x
for i in range(m):
  a,b=map(int,input().split())
  unite(a,b)
print(max(size))

Measured memory_bytes: 18568
use std::io::*;
use std::str::FromStr;

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

fn main() {
  let n = read::<String>();
  let n_char: Vec<char> = n.chars().collect();
  let a = n_char[0].to_digit(10).unwrap() as i64;
  let b = n_char[1].to_digit(10).unwrap() as i64;
  let c = n_char[2].to_digit(10).unwrap() as i64;
  let d = n_char[3].to_digit(10).unwrap() as i64;

  if a + b + c + d == 7 {
    println!("{}+{}+{}+{}=7", a, b, c, d);
  } else if a + b + c - d == 7 {
    println!("{}+{}+{}-{}=7", a, b, c, d);
  } else if a + b - c + d == 7 {
    println!("{}+{}-{}+{}=7", a, b, c, d);
  } else if a - b + c + d == 7 {
    println!("{}-{}+{}+{}=7", a, b, c, d);
  } else if a - b - c + d == 7 {
    println!("{}-{}-{}+{}=7", a, b, c, d);
  } else if a + b - c - d == 7 {
    println!("{}+{}-{}-{}=7", a, b, c, d);
  } else if a - b + c - d == 7 {
    println!("{}-{}+{}-{}=7", a, b, c, d);
  } else if a - b - c - d == 7 {
    println!("{}-{}-{}-{}=7", a, b, c, d);
  }
}

Measured memory_bytes: 4352
/*
  -------------
  Prateek Celly
  DA-IICT
  -------------
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n,m,ans=0;
  cin>>n>>m;
  ll a[m],b[m],c[n+2]={};
  for(ll i=0;i<m;i++) {cin>>a[i]>>b[i]; c[a[i]]++; c[b[i]+1]--;}
  for(ll i=1;i<=n+1;i++) c[i]+=c[i-1];
  for(ll i=1;i<=n;i++) if(c[i]>=m) ans++;
  cout<<ans;
  return 0;
}


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

// ----------- define --------------
#define int long long
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    s.insert(t);
  }
  if (s.size() == n) cout << "YES" << '\n';
  else cout << "NO" << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 13032
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> costs(N);
    vector<vector<int>> vec(N, vector<int>(M));
    rep(i, N)
    {
        cin >> costs[i];
        rep(j, M)
        {
            cin >> vec[i][j];
        }
    }
    int mini = INF;
    int all_bit = pow(2, N);
    for (int i = 0; i < all_bit; i++)
    {
        // どの本を使用するか全探索
        vector<int> bt;
        int cp_i = i;
        for (int j = 0; j < N; j++)
        {
            int tmp = cp_i % 2;
            bt.push_back(tmp);
            cp_i /= 2;
        }
        vector<int> know(M, 0);
        int cost = 0;
        for (int j = 0; j < N; j++)
        {
            if (bt[j] == 1)
            {
                cost += costs[j];
                for (int k = 0; k < M; k++)
                {
                    know[k] += vec[j][k];
                }
            }
        }
        bool flag = true;
        for (int j = 0; j < M; j++)
        {
            if (know[j] < X)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            mini = min(mini, cost);
        }
    }
    if (mini == INF)
    {
        cout << -1 << endl;
        return 0;
    }
    cout << mini << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 4112
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const int i_INF = 2147483647;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int a,b;
  cin>>a>>b;
  int c=a*b;
  if(c%2==0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 384
n = int(input()) #整数
s = input() #文字列

x="abcdefghijklmnopqrstuvwxyz"
MOD = 1000000007

counter = list([])
for c in x:
    l = s.count(c)
    if l != 0:
        counter.append(l)

ans = 1
for i in counter:
    ans *= (i+1)
    ans %= MOD
ans -= 1

print(ans)

Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N, K;
vv<int> tree;
vector<int> low, high;

int main() {
    cin >> N;
    tree.resize(N);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    low.resize(N, INF);
    high.resize(N, INF);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    cin >> K;
    rep(i, K) {
        int v, p;
        cin >> v >> p;
        v--;
        low[v] = high[v] = p;
        pq.emplace(0, v);
    }
    
    bool ok = true;
    while (!pq.empty()) {
        auto v = pq.top();
        pq.pop();
        if (v.first != high[v.second] - low[v.second]) continue;
        for (int u : tree[v.second]) {
            if (low[u] == INF) {
                low[u] = low[v.second] - 1;
                high[u] = high[v.second] + 1;
                pq.emplace(high[u] - low[u], u);
                continue;
            }
            else if ((low[v.second] ^ low[u]) % 2 == 0) ok = false;
            else if (low[v.second] - 1 > high[u] || high[v.second] + 1 < low[u]) ok = false;
            else if (low[v.second] - 1 <= low[u] && high[v.second] + 1 >= high[u]) continue;
            else {
                low[u] = max(low[u], low[v.second] - 1);
                high[u] = min(high[u], high[v.second] + 1);
                pq.emplace(high[u] - low[u], u);
            }
        }
    }

    if (ok) {
        write("Yes");
        for (int x : low) write(x);
    }
    else write("No");
}

Measured memory_bytes: 8564
N, M = map(int, input().split())
G = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)

for i in range(N):
    print(len(G[i]))


Measured memory_bytes: 3060
N, M = map(int, input().split())

mod_num = 10 ** 9 + 7
a = [0] * N

for i in range(M):
    a[i] = int(input())

val = [0,1]
j = 0
for i in range(1, N + 1):
    ans = (val[0] + val[1]) % mod_num
    val[0] = val[1]
    val[1] = ans
    if len(a) > 0:
        if i == a[j]:
            val[1] = 0
            if len(a) - 1 != j:
                j += 1
 
print(ans)

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n + 1) / 2 << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll a, b, c;
    cin>>a>>b>>c;
    if(a + b >= c) cout<<"No"<<endl;
    else if(4 * a * b < (c - a - b) * (c - a - b)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 384
program sample
    implicit none
    character(100)s1,s2,s3
    integer(8) :: i,j,m,n,y,a,b,c,x,z
    
  
    read(*,*) n,y
    a=y/10000
    x=mod(y,10000)
    if(n>y/1000)then
        write(*,*)'-1 -1 -1'
        stop
    end if
    
    if(x>=5000)then
        b=1
        c=x/1000-5
    else
        c=x/1000
    end if!ここで最小の枚数
  
    if(a+b+c>n)then
        write(*,*)'-1 -1 -1'
        stop
    end if

    if(2*a+b+c>=n)then
        z=n-a-b-c
        a=a-z
        b=b+2*z
        
    else
        x=mod(n,4)
        z=mod(2*a+b+c,4)
        x=mod(z+4-x,4)
        if(a-x<0)then
            write(*,*)'-1 -1 -1'
            stop
        end if
        b=b+2*(a-x)
        a=x
        x=(n-a-b-c)/4
        b=b-x
        if(b<0)then
            write(*,*)'-1 -1 -1'
            stop
        end if
        c=c+5*x

    end if
    write(s1,'(i4)')a
    write(s2,'(i4)')b
    write(s3,'(i4)')c
 
    write(*,fmt='(a,x,a)',advance='no')s1,s2
    write(*,fmt='(a)',advance='no')s3

    stop
end program sample
  



Measured memory_bytes: 2892
#include <cstdio>
int main(void)
{
	char c[4];
	int bucket[5],flag=1,i;
	scanf("%s",c);
	bucket[0]=0;
	bucket[1]=0;
	bucket[2]=0;
	for (i=0;i<3;i++)
		bucket[c[i]-'a']++;
	for (i=0;i<3;i++)
		if(bucket[i]!=1)
			flag=0;

	if(flag==1)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;

}

Measured memory_bytes: 128
import java.io.PrintWriter

fun main() {
    val pw = PrintWriter(System.out)

    val (n, m) = readInputLine().split(" ").map { it.toLong() }
    val aSum = readInputLine().split(" ").map { it.toLong() }.sum()

    if (aSum > n) {
        pw.println(-1)
    } else {
        pw.println(n - aSum)
    }

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 39744
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

int main() {
  int N,L; cin>>N >>L;
  vector<string> s(N);
  rep (i,0,N) cin >>s[i];
  sort(s.begin(),s.end());
  rep(i,0,N) cout <<s[i];
  cout <<endl;
  return 0;
}


Measured memory_bytes: 256