akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().split())
ks = []
for _ in range(M):
    ks.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0
for bit in range(2**N):
    on_list = []
    for i in range(N):
        if bit & (1 << i):
            on_list.append(i+1)
    flag = True
    for s, p_ in zip(ks, p):
        on_sum = len(list(set(on_list) & set(s[1:])))
        if on_sum % 2 != p_:
            flag = False
            break
    
    if flag:
        ans += 1
        
print(ans)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
	int vn,en,r;
	cin >> vn >> en >> r;
	vector<int> d(vn,INF);
	vector<vector<pair<int,int>>> e(vn);
	for(int i=0; i<en; i++){
		int a,b,dist;
		cin >> a >> b >> dist;
		e.at(a).push_back({dist,b});
	}
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
	d.at(r) = 0;
	for(auto i:e.at(r)) q.push(i);
	while(!q.empty()){
		auto p = q.top();q.pop();
		if(d.at(p.second)<p.first) continue;
		d.at(p.second) = p.first;
		for(auto j:e.at(p.second)) q.push({j.first+p.first,j.second});
	}
	for(auto i:d) 
		if(i==INF) cout << "INF" << endl;
		else cout << i << endl;
	return 0;
}


Measured memory_bytes: 13916
using System;

class Program2
{
    static void Main(string[] args)
    {
        string _strinput = Console.ReadLine();
        string[] _stringh = _strinput.Split((char)105);
        string[] _stringi = _strinput.Split((char)104);
        if ((_strinput.Length % 2) != 0 || _strinput == "")
        {
            Console.WriteLine("No");
            return;
        }
        else if (_stringh.Length != _stringi.Length) {
            Console.WriteLine("No");
            return;
        }

        for(int i1 = 0; i1< _stringh.Length -1; i1++) {
            if (_stringh[i1] != "h") {
                Console.WriteLine("No");
                return;
            }
        }
        if (_stringh[_stringh.Length - 1] != "")
        {
            Console.WriteLine("No");
            return;
        }
        for (int i2 = 1; i2 < _stringi.Length ; i2++)
        {
            if (_stringi[i2] != "i")
            {
                Console.WriteLine("No");
                return;
            }
        }
        if (_stringi[0] != "")
        {
            Console.WriteLine("No");
            return;
        }
        Console.WriteLine("Yes");
        

    }
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

vector<string> ans;
int a;
void dfs(vector<int> S,int maxi){
    if(S.size()==a){
        string tmp;
        for(int i:S){
            char k='a'+i;
            tmp+=k;
        }
        ans.push_back(tmp);
        return;
    }

    for(int i=0;i<=maxi;++i){
        vector<int> T=S;
        T.push_back(i);
        dfs(T,maxi);
    }

    vector<int> T=S;
    T.push_back(maxi+1);
    dfs(T,maxi+1);


}

int main() {
    cin>>a;
    dfs({0},0);
    sort(ans.begin(),ans.end());
    for(auto s:ans) cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 9588
int main(void){
  int i,j;
  char x[8][9];

  for(i=0;i<8;i++){
    scanf("%s",x[i]);
  }

  printf("90\n");
  for(j=0;j<8;j++){
    for(i=7;i>=0;i--){
      putchar(x[i][j]);
    }
    putchar('\n');
  }
  printf("180\n");
  for(i=7;i>=0;i--){
    for(j=7;j>=0;j--){
      putchar(x[i][j]);
    }
    putchar('\n');
  }
  printf("270\n");
  for(j=7;j>=0;j--){
    for(i=0;i<8;i++){
      putchar(x[i][j]);
    }
    putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-

import sys
import os
import math


dice = list(map(int, input().split()))
q = int(input())

def dice_roll(c):
    copy = dice[:]
    if c == 'E':
        dice[2] = copy[0]
        dice[5] = copy[2]
        dice[3] = copy[5]
        dice[0] = copy[3]
    elif c == 'N':
        dice[0] = copy[1]
        dice[4] = copy[0]
        dice[5] = copy[4]
        dice[1] = copy[5]
        pass
    elif c == 'S':
        dice[1] = copy[0]
        dice[0] = copy[4]
        dice[4] = copy[5]
        dice[5] = copy[1]
    elif c == 'W':
        dice[0] = copy[2]
        dice[2] = copy[5]
        dice[5] = copy[3]
        dice[3] = copy[0]
    # Y???????????¢
    elif c == 'R':
        dice[2] = copy[1]
        dice[4] = copy[2]
        dice[3] = copy[4]
        dice[1] = copy[3]

for i in range(q):
    up, front = list(map(int, input().split()))

    # up???????????????
    num = 0
    while dice[0] != up:
        if num % 2 == 0:
            dice_roll('E')
        else:
            dice_roll('N')
        num += 1

    # front???????????????
    while dice[1] != front:
        dice_roll('R')

    print(dice[2])

Measured memory_bytes: 7844
def solve(n, a):
    from itertools import accumulate

    inf = (400 ** 2) * (10 ** 9) + 10

    # [l,r)
    def dfs(l, r):
        if memo[l][r] != -1:
            return memo[l][r]
        if r - l == 1:
            return 0
        res = inf
        for c in range(l + 1, r):
            # [l, c), [c, r)
            res = min(res, dfs(l, c) + dfs(c, r))
        res += acc[r] - acc[l]
        memo[l][r] = res
        return res

    acc = (0,) + tuple(accumulate(a))
    memo = [[-1] * (n + 1) for _ in range(n + 1)]

    return dfs(0, n)


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


Measured memory_bytes: 44636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1000000007;

//↓combination(ll a, ll b) でaCr計算。
//------------------------------------------------------------------------------------------
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll kj(ll x){
    ll s = 1;
    for(ll i = 1; i <= x; i++){
        s = s * i % MOD;
    }
    return s;
}
ll combination(ll a, ll b){
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    return (kj(a) * mpow(kj(b), MOD-2) % MOD) * mpow(kj(a-b), MOD-2) % MOD;
}
//---------------------------------------------------------------------------------------------
//↑combination(ll a, ll b) でaCr計算。

int main(){
    int N,D;
    cin >> N >> D;
    if(2*D+1 >= N){
        cout << 1;
    }else if( N%(2*D+1) == 0){
        cout << N/(2*D+1);
    }else{
        cout << N/(2*D+1) + 1;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int blue = sc.nextInt();
		String[] s = new String[blue];
		for (int i = 0; i < blue; i++)
			s[i] = sc.next();
		int red = sc.nextInt();
		String[] t = new String[red];
		for (int i = 0; i < red; i++)
			t[i] = sc.next();
		int count = -1;
		int max = 0;
		for (int i = 0; i < blue; i++) {
			for (int j = 0; j < blue; j++) {
				if (s[i].equals(s[j]))
					count++;
			}
			for (int k = 0; k < red; k++) {
				if (s[i].equals(t[k]))
					count--;
			}
			max = Math.max(max, count);
			count = 0;
		}
		System.out.println(max);
	}
}

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

public class Main {
	public static void main(String[] age)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		String input = br.readLine();
		int M = Integer.parseInt(input);
		int i = 0;
		int j = 0;
		String card = new String();
		int[] spade = {1,2,3,4,5,6,7,8,9,10,11,12,13};
		int[] heart = {1,2,3,4,5,6,7,8,9,10,11,12,13};
		int[] clab = {1,2,3,4,5,6,7,8,9,10,11,12,13};
		int[] dia = {1,2,3,4,5,6,7,8,9,10,11,12,13};


		for( i=0 ; i<M ; i++ ){
			card = br.readLine();
			String[] cardvo = card.split(" ");

			if( cardvo[0].equals("S")){
				for( j=0 ; j<13 ;j++ ){
					if( spade[j]==Integer.parseInt(cardvo[1]) ) spade[j]=100;
				}
			}else if( cardvo[0].equals("H")){
				for( j=0 ;j<13 ;j++ ){
					if( heart[j]==Integer.parseInt(cardvo[1]) ) heart[j]=100;
				}
			}else if( cardvo[0].equals("C")){
				for( j=0; j<13 ; j++ ){
					if( clab[j]==Integer.parseInt(cardvo[1]) ) clab[j]=100;
				}
			}else{
				for( j=0 ; j<13 ; j++ ){
					if( dia[j]==Integer.parseInt(cardvo[1]) ) dia[j]=100;
				}
			}
		}

		for( i=0 ; i<13 ; i++ ){
			if( spade[i]!=100 ) sb.append("S ").append(spade[i]).append("\n");
		}
		for( i=0 ; i<13 ; i++ ){
			if( heart[i]!=100 ) sb.append("H ").append(heart[i]).append("\n");
		}
		for( i=0 ; i<13 ; i++ ){
			if( clab[i]!=100 ) sb.append("C ").append(clab[i]).append("\n");
		}
		for( i=0 ; i<13 ; i++ ){
			if( dia[i]!=100 ) sb.append("D ").append(dia[i]).append("\n");
		}

		System.out.print(sb);
	}
}

Measured memory_bytes: 24336
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define vec_rep(itr,v) for(auto itr = v.begin(); itr != v.end(); ++itr)

int main(void){
    ll X;
    cin >> X;
    ll ans = X / 500 * 1000;
    X %= 500;
    ans += X / 5 * 5;
    cout << ans << endl;
    return 0;
}

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

int main(){
	int a,b;
	string s;
	cin>>a>>b>>s;

	if(s[a]!='-'){
		cout<<"No"<<endl;
		return 0;
	}

	for (int i = 0; i < a+b+1; i++){
		if(i==a)continue;
		if(s[i]<'0'||s[i]>'9'){
			cout<<"No"<<endl;
			return 0;
		}
	}

	cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, b) for (int i = a; i < (int)(b); i++)
    #define all(v) v.begin(), v.end()
    const int MOD = 1e9 + 7;
    const int INF = 1e9;
    //'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
     
    ll calc(ll a, ll b) {
        a /= b;
        return b * a * (a + 1) / 2;
    }
     
    int main() {
        ll n;
        cin >> n;
        ll ans = 0;
        for (ll i = 1; i <= n; i++) {
            ans += calc(n, i);
        }
        cout << ans << endl;
        return 0;
    }

Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        String S = scanner.next();
        int count = 0;
        
        for(int i=0; i<N-2; i++){
            
            if(S.charAt(i)=='A' && S.charAt(i+1)=='B' && S.charAt(i+2)=='C'){
                
                count = count +1;
                
            }
        }
        
        System.out.println(count);
        
    }
}


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

int main() {

     int N;
    cin >> N;
    
    if (N == 1) {
        cout << N * N * N << endl;
    }
    
    if (N == 2) {
        cout << N * N * N << endl;
    }
    
    if (N == 3) {
        cout << N * N * N << endl;
    }
    
    if (N == 4) {
        cout << N * N * N << endl;
    }
    
    if (N == 5) {
        cout << N * N * N << endl;
    }
    
    if (N == 6) {
        cout << N * N * N << endl;
    }
    
    if (N == 7) {
        cout << N * N * N << endl;
    }
    
    if (N == 8) {
        cout << N * N * N << endl;
    }
    
    if (N == 9) {
        cout << N * N * N << endl;
    }
    
 }

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

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

