akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int compar(const void *a,const void *b);

int main()
{
    int N,H,a[100001],b[100001],i;
    int a_max,count;

    scanf("%d %d",&N,&H);
    for(i=0;i<N;i++){
        scanf("%d %d",&a[i],&b[i]);
    }

    qsort(b,N,sizeof(int),compar);

    a_max=0;
    for(i=0;i<N;i++){
        if(a_max<a[i]){
            a_max = a[i];
        }
    }

    count=0;

    for(i=0;i<N;i++){
        if((b[i]>a_max)&&(H>0)){
            H = H - b[i];
            count++;
        }else{
            break;
        }
    }
    if(H>0) count = count + (H + a_max - 1)/a_max;

    printf("%d\n",count);

    return 0;

}

int compar(const void *a,const void *b)
{
    return *(int *)b - *(int *)a;
}

Measured memory_bytes: 1276
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

int main() {
  ll a[] = {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 << a[k - 1] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = Integer.parseInt(scanner.next());
        int f = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());

        if (m >= b) {
            System.out.println(0);
        } else {
            if (f >= b - m) {
                System.out.println(b - m);
            } else {
                System.out.println("NA");
            }
        }
    }
}



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

int main(){
  string s, t;
  cin >> s >> t;
  string INF(s.size(), '}');
  string ans = INF;
  for(int i = 0; i + t.size() <= s.size(); i++){
    int flag = 1;
    for(int j = 0; j < t.size(); j++){
      if(s[i+j] != '?' && s[i+j] != t[j]) flag = 0;
    }
    if(!flag) continue;
    string x = s;
    for(int k = 0; k < t.size(); k++) x[i+k] = t[k];
    for(int k = 0; k < s.size(); k++){
      if(x[k] == '?') x[k] = 'a';
    }
    ans = min(ans, x);
  }
  if(ans == INF) cout << "UNRESTORABLE" << endl;
	else cout << ans << endl;
  return 0;
}


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

//E869120は1円硬貨をA枚と500円硬貨を無限枚持っています.
//これらの硬貨だけを使うことによって, ちょうどN円を支払うことができるかを判定しなさい.

int main() {
  
  int N, A, M;
  cin >> N >> A;
  
  M = N % 500;

  if (M <= A) {
    cout << "Yes" << endl;
  }
  
  else {
  	cout << "No" << endl;  
  }
  
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}




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


	solve();
#ifdef _WIN32
	system("PAUSE");
#endif
	return 0;
}

Measured memory_bytes: 3100
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const llong MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname);
int range_check(int val, int min, int max) {
	if (val < min) {
		return min;
	}
	if (val > max) {
		return max;
	}
	return val;
}
template<class T,class T1>
bool array_find(const T& array, const T1& dst) {
	auto result = find(array.first(), array.end(), dst);
	if (result == array.end()) {
		return false;
	}
	else {
		return true;
	}
}
int main() {
	llong n;
	cin >> n;
	vector<llong> vec(n);
	REP(i, n) {
		cin >> vec[i];
	}
	vector<llong> cnt1(61,0);
	REP(b, 61) {
		llong check_bit = static_cast<llong>(1) << b;
		REP(i, n) {
			if (check_bit & vec[i]) {
				cnt1[b] += 1;
			}
		}
	}
	llong ans = 0;
	REP(b, 61) {
		llong add_bit = (static_cast<llong>(1) << b) % MOD;
		llong add_num = (add_bit * cnt1[b]) % MOD;
		add_num = (add_num * (n - cnt1[b])) % MOD;
		ans = (ans + add_num) % MOD;
	}
	cout << ans << endl;
	return 0;
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname) {
	ofstream ofs(fname);
	if (ofs.fail()) { cerr << "cannot open file. :" + fname << endl; return -1; }
	for (auto dp_row : dp) {
		for (auto dp_cell : dp_row) {
			ofs << dp_cell << ",";
		}
		ofs << endl;
	}
	ofs.close();
	return 0;
}


Measured memory_bytes: 2560
N,L = map(int,input().split())
Ans = 0
if L > 0:
    for a in range(0,N):
        Ans = L + a + Ans
    print(Ans - L)
