akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int n;
  	cin >> n;
  	vll a(n);
  	rep(i,n) cin >> a[i];
  	sort(rall(a));
  	
  	ll temp;
  	int flag = 0;
  	ll ans = 0;
	
  	rep(i,n){
      	if(flag == 0 && a[i] == a[i+3]){
        	ans = a[i] * a[i];
          	break;
        }
    	else if(flag == 0 && a[i] == a[i+1]){
        	temp = a[i];
          	flag = 1;
        }
      	else if(flag == 1 && a[i] != temp && a[i] == a[i+1]){
        	ans = temp * a[i];
          	flag = 2;
          	break;
        } 
    }
  	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 1024
//https://atcoder.jp/contests/abc144/tasks/abc144_d
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
using ld=long double;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ld a,b,x; cin>>a>>b>>x;
#if 1 //二分法
	auto calc = [&](ld deg){
		ld rad=deg*M_PI/180.0; //deg2rad
		ld bb=a*tan(rad);
		ld ft=-1.0;
		if (b>bb){
			ft=(bb*a/2 + (b-bb)*a)*a;
		} else {
			ft=b*b/tan(rad)/2*a;
		}
		return ft;
	};
//	dump(calc(5)-x);
//	dump(calc(4.2363947991)-x);
//	dump(calc(4)-x);
    ld lb=0, ub=90;
    REP(i,1000){
        auto deg=(lb+ub)/2.0;
		auto ft=calc(deg)-x;
        if (ft>0){
            lb=deg;
        } else {
            ub=deg;
        }
		//dump(lb,ub,ft);
    }
    cout<<fixed<<std::setprecision(10)<<lb<<endl;
#else
    dump(a*a*b);
    {
		ld t = (2 * a * a * b - 2 * x) / (a * a);
		if(b - t < 0) {
			ld t2 = 2 * x / (b * a);
			ld at = b/ t2;
			ld rad = atan(at);
            //ld rad2=atan2(t2,b);
		    ld deg = rad * 180.0 / M_PI;
			cout << fixed << std::setprecision(10) << deg << endl;
            return 0;
		}
		dump(t);
		ld at = t / a;
		ld rad = atan(at);
		ld deg = rad * 180.0 / M_PI;
        cout<<fixed<<std::setprecision(10)<<deg<<endl;
	}
#endif
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#define ll long long
using namespace std;

int n,num[10];
char s[10];