    int l = a + b;
    int r = c + d;

    if (l > r) {
        cout << "Left" << endl;
    } else if (l == r) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }
}

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

int main(void)
{
	int n,m,x,k,i;
	cin>>n>>m>>x>>k;
	
	if(n>=k) cout<<k;
	else if(n<k&&k<=n+m) cout<<n;
	else cout<<n-(k-m-n);	
} 

Measured memory_bytes: 3620
#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
int main()
{
    double r;
    cin>>r;
    double pi=3.1415926;
    pi=2*pi*r;
    cout<<pi<<endl;
	return 0;
}


Measured memory_bytes: 3772
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


N,X=map(int,input().split(" "))
xl=list(map(int,input().split(" ")))
xl.append(X)
xl=sorted(xl)

xx=[xl[i+1]-xl[i] for i in range(len(xl)-1)]

ans=max(xx)
for i in range(len(xx)):
    ans=gcd(ans,xx[i])

print(ans)

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

string to_binString(int val)
{
    if( !val )
        return std::string("0");
    string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  // val は偶数か？
            str.insert(str.begin(), '0');  //  偶数の場合
        else
            str.insert(str.begin(), '1');  //  奇数の場合
        val >>= 1;
    }
    return str;
}

map<ll,int> prime_factor(ll n){
    map<ll, int> ret;
    REP(i,2,sqrt(n) + 1){
        while(n%i == 0){
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1)ret[n] = 1;  
    return(ret);
}
int main()
{
    ll m,n;
    cin >> m >> n;
    ll tmp = gcd(m,n);
    auto p = prime_factor(tmp);
    ll ans=0;
    for(auto x: p){
        ans++;
    }
    cout<< ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,c,g;
  scanf("%d%d%d",&a,&b,&c);
  while(1){
    if(a%b==0 || b%a==0){
      g = a>b?b:a;
      break;
    }else{
      if(a > b){
        a = a % b;
      }else{
        b = b % a;
      }
    }
  }
  if(c % g == 0){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
def examA():
    group1 = [1,3,5,7,8,10,12]
    group2 = [4,6,9,11]
    x,y = LI()
    ans = "No"
    if x in group1 and y in group1:
        ans = "Yes"
    elif x in group2 and y in group2:
        ans = "Yes"
    print(ans)

import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 38256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;

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

	int max = 100000;
	int min = 0;
	for(int i = 0; i<m; i++) {
		int x, y;
		cin >> x >> y;
		if (min < x) {
			min = x;
		}
		if (max > y) {
			max = y;
		}
	}

	int ret = max - min + 1;
	cout << (ret > 0 ? ret : 0);

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> list(N);
  for (int i = 0; i < N; i++) {
      cin >> list.at(i);
  }
  sort(list.begin(), list.end());
  reverse(list.begin(), list.end());
  int A = 0;
  int B = 0;
  for (int i = 0; i < N; i += 2) {
      A += list.at(i);
  }
  for (int i = 1; i < N; i += 2) {
      B += list.at(i);
  }
  cout << A - B << endl;
  
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  cout << d.at(n / 2) - d.at(n / 2 - 1) << endl;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  int H[N];
  int sum=0;
  for(int i; i<N; i++){
    cin >> H[i];
    if(H[i]>=K){
      sum++;
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	private void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		
		int g = M/N;
		
		while(g>0) {
			if(M%g == 0) {
				System.out.println(g);
				return;
			}
			g--;
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> ans(n,0);
    rep(i,100)rep(j,100)rep(k,100){
        int a=i+1;
        int b=j+1;
        int c=k+1;
        int tmp=a*a+b*b+c*c+a*b+a*c+b*c;
        if(tmp>n) continue;
        ans[tmp-1]++;
    }
    rep(i,n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 500005
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back 
#define F first
#define S second
 
#define fixx(n) fixed << setprecision(n)
 
#define ll 	  long long 
 
#define mod  1000000007


 
int main()
{
	FAST;
	int a, b, c;
	cin >> a >> b >> c;
	int k = a/b;
	if(a % b){
		k ++;
	}
	cout << k * c;
	return 0;
}

Measured memory_bytes: 3644
#pragma region Macros
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

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;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  int N;
  cin >> N;
  vector<vector<int>> shougen(N, vector<int>(N, -1));
  REP(i, N) {
    int a;
    cin >> a;
    REP(j, a) {
      int x, y;
      cin >> x >> y;
      x--;
      shougen[i][x] = y;
    }
  }

  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<int> man(N, 0);
    int count = 0;
    REP(i, N) {
      if (bit & (1 << i)) {
        man[i] = 1;
        count++;
      }
    }
    bool valid = true;
    REP(i, N) {
      REP(j, N) {
        if (shougen[i][j] == 1 and man[i] == 1 and man[j] == 0) {
          valid = false;
        } else if (shougen[i][j] == 0 and man[i] == 1 and man[j] == 1) {
          valid = false;
        }
      }
    }
    if (valid) {
      chmax(ans, count);
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def main():
    N,K = map(int,input().split())
    ans = 0
    dict = {}
    cnt = 0
    tmp = 1/N
    for i in range(N,0,-1):
        i = float(i)
        if K <= i:
            ans += tmp*(0.5**cnt)
        else:
            while True:
                K = K/2
                cnt += 1
                if K <= i:
                    break
            ans += tmp*(0.5**cnt)
    return ans

print(main())


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

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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

const string YES = "Yes";
const string NO = "No";

int main(){
    string s, t;
    cin >> s >> t;
    if (t.substr(0, sz(s)) == s) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


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

int main(void) {
	int payment;
  	int onecoin;
  	int last;
  cin >> payment >> onecoin;
  
  last = payment % 500;
  if (last <= onecoin) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;}
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main() {
    int N;
    cin >> N;
    int a, b, c;
    string ans = "No";
    a = N / 100;
    N = N % 100;
    b = N / 10;
    c = N % 10;
    if(a==7 || b==7 || c==7)
        ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
  int N;
  int s=1;
  int i,j;
  int a=0,b=0,c=0;
  int num[100];
  scanf("%d", &N);
  for(i=0;i<N;i++){
    num[i]=i+1;
  }
  for(i=0;i<N;i++){
    a=0;
    s=1;
    for(j=0;10;j++){
      s=s*2;
      if(num[i]%s==0)
        a++;
      else break;
    }
      if(a>b){
        b=a;
        c=num[i];
      }
  }
  if(N==1)
    printf("%d", N);
  else
    printf("%d", c);
    return 0;
}

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

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){
 ll n,x,t;
 cin>>n>>x>>t;
 if(n%x==0)
    cout<<(n/x)*t;
else
    cout<<(n/x)*t+t;


return 0;
}

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

int main() {
  string s;
  cin >> s;
  string days[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  for (int i = 0; i<7; i++){
    if (s==days[i]){
      int a = 7-i;
      cout << a << endl;
    }
  }
}


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

humans = []

for i in range(n):
  human = []
  ai = int(input())
  for j in range(ai):
    x,y = map(int, input().split())
    human.append([x-1,y])
  humans.append(human)
num = 0
for i in range(pow(2, n)):
  k = i
  honest = []
  for j in range(n):
    x = pow(2,n-j-1)
    honest.append(1 - (k // x))
    k = k % x
  
  flg = True
  for j in range(n):
    if(honest[j]==0):
      continue
    for k in humans[j]:
      if(honest[k[0]] != k[1]):
        flg = False
        break
    if(not(flg)):
      break
        
  if(flg):
    num = sum(honest)
    break

print(num)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int& a, int b) { if (a < b) { a = b; return true; } else return false; }
inline bool minch(int& a, int b) { if (a > b) { a = b; return true; } else return false; }

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

	if (c-a-b >= 0 && 4*a*b < (c-a-b)*(c-a-b)) cout << "Yes" << endl;
	else if (c - a - b < 0){
	  cout << "No" << endl;
	}
	else cout << "No" << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
   a, b = map(int, input().split())
   edges[a-1].append(b-1)
   edges[b-1].append(a-1)

# bfs
def bfs(v):
   dist = [-1] * n
   dist[v] = 0
   visit = [v]
   c = 1
   while visit:
      next = []
      for i in visit:
         for j in edges[i]:
            if dist[j] == -1:
               dist[j] = c
               next.append(j)
      visit = next
      c += 1
      if c > 2:
         break

   return dist

dist = bfs(0)
if dist[-1] == -1:
   print('IMPOSSIBLE')
else:
   print('POSSIBLE')


Measured memory_bytes: 43492
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();

		if (((x - r) >= 0) && ((x + r) <= W) &&
				((y - r) >= 0) && ((y + r) <= H)) {

			System.out.println("Yes");

		} else {

			System.out.println("No");

		}

		sc.close();

	}

}


Measured memory_bytes: 26408
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;


int Main(int X)
{
    int MAX = 100100;
    VB isPrime(MAX, true);
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i*i <= MAX; i++) {
        if(isPrime[i]) {
            for(int j = 2; i*j <= MAX; j++) {
                isPrime[i*j] = false;
            }
        }
    }
    for(int i = X; i < MAX; i++) {
        if(isPrime[i]) return i;
    }
    return X;    
}

int main(void){
    int X;
    cin >> X;
    cout << Main(X) << endl;
    return 0;
}

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

int main(){
  int x0 = 0, y0 = 0, W, H, N, x, y, a;
  cin >> W >> H >> N;
  while(cin >> x >> y >> a){
    if(a == 1 && x0 < x){
      x0 = x;
    } else if(a == 2 && W > x){
      W = x;
    } else if(a == 3 && y0 < y){
      y0 = y;
    } else if(a == 4 && H > y){
      H = y;
    }
  }
  int area = (W - x0) * (H - y0);
  if(W - x0 < 0 || H - y0 < 0){
    area = 0;
  }
  cout << area << endl;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	cout << min((n*a),b) << endl;

}


Measured memory_bytes: 764
def StalinSort(L):
    """スターリンソート
    参考
    https://qiita.com/Sirloin/items/c9e5c74be3366df65bce
    ソート対象のリストを先頭要素から調べて、昇順になっていない要素をリストで返す
    input   L:ソート対象のリスト
    output  purge:昇順になっていない（邪魔になる）要素のリスト
    """

    targ = 1
    purge = []
    for l in L:
        if l != targ:
            purge.append(l)
        else:
            targ += 1
    return purge

N = int(input())
A = list(map(int, input().split()))

if len(A) == len(StalinSort(A)):
    print(-1)
else:
    print(len(StalinSort(A)))


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<long long int> A(N);
  for(int i=0; i < N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());

  vector<pair<long long int,long long int>> cb(M);
  for(int i=0; i < M; i++){
    long long int B, C; cin >> B >> C;
    cb.at(i) = make_pair(C, B);
  }

  sort(cb.rbegin(), cb.rend());

  int now = 0;
  bool flag = false;
  for(int i = 0; i < M; i++){
    for(int j = 0; j < cb.at(i).second; j++){
      if((now+j) >= N || A.at(now+j) >= cb.at(i).first){
        flag = true;
        break;
      }
      A.at(now+j) = cb.at(i).first;
    }
    now+=cb.at(i).second;
    if(flag) {
      break;
    }
  }

  long long int sum = 0;
  for(int i=0; i < N; i++){
    sum += A.at(i);
  }

  cout << sum << endl;
}



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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;

int main() {
    fast;
    cin.tie(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w" , stdout);
#endif*/
    /*lld i,n,m,q;
    cin>>n>>m>>q;
    lld a[q],b[q],c[q],d[q];
    for(i=0;i<q;i++){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
        c[i]--;
        d[i]--;
    }
    vector<lld> v(n);
    for(i=0;i<q;i++){
        lld from=b[i];
        lld to=a[i];
        v[to]=1;
        v[from]=v[to]+c[i];
    }*/
    lld a, b, n;
    cin >> a >> b >> n;
    lld x = min(n, b - 1);
    lld ans = ((a * x) / b) - (a * (x / b));
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main ()
{
   string a;
   cin>>a;
if (a=="SUN")
      cout << "7" << endl;
if (a=="MON")
      cout << "6" << endl;
if (a=="TUE")
      cout << "5" << endl;
if (a=="WED")
      cout << "4" << endl;
if (a=="THU")
      cout << "3" << endl;
if (a=="FRI")
      cout << "2" << endl;
if (a=="SAT")
      cout << "1" << endl;


   return 0;
}


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

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int div_2(int N){
    if(N % 2 == 0) return - N / 2;
    else return - (N - 1) / 2;
}

string mod_2(int N){
    int s = abs(N) % 2;
    return to_string(s);
}

string base(int N, string S){
    if(N == 0){
        if(S == "") return "0";
        else return S;
    }
    return base(div_2(N), mod_2(N) + S);
}

int main(){
    int N;
    cin >> N;
    cout << base(N, "") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;



int main()
{
    int N;
    cin >> N;
    vl a(N);
    in(N,a);
    vl b(N,0);
    b[0] = a[0];
    reps(i,1,N){
        b[i] = b[i-1] + a[i];
    }
    ll x,y;
    ll ans = 1e18+10;
    
    reps(i,0,N-1){
        x = b[i];
        y = b.back() - b[i];
        ans = min(ans,abs(x-y));
    }
    out(ans);
    



    return 0;
}


Measured memory_bytes: 3328
from collections import defaultdict
import sys
input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(N)]
    dd = defaultdict(int)
    dd[0] = 0
    for w, v in items:
        for tw, tv in list(dd.items()):
            if tw + w <= W:
                dd[tw + w] = max(tv + v, dd[tw + w])
    print(max(dd.values()))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

bool flag[200];

int main(){
    int n, k;
    cin >> n >> k;
    vi d(k);
    vector<vector<int>> a(k, vector<int>(200, 0));
    rep(i, k){
        cin >> d[i];
        rep(j, d[i]){
            cin >> a[i][j];
            flag[a[i][j]] = true;
        }
    }
    int cnt = 0;
    rep(i, n){
        if(!flag[i+1]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
	ll A, B, C;
	cin >> A >> B >> C;

	if(C<=A+B+1){
		cout << B+ C <<endl;
	}else{
		ll ans = A+B+1;
		ans += B;
		cout << ans <<endl;
	}
  	
   
  	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N=200010;
int a[N];
int n, m;
int main(){
	int t;
	// while(){
		scanf("%d",&n);
		int cnt=0;
		for(int i=0; i<n; ++i){
			scanf("%d",a+i);
			if((i%2==0)&&a[i]%2)++cnt;
		}
		cout<<cnt<<endl;
	// }
}

Measured memory_bytes: 3656
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [n, k] <- fmap read . words <$> getLine :: IO [Int]
    as <- fmap read . words <$> getLine :: IO [Int]
    let gcds = foldr1 gcd as
    let mx = maximum as
    if (k <= mx) && (k `mod` gcds == 0)
        then putStrLn "POSSIBLE"
        else putStrLn "IMPOSSIBLE"

Measured memory_bytes: 36220
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      	int h[] = new int[n];
      
      for(int i= 0;i < n;i++){
      	h[i] = sc.nextInt();
      }
      
      int dp[] = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(h[1]-h[0]);
      
      for(int i = 2;i < n;i++){
      	dp[i] = Math.min(dp[i-1]+Math.abs(h[i]-h[i-1]),
                         dp[i-2]+Math.abs(h[i]-h[i-2]));
      }
        System.out.print(dp[n-1]);
    }
}

Measured memory_bytes: 51412
def resolve():
  N = int(input())
  A = [int(i) for i in input().split()]
  
  A = sorted(A, reverse=True)
  alice = 0
  bob = 0
  for i in range(0, len(A), 2):
    alice += A[i]
    if i+1 < len(A):
      bob += A[i+1]

  print(alice - bob)
  
resolve()

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#define PI 3.1415926535
#include<stdio.h>
#include<math.h>
int halftilting(double a, double b, double x);
int main()
{
	double a, b, x;
	long double alpha;
	scanf("%lf %lf %lf", &a, &b, &x);
	if (halftilting(a, b, x) == 1)
	{
		double tmp = 2 * (a * a * b - x) / (a * a * a);
		alpha = atan(tmp);
	}
	else
	{
		double tmp = b * b * a / (2*x);
		alpha = atan(tmp);
	}
	alpha = alpha * 180 / PI;
	printf("%.10Lf\n", alpha);
	return 0;
}
int halftilting(double a, double b, double x)
{
	if (x > 0.5 * a * a * b)
		return 1;
	else
		return -1;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

def bfs(pt,v):
    n = len(pt)
    d = [-1]*n
    d[v] = 0
    q = [v]
    c = 1
    while q:
        q1 = []
        for i in q:
            for j in pt[i]:
                if d[j]==-1:
                    d[j] = c
                    q1.append(j)
        q = q1
        c += 1
    return d

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n)]
    for i in range(len(s)):
        pt[s[i]-1].append(t[i]-1)
        if directed==False:
            pt[t[i]-1].append(s[i]-1)
    return pt

N = I()
a = Line(N-1,1)

s = [0]*(N-1)
t = [0]*(N-1)
for i in range(N-1):
    s[i] = a[i]
    t[i] = i+2

pt = edges_to_pt(s,t,N,True)
d = bfs(pt,0)
dmax = max(d)

v = [[] for _ in range(dmax+1)]
for i,d1 in enumerate(d):
    v[d1].append(i)

val = [0]*N
level = dmax-1
while level>=0:
    for v1 in v[level]:
        child_val_list = []
        for child in pt[v1]:
            child_val_list.append(val[child])
        if child_val_list:
            child_val_list.sort(reverse=True)
            val[v1] = max([x+(i+1) for i,x in enumerate(child_val_list)])
    level -= 1

print(val[0])

Measured memory_bytes: 70236
#include<stdio.h>
int main(){
	int i,j,a[3],temp;
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	for (i=0; i<3; i++){
		for(j=i+1; j<3; j++){
			if(a[i]>a[j]){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	}
	printf("%d %d %d\n", a[0], a[1], a[2]);
}


Measured memory_bytes: 2104
l=[]
a=int(input())
for i in range(a):
  b=int(input())
  l.append(b)
c=l.copy()
c.sort()
max1=c[-1]
max2=c[-2]

for i in l:
  if i==max1:
    print(max2)
  else:
    print(max1)

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

int main(){
	int S,h,m,s;
	cin>>S;
	h = S/3600;
	m = (S/60)%60;
	s = S % 60;
	cout<<h<<":"<<m<<":"<<s<<endl;

	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll inv(ll x){
  return pow(x,mod-2);
}
ll dp[100005]={0},ndp[100005]={0};
signed main(){
  ll n,x;
  cin>>n>>x;
  dp[x]=1;
  vector<ll> vec;
  vec.push_back(17441744);
  for(int i=1;i<=n;i++){
    ll a;
    cin>>a;
    vec.push_back(a);
  }
  sort(vec.begin(),vec.end(),greater<ll>());
  for(int i=1;i<=n;i++){
    ll val=vec[i];
    ll perm=inv(n-i+1);
    ll non_perm=(mod+1-perm)%mod;
    for(int j=0;j<=x;j++){
      ndp[j%val]+=dp[j]*perm%mod;
      ndp[j]+=dp[j]*non_perm%mod;
    }
    for(int j=0;j<=x;j++) {
      dp[j]=ndp[j]%mod;
      ndp[j]=0;
    }
  }
  //for(int i=0;i<=x;i++) cout<<dp[i]<<" ";
  //cout<<endl;
  ll ans=0;
  for(int i=0;i<=x;i++) {
    ans+=(dp[i]*i)%mod;
    ans%=mod;
  }
  for(int i=1;i<=n;i++){
    ans*=i;
    ans%=mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
b=list(set(a))
m=len(b)

p=[0]*(10**6+1)
for i in b:
    if p[i]==0:
        j=2
        while i*j<=10**6:
            p[i*j]=1
            j+=1
a.append(-1)
a.insert(0,-1)
ans=0
for i in range(1,n+1):
    if a[i]!=a[i+1] and a[i]!=a[i-1] and p[a[i]]==0:
        ans+=1
print(ans)


Measured memory_bytes: 134784
#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 2e9
#define ll long long
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(v) v.begin(), v.end()

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c; cin >> c;
    if (c == 'a' or c=='e' or c == 'i' or c == 'u' or c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}



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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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



int main(){
  string s,t;
  cin >> s >> t;
  vector<vector<string> > dp_s(3,vector<string>(t.size()+1,""));
  for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]){
                dp_s[i%3][j].push_back(s[i]);
                dp_s[(i + 1)%3][j + 1] = dp_s[i%3][j];
            }
            else{
                if(dp_s[(i+1)%3][j].size() > dp_s[i%3][j+1].size()){
                    dp_s[(i + 1)%3][j + 1] = dp_s[(i+1)%3][j];
                }else{
                    dp_s[(i + 1)%3][j + 1] = dp_s[i%3][j+1];
                }
            }
        }
        rep(j,t.size()) dp_s[i%3][j].clear();

    }
    cout << dp_s[s.size()%3][t.size()] << endl;

  return 0;
}


Measured memory_bytes: 14096
#include <bits/stdc++.h>
 using namespace std;
  int main (){
      int n;
      cin >> n;
      if(n%1000==0){
          cout << 0 << endl;
      }
      else{
      int ans=1000-(n%1000);
      cout << ans << endl;
      }
      return 0;
  }

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
const int M=1001;
int n,A[M][M];
int id[M][M],tot;
vector<int>d[500001];
int dp[500001],ans;
bool fl;
int dfs(int x){
	if(dp[x])return dp[x];
	int res=0;
	for(int i=0;i<(int)d[x].size();i++){
		int y=d[x][i];
		res=max(res,dfs(y));
	}
	dp[x]=res+1;
	return dp[x];
}
int dfn[500001],ToT,low[500001],ins[500001],stk[500001],top;
void Tarjan(int x){
	dfn[x]=low[x]=++ToT;
	ins[x]=1;
	stk[++top]=x;
	for(int i=0;i<(int)d[x].size();i++){
		int y=d[x][i];
		if(!dfn[y]){
			Tarjan(y);
			low[x]=min(low[x],low[y]);
		}else if(ins[y])low[x]=min(low[x],dfn[y]);
	}
	if(dfn[x]==low[x]){
		int e;
		int cnt=0;
		do{
			e=stk[top--];
			ins[e]=0;
			cnt++;
		}while(e!=x);
		if(cnt>1)fl=1;
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++)scanf("%d",&A[i][j]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<i;j++)id[i][j]=id[j][i]=++tot;
	}
	for(int i=1;i<=n;i++)
		for(int j=2;j<n;j++)
			d[id[i][A[i][j-1]]].push_back(id[i][A[i][j]]);
	for(int i=1;i<=tot;i++)if(!dfn[i])Tarjan(i);
	if(fl){
		puts("-1");
		return 0;
	}
	for(int i=1;i<=tot;i++)ans=max(ans,dfs(i));
	printf("%d\n",ans);
}

Measured memory_bytes: 45440
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    int a = 0;
    for(int i=1;i<=int(sqrt(N));i++){
        if(N%i==0){
            if(a<i) a = i;
        }
    }
    cout << a+N/a-2 << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

bool is_prime[1121];
int dp[40001][20]; //dp[num][size] = count

int main(){

  memset(is_prime,true,sizeof(is_prime));

  is_prime[0] = false;
  is_prime[1] = false;
  for(int i=2;i*i<=1120;i++){
    if(!is_prime[i]) continue;

    for(int j=i+i;j<=1120;j+=i){
      is_prime[j] = false;
    }
  }

  vector<int> primes;
  for(int i=0;i<=1120;i++){
    if(is_prime[i]) {
      primes.push_back(i);
    }
  }

  memset(dp,0,sizeof(dp));
  dp[0][0] = 1;
  for(int i=0;i<primes.size();i++){
    for(int num=1120*14;num>=0;num--){
      for(int j=14;j>=0;j--){
	dp[num + primes[i]][j+1] += dp[num][j];
      }
    }
  }
  
  int target;
  int size;
  while(~scanf("%d %d",&target,&size)){
    if(target == 0 && size == 0) break;
    printf("%d\n",dp[target][size]);
  }
}

Measured memory_bytes: 4336
N = int(input())

A = []
tmp = N

while tmp>0:
    A.append(tmp%10)
    tmp = (tmp - tmp%10)//10

ans1 = sum(A)

for i in range(len(A)-1):
    A[i] = 9
    A[i+1] = A[i+1] -1

print(max(ans1, sum(A)))

Measured memory_bytes: 3064
import sys
def input():
	return sys.stdin.readline().strip()

M, K = list(map(int, input().split()))

if K >= 2**M:
	print(-1)
	exit()


def list_print(A):
	length = len(A)
	for i in range(length - 1):
		print(A[i], end="")
		print(" ", end="")
	print(A[- 1])

if M == 1:
	if K == 0:
		list_print([0, 0, 1, 1])
		exit()
	elif K == 1:
		print(-1)
		exit()


ans = [K]

for i in range(2**M):
	if i != K:
		ans.append(i)

ans.append(K)
for i in range(2**M - 1, -1, -1):
	if i != K:
		ans.append(i)



list_print(ans)

Measured memory_bytes: 68892
#include<stdio.h>

int main(void)
{
	int a, b, c;


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

	c = b % a;


	if (c == 0)
	{
		printf("%d", a + b);
	}
	else
	{
		printf("%d", b - a);

	}

	return 0;


}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &s[i])
	}

	sort.Ints(s)
	ans := 0
	for i := s[n/2-1]+1; i <= s[n/2]; i++ {
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
import java.util.Scanner;

public class Main {
	static int n,k,m,l,a,b;
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		n=sc.nextInt();
		int ans=0;
		int v[]=new int[n];
		int c[]=new int[n];
		for(int i=0;i<n;i++) {
			v[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			c[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			if(v[i]-c[i]>0)ans+=v[i]-c[i];
		}
		System.out.println(ans);
    }
}


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

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

typedef long long ll;

int main() {
	int N; cin >> N;
	vector<int> a(N), b(N);
	rep(i, N) scanf("%d%d", &a[i], &b[i]);
	if (a == b) {
		cout << 0 << endl;
		return 0;
	}
	ll sum = 0;
	int mi = INT_MAX;
	rep(i, N) {
		sum += a[i];
		if (a[i] > b[i]) mi = min(mi, b[i]);
	}
	cout << sum - mi << endl;
}


Measured memory_bytes: 384