akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

double length(double x1,double y1,double x2,double y2){
	return sqrt(pow(x1-x2,2)+pow(y1-y2,2));
}

signed main(){
	int n;
	cin>>n;
	vi f(n),a(n),t(n),x(n),y(n);
	rep(i,0,n) cin>>f[i]>>a[i]>>t[i]>>x[i]>>y[i];
	double l[2]={-1},tt[2]={0};
	l[1]=-1;
	rep(i,1,n){
		if(t[i-1]==t[i] && a[i-1]!=a[i]){
			double tmp=length(x[i],y[i],x[i-1],y[i-1]);
			rep(j,0,2){
				if(t[i]==j){
					if(fabs(l[j]-tmp)<1e-10){
						tt[j]=min((int)tt[j],f[i]-f[i-1]);
					}else if(l[j]<tmp){
						l[j]=tmp; tt[j]=f[i]-f[i-1];
					}
				}
			}
		}
	}
	rep(i,0,2){
		if(fabs(l[i]+1)<1e-10) o(-1<<" "<<-1);
		else printf("%.10lf %.10lf\n",l[i],tt[i]/60.0);
	}
}

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

const int MAX = 100005;
int A[MAX], B[MAX], C[MAX];
long long D[MAX];

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);
    for (int i = 0; i < N; i++) scanf("%d", &B[i]);
    for (int i = 0; i < N; i++) scanf("%d", &C[i]);
    sort(A, A+N);
    sort(B, B+N);
    sort(C, C+N);

    int *p;
    long long ans = 0;
    D[0] = 0;
    for (int i = 1; i <= N; i++) {
        p = lower_bound(A, A+N, B[i-1]);
        D[i] = (long long)distance(A, p);
        D[i] += D[i-1];
    }
    for (int i = 0; i < N; i++) {
        p = lower_bound(B, B+N, C[i]);
        ans += D[distance(B, p)];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,q;
  cin>>n>>k>>q;
  vector<int>a(n);
  for(int i=0;i<q;i++)
  {
    int d;
    cin>>d;
    a[d-1]++;
  }
   for(int i=0;i<n;i++)
  {
   	if(k+a[i]-q>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  

  return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    K, S = map(int, input().split())

    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - (x + y)
            if 0 <= z <= K:
                ans += 1
    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 73264
def prime(x):
    a = 0
    for i in range(2, int(x**0.5)):
        if x % i == 0:
            a = 1
    return a

X = int(input())

while True:
    b = prime(X)
    if b == 0:
        print(X)
        exit()
    X += 1


Measured memory_bytes: 3064
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
int a[MAXN];
int z[MAXN];

bool solve() {
	ll sum=0; REP(i,n) sum+=a[i];
	ll once=(ll)n*(n+1)/2;
	//printf("sum=%lld once=%lld dv=%.2lf\n",sum,once,1.0*sum/once);
	if(sum%once!=0) return false;
	ll t=sum/once;
	REP(i,n) {
		int p=a[i],q=a[(i+1)%n];
		// i:	x*n+?
		// i+1: x*1+?+(t-x)
		// p=x*n+?
		// q=x*1+?+(t-x)
		// ?=p-x*n
		// q=x*1+p-x*n+(t-x)
		// x=(p-q+t)/n
		//printf("%d: %lld/%d=%.2lf\n",i,p-q+t,n,1.0*(p-q+t)/n);
		if(p-q+t<0||(p-q+t)%n!=0) return false;
		z[i]=(p-q+t)/n;
	}
	ll have=0; REP(i,n) have+=z[i]; if(have!=t) return false;
	return true;
}

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);
	printf("%s\n",solve()?"YES":"NO");
}

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


Measured memory_bytes: 1024
import numpy as np

n , m , x = map(int,input().split())
understand_list = [list(map(int,input().split()))]
for _ in range(n-1):
    understand_list.append(list(map(int,input().split())))

money_list = []
for i in range(1,2 ** n):
    buy_list = []
    money = 0
    for j in range(n):
        if ((i >> j) & 1):
            buy_list.append(understand_list[j])
            money += understand_list[j][0]

    buy_list = np.sum(buy_list, axis=0)
    if all([i >= x for i in buy_list[1:]]):
        money_list.append(buy_list[0])

if money_list == []:
    print(-1)
else:
    print(min(money_list))

Measured memory_bytes: 27328
import java.util.Scanner;

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

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int n;
  cin>>n;
  n%=7;
  string a;
  if(n==1) a="fri";
  if(n==2) a="sat";
  if(n==3) a="sun";
  if(n==4) a="mon";
  if(n==5) a="tue";
  if(n==6) a="wed";
  if(n==0) a="thu";
  cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;//1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v, LL st = -1, LL en = -1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL v[32] = {
		1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
	};
	LL K;
	cin >> K;
	cout << v[K - 1] << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
