akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N*A, B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main(){

    int a,b;

    cin >> a >> b;

    if(b%a==0){
        cout << a+b << endl;
    } else {
        cout << b-a << endl;
    }
    

}

Measured memory_bytes: 256
a,b,c = map(int, input().split())

if a==b==c and a%2==0:
    print(-1)
    exit()
ans = 0
while a%2==0 and b%2==0 and c%2==0:
    aa = a
    bb = b
    cc = c
    a = (bb+cc)//2
    b = (aa+cc)//2
    c = (aa+bb)//2
    ans += 1

print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int main(){
  int n;
  cin>>n;
  double ans;
  double kc,dc;
  dc=n/2;
  kc=n-dc;
  ans=kc/n;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import re
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  s=pin()[:-1]
  if re.fullmatch(r"[A-Z]*C+[A-Z]*F+[A-Z]*", s)==None:
    print("No")
    return
  print("Yes")
  return

main()

Measured memory_bytes: 9780
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	cin>>N;
	queue <int> Q;
	int A=N;
	eFOR(i,1,N){
		Q.push(i);
		A-=i;
		if(A<=0){
			A*=-1;
			//Q.erase(A);
			break;
		}
	}
	while(!Q.empty()){
		if(A!=Q.front())
		cout<<Q.front()<<endl;
		Q.pop();
	}
	return 0;
}




















Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		char c = sc.next().charAt(0);
		if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c =='u'){
			System.out.println("vowel");
		}
		else{
			System.out.println("consonant");
		}
		
		sc.close();
	}

}


Measured memory_bytes: 23764
s = list(input())
flg = True
for i in range(len(s)):
	if i % 2 == 0:
		if s[i] == "L":
			flg = False
			break
	else:
		if s[i] == "R":
			flg = False
			break

if flg == True:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
	char s[10];
  for(int a=0;a<3;a++){
	scanf("%c",&s[a]);
  }
  if(s[0] == s[1] && s[1] == s[2]){
  printf("No");
  }else{
  printf("Yes");
  }
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 