else:
    for a in range(0,N):
        Ans = L + a + Ans
        if 0 > a + L:
            if a == N - 1:
                print(Ans - (L + a))
        else:
            if a == N - 1:
                print(Ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<math.h>
#include<map>
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
typedef pair<int, int> P;
typedef pair<pair<P, P>, P>PP;
typedef long long LL;
#define INF LL(1e18)
#define N 2*100000
LL n, sum;
LL a[N], rui[N], ans = INF;
int main()
{
	cin >> n;
	REP(i, n)
		cin >> a[i];
	REP(i, n)
		rui[i] = a[i] + (i ? rui[i - 1]: 0);
	REP(i, n - 1)
		ans = min(abs(rui[i] - rui[n - 1] + rui[i]), ans); 
	cout << ans << endl;
	return 0;
}

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

string s;

int C(){
	int c=0;
	for(int i=0;i<s.length()-1;i++){
		if(s[i]!=s[i+1]) c++;
	}
	return c;
}

int main(){
	cin >> s;
	int c=0;
	cout << C() << endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    string s;
    cin>>s;
    int p=0;
    bool w=true;
    while(p<s.size()){
        if(s.at(p)=='h'){
            if(p<s.size()-1&&s.at(p+1)=='i')p+=2;
            else{
                w=false;p++;
            }
        }
        else {
            w=false; p++;
        }

    }
    if(w)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int cnt = 0;


	if (s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
	else if (s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

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 x;

signed main(){
    cin>>x;
    cout<<(!x)<<endl;
}

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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

using pii = pair<int, int>;

inline void Main() {
  // code
  int n,m,l[(int)1e5],r[(int)1e5];
  cin>>n>>m;
  rep(i,m) cin >>l[i]>>r[i];
  sort(l,l+m);
  sort(r,r+m);
  int res = r[0]-l[m-1]+1;
  cout<<(res < 0 ? 0 : res)<< endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main()
{
  int n;
  int a[2][101];
  int i,j,k;
  int sum=0,ans=-1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[0][i]);
  }
  for(i=0;i<n;i++){
    scanf("%d",&a[1][i]);
  }
  for(k=0;k<n;k++){
    sum=0;
    for(i=0;i<=k;i++){
      sum+=a[0][i];
    }
    for(j=k;j<n;j++){
      sum+=a[1][j];
    }
    if(sum>ans) ans=sum;
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1732
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next()); //N軒の店があり
        int M = Integer.parseInt(sc.next()); //M本の栄養ドリンクを買いたい
       
        long[] A = new long[N]; //iの店　1本Ai円の栄養ドリンクを
        int[] B = new int[N]; //Bi本買える
        //key：値段　value：本数
        Map<Long, Integer> map = new HashMap<>();
        
        for(int i=0; i<N; i++) {
            A[i] = Long.parseLong(sc.next());
            B[i] = Integer.parseInt(sc.next());
            if(map.containsKey(A[i])) {
                map.put(A[i], map.get(A[i])+B[i]);
            }else {
                map.put(A[i], B[i]);
            }
        }
        //昇順(安い順)に並べ替え
        Object[] key = map.keySet().toArray();
        Arrays.sort(key);
        
        int bin = M; //必要な本数
        long sum = 0;
        for(Object ob : key) {
            String s = String.valueOf(ob);
            long k = Long.parseLong(s);
            if(bin > map.get(k)) {
                sum += k * map.get(k);
                bin -= map.get(k);
            }else {
                sum += k * bin;
                bin = 0;
            }
            if(bin <= 0) {
                break;
            }
        }
        System.out.println(sum);
        
    }
}

Measured memory_bytes: 68884
L, R = map(int, input().split())

if R-L > 2020:
  print(0)
  exit()

R = min(R, L+4038)
ans = 2018
for i in range(L, R):
  for j in range(i+1, R+1):
    x = i*j%2019
    ans = min(ans, x)
print(ans)    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N,M,X,lc,rc;
    cin>>N>>M>>X;
    lc=rc=0;
    REP(i,M){
        int a;
        cin>>a;
        if(a<X)lc++;
        if(a>X)rc++;
    }
    cout<<min(lc,rc)<<endl;
}



Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC158C
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            var A = AB[0];
            var B = AB[1];

            if (decimal.Floor(A / 0.08M) == decimal.Floor(B / 0.1M))
            {
                Console.WriteLine(Math.Round(A / 0.08M, 0).ToString("#"));
                return;
            }
            else
            {
                var ans = Math.Min(decimal.Floor(A / 0.08M), decimal.Floor(B / 0.1M));
                while (ans <= 1000)
                {
                    if (decimal.Floor(ans * 0.08M) == A && decimal.Floor(ans * 0.1M) == B)
                    {
                        Console.WriteLine(ans.ToString("#"));
                        return;
                    }
                    ans++;
                }
            }

            Console.WriteLine(-1);

        }
    }
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }


int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI A(n);
        FOR(i,0,n)
            cin >> A[i];
        int ans = 0;
        FOR(i,1,n-1) {
            set<int> S;
            S.insert(A[i]);
            S.insert(A[i-1]);
            S.insert(A[i+1]);
            if (S.size() == 3) {
                S.erase(S.begin());
                if (A[i] == *S.begin())
                    ans ++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 764
inputval = input()
in2 = list (inputval)
result = 1
count = 0
for i in in2:
    count += 1
    if count%2 == 1:
        if i == 'L':
            result = result * 0
    if count%2 == 0:
        if i =='R':
            result = result * 0

if result == 0:
    print ('No')
else :
    print ('Yes')

Measured memory_bytes: 3060
// 及时当勉励，岁月不待人！
//当前状态 : attempted
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<cmath>
#include<string>
#include<iomanip>
#define MP make_pair
using namespace std;
typedef long long ll;

const int inf=0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
inline int read(){int ret = 0, sgn = 1;char ch = getchar();while(ch < '0' || ch > '9'){if(ch == '-')sgn = -1;ch = getchar();} while (ch >= '0' && ch <= '9'){ret = ret*10 + ch - '0';ch = getchar();}return ret*sgn;}
struct MN{int a;int b;};


//结构体
//全局变量
const int maxn=1005;
//函数
int main()
{
  std::ios::sync_with_stdio(false);std::cin.tie(0);
  //freopen("d:\\desk\\in.txt","r",stdin);
  //freopen("d:\\desk\\out.txt","w",stdout);
  ll a,b,c,d;cin>>a>>b>>c>>d;
  ll ans=max(max(a*c,a*d),max(b*c,b*d));
  cout<<ans<<endl;
}

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

int main() {
	int n;
	cin >> n;
	
	if(n == 25) {
		cout << "Christmas";
	} else if(n == 24) {
		cout << "Christmas Eve";
	} else if(n == 23) {
		cout << "Christmas Eve Eve";
	} else {
		cout << "Christmas Eve Eve Eve";
	}
	return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

bool isPalindrome(int x){
  string s = to_string(x);
  int n=s.length();
  bool ret=true;
  repeat(i,(n+1)/2){
    ret &= s[i]==s[n-1-i];
  }
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A,B,K;cin>>A>>B>>K;
  if(B-A+1<=2*K){
    for(int i=A;i<=B;i++){
      cout << i << endl;
    }
  }else{
    repeat(i,K){
      cout << A+i << endl;
    }
    repeat(i,K){
      cout << B-K+1+i << endl;
    }
  }
  return 0;
}


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

static const int NEVER = -1;
static const int CLOUD = 0;

int main(){
    int h,w;
    cin >> h >> w;
    char C[h][w];
    int N[h][w];
    char ch;
    
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> ch;
            if(ch=='.'){
                C[i][j] = '.';
            }else{
                C[i][j] = 'c';
            }
        }
    }
    for(int i=0; i<h; i++){
        bool cloud = false;
        int clou = 0;
        for(int j=0; j<w; j++){
            if(C[i][j]=='c'){
                N[i][j] = CLOUD;
                cloud = true;
                clou = 0;
            }else{
                if(cloud){
                    clou++;
                    N[i][j] = clou;
                }else{
                    N[i][j] = NEVER;
                }
            }
        }
    }
    for(int i=0; i<h; i++){
        int s=0;
        for(int j=0; j<w; j++){
            if(s++) cout << " ";
            cout << N[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3124
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main(void){
    
    int N;
    double S[1000] = {}, a = 0, m, sum = 0;    // 変数：得点「 S 」、標準偏差「 a 」、平均値「 m 」、合計値「 sum 」
    
    while(cin >> N, N){
        for(int i = 0; i < N; i++){
            cin >> S[i];
            sum += S[i];
        }
        
        m = sum / N;     // 計算：平均値を求めた（平均値　＝　合計値　÷　データの個数）
    
        for(int j = 0; j < N; j++){
            a += pow(S[j] - m, 2) / N;
        }
        
        printf( "%.8f\n", sqrt(a) );
        
        // 代入：再度計算するために初期値に戻す
        a = 0;
        sum = 0;
    }
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <algorithm>
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
 
int main() {
  int n,k,a=1,b;
  long double t=0;
  cin >> n>> k;
  if(k==1) cout << 1 << endl;
  else{
    for(int i=0;i<100;i++){
    a *= 2;
    if(a>=k){
      break;
    }
  }
  t += (long double)1/a;
  if(n>=2){
    
  for(int j=2;j<=n;j++){
   if(a>=2){
     if(j*a/2>=k){
      a /= 2;
     }
     t += (long double)1/a;
   }
   else t += 1;
  }
  }
  t *= (long double) 1/n;
  cout << std::setprecision(12)<< t << endl;
  }
}


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

int X, Y;
const int MOD = 1000000007;
const int MAX = 710000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();

    cin >> X >> Y;

    if ((X+Y) % 3 == 0 && (X+Y)/3 <= X && (X+Y)/3 <= Y) {
        cout << COM((X+Y)/3, Y-(X+Y)/3) << endl;
    }
    else {
        cout << 0 << endl;
    }


    return 0;
}


Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"


int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0;
	cin>>x;
	for(ll i=2;i<x;i++)
	{
		m=x%i;
		if(m==0){
			i=2,x++;
		}

	}
	cout<<x<<nw;
	
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <stdio.h>
#include <cmath>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int x[110]={}, y[110]={};

double minko(int p,int n){
  double d=0;
  if(p==INF){
    rep(i,n) d = max(abs(x[i]-y[i])*1., d);
    return d;    
  }
  
  rep(i,n) d += pow(abs(x[i]-y[i]),p);
  return pow(d, 1./p);
}

int main(){
  int n;
  cin >> n;
  rep(i,n) cin >> x[i];
  rep(i,n) cin >> y[i];  

  printf("%.10f\n", minko(1,n));
  printf("%.10f\n", minko(2,n));
  printf("%.10f\n", minko(3,n));
  printf("%.10f\n", minko(INF,n));  
}



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

int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  vector<string> res(30000);
  int iter = 0, alpha = 0;
  rep(i,5){
    rep(j,int(s.size())-i){
      rep(k,i+1)res[iter].push_back(s[j+k]);
      iter++;
    }
  }
  sort(res.begin(),res.end());
  res.erase(unique(res.begin(),res.end()),res.end());
  cout << res[k] << endl;
  return 0;
}

Measured memory_bytes: 4320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using vll = vector<ll>;
using vvll = vector<vll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using plli = pair<ll, int>;
using vplli = vector<pair<ll, int>>;
using pllll = pair<ll, ll>;
using vpllll = vector<pair<ll, ll>>;

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;
}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i - 1; i >= (ll)end_i; i--)

long long INF = 1LL << 60;
int main()
{
    while (true)
    {
        int n;
        cin >> n;
        if (n == 0)
            break;
        ll res = 0;
        int max = -(1 << 30), min = 1 << 30;
        rep(i, 0, n)
        {
            int s;
            cin >> s;
            res += s;
            chmax(max, s);
            chmin(min, s);
        }
        cout << (res - max - min) / (n - 2) << endl;
    }
    return 0;
}



Measured memory_bytes: 2984
// Getting Started - Maximum Profit
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D
using System;
using System.Linq;

namespace ALDS1_1_D {
	class Program {
		public Program() {}
		
		public static void Main() {
			new Program().Calc();
		}
		
		void Calc() {
			var N = int.Parse(Input);	// Number of elements
			int min = int.Parse(Input);
			int max = -min;
			
			for(int i = 1; i < N; i ++) {
				int r = int.Parse(Input);
				if(max < r - min) max = r - min;
				if(min > r) min = r;
			}
			
			Output(max.ToString());
		}
		
		String Input {
			get {
				return Console.ReadLine();
			}
		}
		
		void Output(String str) {
			Console.WriteLine(str);
		}
	}
}

Measured memory_bytes: 9244
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    vector<long long> x(N);

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


    if(K==1){
        cout << min( abs(x[minus-1]),x[minus]);
    }else{
        long long min_length = 0x7fffffffffffffff;
        for(int i=0;i<N-K+1;i++){
            long long min_val = x[i];
            long long max_val = x[i+K-1];
            if(min_val*max_val>0){
                long long new_length = max(abs(min_val),abs(max_val));
                if(new_length<min_length){
                    min_length=new_length;
                }
            }else{
                long long new_length = min(abs(min_val)*2+abs(max_val),abs(min_val)+abs(max_val)*2);
                if(new_length<min_length){
                    min_length=new_length;
                }
            }
        }
        cout << min_length;
    }

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(void)
{
	int s;
	cin>>s;
	if(s==0) cout<<"0"<<endl;
	if(s==100) cout<<"1"<<endl;
	if(s==10) cout<<"1"<<endl;
	if(s==1) cout<<"1"<<endl;
	if(s==110) cout<<"2"<<endl;
	if(s==11) cout<<"2"<<endl;
	if(s==101) cout<<"2"<<endl;
	if(s==111) cout<<"3"<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/dp_3rd/g.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
#include <queue>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const int MAX = 100100;
ll N, M;
vector<int> G[MAX];
vector<int> G_INV[MAX];
ll indeg[MAX] = {0};
ll sorted[MAX] = {0};
ll dp[MAX] = {0};

void input() {
  cin >> N >> M;
  ll x, y;
  loop(n,0,M) {
    cin >> x >> y;
    x--;y--;
    G[x].push_back(y);
    G_INV[y].push_back(x);
    indeg[y]++;
  }
}

void tsort() {
  queue<int> Q;
  int index = 0;
  for (int n=0; n<N; n++) {
    if (indeg[n] == 0) {
      Q.push(n);
      indeg[n]--;
      sorted[index++] = n;
    }
  }

  while (Q.size()) {
    int u = Q.front(); Q.pop();
    for (auto&& v: G[u]) {
      indeg[v]--;
      if (indeg[v] == 0) {
        Q.push(v);
        sorted[index++] = v;
      }
    }
  }
}

void dump() {
  for (int n=0; n<N; n++) {
    cout << sorted[n] << " ";
  }
  cout << endl;
}

void solve() {
  tsort();
  // dump();
  ll max_ = 0;
  // 最長経路を求める
  for (int n=N-1; n>=0; n--) {
    // トポロジカルソート済みの先頭からn番目の頂点
    int u = sorted[n];
    // v := 頂点uに向かう始点
    for (auto&& v: G_INV[u]) {
      chmax(dp[v], dp[u] + 1);
      chmax(max_, dp[v]);
    }
  }
  cout << max_ << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 13568
#include<iostream>

int main(){
  int n1, n2, n3;
  std::cin >> n1;
  std::cin >> n2;
  std::cin >> n3;
  if(n1 == 7){
   if(n2 == 5 && n3 == 5){
	  std::cout << "YES" << std::endl;
     return 0;
   }
  }
  else if(n2 == 7){
    if(n1 == 5 && n3 == 5){
	  std::cout << "YES" << std::endl;
      return 0;
    }
  } else if(n3 == 7){
    if(n1 == 5 & n2 == 5){
	  std::cout << "YES" << std::endl;
      return 0;
    }
  }
  std::cout << "NO" << std::endl;
  return 0;
}

Measured memory_bytes: 2992
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

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

int lcm(int x, int y){
    return x / gcd(x, y) * y;
}

int main(){
    int n;
    cin >> n;
    int ans = 1;
    rep(i, n){
        int a;
        cin >> a;
        ans = lcm(ans, a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
constexpr int inf = 1 << 30;
signed main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	vector<vector<int>> a(n, vector<int>(0));
	for(int i = 0, j, k; i < m; ++i)
	{
		scanf("%d%d", &j, &k);
		a[j - 1].push_back(k - 1);
		a[k - 1].push_back(j - 1);
	}
	queue<int> q;
	q.push(0);
	vector<int> cost(n, inf);
	cost[0] = 0;
	vector<int> ans(n, -1);
	for(int s; !q.empty(); )
	{
		s = q.front();
		q.pop();
		for(int i = 0; i < a[s].size(); ++i)
		{
			if(cost[a[s][i]] > cost[s] + 1)
			{
				cost[a[s][i]] = cost[s] + 1;
				ans[a[s][i]] = s;
				q.push(a[s][i]);
			}
		}
	}
	bool yes = true;
	for(int i = 1; i < n; ++i)
	{
		yes &= ans[i] != -1;
	}
	if(yes)
	{
		printf("Yes\n");
		for(int i = 1; i < n; ++i)
		{
			printf("%d\n", ans[i] + 1);
		}
	}
	else
	{
		printf("No\n");
	}
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S[101010];

ll cnt[256];

void solve() {
	int i,j,k,l,r,x,y,z; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>S[i];
		cnt[S[i][0]]++;
	}
	
	string T="MARCH";
	ll ret=0;
	FOR(z,5) FOR(y,z) FOR(x,y) ret+=cnt[T[x]]*cnt[T[y]]*cnt[T[z]];
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ll long long
int main() {
	int i,j,k,l,n,m,a,b,c;
	cin>>a>>b>>c;
	i = a;
	a = b;
	b = i;
	i = a;
	a = c;
	c = i;
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
 
typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;
 
const double PI = 3.141592653589793238463;
 
using namespace std;
 
const int MAXN = 1000500;
// const int MAXN = 1050;
// const long long int mod = 1000003;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
 
i64 mod = 1000000009;
 
i64 n, m, r;
 
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	cout.precision(16);
 
	cin >> r;
	cout << 2 * r*PI << endl;
 
 
	//a.resize(n + 1);
	//dp.assign(n + 1, -1);	
 
	return 0;
}


Measured memory_bytes: 3176
# https://atcoder.jp/contests/keyence2019/tasks/keyence2019_b

import re

S = input()

if "keyence" == S:
    print("YES")
else:
    patterns = ["^keyence(.*)", "^k(.*)eyence$", "^ke(.*)yence$", "^key(.*)ence$", "^keye(.*)nce$", "^keyen(.*)ce$", "^keyenc(.*)e$", "keyence$"]

    matched = False
    for pattern in patterns:
        matchOB = re.search(pattern, S)
        if matchOB:
            matched = True
            break
    if matched:
        print("YES")
    else:
        print("NO")




Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define sz 200009
using namespace std;
typedef long long ll;
int vis[sz+7];
void sieve()
{
  ll i,j;
  vis[0]=vis[1]=1;
  for (i=4; i<=sz; i+=2) vis[i]=1;

  for(i=3; i<=sz; i+=2)
  {
     if (vis[i]==0)
     {
       for (j=i*i; j<=sz; j+=i) vis[j]=1;
     }
  }
}
int main()
{
  sieve();

  int i,n=0;
  cin>>n;
  for(i=n; ; i++)
  {
  	if(vis[i]==0) {
  		cout<<i<<endl;
  		break;
  	}
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 1e6+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n,a[maxn],cnt[maxn];

int main()
{
    fastio();
    cin>>n;
    int lim = 1e6,one = 0;
    rep(i,1,n){
        cin>>a[i];
        if(a[i]==1) one = 1;
        cnt[a[i]]++;
    }
    if(one){
        if(cnt[1]>1) cout<<0<<endl;
        else cout<<1<<endl;
        return 0;
    }
    int ans = 0;
    rep(i,1,n){
        if(cnt[a[i]]>1) continue;
        int flag = 1;
        for(int j=2;j*j<=a[i];j++){
            if(a[i]%j==0 && (cnt[j]||cnt[a[i]/j])) flag = 0;
        }
        ans += flag;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8344
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,S[100000],q,key,sum;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d",&key);
    if(*lower_bound(S,S+n,key)==key)sum++;
  }
  printf("%d\n",sum);
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> b(n + 1);
  b[0] = b[n] = 1e7;
  for (int i = 1; i < n; i++) {
    cin >> b[i];
  }
  int ans = 0;
  rep(i, n) { ans += min(b[i], b[i + 1]); }
  cout << ans << endl;
  return 0;
}

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

class Combination {
public:
    Combination(ll max_num, ll mod) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        mod_ = mod;
        for (ll i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % mod_;
            inv_fact_[i] = MODpow(fact_[i], mod_ - 2);
            assert(fact_[i] * inv_fact_[i] % mod_ == 1);
        }
    }
    ll operator()(ll n, ll m) const {
        return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
    }
private:
    ll MODpow(ll n, ll m) const {
        ll result = 1;
        while (m) {
            if (m % 2 == 1) {
                result *= n;
                result %= mod_;
            }

            m /= 2;
            n *= n;
            n %= mod_;
        }

        return result;
    }

    vector<ll> fact_, inv_fact_;
    ll mod_;
};

int main() {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;

    constexpr ll MOD = (ll)1e9 + 7;
    Combination comb(H + W + 1, MOD);

    ll ans = 0;
    for (ll i = B; i < W; i++) {
        //スタートから(H - A, i)に行く方法 * (H - A + 1, i)からゴールへ行く方法
        ans += comb(H - A - 1 + i, i) * comb(A - 1 + W - i - 1, A - 1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define foru(i,a,n) for(ll i=(a); i<=(n); ++i)
#define ford(i,n,a) for(ll i=(n); i>=(a); --i)
using namespace std;
const int N = 202020;
ll n, k, a[N], b[N], z[N], su[N], m = 0;
string s;

int main() {
    //freopen("a.in","r",stdin);
    cin >>n >>k >>s;
    s = s + '@';
    int j = 0;
    foru(i,1,n) if(s[i] != s[i-1]){
        a[++m] = i - j;
        b[m] = s[j] - 48;
        j = i;
    }
    su[0] = 0;
    z[0] = 0;
    foru(i,1,m){
        z[i] = z[i-1] + (b[i]==0);
        su[i] = su[i-1] + a[i];
    }
    ll res = 0;
    foru(i,1,m){
        int d = 1, c = i, mid, pos = i + 1;
        while(d<=c){
            mid = (d+c)/2;
            if(z[i] - z[mid-1] <= k) pos = mid, c = mid - 1; else d = mid + 1;
        }
        res = max(res, su[i] - su[pos - 1]);
    }
    cout <<res;
    return 0;
}

Measured memory_bytes: 5756
#include<bits/stdc++.h>
using namespace std;
bool can[410][410];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	memset(can,true,sizeof(can));
	for (int i=1;i<=m;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		if (can[x][y])
		{
			can[x][y]=can[y][x]=0;
			for (int j=1;j<=n;j++)
			{
				if (!can[j][x]) can[j][y]=can[y][j]=0;
				if (!can[j][y]) can[j][x]=can[x][j]=0;
			}
		}
		else for (int j=1;j<=n;j++) can[j][x]=can[x][j]=can[j][y]=can[y][j]=0;
	}
	int ans=0;
	for (int i=1;i<=n;i++)
	for (int j=i+1;j<=n;j++) ans+=can[i][j];
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    double a=-1,b=-1,c;
    while(scanf("%lf",&c)!=EOF){
        if(b==-1){
            b=c;
            a=c;
        }else{
        a=max(a,c);
        b=min(b,c);
        }
    }
    printf("%.10lf\n",a-b);
    return 0;
}

Measured memory_bytes: 1224
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100010;

int dp[MAXN][5], s[5];
char str[MAXN];

int judge(char x)
{
    if (x == 'r')
    {
        return 3;
    }
    else if (x == 's')
    {
        return 1;
    }
    else
    {
        return 2;
    }
}

int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    scanf("%d%d%d", &s[1], &s[2], &s[3]);
    scanf("%s", &str);
    memset(dp, 0, sizeof(dp));
    int ans = 0;
    for (int i = 1; i <= k; i ++)
    {
        int j = i + k;
        int now = judge(str[i - 1]);
        ans += s[now];
        while (j <= n)
        {
            int tmp = judge(str[j - 1]);
            if (tmp != now)
            {
                ans += s[tmp];
                now = tmp;
            }
            else
            {
                now = 0;
            }
            j += k;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main()

{
        int a,b,c;
        cin>>a>>b>>c;
        if(a==b&&a!=c)
            cout<<c;
       else if(b==c&& b!=a)
        cout<<a;
       else cout<<b;
     return 0;
}



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

int main(){
int n,count=0;
cin >>n;
int a[n];
for(int i=0;i<n;i++){
cin >> a[i];
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
bool x=false;
if (a[i]%2==0) {
a[i]/=2;
count++;
}
else x=true;
if(x) break;
}
}
cout << count <<  endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define DEBUG false

#define MAX_V 1100

int V;
vector<vector<int>> G(1100);
int match[MAX_V];
bool used[MAX_V];

bool dfs(int v){
	used[v] = true;
	rep(i, G[v].size()){
		int u = G[v][i], w = match[u];
		if(w < 0 || !used[w] && dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

ll solve(){
	ll ret = 0;
	memset(match, -1, sizeof(match));
	rep(v, V){
		if(match[v] < 0){
			memset(used, 0, sizeof(used));
			if(dfs(v)) ret++;
		}
	}
	return ret;
}

int main(){

	ll n, m;
	/*
	vector<int> prime;
	vector<bool> used(10000001);
	REP(i, 2, 10000001){
		if(!used[i]) prime.push_back(i);
		for(int j = 2; i * j < 10000001; j++) used[i*j] = true;
	}
	*/
	
	while(cin >> n >> m){
		if(n == 0 && m == 0) break;
		
		rep(i, MAX_V) G[i].clear();
		V = n + m;
		vector<ll> b(n), r(m);
		rep(i, n) cin >> b[i];
		rep(i, m) cin >> r[i];
		
		rep(i, n){
			rep(j, m){
				if(__gcd(b[i], r[j]) != 1){
						G[i].push_back(n+j);
						G[n+j].push_back(i);
				}
			}
		}
	
		cout << solve() << endl;
	
		
	}
	
	return 0;
}

Measured memory_bytes: 5228
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N; cin>>N;
    queue<int> aite[1010];
    int enemy;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N-1; ++j) {
            scanf("%d",&enemy); enemy--;
            aite[i].push(enemy);
        }
    }
    vector<int> lastgame(N,0);
    int cnt=0;
    int term=(N*(N-1))>>1;
    int tmp;
    bool nogame;
    while(cnt<term){
        nogame=true;
        for (int i = 0; i < N; ++i) {
            if(aite[i].empty()) continue;
            tmp=aite[i].front();
            if(aite[tmp].front()==i){
                cnt++;
                nogame=false;
                int day=max(lastgame[i],lastgame[tmp])+1;
                lastgame[i]=day; lastgame[tmp]=day;
                aite[i].pop(); aite[tmp].pop();
            }

        }
        if(nogame){
            cout<<-1<<endl;
            return 0;
        }
    }
    int ans=0;
    for (int i = 0; i < N; ++i) {
        ans=max(ans,lastgame[i]);
    }
    printf("%d\n",ans);
    return 0;
}

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

int main() {
    vector<int> a(3);
    rep(i,3) cin>>a[i];
    int ans=0;
    rep(i,3) ans+=a[i];
    if(ans>=22) cout<<"bust"<<endl;
    else  cout<<"win"<<endl;
}

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

int power(int a, int N){
	if(N == 0){
		return 1;
	}
	else if(N % 2 == 0){
		return power(a * a, N / 2);
	}
	else{
		return a * power(a, N - 1);
	}
}

signed main(){
	int N, i, j;
	scanf("%lld", &N);
	int ans = -1;
	for(i = 1; i * i <= N - 1; i++){
		if(i * i == N - 1){
			ans++;
		}
		else if((N - 1) % i == 0){
			ans += 2;
		}
	}
//	printf("ans = %lld\n", ans);
	for(j = 2; j * j <= N; j++){
		if((N - j) % (j * j) == 0){
			ans++;
		}
	}
	ans++;
	for(i = 2; power(2, i) <= N; i++){
		for(j = 2; power(j, i) <= N; j++){
//			printf("(i, j) = (%lld, %lld)\n", i, j);
			if((N - power(j, i)) % power(j, i + 1) == 0){
//				printf("test6\n");
				ans++;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){

    int n;
    cin>>n;
    bool right=true;
    vector<string> w(n);
    set<string> s;

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

    for(int i=0;i<n;i++){
        if(i<n-1&&w[i].back()!=w[i+1].front()) right=false;
        if(s.count(w[i])) right=false;
        else s.insert(w[i]);
    }

    cout<<(right?"Yes":"No")<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int k,c,t,x;
	while(scanf("%d",&k)&&k!=0)
	{
		for(x=k*(k-1)/2,t=0;x>0;t+=c,x--)
			scanf("%d",&c);
		printf("%d\n",t/(k-1));
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include <math.h>
#include <iomanip>

using namespace std;
#define PIE 3.14159265358979
int main() {
	long double a, b, c,S,L,H;
	cin >> a >> b >> c;
	S = a*b*sin(c / 180 * PIE) / 2;
	L = a + b + sqrt(a*a + b*b - 2 * a*b*cos(c / 180 * PIE));
	H= b*sin(c / 180 * PIE);
	cout << fixed << setprecision(8) << S << endl << L << endl << H << endl;
	return 0;
}

Measured memory_bytes: 3480
# -*- coding: utf-8 -*-
"""
A First Grader
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0557

"""
import sys
from collections import Counter


def solve(numbers):
    status = Counter({numbers[0]: 1})
    for n in numbers[1:-1]:
        u = Counter()
        for k, v in status.items():
            u[k+n] += v * (0 <= k + n <= 20)
            u[k-n] += v * (0 <= k - n <= 20)
        status = Counter({k: v  for k, v in u.items() if v > 0})
    return status[numbers[-1]]


def main(args):
    input()
    numbers = [int(n) for n in input().split()]
    ans = solve(numbers)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



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

int main(){
    int n, k;
    cin >> n >> k;
    int count = 0;
    for (int i = 0; i < n; i++) {
        int buf;
        cin >> buf;
        if (buf >= k) {
            count++;
        }
    }
    
    cout<< count << endl;
}


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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[9] {0,1,2,4,8,16,32,64,128};
            
            for(int i = a.Length-1; i > 0 ;i--)
            {
                if(a[i] <= n)
                {
                    Console.WriteLine(a[i]);
                    break;
                }
            }
        }
        
    }
}

Measured memory_bytes: 11092
import numpy as np
N, A, B, C = list(map(int, input().split()))
l_li = []
for i in range(N):
    l_li.append(int(input()))
INF = 10 ** 9
def dfs(n, a, b, c):
  if n == N:
    if min(a, b, c) == 0:
      return INF
    else:
      return abs(a-A) + abs(b-B) + abs(c-C) -30
  res0 = dfs(n + 1, a, b, c)
  res1 = dfs(n + 1, a + l_li[n], b, c) + 10
  res2 = dfs(n + 1, a, b + l_li[n], c) + 10
  res3 = dfs(n + 1, a, b, c + l_li[n]) + 10
  return min(res0, res1, res2, res3)

print(dfs(0,0,0,0))

Measured memory_bytes: 12508