/* data type, special numbers, defines */
//#define int ll //use if ded
#define ll long long
#define ld long double
const ll inf=LLONG_MAX;
//const ll mod=1e9+7;
const ll mod=998244353;
const ld pi=acos(-1.0);
#define all(v) v.begin(), v.end()
/* end data type and special numbers */
 
/* fast input.output */
#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define endl pc('\n')
int get_i(){
	char c=gc(); bool neg=false;
	for(; c<'0'||'9'<c; c=gc())
		if(c=='-') neg=true;
	int rs=c-'0'; c=gc();
	for(; '0'<=c && c<='9'; c=gc())
		rs=(rs<<1)+(rs<<3)+(c-'0');
	if(neg) rs=-rs;
	return rs;
}
ll get_l(){
	char c=gc(); bool neg=false;
	for(; c<'0'||'9'<c; c=gc())
		if(c=='-') neg=true;
	ll rs=c-'0'; c=gc();
	for(; '0'<=c && c<='9'; c=gc())
		rs=rs*10ll+(c-'0');
	if(neg) rs=-rs;
	return rs;
}
string get_s(){
	char c=gc();
	for(; c<33 || 126<c; c=gc());
	string s=""; s+=c; c=gc();
	for(; 33<=c && c<=126; c=gc())
		s+=c;
	return s;
}
char get_c(){
	char c=gc();
	for(; c<33 || 126<c; c=gc());
	return c;
}
void print_i(int _n){
	bool neg=false; if(_n<0) {neg=true; _n=-_n;}
	if(neg) pc('-');
	int N=_n, rev, count=0;
	rev=N;
	if(N==0) {pc('0'); return;}
	while((rev%10)==0) {count++; rev/=10;}
	rev=0;
	while(N!=0) {rev=(rev<<3)+(rev<<1)+N%10; N/=10;}
	while(rev!=0) {pc(rev%10+'0'); rev/=10;}
	while(count--) pc('0');
}
void print_l(ll _n){
	ll N=_n, rev, count=0;
	rev=N;
	if(N==0) {pc('0'); return;}
	while((rev%10)==0) {count++; rev/=10;}
	rev=0;
	while(N!=0) {rev=rev*10ll+N%10; N/=10;}
	while(rev!=0) {pc(rev%10+'0'); rev/=10;}
	while(count--) pc('0');
}
void print_s(string a){
	for(int i=0; i<a.size(); i++)
		pc(a[i]);
}
#define endline pc('\n');
#define space pc(' ');
/* end fast input/output */

/*   E N D   O F   T E M P L A T E   */

int main(){
	int n=get_i(), m=get_i();
	int ans=n*(n-1)/2+m*(m-1)/2;
	print_i(ans); endline
}

Measured memory_bytes: 768
#include <iostream>

using namespace std;
int main()
{
    while(true){
        int i, k;
        cin >> i;
        cin >> k;
        if( i == 0 && k == 0)
            break;
        int a[i], b[i];
        
        for(int j = 0 ; j < i ; j++)
            cin >> a[j];
        
        b[0] = a[0];
        for(int j = 0 ; j < i-1 ; j++)
            b[j+1] = b[j] + a[j+1];
        
        int N = b[k-1];
        for(int j = 0 ; j < i-k ; j++){
            if( b[j+k] - b[j] > N ){
                N = b[j+k] - b[j];
            }
        }
        
        cout << N <<endl;
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int64_t> A(n);
    const int64_t p = 1e9;

    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        int m = s.length();
        for (int j = 0; j < m; j++){
            if (s[j] == '.'){
                A[i] = stoll(s.substr(0, j)) * p;
                A[i] += stoll(s.substr(j + 1, m - j - 1)) * (p / pow(10, m - j - 1));
            }

        }
        if (A[i] == 0)
            A[i] = stoll(s) * p;
    }

    vector<vector<int>> C(19, vector<int>(19));
    vector<array<int, 2>> B(n);

    for (int i = 0; i < n; i++){
        auto b = A[i];
        int cnt_2 = 0;
        while (b % 2 == 0){
            cnt_2++;
            b /= 2;
        }
        int cnt_5 = 0;
        while (b % 5 == 0){
            cnt_5++;
            b /= 5;
        }
        cnt_2 = min(18, cnt_2);
        cnt_5 = min(18, cnt_5);
        C[cnt_2][cnt_5]++;
        B[i] = {cnt_2, cnt_5};
    }

    int64_t ans = 0;
    for (int i = 0; i < n; i++){
        auto [cnt_2, cnt_5] = B[i];
        for (int j = 18 - cnt_2; j < 19; j++){
            for (int k = 18 - cnt_5; k < 19; k++){
                ans += C[j][k];
                if (j == cnt_2 and k == cnt_5)
                    ans--;
            }
        }
    }

    cout << ans / 2 << endl;
}

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

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 60;