ll m = 1e9+7;
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	vector <vector<int>> arr(n,vector<int>(n,-1));
	for (int z=0;z<n;z++){
		ll t;
		cin >> t;
		for (int x=0;x<t;x++){
			ll a,b;
			cin >> a >> b;
			arr[z][a-1] = b;
		}
	}
	ll ans = 0;
	for (ll z=0;z<(ll(1)<<n);z++){
		bool ok = true;
		for (ll x=0;x<n && ok;x++){
			if (z & ((1) << x)){
				for (int q=0;q<n && ok;q++){
					if (arr[x][q] == -1) continue;
					if (arr[x][q] == 0){
						if (z & ((1) << q)){
							ok = false;
						} 
					} else {
						if (z & ((1) << q)){

						} else ok = false;
					}
				}
			}
		}
		if (ok){
			ll t = 0;
			for (int x=0;x<n;x++){
				if (z & (1) << x) t++;
			}
			ans = max(ans,t);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>

using namespace std;

typedef long long ll;

#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--)

int const N_MAX = 100000;

int N;
ll C;
ll xs[N_MAX + 1], vs[N_MAX + 1];
ll ls[N_MAX + 1], rs[N_MAX + 1];
ll gls[N_MAX + 1], grs[N_MAX + 1];

int main() {
  scanf("%d %lld", &N, &C);
  xs[0] = 0;
  vs[0] = 0;
  FOR(i, 1, N + 1) {
    scanf("%lld %lld", &xs[i], &vs[i]);
  }

  FOR(i, 1, N + 1) {
    ls[i] = ls[i - 1] + vs[i];
    rs[i] = rs[i - 1] + vs[N - i + 1];
  }

  FOR(i, 1, N + 1) {
    ll dist = C - xs[N - i + 1];
    ll cal = rs[i] - dist;
    gls[i] = max(gls[i - 1], cal);
    grs[i] = max(grs[i - 1], cal - dist);
  }

  ll max_cal = 0;
  rep(i, N + 1) {
    ll l = ls[i];
    ll l_dist = xs[i];
    ll l_cal = l - l_dist;

    int j = N - i;
    ll rl_cal = gls[j];
    ll cal = l_cal + rl_cal - l_dist;
    max_cal = max(max_cal, cal);

    ll rr_cal = grs[j];
    cal = l_cal + rr_cal;
    max_cal = max(max_cal, cal);

  }
  printf("%lld\n", max_cal);
}


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

int main(){
	string S;
	cin >> S;
	bool a = false, b = false;
	int A = stoi(S.substr(0, 2)), B = stoi(S.substr(2, 2));
	if (1 <= A && A <= 12)a = true;
	if (1 <= B && B <= 12)b = true;
	if (a && b)puts("AMBIGUOUS");
	else if (a)puts("MMYY");
	else if (b)puts("YYMM");
	else puts("NA");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;    
#define int long long        
#define endl "\n"
#define deb(x) cout<<#x<<" "<<x<<endl
#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar) for(int pen=0;pen<sizeof(ar)/8;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rt return 0;
#define mod 1000000007
const int N= 8*1e5+ 10;
int st[N]={0};
void update(int ss, int se, int i, int diff, int si)  
{  
    // Base Case: If the input index lies outside the range of  
    // this segment  
    if (i < ss || i > se)  
        return;  
  
    // If the input index is in range of this node, then update  
    // the value of the node and its children  
    st[si] = st[si] + diff;  
    if (se != ss)  
    {  
        int mid = (ss+se)/2;  
        update(ss, mid, i, diff, 2*si);  
        update(mid+1, se, i, diff, 2*si + 1);  
    }  
}  
int get_sum(int ss, int se, int qs, int qe, int si)  
{  
    // If segment of this node is a part of given range, then return  
    // the sum of the segment  
    if (qs <= ss && qe >= se)  
        return st[si];  
  
    // If segment of this node is outside the given range  
    if (se < qs || ss > qe)  
        return 0;  
  
    // If a part of this segment overlaps with the given range  
    int mid = (ss+se)/2;
    return get_sum(ss, mid, qs, qe, 2*si) +  
        get_sum(mid+1, se, qs, qe, 2*si+1);  
}
int dp[3001][3001];
int cnt=0; 
int lcs( char X[], char Y[], int m, int n )  
{  
    //cout<<m<<" "<<n<<endl;

    if (m == 0 || n == 0)  
    {
        dp[m][n]=0;
       return 0;
    }
    if(dp[m][n]!=-1)
    {
        return dp[m][n];
    }  
    if (X[m-1] == Y[n-1])  
    {
        dp[m][n]=1+lcs(X,Y,m-1,n-1);
        
        // return 1 + lcs(X, Y, m-1, n-1);
        return dp[m][n];
    }  
    else
     {
         dp[m][n]= max(lcs(X, Y, m, n-1), lcs(X, Y, m-1, n));
        return dp[m][n];
     }  
} 
signed main()
{
    fastio;
    char s[3001],t[3001];
    cin>>s>>t;
    int m= strlen(s);
    int n= strlen(t);
    for(int i=0;i<=m+10;i++)
    for(int j=0;j<=n+10;j++)
    dp[i][j]=-1;

    int final=lcs(s,t,m,n);

   char lcs[final+1];
   lcs[final]='\0';
   int i=m;
   int j=n;
   while(i>0 && j>0){
       if(s[i-1]==t[j-1]){
           lcs[final-1]=s[i-1];
           i--;
           j--;
           final--;
       }
       else if(dp[i-1][j]>dp[i][j-1]){
           i--;
       }
       else
       {
           j--;
       }
   }
   cout<<lcs<<endl;
}

Measured memory_bytes: 72320
import sys
from itertools import groupby
def input(): return sys.stdin.readline().rstrip()

def main():
    n,k=map(int, input().split())
    S=list(input())
    p=len(list(groupby(S)))-2*k 
    pp=max(p,1)
    print(n-pp)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21692
#include <bits/stdc++.h>
#define maxtam 1000

using namespace std;
typedef long long ll;

ll mcd(ll a, ll b)
{
	ll c;
	if(a < b)
	{
		c = a;
		a = b;
		b = c;
	}
	return( a % b == 0 ? b : mcd(b, a % b));
}

int main()
{
	ll num,b;
	cin>>num;
	b=mcd(2,num);
	
	cout<<(num*2)/b<<endl;;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int a[110];
void sum(int a[],int n){
  int i;
  for(i=0;i<n;i++){
    if(i>0){printf(" ");
  }
   printf("%d",a[i]);
  }
  printf("\n");
}
void ans(int a[],int n){
    int v,j,i;
  for(i=1;i<n;i++){
  v=a[i];
  j=i-1;
   while(j>=0&&a[j]>v){
    a[j+1]=a[j];
     j--;
   }
    a[j+1]=v;
 sum(a,n);
}
}

int main(){
int n;
int i;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d ",&a[i]);
}
sum(a,n);
ans(a,n);
  return 0;
}

Measured memory_bytes: 2728
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>

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

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

typedef long long ll;

using namespace std;

template <class Abel>
class BIT
{
public:
  using F=function<Abel(Abel,Abel)>;
  F f;
  int l;
  vector<Abel> bit;
  Abel m0;
  BIT(int maxidx,F fu,Abel m0):f(fu),l(maxidx),m0(m0)
  {
    bit.assign(l,m0);
  }
  void update(int idx,int val)
  {
    while(idx<=l)
    {
      bit[idx]=f(bit[idx],val);
      idx+=idx & -idx;
    }
  }
  int query(int idx)
  {
    idx--;
    int res=m0;
    while(idx>0)
    {
      res=f(bit[idx],res);
      idx-=idx& -idx;
    }
    return res;
  }
};
int mod=1e9+7;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int> s(n);
  rep(i,n)cin>>s[i];

  s.erase(unique(all(s)),s.end());

  int l=s.size();
  map<int,vector<int>> cidx;
  vector<int>tv;
  rep(i,l)
  {
    if(cidx.count(s[i])==0)
    {
      cidx[s[i]]=tv;
    }
    cidx[s[i]].push_back(i);
  }

  BIT<int>bt(l+10,[](int a,int b){return (a+b)%mod;},0);
  rep(i,l)
  {
    auto nitr=upper_bound(all(cidx[s[i]]),i);
    if(nitr==cidx[s[i]].end())continue;
    bt.update(*nitr,bt.query(i+1)+1);
  }
  cout<<(bt.query(l)+1)%mod<<endl;



  return 0;

}



Measured memory_bytes: 23680
#include<iostream>
using namespace std;
int apple[205];
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,l,sum=0;
    cin >> n >> l;
    for(int i=1;i<=n;i++)
        apple[i]=l+i-1;
    if(apple[1]>=0)
    {
        for(int i=2;i<=n;i++)
            sum+=apple[i];
    }
    else
    {
        for(int i=1;i<=n;i++)
            sum+=apple[i];
        if(apple[n]<0)
            sum-=apple[n];
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 10000;

void compute(int N, int K){
  if ( N < 2*K ) {
    cout << -1 << endl;
    return;
  }

  int base[MAX], w, b;

  base[0] = 0;
  base[1] = 1;
  w = N-2;
  b = 1;
  for ( int i = 2; i < N; i++ ){
    base[i] = (base[i-1] + (w*b))%N;
    w--;
    b *= -1;
  }

  for ( int k = 0; k < K; k++ ){
    for ( int i = 0; i < N-1; i++ ){
      printf("%d %d\n",(base[i]+k)%N+1, (base[i+1]+k)%N+1);
    }
  }




}

main(){
  int N, K;

  //  while(1){
    cin >> N >> K;
    //if ( N == 0 && K == 0 ) break;
    compute(N, K);
    //  }
}

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

main(){
  //set;
  int a[17];
  for(int i=0;i<17;i++){
    a[i]=(i+1)*(i+1);
  }
  
  int data[17][301]={0};
  for(int i=0;i<301;i++)data[0][i]=1;
  data[0][0]=0;
  for(int i=1;i<17;i++){
    data[i][0]=0;
    for(int j=1;j<301;j++){
      if (a[i] >j){
        data[i][j]=data[i-1][j];
      }else if (a[i] == j)data[i][j]=data[i-1][j]+1;
      else {
        data[i][j]=data[i-1][j]+data[i][j-a[i]];
      }
    }
  }
  
  int n;
  while(cin >> n&&n)cout <<data[16][n]<<endl;
  
  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int a[6],ap[4];
int main(){
  for(int i=0;i<6;i++){cin>>a[i];ap[a[i]-1]++;}
  for(int i=0;i<4;i++)if(ap[i]==3){cout<<"NO"<<endl;return 0;}
  cout<<"YES"<<endl;
}


Measured memory_bytes: 3640
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        if(s.equals("Sunny")){
            System.out.println("Cloudy");
        } else if(s.equals("Cloudy")){
            System.out.println("Rainy");
        } else {
            System.out.println("Sunny");
        }
    }
}

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

int main() {
    int N, Y;
    cin >> N >> Y;

    for (int i=0; i <= Y/10000; i++) {
        int res1 = Y - 10000*i;
        for (int j=0; j <= res1/5000; j++) {
            int res2 = res1 - 5000*j;
            int k = res2/1000;
            if (i+j+k == N) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

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

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto n = readln.split[0].to!int;
	auto n1 = n/100, n2 = (n - n1*100)/10, n3 = (n - n1*100 - n2*10);
	if (n1 == 1) n1 = 9; else if (n1 == 9) n1 = 1;
	if (n2 == 1) n2 = 9; else if (n2 == 9) n2 = 1;
	if (n3 == 1) n3 = 9; else if (n3 == 9) n3 = 1;
	writeln(n1*100 + n2*10 + n3);
}


Measured memory_bytes: 256
n,m=map(int,input().split())
res=0
q=[]
for i in range(m):
    q.append(list(map(int,input().split())))
p=list(map(int,input().split()))

for s in range(2**n):
    judge=True
    for i in range(m):
        cnt=0
        for j in range(1,len(q[i])):
            w=q[i][j]
            if s >> (w-1) &1 == 1:
                cnt += 1
        if cnt % 2 != p[i]:
            judge=False
    if judge:
        res += 1
print(res)


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

const int INF = 1000000000;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n;  cin >> n;
  vector <int> h(n), dp(n, INF);
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  } 
  dp[0] = 0;
  dp[1] = abs (h[1] - h[0]);
  for (int i = 2; i < n; ++i) {
    dp[i] = min (dp[i - 1] + abs (h[i] - h[i - 1]), dp[i - 2] + abs (h[i] - h[i - 2]));
  }
  cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 1024
ALL_CARDS = (1..10).to_a

readlines.each do |line|
  understood_cards = line.chomp.split.map(&:to_i)
  my_cards_sum = understood_cards.take(2).inject(&:+)
  remaining_cards = ALL_CARDS - understood_cards
  under_20 = remaining_cards.select { |n| n + my_cards_sum <= 20 }

  if (under_20.size.to_f / remaining_cards.length) * 100 >= 50
    puts 'YES'
  else
    puts 'NO'
  end
end

Measured memory_bytes: 8584
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>
#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

inline bool IN(int x, int y, int w, int h)
{
    return 0 <= x && x < w && 0 <= y && y < h;
}


int main()
{
	REP(i,1,10){
		REP(j,1,10){
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "number", long, "times");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    auto s = sread();
    auto k = lread();
    ulong tmp, len = s.length;
    auto substr = new string[](0);
    foreach (i, e; s)
    {
        foreach (j; 1 .. k + 1)
        {
            if (i + j <= len)
                substr ~= s[i .. (i + j)].dup;
        }
    }
    substr.length -= substr.sort().uniq.copy(substr).length;
    substr[k - 1].writeln();
}

Measured memory_bytes: 2812
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
const int dx[8]={1, 1, 1, 0, 0, -1, -1, -1};
const int dy[8]={1, 0, -1, 1, -1, 1, 0, -1};

int main(){
    int H, W;
    cin >> H >> W;
    string s[H];
    rep(i,H) cin >> s[i];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(s[i][j]=='#') continue;
            int sum = 0;
            for(int k=0; k<8; k++){
                int tmpi=i+dx[k]; 
                int tmpj=j+dy[k];
                //cout << tmpi << tmpj << endl;
                if(tmpi<0 || tmpi>=H || tmpj <0 || tmpj>=W){
                    continue;
                }
                if(s[tmpi][tmpj]=='#'){
                    sum++;
                }
            }
            s[i][j] = sum+'0';
            //cout << sum << endl;
        }
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cout << s[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
#define PB push_back
#define MP make_pair
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}

#define INF 100000000000LL
int main() {
    Int h, n;
    cin >> h >> n;
    auto v = vector<pair<Int, Int>>();
    auto maxA = 0LL;
    rep(i, n) {
        Int a, b;
        cin >> a >> b;
        maxA = max(maxA, a);
        v.PB(MP(a, b));
    }
    auto dp = vector<Int>(h + maxA + 1, 0);
    reps(i, h + maxA) {
        Int result = INF;
        rep(j, n) {
            auto x = v[j];
            auto a = x.first;
            auto b = x.second;
            if (i >= a) {
                result = min(dp[i - a] + b, result);
            } else {
                result = min(b, result);
            }
        }
        dp[i] = result;
    }
    Int ans = INF;
    for (Int i = h; i <= h + maxA; i++) {
        ans = min(ans, dp[i]);
    }
    PUTS(ans);
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))

sa = sorted(a,reverse=True)
ans = sa[0]
i = 2
for v in sa[1:]:
  if i >= n:
    break
  #print("i:{} ans:{}".format(i,ans))
  ans += v
  i += 1
  if i >= n:
    break
  #print("i:{} ans:{}".format(i,ans))
  ans += v
  i += 1

print(ans)


Measured memory_bytes: 31460
#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin);

	int n;
	cin >> n;
	vector<int> a(n), dp(n + 1);
	for (auto& i : a)
		cin >> i;
	dp[1] = abs(a[0] - a[1]);
	for (int i = 2; i < n; ++i)
		dp[i] = min(dp[i - 2] + abs(a[i] - a[i - 2]), dp[i - 1] + abs(a[i] - a[i - 1]));

	cout << dp[n - 1];
	


}


Measured memory_bytes: 3988
# def makelist(n, m):
#     return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


N, K = map(int, input().split())
l = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    l[i] = (a, b)


l.sort()
i = 0
cnt = 0
ans = -1
while True:
    a, b = l[i]
    K -= b
    if K <= 0:
        ans = a
        break

    i += 1

print(ans)


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

  int n, d, a;
  cin >> n >> d >> a;

  vii x(n);
  rep(i,0,n) {
    cin >> x[i].fst >> x[i].snd;
  }
  sort(all(x));
  map<int, int> C;
  set<int> t;
  int co=0;

  trav(k,x) {
    t.insert(k.fst);
    t.insert(k.fst-d);
    t.insert(k.fst+d);
  }
  trav(k,t) C[k] = ++co;

  vi b(co+1);
  int lst=-1;
  rep(i,0,n) {
    int pos, hlth;
    tie(pos,hlth) = x[i];
    int done = 0;
    if (C[pos+d] > lst) {
      rep(i,lst+1,C[pos+d]+1) if (i-1 >= 0) b[i] += b[i-1];
      lst=C[pos+d];
    }
    done = b[C[pos+d]];
    if (C[pos-d]-1 >= 0) done -= b[C[pos-d]-1];
    hlth = max(0, hlth-a*done);
    b[C[pos+d]] += (hlth+a-1)/a;
  }
//  rep(i,0,co) cerr << b[i] << endl;
  cout << b[lst] << endl;
}

Measured memory_bytes: 62720
#include<iostream> 
#include<stdio.h>
#include<string>
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (n); ++i)	
//setprecision(16)