int main() {
    scanf("%d",&n);
    for (int i=1;i<=n;++i){
        scanf("%s",s);
        if (s[0]=='A') ++num[0];
        if (s[0]=='W') ++num[1];
        if (s[0]=='T') ++num[2];
        if (s[0]=='R') ++num[3];
    }
    printf("AC x %d\n",num[0]);
    printf("WA x %d\n",num[1]);
    printf("TLE x %d\n",num[2]);
    printf("RE x %d\n",num[3]);
    return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

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

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;
using qul = queue<ll>;

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

int binary_search(ll x, vel a){
    auto ite = lower_bound(ALL(a), x);
    if(ite != a.end() && *ite == x) {
        return ite - a.begin() ;
    } else {
        return -1;
    }

}

ll modpow(ll a, ll n, ll mod) {
    if(n == 0)
        return 1;
    if(n == 1)
        return a % mod;
    if(n % 2 == 1)
        return (a * modpow(a, n - 1, mod)) % mod;
    ll t = modpow(a, n / 2, mod);
    return (t * t) % mod;
}

int main() {
    ll N, num, ans = 0;
    cin >> N;
    vel A(N);
    REP(i, N){
        cin >> A[i];
    }

    REP(i, N-1){
        if(A[i+1] < A[i]){
            ans += A[i] -A[i+1];
            A[i+1] = A[i];
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4836
n, p = map(int,input().split())
A = list(map(int,input().split()))

for i in range(n):
    A[i] %= 2

C = [[0] * (n+1) for i in range(n+1)]

C[0][0] = 1
for i in range(n):
    for j in range(i+1):
        C[i+1][j] += C[i][j]
        C[i+1][j+1] += C[i][j]

ans = 0
n0 = A.count(0)
n1 = A.count(1)
for i in range(p, n+1, 2):
    for j in range(n0+1):
        ans += C[n1][i] * C[n0][j]
print(ans)

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  double sum = 0;
  rep(i, n) {
    in(double, a);
    sum += 1 / a;
  }
  cout << setprecision(20);
  out(1 / sum);
}


Measured memory_bytes: 3764
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

type restaurant struct {
	index int
	city  string
	point int
}

type lessFunc func(i, j *restaurant) bool

type sorter struct {
	res      []restaurant
	lessfunc []lessFunc
}

func (is sorter) Len() int {
	return len(is.res)
}
func (is sorter) Swap(i, j int) {
	is.res[i], is.res[j] = is.res[j], is.res[i]
}
func (is sorter) Less(i, j int) bool {
	var k int
	p, q := &is.res[i], &is.res[j]
	for k = 0; k < len(is.lessfunc)-1; k++ {
		less := is.lessfunc[k]
		switch {
		case less(p, q):
			return true
		case less(q, p):
			return false
		}
	}
	return is.lessfunc[k](p, q)
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	r := make([]restaurant, n)
	for i := 0; i < n; i++ {
		r[i].index = i + 1
		r[i].city = nextLine()
		r[i].point = nextInt()
	}
	byCity := func(p1, p2 *restaurant) bool {
		return p1.city < p2.city
	}
	byPoint := func(p1, p2 *restaurant) bool {
		return p1.point > p2.point
	}
	sort.Sort(sorter{res: r, lessfunc: []lessFunc{byCity, byPoint}})

	for _, v := range r {
		fmt.Println(v.index)
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string s,t;
int main(void){
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(), t.end());
	if(s<t)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
def otoshi():

  #10000a+5000b+1000c=1000/1000*y & a+b+c=n
  n,y=map(int,input().split())
  #をみたすa,b,cの組
  for i in range(n+1):
    for j in range(n+1):
      k=n-i-j
      if k<0:continue
      s=10000*i+5000*j+1000*k
      if s==y:
        print(i,j,k)
        exit()

  print(-1,-1,-1)

otoshi()

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>


void printArray(int array[], int n) {
    for (int i = 0; i < n; i++) {
        if (i != 0) printf(" ");
        printf("%3d", array[i]);
    };
}
void printArrayNoSpace(int array[], int n) {
    for (int i = 0; i < n; i++) {
        if (i != 0) printf(" ");
        printf("%d", array[i]);
    };
}
void printBooleanArray(int array[], int n) {
    for (int i = 0; i < n; i++) {
        if (i != 0) printf("\n");
        if (array[i])
            printf("yes");
        else
            printf("no");
    };
}

// can a value be expressed by the sum of integers (in distinct index) in the array?
int expressibleBySumOf( int value,      // t - value to be expressed
                        int hereIndex,  // p - inclusive onward index of current subsequence
                        int integers[], // A - full sequence
                        int nIntegers) 
{
//    printf("value:%4d, hereIndex: %2d, integers[hereIndex]: %3d\n", value, hereIndex, integers[hereIndex]);
    
    // special case: able to express immediately
    if (value == integers[hereIndex]) 
        return 1;
    
    // special case: subsequence has only 1 element
    if (hereIndex == nIntegers - 1)
        return value == integers[hereIndex]; 
    
    // choose the sum with the integer at hereIndex
                        // ____ KEY BELOW HERE!! _____
    if (expressibleBySumOf(value - integers[hereIndex], hereIndex + 1, integers, nIntegers))
        return 1; 
    
    // choose the sum without the integer at hereIndex
    if (expressibleBySumOf(value, hereIndex + 1, integers, nIntegers))
        return 1; 
    
    return 0; 
};

int main(int argc, char** argv) {
    int n, q, i;
    scanf("%d", &n);
    
    const int nIntegers = n;
    int integers[nIntegers];
    
    for (i = 0; i < n; i++)
        scanf("%d", &integers[i]);

//    printf("integers: ");printArray(integers, nIntegers);printf("\n");
    
    scanf("%d", &q);
    
    const int nQuestions = q;
    int questions[nQuestions];
    int answers[nQuestions];
    
    for (i = 0; i < q; i++) {
        scanf("%d", &questions[i]);
//        printf("-------------question: %d--------------\n", questions[i]);
        answers[i] = expressibleBySumOf(questions[i], 0, integers, nIntegers);
//        printf("answer: %d\n",answers[i]);
//        printf("\n");
    }

//    printf("questions: ");printArray(questions, nQuestions);printf("\n");
//    printf("answers:   ");
    printBooleanArray(answers, nQuestions);
    printf("\n");
    

    return (EXIT_SUCCESS);
}




Measured memory_bytes: 2096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans=1;
int par[200001]={};
int r[200001]={};
int si[200001]={};


int find(int x){
	if(par[x]==x){
		return x;
	}else {
		 return par[x]= find(par[x]);
	}
}

void unite(int x, int y){
	x =find(x);
	y = find(y);
	if(x==y) return ;
	if(r[x] < r[y]){
		par[x]=y;//親をyにする
		si[y]+=si[x];
		ans=max(ans,si[y]);
	}else{
		par[y] =x;
		si[x]+=si[y];
		ans=max(ans,si[x]);
		if(r[x] == r[y]) r[x]++; 
	}
	
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0; i<n+1; i++){
		par[i]=i;
		si[i]=1;
	}
	for(int i=0; i<m; i++){
		int x,y;
		cin>>x>>y;
		unite(x,y);
	}
	cout<<ans<<endl;
}
		


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

int main(){

  int n, hit, blow, b[4];
  int a[10] = {0};

  while(cin >> b[0] >> b[1] >> b[2] >> b[3]){
    hit = 0;
    blow = 0;

    for(int i=1; i<=9; i++){
      a[i] = 0;
    }
    for(int i=1; i<=4; i++){
      a[b[i-1]] = i;
    }

    for(int i=1; i<=4; i++){
      cin >> n;
      if(a[n] == i) hit++;
      else if(a[n] != 0) blow++;
    }
    cout << hit << " " << blow << endl;    
  }

  return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
int main() {
  ll n;
  cin>>n;
  if(n==1)cout<<"Hello World"<<endl;
  else{
    ll a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
  }
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>
     
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;


struct pair_hash
{
	size_t operator()(const std::pair<ll, ll> &v) const 
    {
      
        return std::hash<ll>()(v.first) ^ std::hash<ll>()(v.second);
    }
};

struct state
{
    ll a,b,c;

    state(ll a, ll b, ll c) : a(a), b(b), c(c)
    {

    }

  bool operator==(const state &other) const
  { return (a == other.a
            && b == other.b
            && c == other.c);
  }
};

struct KeyHasher
{
    size_t operator()(const state& k) const
  {
    //using std::size_t;
    //using std::hash;
    //using std::string;

    return ((hash<ll>()(k.a)
               ^ (hash<ll>()(k.b) << 1)) >> 1)
               ^ (hash<ll>()(k.c) << 1);
  }
};  


ll A[20][20];
ll C[20];
ll x;
ll n;
ll m;

bool maskGivesLevel(ll mask)
{
	ll levels[m];

	for (int i = 0; i < m; i++) levels[i] = 0;

	for (ll i = 0; i < n; i++)
	{
		if (mask & (1 << i)) // mask contains i-th book
		{
			for (int q = 0; q < m; q++)
			{
				levels[q] += A[i][q];
			}
		}
	}

	for (int i = 0; i < m; i++)
		if (levels[i] < x) return false;

	return true;	
}

ll costOfMask(ll mask)
{
	ll res = 0;

	for (ll i = 0; i < n; i++)
	{
		if (mask & (1 << i)) // mask contains i-th book
		{
			res += C[i];
		}
	}

	return res;
}

void solve()
{
	//ll n,m,x;
	cin >> n >> m >> x;


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

		for (int j = 0; j < m; j++)
			cin >> A[i][j];
	}

	for (int j = 0; j < m; j++)
	{
		ll sum = 0;

		for (int i = 0; i < n; i++)
		{
			sum += A[i][j];
		}

		if (sum < x)
		{
			cout << -1 << endl;
			return;
		}
	}


	// we can do it

	// check all the subsets of books

	ll res = INT_MAX;

	for (ll mask = 1; mask < (1 << n); mask++)
	{
		if (maskGivesLevel(mask))
		{
			res = min(res, costOfMask(mask));
		}
	}


	cout << res << endl;

}


int main()
{
	solve();

	return 0;
}




Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int count = scan.nextInt();
		int cards[][] = new int[4][52];
		String mark = "";
		int num = 0;
		for(int i = 0;i < count;i++)
		{
			mark = scan.next();
			num = scan.nextInt();
			if(mark.equals("S")){
				cards[0][num - 1] = 1;
			}else if(mark.equals("H")){
				cards[1][num - 1] = 1;
			}else if(mark.equals("C")){
				cards[2][num - 1] = 1;
			}else if(mark.equals("D")){
				cards[3][num - 1] = 1;
			}
		}
		
		for(int i = 0;i < 4;i++)
		{
			for(int j = 0;j < 13;j++)
			{
				if(cards[i][j] == 0){
					switch(i)
					{
						case 0:
							System.out.printf("S %d\n", j + 1);
							break;
						case 1:
							System.out.printf("H %d\n", j + 1);
							break;
						case 2:
							System.out.printf("C %d\n", j + 1);
							break;
						case 3:
							System.out.printf("D %d\n", j + 1);
							break;
						default:
							System.out.println("error");
							break;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 18128
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,m;
void solve(){
	 cin>>n>>m;
	 cout<<(n>=2?(n*(n-1))/2:0)+(m>=2?(m*(m-1))/2:0);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,m,t,s,d;
	while(cin>>n>>m,n){
		vector<pair<int,pair<int,int> > >p(m);
		rep(i,m)cin>>t>>s>>d,p[i]=make_pair(t,make_pair(s-1,d-1));
		sort(p.begin(),p.end());
		bool f[n]; rep(i,n)f[i]=i==0;
		int ans=1;
		rep(i,m)if(f[p[i].second.first]&&!f[p[i].second.second])ans++,f[p[i].second.second]=1;
		cout<<ans<<endl;
	}
	return 0;
}

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


int dp[3000][3000];
//dp[x][y] s wali string me x index per hai
// and t wali string me y index per hai
// isme kitna length of substring hogi

int choice[3000][3000];
// 0 -> // not picking(i - 1,j) , 1 -> (i, j - 1), // picking 2 -> (i - 1,j - 1)

int main()
{
    string s,t;
    cin>>s>>t;
    int n = s.size(), m = t.size();

    dp[0][0] = 0;

    if(s[0] == t[0])
    {
        dp[0][0] = 1;
        choice[0][0] = 2;
    }

    for(int i = 0; i < n ;i++)
    {
        for(int j = 0; j < m; j++)
        {
            // not picking current character
            if(i > 0)
            {
                dp[i][j] = dp[i - 1][j];
                choice[i][j] = 0;
            }
            if(j > 0)
            {
                if(dp[i][j - 1] > dp[i][j])
                {
                    dp[i][j] = dp[i][j - 1];
                    choice[i][j] = 1;
                }
            }
            // picking current character
            if(s[i] == t[j])
            {
                int ans = 1;
                if(i > 0 && j > 0)
                {
                    ans = 1 + dp[i - 1][j - 1];
                }
                if(ans > dp[i][j])
                {
                    dp[i][j] = ans;
                    choice[i][j] = 2;
                }
            }
        }
    }


    //cout<<dp[n - 1][m - 1]<<endl;
    int i = n - 1;
    int j = m - 1;
    string subsequence;

    while( i >= 0 && j >= 0)
    {
        if(choice[i][j] == 0)
        {
            i--;
        }
        else if(choice[i][j] == 1)
        {
            j--;
        }
        else  if(choice[i][j] == 2)
        {
            subsequence.push_back(s[i]);
            i--;
            j--;
        }
    }
    reverse(subsequence.begin(),subsequence.end());
    cout<<subsequence<<endl;

    return 0;


}


Measured memory_bytes: 73888
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S,T;
  cin >> S >> T;
  int count = 0;
  rep(i,3)
  {
    if(S[i]==T[i])
    {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;



#define M 1527791/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1;
  int j,i;
  j =strlen(str);
  for ( i = 0; i < j; i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }
int h(int key,int i){return (h1(key)+i*h2(key))%M;}
bool find(char str[]){
  int i=0;
  long long j,key;
  key=getKey(str);
  while(1){
    j=h(key,i);
    if(strcmp(H[j],str)==0)return 1;
    else if(H[j][0]=='\0'||i>=M)return 0;
    else i++;
  }
    
}

void insert(char str[]){
  int i=0;
  long long j,key;
  key=getKey(str);
  while(1){
    j=h(key,i);
    if(strcmp(H[j],str)==0)break;
    else if(H[j][0]=='\0'){
      strcpy(H[j],str);
      break;
    }
    else i++;
  }
}

int main(){
  int i,n;
  char str[L], com[9];
  //for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
	
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }



  return 0;
}



Measured memory_bytes: 23896
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>
#include <numeric>
#include <set>
#include <map>

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

using namespace std;

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

int main() {

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

	sort(h, h + 10);

	cout << h[9] << endl;
	cout << h[8] << endl;
	cout << h[7] << endl;

	return 0;

}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(void) {
    int K,N;
    long long ans=0;
    cin >> K >> N;

    int A[N+1];

    for(int i=0; i<N; i++){
      cin >> A[i];
    }
    A[N] = A[0] + K;

    long long tmp=0;
    long long max_val = 0;
    for(int i=0; i<N; i++){
        tmp = A[i+1] - A[i];
        ans += tmp;
        if(tmp > max_val){
          max_val = tmp;
          //cout <<"i: " << i <<  "max_val: " << max_val << endl;
        }
    }

    cout<< A[N]-max_val-A[0] <<endl;

    return 0;
}


Measured memory_bytes: 1024
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    s = set()
    for i in range(n):
        x = f()[0]
        if x not in s:
            s.add(x)
        else:
            s.remove(x)
    
    print(len(s))


solve()


Measured memory_bytes: 12012
#include <cstdio>
#include <set>
#include <map>
#include <vector>

int main(void) {
  int w, h, n;
  while (scanf("%d%d%d", &w, &h, &n) == 3) {
    std::vector<std::set<int>> ys(h + 1);
    for (int i = 0; i < n; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      ys[y].insert(x);
    }

    int res = 1000000000;
    int steps = 0;
    int x = 1, y = 1;
    while (true) {
      auto it = ys[y].lower_bound(x);
      int d;
      if (it == ys[y].end()) {
        d = w + 1 - x;
      } else {
        d = *it - x;
      }
      res = std::min(res, steps + d);
      if (d == 1) {
        break;
      }
      x++;
      steps++;
      if (y != h && ys[y + 1].count(x) == 0) {
        y++;
      }
    }
    printf("%d\n", res);
  }
  return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m);i>=(int)(n);--i)
#define debug(x) cout << #x << "=" << (x) << endl;
 
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
  while(true){
    int N,M;
    cin >>N>>M;
    if(!(N|M))return;
    int hs[N+1],ws[M+1];
    rep(i,N){
      cin>>hs[i+1];
      hs[i+1]+=hs[i];
    }
    rep(i,M){
      cin>>ws[i+1];
      ws[i+1]+=ws[i];
    }
    int res=0;
    map<int,int> ct;
    rep(i,M+1)
      REP(j,i+1,M+1)
        ct[ws[j]-ws[i]]++;
    rep(i,N+1)
      REP(j,i+1,N+1)
        res+=ct[hs[j]-hs[i]];
    cout<<res<<endl;
  }

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


Measured memory_bytes: 20952
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
const int mod=1e9+7;
typedef long long ll;
ll A,B,C;
int main(){
	scanf("%lld%lld%lld",&A,&B,&C);
	printf("%lld\n",min(A+B,C)+B+(C>A+B));
	return 0;
}
/*
6
1 3 1 2 3 2
*/

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N;
    int D=0;
    int L[101];
    int X;
    int i = 1;
    scanf("%d %d",&N,&X);
    for(i=1;i<=N;i++){
        scanf("%d",&L[i]);
    }
    int j=1;
    while(D<=X){
        D = D + L[j];
        j++;
        if(j-1==N+1)
        break;
    }
    printf("%d\n",j-1);
}

Measured memory_bytes: 128
n=int(input())
s=set()
for i in range(1000):
    s=s|{i**j for j in range(2,10) if i**j<=1000}
l=sorted(s)
for (i,j) in enumerate(l):
    if n<j:
       print(l[i-1])
       break;
    elif n==j:
        print(n)
        break;


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

int main() {
  vector<int> vec(3);
  for (int i = 0; i < 3; i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  cout << vec.at(0) + vec.at(1) << endl;
}

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


int main() {
    int N, M;
    std::cin >> N >> M;

    int mark[N];
    for (int i = 0; i < N; ++i) {
        mark[i] = -1;
    }

    std::vector<int> G[N];
    int A, B;
    for (int i = 0; i < M; ++i) {
        std::cin >> A >> B;
        --A;
        --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    std::queue<int> que;
    que.push(0);
    while (que.empty() == false) {
        const int p = que.front();
        que.pop();

        for (int v : G[p]) {
            if (mark[v] == -1) {
                mark[v] = p;
                que.push(v);
            }
        }
    }

    std::vector<int> ans;
    for (int i = 1; i < N; ++i) {
        if (mark[i] == -1) {
            std::cout << "No" << std::endl;
            return 0;
        }

        ans.push_back(mark[i] + 1);
    }

    std::cout << "Yes" << std::endl;
    for (int a : ans) {
        std::cout << a << std::endl;
    }

    return 0;
}


Measured memory_bytes: 10708
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n,m;
  cin >> n >> m;
  vi c(m);
  REP(i,m) cin >> c[i];
  vi dp(1e5,INT_MAX);
  dp[0] = 0;
  REP(i,n)REP(j,m){
    dp[i+c[j]] = min(dp[i+c[j]],dp[i]+1);
  }
  cout << dp[n] << endl;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int ans;
int n;
int k;
int s;
void f(int i,int t,int sum){
  if(i==k){
    ans+=(sum==s);
    return;
  }
  for(int j=t;j<=n;j++){
    //    sum+=j;
    f(i+1,j+1,sum+j);
  }
}

int main(){
  while(1){
    cin>>n>>k>>s;
    if(!n)break;
    ans=0;
    f(0,1,0);
    cout<<ans<<endl;
  }
  return 0;
}

  



Measured memory_bytes: 3020
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    #ifndef ONLINE_JUDGE 
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        freopen ("OUTPUT_ERROR.txt" , "w" , stderr);
    #endif

    //start from here

    readb(x, n) readarr(p, n)

    int flag[200] = {}; 
    fori (i, 1, n) flag[p[i]] = 1;

    int ans = 0, mn = INF;

    fori (i, -150, 150)
    {
        int diff = abs(x - i);
        if(i < 0) 
        {
            if(diff < mn) ans = i, mn = diff;
        }

        else if(i >= 0 && !flag[i])
        {
            if(diff < mn) ans = i, mn = diff;
        }
    }

    print(ans)

    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const int INF=1e9;

vector< int > divisor(int n) {
  vector< int > ret;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}



int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,int> b,c;
  rep(i,n){
     cin>>a[i];

  	b[a[i]]=i+1;
    c[a[i]]++;
  }
  int count=0;

  rep(i,n){//a[i]の約数を見る．
    vector<int> ya=divisor(a[i]);
    bool judge=false;
    
    //同じ数を含む場合,continue;
    if(c[a[i]]>1) continue;
    
    
    for(int j=0; j<ya.size(); j++){
      //cout<<j<<endl;
      if(b[ya[j]]>0 && b[ya[j]]!=i+1){
        judge=true;
        break;
      }
      
      
        
      
    }
    
    if(judge){
      continue;
    }
    //cout<<" "<<i<<endl;
    count++;
    
  }
  cout<<count<<endl;


  
}


Measured memory_bytes: 42244
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }
    println!("{} {}", &s[..4], &s[4..]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF =1001001001;
using P = pair<int,int>;

int main(void) 
{
   ll x;
   cin >> x;
   ll ans =0;
   ll m = 100;

   while(x > m){
       m = m * 1.01;
       ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 3620
require 'set'

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

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

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

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

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

def get_int
  gets.chomp.to_i
end

N, K = get_ints
H = get_ints

hx = H.sort

if H.length <= K
  puts '0'
else
  puts hx[0...(H.length - K)].sum
end


Measured memory_bytes: 31012
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
int a,b,c;
signed main(){
	Rd(a),Rd(b),Rd(c),swap(a,b),swap(a,c);
	wr(a),Ps,wr(b),Ps,wr(c);
	exit(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXSIZE = 1e6+7;
int num[MAXSIZE];
int n, q;
int binarySearch(int c){
	int left = 0, right = n;
	while(left < right){
		int mid = (left + right)/2;
		if(num[mid] > c) right = mid;
		else if(num[mid] < c) left = mid + 1;
		else return true;
	}
	return false;
}
int main(){
	while(~scanf("%d",&n)){
		for(int i = 0; i < n; i++){
			scanf("%d",&num[i]);
		}
		scanf("%d",&q);
		int temp, cnt = 0;
		for(int i = 0; i < q; i++){
			scanf("%d",&temp);
			if(binarySearch(temp)) cnt++;
		}
		printf("%d\n", cnt);
	}
	return 0;
}


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

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

struct Button {
  int lx, ly, rx, ry, to;
  bool Check(int cx, int cy) {
    return (lx <= cx) && (cx <= rx) && (ly <= cy) && (cy <= ry);
  }
};

int N, W, H, Q;
vector<int> B(102);
vector<string> vs(102);
vector<Button> vbs[102];

int main() {
  while (cin >> N, N) {
    cin >> W >> H;

    vector<vector<string> > links(N, vector<string>());
    map<string,int> maps;
    string temp;
    int lx, ly, rx, ry;
    
    rep(i,N) {
      cin >> vs[i] >> B[i];
      maps.insert(make_pair(vs[i], i));
      vbs[i].clear();
      rep(j,B[i]) {
        cin >> lx >> ly >> rx >> ry >> temp;
        vbs[i].push_back((Button){lx, ly, rx, ry, -1});
        links[i].push_back(temp);
      }
    }

    rep(i,N) {
      rep(j,links[i].size()) {
        vbs[i][j].to = maps[ links[i][j] ];
      }
    }

    cin >> Q;
    string query;
    int cx, cy;
    vector<string> buffer(1, vs[0]);
    vector<string>::iterator itr;
    int ptr = 0;
    
    rep(q,Q) {
      cin >> query;
      if (query == "click") {
        cin >> cx >> cy;
        int cur = maps[ buffer[ptr] ];
        rep(i,B[cur]) {
          if (vbs[cur][i].Check(cx, cy)) {
            if (ptr != buffer.size()-1) {
              itr = buffer.begin();
              advance(itr, ptr+1);
              buffer.erase(itr, buffer.end());
            }
            buffer.push_back(vs[ vbs[cur][i].to ]);
            ++ptr;            
            // printf("clicked success to %s. current is %s:%d\n",
            //        vs[ vbs[cur][i].to ].c_str(),
            //        buffer[ptr].c_str(),
            //        ptr);
            break;
          }
        }
      } else if(query == "show") {
        cout << buffer[ptr] << endl;
      } else if(query == "back") {
        if (ptr > 0) --ptr;
      } else if(query == "forward") {
        if (buffer.size() - 1 >= ptr + 1) ++ptr;
      } else {
        puts(query.c_str());
        assert(false);
      }
      // printf("state %3d:", q);
      // rep(i,buffer.size()) printf("[%s]",buffer[i].c_str()); puts("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

const int S = 4e3;
const int N = 4010;
const int Mod = 998244353;
int n, ans; bool c[N], g[N], d[N], r[7][N]; char cs[N];

inline int deg(bool *a) {
	for (int i = S; ~ i; --i) if (a[i]) return i;
}
inline void pls(bool *a, bool *b, int l) {
	for (int i = l; i <= S; ++i) a[i] = a[i] ^ b[i-l];
}
inline void gcd(bool *a, bool *b, bool *d) {
	int da = deg(a), db = deg(b);
	if (da < db) swap(da, db), swap(a, b);
	if (!db && !b[0]) {for (int i = 0; i <= S; ++i) d[i] = a[i]; return;}
	pls(a, b, da - db), gcd(b, a, d);
}
template <class T> inline void in(T &x) {
	x = 0; int f = 1; char ch = getchar();
	for (; ch<'0' || ch>'9';) {if (ch=='-') f=-1; ch = getchar();}
	for (; ch>='0' && ch<='9';) x = x*10 + ch-'0', ch = getchar();
	x *= f;
}

inline void red(bool *a) {
	int ls; scanf("%s", cs), ls = strlen(cs) - 1;
	for (int i = 0; i <= ls; ++i) a[i] = cs[ls - i] - '0';
}

inline void work() {
	in(n), red(c);
	for (int i = 1; i <= n; ++i) red(r[i]);
	memset(g, 0, sizeof g);
	for (int i = 1; i <= n; ++i) {
		for (int j = deg(g); ~ j; --j) d[j] = g[j];
		gcd(r[i], d, g);
	}
	int dc = deg(c), dgcd = deg(g);
	memset(d, 0, sizeof d);
	for (int i = dc; i >= dgcd; --i)
		if (d[i] ^ c[i]) pls(d, g, i - dgcd);
	ans = 0;
	for (int i = dc; i >= dgcd; --i) ans = ((ans << 1) + c[i]) % Mod;
	for (int i = dgcd - 1; ~ i; --i)
		if (d[i] < c[i]) break;
		else if (d[i] > c[i]) {--ans; break;}
	printf("%d", ans + 1);
}

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

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

int main()
{
    int n,temp = 0;
    cin>>n;

    for(int i=1;i<=9;i++)
    {
        for(int j=i;j<=9;j++)
        {
            if(i*j==n)
            {
                temp = 1;
                //cout<<i<<"*"<<j<<endl;
                break;
            }
        }
    }
    if(temp == 1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;
}


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

int main() {
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = (double)W*H/2;
    int num = (W == x*2 && H == y*2) ? 1 : 0;
    printf("%.10f %d\n", ans , num);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int K;
    int A, B;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK" << '\n';
            return 0;
        }
    }
    cout << "NG" << '\n';
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>

using namespace std;

bool judge(int a, int b, int c, int d) {
  return (abs(c - a) <= d) || (abs(b - a) <= d && abs(c - b) <= d);
}

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (judge(a, b, c, d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

typedef long long ll;

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

    for (ll x = 0; x <= 9; x++){
        for (ll y = 0; y <= 9; y++){
            if(x * y == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


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

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

cnt = 0
for i in range(N):
    l =min(A[i],B[i])
    #A[i] -= l                       #残存モンスター数
    B[i] -= l                       #さらに勇者が倒せるモンスターの数
    cnt += l
    if B[i] > 0:                    #倒す余裕がある場合
        r = min(A[i+1],B[i])
        A[i+1] -= r                 #本来のA[i+1]から勇者が倒したモンスターrを引く
        #B[i] -= r
        cnt += r
print(cnt)

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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  vector<int> B;
  for (int i = 0; i < N; i++) {
    if (N % 2 == 0 && i % 2 == 0)
      B.push_back(A.at(i));
    else if (N % 2 == 0 && i % 2 == 1)
      B.insert(B.begin(), A.at(i));
    if (N % 2 == 1 && i % 2 == 0)
      B.insert(B.begin(), A.at(i));
    else if (N % 2 == 1 && i % 2 == 1)
      B.push_back(A.at(i));
  }

  for (int i = 0; i < N; i++) cout << B.at(i) << ' ';
  cout << endl;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,dp[3001][3001],a[3001];
int rec(int l,int r){
	if(l>r)swap(l,r);
	if(l==r)return a[l];
	if(dp[l][r]!=0)return dp[l][r];
	return dp[l][r]=max(a[l]-rec(l+1,r),a[r]-rec(l,r-1));
}
main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		dp[i][i]=a[i];
	}
	cout<<rec(1,n);
}

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

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

int main() {
    int N, K, ans = 0;
    cin >> N >> K;
    vector<int> p(N);
    rep(i,N) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    rep(i,K) {
        ans += p[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(10**6)
m,d=map(int,input().split())
def fac(n):
  a=1
  if n==1:
    return a
  else:
    a=n*fac(n-1)
    return a%(10**9+7)
if abs(m-d)>=2:
  print(0)
elif abs(m-d)==1:
  print((fac(m)*fac(d))%(10**9+7))
else:
  print(2*(fac(m)**2)%(10**9+7))


Measured memory_bytes: 88948
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

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

    vector<int> a(N);
    rep(i, N) cin >> a[i];

    vector<bool> dp(K+1);
    for (int stones = 0; stones <= K; ++stones) {
        for (int x : a) {
            if (x <= stones && !dp[stones - x]) {
                dp[stones] = true;
            }
        }
    }

    cout << (dp[K] ? "First" : "Second")  << endl;

    return 0;
}


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

#define ll long long
int main() {
	ll n;
	cin >> n;
	
	ll ans = LLONG_MAX;
	for(ll i = 1; i * i <= n; i++){
		if (n % i == 0){
			ll x = i;
			ll y = n / x;
			ll cur = (x - 1) + (y - 1); 
			ans = min(ans,cur);
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
long long sum = 0;

typedef pair<int, int> Pa;
typedef long long ll;

int main() {
    cin >> N;
    vector<pair<ll,ll>> vec;
    for(ll i=1;i<=sqrt(N);i++){
        if(N%i == 0){
            vec.push_back(make_pair(i, N/i));
        }
    }
    for(int i=0;i<vec.size();i++){
        min_value = min(min_value, vec[i].first+vec[i].second-2ll);
    }
    cout << min_value;
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int xa = min(a,k);
  k -= xa;
  int xb = min(b,k);
  k -= xb;
  int xc = k;
  int ans = xa - xc;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <algorithm> 
#include <cstdio>
#include <cstring>

const int N=5e5+5;

char s[N];

int n,a[N]; long long ans;

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	for(int i=1;i<=n;++i){
		if(s[i]=='<') a[i+1]=a[i]+1;
	}
	for(int i=n;i>=1;--i){
		if(s[i]=='>') a[i]=std::max(a[i],a[i+1]+1);
	}
	for(int i=1;i<=n+1;++i) ans+=a[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>

using namespace std;

void call(int n){
  int i = 1;
 
  do
  {
    int x = i;
    if ( x % 3 == 0 ){
      cout << " " << i;
    }
    else
    {
      do
      {
        if ( x % 10 == 3 ){
          cout << " " << i;
          break;
        }
        x /= 10;
      }
      while (x);
    }
  }
  while ( ++i <= n );
  cout << endl;
}

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



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

using namespace std;

int main() {
    long long k,n;
    cin>>n>>k;
    int vis[10]={};
    while(k --){
        int a;
        cin>>a;
        vis[a]=1;
    }
    while(true){
        bool ok=false;
        stringstream s;
        s << n;
        string x=s.str();
        for(int i=0;i<x.size();i++){
            if(vis[x[i]-'0']==1){
                ok=true;
                break;
            }
        }
        if(!ok)
            break;
        n++;

    }
    cout<<n;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256