vector<lld> fact,inv;


lld f(lld a,lld b, lld p)  // a^b mod pを求める
{
	if (b == 0)
	{
		return 1;
	}else if (b % 2 == 0)
	{
		lld d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return d * d % mod;
	}else
	{
		return a * f(a,b-1,p) % mod;
	}
}

void init(lld n)
{
	fact.resize(n+1,1);
	inv.resize(n+1,1);

	for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
	{
		fact[i] = fact[i-1] * i % mod;
	}
	for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
	{
		inv[i] = f(fact[i],mod-2,mod) % mod;
	}
}

lld comb(lld n,lld k)  //n_C_k
{
	if (n < k)
	{
		return 0;
	}
	return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}


int main()
{
	lld n,p,a[MAXN] = {0};

	cin >> n >> p;

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

	for(int i = 0; i < n; i++)
	{
		a[i] %= 2;
	}

	init(n+1);

	lld zero = 0,one = 0;

	for(int i = 0; i < n; i++)
	{
		if (a[i] == 0)
		{
			zero++;
		}else
		{
			one++;
		}
	}

	lld sol = 0;

	if (p == 0)
	{

		for(int i = 0; i <= n; i = i + 2)
		{
			sol += comb(one,i);
		}

		sol *= (lld)pow((double)2,zero);

		cout << sol << endl;
	}else
	{
		for(int i = 1; i <= n; i = i + 2)
		{
			sol += comb(one,i);
		}

		sol *= (lld)pow((double)2,zero);

		cout << sol << endl;
	}

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
signed main() {
	int n, a, b, ok = 0, cnt = INF, ans = 0; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a >> b; ans += b;
		if (a != b) { ok = 1; }
		if (a > b) { cnt = min(cnt, b); }
	}
	if (ok == 0) { cout << 0 << endl; return 0; }
	cout << ans - cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#金額を渡すと、ケーキとドーナツの組合せでその金額になるかどうかを判定し、
#'Yes'または'No'を返す関数、no_change()を定義
def no_change(N):
    while N > 0:
        if N%7 == 0 or N%4 == 0:
            return 'Yes'
        N -= 4    
    else :
        return 'No'

# 入力値読み込み
N = int(input())

#関数呼び出し
print(no_change(N))

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    vector<string> s(n);
    rep(i, n){
        cin >> s[i];
    }

    int ans = 0;
    rep(k, n){
        vector< vector<char> > v(n, vector<char>(n));
        rep(i, n){
            rep(j, n){
                v[i][j] = s[(i + k) % n][j];
            }
        }
        bool flag = true;
        rep(i, n){
            rep(j, i){
                flag &= v[i][j] == v[j][i];
            }
        }
        if(flag){
            ans += n;
        }
    }

    cout << ans << endl;

    return 0;
}

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

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

	int A, B, C, D;

	scanf("%d %d %d %d", &A, &B, &C, &D);

	while (true) {
		C -= B;
		if (C <= 0) {
			printf("Yes");
			break;
		}
		A -= D;
		if (A <= 0) {
			printf("No");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 10;
int has[N], mp[N];
int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  while(n--){
    int num;
    cin >> num;
    q.push(num);
  }
  while(m--){
    int poped = q.top();
    q.pop();
    q.push(poped >> 1);
  }
  int ans = 0;
  while(!q.empty()){
    ans += (q.top());
    q.pop();
  }
  cout << ans;
}






Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	ll N;
  	cin>>N;
  	ll L[N];
    rep(i,N){
     	cin>>L[i]; 
    }
  	sort(L,L+N);
  	ll count=0;
  	
  	for(int i=0;i<N;i++){
     	for(int j=i+1;j<N;j++){
         	for(int k=j+1;k<N;k++){
              	if(L[i]==L[j] || L[j]==L[k] || L[k]==L[i]) continue;
				if(L[i]+L[j]>L[k]) count++;
            }
        }
    }
  	
  	cout<<count<<endl;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		int total =0;
		
		for(int i=0; i<m; i++) {
			total += sc.nextInt();
		}
		
		if ( n >= total) {
			System.out.println(n-total);
		}else {
			System.out.println(-1);
		}
	}
}