void outi(int x) { cout << x << endl; }
void outl(ll x) { cout << x << endl; }
void outs(string x) { cout << x << endl; }
ll max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
ll min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}
//---------------------------------------------------------------

int main() {
	int x, y;
	cin >> x >> y;

	int a, b;
	b = y - 2 * x;
	a = 4 * x - y;
	if (a >= 0 && b >= 0 && a % 2 == 0 && b % 2 == 0) {
		cout << "Yes " << endl;
	}
	else {
		outs("No");
	}
}

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

using namespace std;

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

    bitset<64> mask[n];
    for(int i=0;i<n;i++)
    {
        int k,b;
        cin>>k;
        while(k--)
        {
            cin>>b;
            mask[i].set(b);
        }
    }

    bitset<64> bit;
    int q,op,m;

    cin>>q;
    while(q--)
    {
        cin>>op>>m;
        if(!op) cout<<bit[m]<<endl;
        if(op==1) bit|=mask[m];
        if(op==2) bit&=~mask[m];
        if(op==3) bit^=mask[m];
        if(op==4) cout<<((bit&mask[m])==mask[m])<<endl;
        if(op==5) cout<<(bit&mask[m]).any()<<endl;
        if(op==6) cout<<(bit&mask[m]).none()<<endl;
        if(op==7) cout<<(bit&mask[m]).count()<<endl;
        if(op==8) cout<<(bit&mask[m]).to_ullong()<<endl;
    }

    return 0;
}



Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
	private static final int N_MAX = 2 << 15;
	private boolean[] era;
	private void run() {
		era = new boolean [ N_MAX + 1 ];
		era[ 1 ] = true;
		for( int i = 2; i <= N_MAX; i++ ) {
			if( era[ i ] ) { continue; }
			for( int j = i * 2; j <= N_MAX; j = j + i ) {
				era[ j ] = true;
			}
		}
		
		Scanner sc = new Scanner( System.in );
		while( sc.hasNext() ) {
			int counter = 0;
			int n = sc.nextInt();
			if( n == 0 ) { break; }
			for( int p1 = 2; p1 <= n / 2; p1++ ) {
				if( era[ p1 ] ) { continue; }
				if( !era[ n - p1 ] ) {
					counter++;
				}
			}
			System.out.println( counter );
		}
		
	}
	public static void main( String[] args ) {
		new Main().run();
	}
}

Measured memory_bytes: 19276
#include <stdio.h>
int main(void)
{
    int a[10], c[10]={0},i,inp,same;
    a[0]=1,a[1]=2,a[2]=4,a[3]=8,a[4]=16,a[5]=32,a[6]=64,a[7]=128,a[8]=256,a[9]=512;
    for(;scanf("%d",&inp)!=EOF;)
    {
        for(i=0;i<10;i++)
            c[i]=0;
        same=inp;
        if(inp%2!=0)
        {
            c[0]=1;
            inp-=1;
        }
        for(i=9;i>=0;i--)
        {
            if(same-a[i]>=0)
            {
                c[i]=1;
                same-=a[i];
            }
        }
        for(i=0;i<10;i++)
        {
            if(c[i]==1)
            {
                printf("%d",a[i]);
                break;
            }
        }
        for(i+=1;i<10;i++)
        {
            if(c[i]==1)
            {
                printf(" %d",a[i]);
            }
            if(i==9)
            {
                printf("\n");
            }
        }
    }
return 0;
}

Measured memory_bytes: 600
def gcd(a, b):
    if a > b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

def lcm(a, b):
    return a * b // gcd(a, b)

a, b, c, d = map(int, input().split())
a -= 1
e = lcm(c, d)
print(b - a - (b // d - a // d) - (b // c - a // c) + (b // e - a // e))

Measured memory_bytes: 3064
// Optimise
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// #define MULTI_TEST
#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#define pc(...)
#endif

#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
auto TimeStart = chrono::steady_clock::now();
auto seed = TimeStart.time_since_epoch().count();
std::mt19937 rng(seed);
using ll = long long;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using Random = std::uniform_int_distribution<T>;

const int NAX = 2e5 + 5, MOD = 1000000007;

int cnt[NAX];
class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n, p;
        cin >> n >> p;
        string s;
        cin >> s;
        ll res = 0;
        if (p == 2 || p == 5)
        {
            for (size_t i = 0; i < n; i++)
                if ((s[i] - '0') % p == 0)
                    res += i + 1;
        }
        else
        {
            ++cnt[0];
            int t = 0, p2 = 1;
            for (int i = n - 1; i >= 0; i--)
            {
                t = (t + (s[i] - '0') * p2) % p;
                res += cnt[t];
                cnt[t]++;
                p2 = (p2 * 10) % p;
            }
        }
        cout << res << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
#ifdef MULTI_TEST
    cin >> t;
#endif
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef TIME
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  string s;
  cin >> s;
  const int n = SZ(s);

  ll ans = 0;

  rep(i, BIT(n)) {
    if (i % 2) continue;
    ll a = 0;
    ll b = 0;
    rep(j, n) {
      if (i & BIT(j)) {
        a += b;
        b = 0;
      }
      b *= 10;
      b += s[j] - '0';
    }
    a += b;
    ans += a;
  }

  _p("%lld\n", ans);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


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

int main()
{
    int n, x, y;
    cin >> n >> x >> y;

    bool isShortestExceeded = false;

    vector<int> pathNumVec(n - 1);

    for (int start = 1; start <= n - 1; ++start)
    {
        for (int goal = start + 1; goal <= n; ++goal)
        {
            int dist = goal - start;

            int distWithShortcut = abs(x - start) + 1 + abs(y - goal);

            int minDist = min(dist, distWithShortcut);

            ++pathNumVec.at(minDist - 1);
        }
    }

    for (const int &singlePathNum : pathNumVec)
    {
        cout << singlePathNum << endl;
    }
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = 1e18;
const int IMOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

int main(void)
{
    int n;
    cin >> n;
    
    v_int a(n);

    irep(i, n) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    irep(i, n-1) {
        if(a[i] < 0 && a[i+1] < 0) {
            a[i] *= -1;
            a[i+1] *= -1;
        } 
        if(a[i] < 0 && a[i+1] >= 0) {
            if(abs(a[i]) > abs(a[i+1])) {
                a[i] *= -1;
                a[i+1] *= -1;
            }
        }
    }
    ll ans = 0;
    irep(i, n) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}
/** atcoder **/



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



int main(){
  int n;
  cin >> n;
  ll sum=0;
  vector<ll> a(n);
  rep(i,0,n){
    cin >> a[i];
    sum= (sum + a[i])%mod;
    }
//  cout << sum << endl;
  vector<ll> t(n);
  t[0]=(sum-a[0]+mod)%mod;
  rep(i,1,n){
    t[i] = (t[i-1]-a[i]+mod)%mod;
  }
  ll ans=0;
  rep(i,0,n){
    ans= (ans + t[i]*a[i]%mod)%mod;
//    cout << t[i] << ' ' << a[i] << endl;
//    cout << ans << endl;
  }
  cout << ans << endl;

}

Measured memory_bytes: 6416
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	cout << n * 800 - n / 15 * 200 << "\n";
	return 0;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
// ll mod_pow(ll x, ll n, ll mod){//x^n % mod
//     if (n == 0)
//         return 1;
//     ll res = mod_pow(x * x % mod, n / 2, mod);
//     if (n & 1)
//         res = res * x % mod;
//     return res;
// }
typedef pair<int,int> P;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int H; cin >> H;
    int W; cin >> W;
    char A[1002][1002];
    REP(i, W+1) {
        A[0][i] = '?';
        A[H+1][i] = '?'; 
    }
    REP(i, H+1) {
        A[i][0] = '?';
        A[i][W+1] = '?';
    }
    queue<P> q;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> A[i][j];
            if (A[i][j] == '#') q.push(make_pair(i,j)); 
        }
    }
    int rest = H*W - q.size();
    int dx[4] = {-1,0,0,1};
    int dy[4] = {0,-1,1,0};
    int res = 0;
    while (rest > 0) {
        int num = q.size();
        for (int i = 0; i < num; i++) {
            P black = q.front(); q.pop();
            for (int j = 0; j < 4; j++) {
                int x = black.second + dx[j];
                int y = black.first + dy[j];
                if(A[y][x]=='.') {
                    A[y][x] = '#';
                    q.push(P(y,x));
                    rest--;
                }
            }
        }
        res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 9488
n = int(input())
for _ in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    if abs((x2 - x1) * (y4 - y3) - (x4 - x3) * (y2 - y1)) < 1e-10:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
#define INF 1e9
struct edge{
    int to,cap,rev;
};

vector<vector<edge> > g;
void add_edge(int from,int to,int cap){
    edge f,t;
    f = (edge){ to,cap,(int)g[to].size() };
    g[from].push_back(f);
    t = (edge){ from,0,(int)g[from].size()-1} ;
    g[to].push_back(t);
}

int dfs( int v,int t,int f,vector<bool> &used){
    if( v== t ) return f;
    used[v] = true;
    for(int i=0;i<g[v].size();i++){
	edge &e = g[v][i];
	if(!used[e.to] && e.cap > 0 ){
	    int d = dfs(e.to , t, min(f,e.cap),used);
	    if( d> 0){
		e.cap -=d;
		g[e.to][e.rev].cap += d;
		return d;
	    }
	}
    }
    return 0;
}
int max_flow(int s,int t){
    int flow = 0;
    while(1){
	vector<bool> used(g.size(),false);
	int f = dfs(s,t,INF,used);
	if(f==0) return flow;
	flow += f;
    }
}


int main(){
    int n;
    cin>>n;
    int m = 30,M = 1;
    g = vector<vector<edge> > ( n + 33);
    int S = 0,T =n+32;
    for(int i=1;i<=31;i++) add_edge(S,i,1);
    for(int i=0;i<n;i++) add_edge( 32 + i , T , 1 );
    for(int i=0;i<n;i++){
	int a,b;
	cin>>a>>b;
	//a--,b--;
	m= min(m,a);
	M = max(M,b);
	for(int j=a;j<=b;j++) add_edge( j , 32 + i , 1);
    }
    int f = max_flow(S,T);
    cout<< (M-m+1)*50 + f*50 << endl;

    return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int c[n-1], s[n], f[n];
    int time[n-1];
    for(int i = 0; i < n-1; i++)
        cin >> c[i] >> s[i] >> f[i];
    f[n-1]=1; s[n-1]=-100;
    int ans[n];
    for(int i = 0; i < n-1; i++){
        ans[i]=s[i];
        for(int j = i; j < n-1; j++){
            ans[i]=ans[i]+c[j];
            if(ans[i]<s[j+1])
                ans[i]=s[j+1];
            else if(ans[i]>=s[j+1]&&ans[i]%f[j+1]!=0)
                ans[i]=ans[i]+f[j+1]-(ans[i]%f[j+1]);    
        }
    }
    for(int i = 0; i < n-1; i++)
        cout << ans[i] << endl;
    cout << '0' << endl;
    return 0;
}

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

int main(){
	int k,a,b;
	cin >> k;
	cin >> a >> b;
	bool flag = false;
	int i;
	for( i = a; i<=b; i++){
		if (i % k == 0){
			flag = true;
		}
	}
	if (flag) cout << "OK" << endl;
	else cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,Int k){
    Mint num(1),dom(1);
    for(Int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  const Int m=20;
  Int sz=1<<m;

  vector<Int> cnt(sz,0);
  for(Int a:as) cnt[a]++;

  for(Int i=0;i<m;i++)
    for(Int b=0;b<sz;b++)
      if((~b>>i)&1) cnt[b]+=cnt[b|(1<<i)];

  using M = Mint<Int>;
  M ans{0};
  for(Int b=0;b<sz;b++){
    if(__builtin_parity(b)) ans-=M(2).pow(cnt[b]);
    else ans+=M(2).pow(cnt[b]);
  }
  cout<<ans<<endl;
  return 0;
}



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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

A,B,H,M = inputIL()

h = H%12

a = (30*h + M/2)/180*math.pi
b = (M*6)/180*math.pi

x1,y1 = math.sin(a)*A ,math.cos(a)*A ,
x2,y2 = math.sin(b)*B ,math.cos(b)*B ,

print(math.sqrt((x1-x2)**2+(y1-y2)**2))

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

using namespace std;

using ll = long long;
using ld = long double;

using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using gr = vector<vll>;
using wgr = vector<vpll>;

#define pb push_back
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define REP(i, n) FOR(i, 0, n)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
struct d_ {
    template<typename T> d_ & operator ,(const T & x) { cerr << ' ' <<  x; return *this;}
    template<typename T> d_ & operator ,(const vector<T> & x) { for(auto x: x) cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) begin(x),end(x)
#define IN(n) ll n;cin >> n;
#define x first
#define y second

int main(void) {
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    ll n; cin >> n;
    F(s.size()) if(i%n == 0) cout << s[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n = input()
str = raw_input()

r = 0
l = 0
i = 0

while i < n:
    if str[i] == '(':
        l += 1
        i += 1
    elif str[i] == ')' and l == 0:
        str = '(' + str
        n += 1
        i = 0
    else:
        l -= 1
        i += 1

if l > 0:
    while l > 0:
        str = str + ')'
        l -= 1

print str

Measured memory_bytes: 2568
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    char a, b;
    cin >> a >> b;
    if ((a == 'H' && b == 'H') || a == 'D' && b == 'D') {
        cout << 'H' << endl;
    }
    else {
        cout << 'D' << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long h, n;
    cin>>h>>n;
    int a;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        h=h-a;
    }
    if(h<=0)
    cout<<"Yes";
    else
    cout<<"No";
    
}

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


//----




//---- Circle in a Rectangle
int main(){
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H)cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 3056
mod = 1000000007
ans = 0
power = [0 for i in range(2005)]
power[0] = 1

for i in range(1,2001):
    power[i] = power[i-1] * i

def C(x,y):
    return 0 if x < y else power[x] // power[y] // power[x-y]

def H(x,y):
    return C(x+y-1,y-1)

n = int(input())
for i in range(3,n+1,3):
    ans += H(n-i,i//3)
ans = (ans % mod + mod) % mod
print(ans)

Measured memory_bytes: 11480
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int search(vector<int> const& w, int n, int k, int const p){
	int offset = 0;
	int i;
	for(i = 1; i <= n; i++){
		if(w[i] - offset > p && k > 0){
			offset = w[i-1];
			--k;
			--i;
		}
	}

	return (k >= 1) && ((i-1) == n);
}

int main(void)
{
	int n, k;
	cin >> n >> k;
	vector<int> w(n+1, 0);
	for(int i = 1; i <= n; i++){
		int temp;
		cin >> temp;
		w[i] = w[i-1] + temp;
	}
	int l = 1, r = w[n];
	while(true){
		if(search(w, n, k, (r-l)/2+l) == 1)
			r = r - (r-l)/2;
		else
			l = (r-l)/2 + l;
		if(abs(r-l) <= 1)
			break;
	}
	if(search(w, n, k, 1) == 1)
		cout << l << endl;
	else
		cout << r << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

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

    int n;
    cin >> n;

    ll L[90] = {0};
    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i < 87; ++i) {
        L[i] = L[i-1] + L[i-2];
    }

    cout << L[n] << endl;

    return 0;
}



Measured memory_bytes: 256