Measured memory_bytes: 46332
#include <stdio.h>
#include <string.h>

int abs(int a) {
  return a > 0 ? a : -a;
}

int main(void) {
  int i, j, now = 0, cnt[100010], ans = 0;
  char s[100010], t[100010];
  scanf("%s", s);
  t[0] = cnt[0] = 0;
  for(i = 0; i < strlen(s); ++i) {
    if(s[i] != 'x') t[now] = s[i], t[++now] = 0, cnt[now] = 0;
    else cnt[now]++;
  }
  for(i = 0; i < now; ++i) {
    if(t[i] != t[strlen(t) - i - 1]) {
      printf("-1");
      return 0;
    }
    ans += abs(cnt[i] - cnt[now - i]);
  }
  ans += abs(cnt[now] - cnt[0]);
  printf("%d", ans / 2);
  return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
int main(void)
{
    int N;
    int flag[101] = {};
    int c = 0;
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        int d;
        scanf("%d", &d);
        flag[d] = 1;
    }
    for (int i = 0; i < 101; i++)
    {
        c += flag[i];
    }
    printf("%d\n", c);
    return 0;
}

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

int main(){
	
	long long N;
	cin>>N;
	
	vector<int> pre,suf;
	
	for(int i=0;true;i++){
		if(N>=(1LL<<i)){
			N-=(1LL<<i);
			pre.push_back(i+1);
			suf.push_back(i+1);
		}
		else break;
	}
	//cout<<N<<endl;
	for(int i=50;i>=0;i--){
		if((1LL<<i)&N){
			pre.push_back(pre.back()+1);
			suf.insert(suf.begin()+i,pre.back());
		}
	}
	
	cout<<pre.size()*2<<endl;
	
	for(int i=0;i<pre.size();i++){
		if(i!=0)cout<<' ';
		cout<<pre[i];
	}
	
	for(int i=0;i<pre.size();i++){
		cout<<' ';
		cout<<suf[i];
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)
	A, B, C, D, E, F := getInt(), getInt(), getInt(), getInt(), getInt(), getInt()

	alim := F / (100 * A)
	blim := F / (100 * B)

	suger := (F * E) / 100
	clim := suger / C
	dlim := suger / D

	max := float64(0)
	maxw := 0
	maxs := 0

	for a := 0; a <= alim; a++ {
		for b := 0; b <= blim; b++ {
			for c := 0; c <= clim; c++ {
				for d := 0; d <= dlim; d++ {
					w := a*A + b*B
					s := c*C + d*D
					f := w*100 + s
					if f == 0 {
						continue
					}
					rate := float64(s*100) / float64(s+w)
					//out(w, f, s, (s*1000)/(s+w))
					if f <= F && s <= E*w && max <= rate {
						max = rate
						maxw = w * 100
						maxs = s
					}
				}
			}
		}
	}

	if E == 0 {
		out(A*100, 0)
	} else {
		out(maxw+maxs, maxs)
	}
}


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

int main(){
    long long n, k;
    cin >> n >> k;

    long long count = 0;
    for(long long a = 1; a <= n; a++){
        if(2*a % k == 0){
            long long amari = a % k;
            long long b = -amari+k;
            long long kazu = (n-b)/k + 1;
            count += kazu*kazu;
        }
    }

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

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc166_b solver = new abc166_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc166_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int sunuke[] = new int[N];
            for (int i = 0; i < K; i++) {
                int d = in.nextInt();
                for (int j = 0; j < d; j++) {
                    int sunuidx = in.nextInt() - 1;
                    sunuke[sunuidx]++;
                }
            }
            int count = 0;
            for (int i = 0; i < N; i++) {
                if (sunuke[i] == 0) {
                    count++;
                }
            }
            out.println(count);

        }

    }
}



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

int main() {

  int n;
  cin >> n;

  int count = 0;
  while(n > 1) {
    count++;
    int flg = 0;
    if(n%3 !=0) flg = 1;
    n = n/3 + flg;
    if (n == 2) {
      count++;
      break;
    }
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <queue>
using namespace std;

const int N = 30;
const int dx[4] = { 1, -1, 0, 0 };
const int dy[4] = { 0, 0, 1, -1 };
bool data[N][N];

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char c;
			cin >> c;
			data[i][j] = c == '.';
		}
	}


	int ans = 0;
	for (int k = 0; k < n; k++) {
		for (int L = 0; L < m; L++) {
			if (!data[k][L])
				continue;
			int dist[n][m];
			memset(dist, -1, sizeof dist);
			dist[k][L] = 0;
			queue<pair <int, int> > q; q.push(make_pair(k, L));
			while (!q.empty()) {
				pair <int, int> cur = q.front(); q.pop();
				int x = cur.first, y = cur.second;

				for (int i = 0; i < 4; i++) {
					int tx = cur.first + dx[i], ty = cur.second + dy[i];
					if (tx < 0 || tx >= n || ty < 0 || ty >= m)
						continue;
					if (!data[tx][ty])
						continue;
					if (dist[tx][ty] != -1)
						continue;
					dist[tx][ty] = dist[x][y] + 1;
					q.push(make_pair(tx, ty));
					ans = max(ans, dist[tx][ty]);
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a[3];
    rp(i,3) cin >> a[i];
    sort(a,a+3);
    if(a[0]*100 + a[1]*10 + a[2] == 557) cout << "YES";
    else cout << "NO";
    cout << endl; 
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	int v0 = (s[0]-'0')*10 + s[1] - '0';
	int v1 = (s[2]-'0')*10 + s[3] - '0';
	if(1 <= v0 && v0 <= 12 && 1 <= v1 && v1 <= 12) cout << "AMBIGUOUS" << endl;
	else if(1 <= v0 && v0 <= 12) cout << "MMYY" << endl;
	else if(1 <= v1 && v1 <= 12) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

#標準入力で受け取り配列に入れる
num_line = input().split()

#配列から変数を取り出す
num_one = int(num_line[0])
num_zero = int(num_line[1])
num_mini = int(num_line[2])
num_amount = int(num_line[3])

#num_oneから順に取っていく
if num_one >= num_amount:
    print(num_amount)
elif num_one + num_zero >= num_amount:
    print(num_one)
else:
    #マイナスの数を計算して保存
    minus_count = num_amount - (num_one + num_zero)
    print(num_one - minus_count)

Measured memory_bytes: 9184
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            for (int n = 1; n < 1e6; n++) {
                if ((int) (n * 0.08) == A && (int) (n * 0.1) == B) {
                    System.out.println(n);
                    return;
                }
            }
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define mid ((s + e) / 2)
#define makefast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define comp(x) (lower_bound(vec.begin(), vec.end(), x) - vec.begin())
#define lc (v * 2)
#define rc (v * 2 + 1)
long long M = 1e9 + 7;
//>>>>>>>>>>>>>>>>>>>

#define int long long

const int N = 1e6 + 7;

int n;

int pw(int a, int b) {
	int res = 1;
	while (b) {
		if (b % 2)
			res = (res * a) % M;
		b /= 2;
		a = (a * a) % M;
	}
	return res;
}
int f[N], rf[N];
int chs(int a, int b) {
	if (a > b)
		return 0;
	if (a < 0 || b < 0 || a >= N || b >= N) {
		cout << "FITA";
		exit(0);
	}
	return (((f[b] * rf[a]) % M) * rf[b - a]) % M;
}
int sm3[N], sm2[N];
int32_t main() {
	makefast;
	cin >> n >> M;
	f[0] = rf[0] = 1;
	for (int i = 1; i < N; i++) {
		f[i] = (f[i - 1] * i) % M;
		rf[i] = (rf[i - 1] * pw(i, M - 2)) % M;
	}
	sm3[0] = 1;
	for (int i = 1; i < 10000; i++)
		sm3[i] = (((sm3[i - 1] * chs(3, 3 * i)) % M) * pw(i, M - 2)) % M;
	sm2[n + 1] = 1;
	for (int i = n; i >= 0; i--) 
		sm2[i] = (((sm2[i + 1] * chs(2, 3 * n - 2 * (n - i))) % M) * pw(n - i + 1, M - 2)) % M;
	int res = 0;
	for (int b = 0; b <= n; b++) 
		for (int a = b; a + 2 * b <= 3 * n; a++) {
			if ((a + 2 * b) % 3)
				continue;
			int c = (3 * n - (a + 2 * b)) / 3;
			int t = sm2[n - b + 1];
			t = (t * chs(a, 3 * n - 2 * b)) % M; 
			t = (t * ((sm3[c] * pw(2, c)) % M)) % M;
			res = (t + res) % M;
		//	cout << a << " " << b << " " << c << " > " << t << " sm2 : " << sm2[n - b + 1] << " chs : " << chs(a, 3 * n - 2 * b) << " sm3 : " << sm3[c] << endl;
		}
	cout << res;
	return 0;
}


Measured memory_bytes: 19200
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <cstdio>
#include <set>
#include <map>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;

struct edge{
	int to;
	double dist;
	int c;
	edge(int t, double d, int c):to(t), dist(d), c(c){}
};

struct state{
	int pos;
	double total;
	int speed;
	int prev;
	state(int p, double t, int s, int pr):pos(p), total(t), speed(s), prev(pr){}
	bool operator<(const state &r)const {
		return total > r.total;
	}
};

int main(){
	//freopen("test.txt", "r", stdin);
	cout.setf(ios::fixed);
	cout.precision(8);

	int n, m;
	while(cin >> n >> m, n|m){
		int s, g;
		cin >> s >> g;
		s--, g--;
		vector<vector<edge> > G(n);
		rep(i, m){
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--, y--;
			G[x].push_back(edge(y, d, c));
			G[y].push_back(edge(x, d, c));
		}

		priority_queue<state> q;
		q.push(state(s, 0, 0, s));

		vector<vector<vector<double> > > best(n, vector<vector<double> >(n, vector<double>(31, 1e30))); // pos, prev, speed

		double ans = -1;
		while(!q.empty()){
			state st = q.top();
			q.pop();

			if(best[st.pos][st.prev][st.speed] < st.total) continue;

			if(st.pos == g && st.speed == 1){
				ans = st.total;
				break;
			}

			rep(i, G[st.pos].size()){
				if(st.prev == G[st.pos][i].to) continue;
				for(int j = -1; j <= 1; j++){
					state next = st;
					next.speed += j;
					if(next.speed <= 0 || next.speed > G[st.pos][i].c) continue;
					next.pos = G[st.pos][i].to;
					next.prev = st.pos;
					next.total += G[st.pos][i].dist/next.speed;
					if(next.total < best[next.pos][next.prev][next.speed]){
						best[next.pos][next.prev][next.speed] = next.total;
						q.push(next);
					}
				}
			}
		}

		if(ans == -1) cout << "unreachable" << endl;
		else cout << ans << endl;
	}

	return 0;
}

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

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

	vector<int> a(n);

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

	int cnt = 0;

	for (int i = 0; i < n; i++) {
	 	if (a[i] >= sum * 1 / (4 * m * 1.0)) cnt++;
	}                                                             

	cout << (cnt >= m ? "Yes\n" : "No\n");	
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, cnt= 0, d= 0;

    cin>> n;

    if(n<105)
    {
        cout<< 0;
        nl;
        return 0;
    }

    for(int i=107; i<=n; i+=2)
    {
        d= 0;

        for( int j= 3; j* j<= i; j++)
        {
            if(i% j== 0)
            {
                if(i== j* j)
                    d++;
                else
                    d+= 2;
            }

            if(d> 6)
                break;
        }

        if(d== 6 )
            cnt++;
    }

    cout<< cnt + 1;
    nl;

    return 0;
}




Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);I++) cin >> x[i];

int main(){
  int x;
  cin >> x;
  if(x < 1200)
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int
A = get_ints

A.sort!


cur = A.shift

while A.length > 0
  test = A.shift % cur
  if test != 0 && test < cur
    A.unshift cur
    cur = test
  end
  break if cur == 1
end

puts cur


Measured memory_bytes: 22536
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int reverseNo(int n) {
  int rev = 0, rem;
  while (n != 0) {
    rem = n % 10;
    rev = (rev*10) + rem;
    n /= 10;
  }
  return rev; 
}

int main() {

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, 0, n) cin >> s[i];
    sort(all(s));
    int cnt = 0;
    rep(i, 0, n) {
      if (s[i] != s[i+1])
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
	char a;
	
	cin>>a;
	
	if(a=='T'){
		cout<<'A'<<endl;
	}else if(a=='A'){
		cout<<'T'<<endl;
	}else if(a=='G'){
		cout<<'C'<<endl;
	}else if(a=='C'){
		cout<<'G'<<endl;
	}
	
	return 0;
}

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


int main() {
  int n;
  cin>>n;
  int p[n],a[n]={0};
  
  for(int i=0;i<n;i++){
  	cin>>p[i];
    p[i]--;
    if(p[i]!=n-1&&a[p[i]]==0) a[p[i]]=1;
    if(p[i]!=0&&a[p[i]-1]==0) a[p[i]-1]=-1;
  }
  int count=1,ans=0;
  for(int i=0;i<n-1;i++){
  	if(a[i]==1) count++;
    if(a[i]==-1){
      ans=max(ans,count);
      count=1;
    }
  }
  ans=max(ans,count);
  cout<<n-ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int T,A,B;cin>>T>>A>>B;
	cout<<min(A*T,B)<<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BGoldenCoins {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int x; cin >> x;
      int r = x/500*1000;
      x -= x/500*500;
      int s = x/5*5;
      cout << r+s << endl;
    }
};

signed main() {
  BGoldenCoins solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

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

        public void Solve(ConsoleInput cin)
        {
            // [1,100]
            int n = cin.ReadInt;
            
            // [0,
            bool res = false;

            for (int i = 0; i <= 25; i++)
            {
                for (int j = 0; j <= 14; j++)
                {
                    if (n == (4 * i + 7 * j))
                    {
                        res = true;
                    }
                }
            }
            
            WriteLine(res ? "Yes" : "No");
        }
    }

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


Measured memory_bytes: 11220
i = int(input())
v=[]
ac =0
wa =0
tle=0
re =0
for _ in range(0, i):
    v.append(input())


for value in v:
    if value == 'AC':
        ac += 1
    elif value == 'WA':
        wa += 1
    elif value == 'TLE':
        tle += 1
    elif value == 'RE':
        re += 1

print('AC x %d' % ac)
print('WA x %d' % wa)
print('TLE x %d' % tle)
print('RE x %d' % re)

Measured memory_bytes: 16228
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int INF = 1e10 + 5;

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, m, x;
        cin >> n >> m >> x;
        int a[n], b[n][m];
        for(int i = 0; i < n; i++) {
            cin >> a[i];
            for(int j = 0; j < m; j++)
                cin >> b[i][j];
        }

        int ans = INF;
        int N = pow(2, n);
        for(int i = 0; i < N; i++) {
            int tot[m] = {}, curr = 0;
            for(int j = 0; j < n; j++) {
                if(i & (1 << j)) {
                    curr += a[j];
                    for(int k = 0; k < m; k++) 
                        tot[k] += b[j][k];
                }
            }
            bool ok = true;
            for(int j = 0; j < m; j++)
                ok &= tot[j] >= x;

            if(ok)
                ans = min(ans, curr);
        }

        if(ans == INF)
            ans = -1;
        cout << ans << '\n';
        
    }
    
    return 0;
}



Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N;
	cin>>N;
	string s;
	cin>>s;
	for (int i = 0 ; i < s.size() ; i++)
	{
		cout<<(char)((s[i] - 'A' + N) % 26 + 'A');
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;


int main() { 
  int n;
  cin >> n;
  if (n<1200) {
    cout << "ABC" << endl;
  } else {
    cout << "ARC" << endl;
  }

  return 0;
}


Measured memory_bytes: 764
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }


void main() {
    int n = readint();
    int d, x; readf("%d %d\n", &d, &x);
    foreach (_; 0..n) {
        x += (d - 1) / readint() + 1;
    }
    writeln(x);

    auto _ = readln(); // dbg
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#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)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
 
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
 
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹ここにすきなもじをいれてね！╹) */
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/* (๑╹最強╹) */


int main() {
   int N,M,ans;
   ans = 0;
   int adj[52][52] = {}; //辺を格納する51*51の行列を作る． ={}で全ての値を0にする．
   cin >> N >> M;
   vector<pair<int,int>> root; //直接つながるタイプの辺をpairで記録する．
   rep(i,M)
   {
      int a,b;
      cin >> a >> b;
      adj[a][b] = adj[b][a] = 1; //行列adjの(a,b)成分と(b,a)成分に1を代入する．
      root.PB(MP(a,b)); //rootのケツにペア(a,b)を挿入する
   }
   rep(i,M) //i番目に追加された辺が橋であるかを調べる．
   {
      int a = root[i].first; //rootのi+1番目の成分のペアの最初を取り出す．
      int b = root[i].second;//rootのi+1番目の成分のペアの最後を取り出す．
      queue<int> Q; //幅優先探索をするに使いやすいQueue
      int visited[52] ={}; //もう通った点を配列visitedに格納したいので定義する．
      Q.push(1); //Queueに1を代入する
      while(!Q.empty()) // Qがからでない限りループする．whileは条件を満たす限りループ
      {
         int now = Q.front(); //Q.front()で，Qの一番上の数を取り出す
         Q.pop(); //先ほど拾い出した値を消す．
         visited[now] = 1; //今取り出した値を通過済み配列に追加する．
         FORq (j,1,M) //幅優先探索でi番目に追加された辺を除いて1から移動可能な点を調べる．
         {
            if (adj[now][j] == 0) continue; 
            if (now == a && j == b) continue;
            if (j == a && now == b) continue;
            if (1 == visited[j]) continue;
            Q.push(j);
         }
      }
      FORq(pppppp, 1, N) //i番目に追加された辺を取り除いた場合に非連結になっているかを調べる．
         {
         if ( visited[pppppp] == 0) //もし非連結化になっていたら
            {
            ans += 1;
            break;
            }
         }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

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

    if(b>=c){
        cout<<b+c<<endl;
    }
    else{
        c-=b;
        if(a+1<c){
            cout<<2*b+a+1<<endl;
        }
        else{
            cout<<2*b+c<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int x, a;
  cin >> x >> a;
  if(x < a) cout << 0;
  else cout << 10;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
 int x,N;
  cin >> N;
  x=((N%100)%10);
  if(x==2 or x==4 or x==5 or x==7 or x==9){
  cout << "hon" << endl;
  }
  else if(x== 0 or x==1 or x == 6 or x == 8)
    cout << "pon" << endl;
  else if (x ==3) cout << "bon" << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int i=0,j,c=0,saidai=0,m,n,a,b;
    cin >> a >> b;
    if(a>b)
    cout << "No" << endl;
    else
    cout << "Yes" << endl; 
    return 0;
}


Measured memory_bytes: 3600
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	current = [0,0,0]
	flag = True
	for i in range(int(input())):
		c = list(map(int,input().split()))
		mh = abs(c[1]-current[1]) + abs(c[2]-current[2])
		if(abs(c[0]-current[0])%2 != mh%2 or abs(c[0]-current[0]) < mh):
			flag = False
		current = c
	if flag:
		print('Yes')
	else:
		print('No')
main()

Measured memory_bytes: 71400
H, W = map(int, input().split())
grid = [input() for n in range(H)]

dummy = ''
for i in range(W):
    dummy += '.'

extended = [dummy] + grid + [dummy]
extended = ['.'+v+'.' for v in extended]

result = []
for h in range(1, H+1):
    row = []
    for w in range(1, W+1):
        if extended[h][w] == '#':
            row.append('#')
        else:
            count = 0
            if extended[h-1][w-1] == '#': count+=1
            if extended[h-1][w] == '#': count+=1
            if extended[h-1][w+1] == '#': count+=1
            if extended[h][w-1] == '#': count+=1
            if extended[h][w+1] == '#': count+=1
            if extended[h+1][w-1] == '#': count+=1
            if extended[h+1][w] == '#': count+=1
            if extended[h+1][w+1] == '#': count+=1
            row.append(count)
    result.append(row)

out = '\n'.join([''.join(map(str,r)) for r in result])
print(out)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  ll N;
  vector<pair<ll, ll>> tasks; // task<deadline, requested time>
  cin >> N;
  for(int i=0; i<N; i++) {
    ll tmp1, tmp2;
    cin >> tmp1 >> tmp2;
    tasks.push_back(make_pair(tmp2, tmp1));
  }
  sort(tasks.begin(), tasks.end());
  
  ll time = 0;
  bool tf = false;
  for(int i=0; i<N; i++) {
    if(time + tasks[i].second > tasks[i].first) {
      break;
    }
    time += tasks[i].second;
    if(i==N-1) tf = true;
  }
  if(tf) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 6384
import java.util.Scanner;
import java.util.TreeSet;
import java.util.Arrays;
public class Main {
 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n;
       n= sc.nextInt();
       int [] a=new int[n];
       for(int i=0;i<n;i++){
           a[i]=sc.nextInt();
       }
       int count=0;
       for(int i=0;i<n-1;i++){
           int m=a[i];
           int comp=1000000;
           int minj=0;
           for(int j=i+1;j<n;j++){
                if(comp>a[j]){
                    minj=j;
                    comp=a[j];
                }
           }
           if(m>comp){
            int tmp=a[i];
            a[i]=a[minj];
            a[minj]=tmp;
            count++;
        }
       }

       for(int i=0;i<n;i++){
        if(i!=(n-1))System.out.print(a[i]+" ");
        else  System.out.println(a[i]);
       }
       System.out.println(count);
}
}




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

int selectionSort(int A[], int N) {
	int sw = 0;
	for (int i = 0; i < N; i++) {
		int imin = i;
		for (int j = i + 1; j < N; j++) {
			if (A[imin] > A[j]) imin = j;
		}
		if (imin != i) {
			swap(A[imin], A[i]);
			sw++;
		}
	}
	return sw;
}
			
	
int main() {
	int N, sw;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	sw = selectionSort(A, N);
	
	for (int i = 0; i < N; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	
	return 0;
}

Measured memory_bytes: 1160