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

int main(){
  string s, t;
  cin >> s >> t;
  
  int size = s.size();
  for(int i = 0 ; i < size; i ++){
    bool ret = true;
    for(int j = 0 ; j < size; j ++){
    	if(t.at(j) != s.at((i + j) % size)){
          ret = false;
          break;
        }
    }
    if(ret){
      cout <<"Yes"<<endl;
      return 0;
    }
  }
  
  cout << "No" << endl;

  return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li r,d,x;
    cin>>r>>d>>x;
    rep(i,10){
        x = r*x-d;
        cout<<x<<endl;
    }

    return 0;
}

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

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    bool flag = false;
    rep(i, N){
        cin >> A[i];
        if(A[i] == 0) flag = true;
    }

    if(flag) cout << 0 << endl;
    else{
        ll ans = 1;
        rep(i, N){
            if(INF / ans < A[i]){
                cout << -1 << endl;
                return 0;
            }
            ans *= A[i];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4052
N = int(input())
ans = 0
l = [0] * (10 ** 7 + 1)
for i in range(1, N + 1):
    for j in range(i, N + 1, i):
        l[j] += 1

for i in range(1, N + 1):
    ans += i * l[i]
print(ans)


Measured memory_bytes: 145916
using System;

public class Odds{
   public int getNOdd(int n, int[]arr){
      int ct = 0;
      for(int i=0;i<n;i+=2){
         if((arr[i]%2)==1){
	    ct++;
	 }
      }
      return ct;
   }
       static int[]strToIntArr(String s){
//          s = s.Substring(1,s.Length-2);
	  string[] strArr = s.Split(new char[]{' '});
	  int len = strArr.Length;
          int[] retArr = new int[len];       
	  for(int i=0;i<len;i++){
	     string sVal = strArr[i];
	     int intVal = int.Parse(sVal);
	     retArr[i] = intVal;
	  }
          return retArr;
       }
       
   public static void Main(string[]args){
      Odds o = new Odds();
      string nLn, aLn;
      nLn  = Console.ReadLine();
      aLn  = Console.ReadLine();
      int n = int.Parse(nLn);
      int[]arr = strToIntArr(aLn);
      int nOdd = o.getNOdd(n,arr);
      Console.WriteLine("{0}",nOdd);
   }
}

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

const int maxN = 510;
const char ch[8] = "RYGB";

int h, w;
char str[maxN][maxN];

inline void mark(int x, int y, int k){
	if(0 <= x && x < h && 0 <= y && y < w){
assert(!str[x][y] || str[x][y] == ch[k]);
		str[x][y] = ch[k];
}
}

int main (){
	int d, i, j;
	scanf("%d%d%d", &h, &w, &d);
	if(d & 1){
		for(i = 0; i < h; ++i){
			for(j = 0; j < w; ++j)
				printf("%c", ch[(i + j) & 1]);
			puts("");
		}
	}
	else{
		if(d & 2){
			for(i = 0; i < h; ++i){
				for(j = 0; j < w; ++j)
					printf("%c", ch[((i & 3) + (j & 2)) & 3]);
				puts("");
			}
		}
		else{
			int s, t, p, q, k, dm = d / 2;
			for(p = -1; p <= max(0, h / dm) + 1; ++p){
			for(q = -1; q <= max(0, w / dm) + 1; ++q){
				s = p * dm, t = q * d;
				if(p & 1) t += dm;
				k = (p & 1) + ((p / 2 + q) & 1) * 2;
				for(i = 0; i < dm; ++i){
					for(j = 0; j < dm - i; ++j){
						mark(s + i, t + dm - j - 1, k);
						mark(s + i, t + dm + j, k);
						mark(s - i, t + dm - j - 1, k);
						mark(s - i, t + dm + j, k);
					}
				}
			}}
			for(i = 0; i < h; ++i) puts(str[i]);
		}
	}
	return 0;
}

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

namespace ABC124C
{
    class MainClass
    {

       

        public static void Main(string[] args)
        {

            string s = Console.ReadLine();
            int l = s.Length;

            string rs = "";
            string ls = "";
            /*for(int i = 0; i < l; i++)
            {
                if (i % 2 == 0)
                {
                    rs += '0';
                    ls += '1';
                }
                else
                {
                    rs += '1';
                    ls += '0';
                }
            }*/
            int rans = 0;
            int lans = 0;
            int div = 0;
            for(int i = 0; i < l; i++)
            {
                div = i % 2;
                //Console.WriteLine(div);
                if (s[i] == div.ToString()[0])
                {
                    lans++;
                }
                else
                {
                    rans++;
                }
            }
            Console.WriteLine(Math.Min(lans, rans));
        }
    }
}


Measured memory_bytes: 13280
// jag201
#include<string>
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	int a = 0; int un = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s == "A") { a++; }
		else if (s == "Un") { un++; }
		if (un > a) {
			cout << "NO";
			break;
		}
		if (i == n - 1) {
			if (a == un) { cout << "YES"; }
			else { cout << "NO"; }
		}
	}cout << endl;
	return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>

int main()
{
  int i, n, a[200000];
  scanf("%d", &n);
  int max1=-1;
  int max2=-1;
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
    if(a[i]>max1){
      max2=max1;
      max1=a[i];
    }else if(a[i]>max2){
      max2=a[i];
    }
  }
  for(i=0;i<n;i++){
    if(a[i]==max1) printf("%d\n", max2);
    else printf("%d\n", max1);
  }
  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
const double PI = 3.14159265358979323846;

int main(){
    int a, b, h, m; cin >> a >> b >> h >> m;
    double d = 30*h - 5.5*m;
    if(d < 0) d *= -1;
    if(d > 180) d = 360 - d;
    double r = d * PI / 180;
    double c2 = a*a + b*b -2*b*a*cos(r);
    double c = sqrt(c2);
    cout << fixed << setprecision(11);
    cout << c << endl;
}

Measured memory_bytes: 4084
#include <iostream>
#include <queue>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <set>
#include <string>
#include <sstream>
#include<map>
#include <vector>
#define maxn 100000+15
using namespace std;
int main(){
	int a[4]={0},x[4]={0};
	cin>>a[0]>>a[1]>>a[2];
	int sum=0;
	int b=a[0],c=a[1],d=a[2];
	int time=0,flag=0,flag3=0;
	for(int j=0;j<3;j++){
				
//				cout<<a[j];
			if(a[j]%2!=0){
				flag3=1;
				break;
			}
			
		}
		int n=101;
	while(n--){
		int flag2=0;

//		cout<<endl;
			for(int i=0;i<3;i++){
				x[i]=a[i];
			}
			time++;
			a[0]=x[1]/2+x[2]/2;
			a[1]=x[0]/2+x[2]/2;
			a[2]=x[0]/2+x[1]/2;
			for(int j=0;j<3;j++){
				if(a[j]%2!=0){
					flag=1;
					flag2=1;
					break;
				}
		}
		if(flag2){
			break;
		}

	}
	if(flag3){
		cout<<"0"<<endl;
	}else	if(flag){
		cout<<time<<endl; 
	}else{
		cout<<"-1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
    int n;
    cin>>n;
    double ans=0.0;
    for(int i=0;i<n;i++){
        double tmp;
        cin>>tmp;
        string s;
        cin>>s;
        if(s=="JPY"){
            ans+=tmp;
        }else{
            ans+=(tmp*380000.0);
        }
    }
    printf("%.8lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

int main() {
    long double A, B;
    cin >> A >> B;
    cout << (long long)(A * B + 0.001) << endl;
}

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

int main(){
    int A[4],i;
    char s[4];
    scanf("%s",s);
    for(i=0;i<4;i++){
        A[i] = s[i] - '0';
    }

    int j,sum;
    char op[3];
    for(i=0;i<8;i++){
        sum = A[0];
        for(j=0;j<3;j++){
            if( i & ( 1 << j ) ){
                op[j] = '+';
                sum += A[j+1];
            }else{
                op[j] = '-';
                sum -= A[j+1];
            }
        }
        if( sum == 7 ){
            break;
        }
    }

    for(i=0;i<3;i++){
        printf("%d%c",A[i],op[i]);
    }
    printf("%d=7\n",A[3]);

    return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
const int twx=+100;
const int inf=0x3f3f3f3f;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int n;
char s[twx][twx];
char ans[twx];
int cnt=0;
int asd[twx][twx];
int changdu=inf;
void init()
{
	n=read();
    f1(1,n,i)
    {
        scanf("%s",s[i]);
    }
}
void work()
{
	f1(1,n,i)
	{
		int x=strlen(s[i]);
		f1(0,x-1,j)
		{
			int qwe=s[i][j]-'a';
			asd[qwe][i]++;//第i个字符串中的字母出现了多少次 
		}
	}

		f1(0,25,j)//求出第j个字符最少出现次数
		{
			changdu=inf;
			f1(1,n,k)
			{
				changdu=min(changdu,asd[j][k]);
			}
			//cout<<changdu<<endl;
			f1(1,changdu,k)
			{
				//cout<<char(j+97);
				ans[cnt++]=char(j+97);
			}
		}
}
void print()
{
	sort(ans,ans+cnt);
	cout<<ans;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	init();
	work();
	print();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<utility>
#define MAX_N 2 * 100005
#define mp make_pair
using namespace std;
typedef pair<int, int> P;

int road_par[MAX_N], road_rank[MAX_N], rail_par[MAX_N], rail_rank[MAX_N];

void init(int n, int par[], int _rank[]) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        _rank[i] = 0;
    }
    return;
}

int root(int x, int par[]) {
    return par[x] == x ? x : par[x] = root(par[x], par);
}

void unite(int x, int y, int par[], int _rank[]) {
    x = root(x, par);
    y = root(y, par);
    if (x == y) return;

    if (_rank[x] < _rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (_rank[x] == _rank[y]) _rank[x]++;
    }
    return;
}

int main() {
    int N, K, L, p, q, r, s;
    vector<P> v;
    cin >> N >> K >> L;
    init(N, road_par, road_rank);
    init(N, rail_par, rail_rank);
    for (int i = 0; i < K; i++) {
        cin >> p >> q;
        p--;
        q--;
        unite(p, q, road_par, road_rank);
    }
    for (int i = 0; i < L; i++) {
        cin >> r >> s;
        r--;
        s--;
        unite(r, s, rail_par, rail_rank);
    }
    for (int i = 0; i < N; i++) {
        root(i, road_par);
        root(i, rail_par);
    }
    for (int i = 0; i < N; i++) {
        v.push_back(mp(road_par[i], rail_par[i]));
    }
    sort(v.begin(), v.end());
    map<P, int> MP;
    int count = 0;
    P now_pair = v[0];
    for (int i = 0; i < v.size(); i++) {
        if (now_pair != v[i]) {
            MP[now_pair] = count;
            count = 1;
            now_pair = v[i];
        }
        else {
            count++;
        }
    }
    if (count != 0) MP[now_pair] = count;
    for (int i = 0; i < N; i++) {
        cout << MP[mp(road_par[i], rail_par[i])] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 16624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
//解答写し
int n,m,q;
vector<int>a,b,c,d;
int ans;

void dfs(vector<int>A){
  if(A.size()==n+1){
    int now=0;
    rep(i,q){
      if(A[b[i]]-A[a[i]]==c[i])now+=d[i];
    }
    ans=max(ans,now);
    return;
  }
  A.push_back(A.back());
  while(A.back()<=m){
    dfs(A);
    A.back()++;
  }
}
int main(){
  cin>>n>>m>>q;
  a=b=c=d=vector<int>(q);
  rep(i,q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  dfs(vector<int>(1,1));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    char c;
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        cin >> c;
        if(c=='1')cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a=Integer.parseInt(sc.next());
int b=Integer.parseInt(sc.next());
int seki=a*b;
int shu=(a+b)*2;
System.out.println(seki+" "+shu);
}
}


Measured memory_bytes: 26024
package main

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

func solve() {
	x := getInt()

	ans := 0
	for {
		ans++
		if ans*(ans+1)/2 >= x {
			break
		}
	}

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n, arr[55][55];
unordered_map<ll, ll>cnt;
	
int main(void){
	IOS
	memset(arr, 0, sizeof arr);
	cin >> n;
	vector<string>s(n);
	for(int i=0;i<n;i++){
		cin >> s[i];
		ll sais=s[i].size();
		for(int j=0;j<sais;j++){
			ll c=s[i][j]-'a';
			arr[i][c]++;
		}
	}
	for(int i=0;i<26;i++) cnt[i]=inf;
	for(int i=0;i<n;i++){
		for(int j=0;j<26;j++){
			cnt[j]=min(cnt[j], arr[i][j]);
		}
	}
	for(int i=0;i<26;i++){
		int ukuran=cnt[i];
		while(ukuran--){
			char k=i+'a';
			cout << k;
		}
	}
	cout << '\n';
}


Measured memory_bytes: 3656
from string import*
s =input()
s=sorted(s)
alpha_l =[ascii_lowercase[i] for i in range(0,26)]
n='a'
for x in range(0,26):
	if x == 25 and alpha_l[x] in s:
		n = 'None'
	elif alpha_l[x] in s:
		continue
	else:
		n = alpha_l[x]
		break
print(n)

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

const int N = 100000;
const long long P = 1000000007;

vector<int> G[N+5];

int n, k;

long long ans;

long long fact[N+5];

template<typename T> T inv(T a){
    T res = 1, n = P - 2; a %= P;
    while (n){ if (n & 1) res = res * a % P; a = a * a % P; n >>= 1; }
    return res;
}

void dfs(int u, int p){
    if (k < 1 + (int)G[u].size()) ans = 0;
    else ans = ans * (fact[k - 1 - (bool)p] * inv(fact[k - 1 - G[u].size()]) % P) % P;
    for (int v : G[u]) if (v != p){
        dfs(v, u);
    }
}

int main(){
    fact[0] = 1;
    for (int i = 1; i <= N; ++i){
        fact[i] = fact[i-1] * i % P;
    }
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n-1; ++i){
        int u, v;
        scanf("%d %d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ans = k;
    dfs(1, 0);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 13504
#include <iostream>
#include <cstdlib>
#include <map>
using namespace std;
// int memo[1000000001];
map<int, int> memo;
int main(void)
{
  int n, m, d, t;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> d;
    memo[d]++;
  }
  cin >> m;
  for (int i = 0; i < m; i++)
  {
    cin >> t;
    if (memo[t])
    {
      memo[t]--;
    }
    else
    {
      cout << "NO" << endl;
      exit(0);
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
#include <list>
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (long long i = 0; i < (n); ++i)
#define rep(i, a, b) for (long long i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

typedef long long ll;
const ll MOD = 2019;
// xにmultをn回%modでかける
ll mod_pownum(ll x,ll mult, ll n, ll mod)
{
    if(n == 1)
    {
        return x * mult;
    }
    else if(n == 0)
    {
        return x;
    }
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * mult % mod;
        mult = mult * mult % mod;
        n >>= 1;
    }
    return (res * x) % mod;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int len = s.length();

    vector<ll> cnt(2019);
    ll sum = 0;
    cnt[0]++;
    ll ans = 0;
    int x = 1;
    REP(i, len)
    {
        int val = s[i] - '0';
        //val = mod_pownum(val, 10,  i, MOD);
        val = val * x % MOD;
        sum = (sum + val) % MOD;
        ans += cnt[sum];
        cnt[sum]++;
        x = x * 10 % MOD;
    }

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


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
int dp(int now);
vector<int>node[100009];
int memo[100009];

int main(){
  memset(memo,-1,sizeof(memo));
  int n,m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    node[x].push_back(y);
  }
  int ans=0;
  for(int i=1;i<=n;i++){
    ans=max(ans,dp(i));
  }
  cout<<ans<<endl;
  return(0);
}

int dp(int now){
  int rec=0;
  if(memo[now]!=-1)return memo[now];
  for(int i=0;i<node[now].size();i++){
    int next=node[now][i];
    rec=max(rec,dp(next)+1);
  }
  return memo[now]=rec;
}


Measured memory_bytes: 8192
from itertools import accumulate
from bisect import bisect_left


N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
B = [0] + list(accumulate(A))

def check(X):
    cnt = 0
    for i in range(N):
        cnt += N - bisect_left(A, X - A[i])
    return cnt >= M


def main():

    ng = 10 ** 9
    ok = 0
    while abs(ng - ok) > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid

    ans = 0
    cnt = 0
    for i in range(N):
        tmp = bisect_left(A, ok - A[i])
        cnt += N - tmp
        ans += B[N] - B[tmp]
        ans += A[i] * (N - tmp)
    ans -= ok * (cnt - M)
    print(ans)




if __name__ == "__main__":
    main()

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

int n;
vector<string> city;
string tmp[20];
int dp[1<<20][20];
int cost[20][20];
bool ng[20];
const int inf=1e7;

int main(){
	
	while(cin>>n,n){

		for(int i=0;i<n;i++) cin>>tmp[i],ng[i]=false;

		//?????¨?????????????????????????????????
		for(int i=0;i<n;i++){
			if(ng[i]) continue;
			for(int j=0;j<n;j++){
				if(i==j) continue;

				if(tmp[i].find(tmp[j])!=string::npos) ng[j]=true;
			}
		}
		city.clear();
		for(int i=0;i<n;i++){
			if(!ng[i]) city.push_back(tmp[i]);
		}

		n=city.size();
		const int N=1<<n;
		
		fill(&dp[0][0],&dp[N][n],inf);
		fill(&cost[0][0],&cost[n][n],inf);

		for(int i=0;i<n;i++){
			dp[1<<i][i]=city[i].size();
		}

		//city[i]????????????city[j]?????????????????????
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(i==j) cost[i][j]=0;
				//city[i]???????????????len????????¨city[j]????????????len??????????????????
				for(int len=min(city[i].size(),city[j].size());len>=0;len--){
					if(city[i].substr(city[i].size()-len,len)==city[j].substr(0,len)){
						cost[i][j]=city[j].size()-len;
						break;
					}
				}
			}
		}

		for(int bit=1;bit<N;bit++){
			for(int from=0;from<n;from++){
				if(!(bit&(1<<from))) continue;
				for(int to=0;to<n;to++){
					if(bit&(1<<to)) continue;
					dp[bit|(1<<to)][to]=min(dp[bit|(1<<to)][to],dp[bit][from]+cost[from][to]);
				}
			}
		}
		
		cout<<*min_element(dp[N-1],dp[N])<<endl;

	}

}

Measured memory_bytes: 4408
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();

		int res = 0;

		for(int a = 0; a <= A; a++){
			for(int b = 0; b <= B; b++){
				int c = (X - (a * 500 + b * 100)) / 50;
				if( c >= 0 && c <= C) res++;
			}
		}

		System.out.println(res);
	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, Q; 
	cin >> N >> Q; 
	long long int A[114514] = {}; 
	long long int S[114514] = {}; //累積和
	long long int E[114514] = {}; //偶数番目のみ
	long long int O[114514] = {}; //奇数番目のみ
	for(int i = 1; i <= N; i++){
		cin >> A[i]; 
		S[i] = S[i-1] + A[i]; 
		if(i % 2 == 0){
			E[i] = E[i-1] + A[i], O[i] = O[i-1]; 
		}
		if(i % 2 == 1){
			E[i] = E[i-1], O[i] = O[i-1] + A[i]; 
		}
	}
	int B[60000] = {};
	for(int i = 0; i < (N+1)/2; i++){
		B[i] = A[N - 2 * ((N-1)/2 -i)] + A[N - ((N-1)/2 -i)]; 
	}
	for(int q = 0; q < Q; q++){
		long long int X;
		cin >> X; 
		if(N % 2 == 1){ 
			int m = lower_bound(B, B + (N+1)/2, X * 2) - B; 
			if(m == (N+1)/2){cout << O[N] << endl;}
			else if(m == 0){cout << S[N] - S[N/2] << endl;}
			else{cout << S[N] - S[N/2+m] + O[m*2-1] << endl;}
		}
		else if(N % 2 == 0){
			int m = lower_bound(B, B + (N+1)/2, X * 2) - B; 
			if(m == N/2){cout << E[N] << endl;}
			else{cout << S[N] - S[N/2+m] + E[m*2] << endl;}
		}
	}
}

Measured memory_bytes: 5504
// D

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int N;
  ll x;
  cin>>N>>x;
  ll L[51] = {0};
  L[0] = 1;
  ll p[51] = {0};
  p[0] = 1;
  for (int i(1);i<N;i++){
    L[i] = 2 * L[i-1] + 3;
    p[i] = 2 * p[i-1] + 1;
  }
  for (int i(0);i<N;i++){
    //cout << L[i] << " " << p[i] << endl;
  }
  ll now(0);
  ll ans(0);
  int v(1);
  for (int i(N-1);i>=0;i--){
    if (v == 1){
      now += L[i] + 2;
      ans += p[i] + 1; 
    }else{
      now -= L[i] + 2;
      ans -= p[i] + 1; 
    }
    if (now == x){
      cout << ans << endl;
      return 0;
    }else if (now < x){
      v = 1;
    }else{
      v = -1;
    }
  //  cout << now << " "<<ans << endl;
  }
  if (now - x <= 2 && now - x > 0){
    cout << ans - (now - x) << endl;
  }else if(now - x == 3){
    cout << ans - 2 << endl;
  }else if (now - x < 0){
    cout << ans + 1 << endl;
  }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,ok=0;
    cin>>n;
    while(n){
        if(n%10==7){
            ok=1;break;
        }
        n/=10;
    }
	cout<<(ok?"Yes\n":"No\n");
	return 0; 
}


Measured memory_bytes: 3632
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


# 累積和
counts = [0]
buf = 0
for i in range(1, 10**5 + 2):
    if i % 2 == 0:
        counts.append(buf)
        continue
    
    judge1 = is_prime(i)
    judge2 = is_prime((i + 1) // 2)
    
    if judge1 and judge2:
        buf += 1
    
    counts.append(buf)


# 入力
Q = int(input())

for i in range(Q):
    l, r = map(int, input().split())
    print(counts[r] - counts[l - 1])


Measured memory_bytes: 54492
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
   string s;
   cin >> s;
   rep(i, s.size()){
      if((s.at(i)-'0')==7){
         cout << "Yes" << endl;
         return 0;
      }
   }

   cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

typedef struct {
	int key, id;
} data;

void merge_sort(data x[], int n)
{
	static data y[100001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

void add_BIT(int N, int BIT[], int i, int k)
{
	while (i <= N) {
		BIT[i] += k;
		i += (i & -i);
	}
}

int sum_BIT(int BIT[], int r)
{
	int sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, N, a[100001];
	data d[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d", &(a[i]));
		d[i-1].key = a[i];
		d[i-1].id = i;
	}
	merge_sort(d, N);
	
	int l = 0, r = N - 1, m, zero, BIT[200001];
	long long n = ((long long)N * (N + 1) + 2) / 4, sum;
	while (l < r) {
		m = (l + r + 1) / 2;
		for (i = 0, zero = N, sum = 0; i <= N * 2; i++) BIT[i] = 0;
		for (i = 1; i <= N; i++) {
			if (a[i] >= d[m].key) add_BIT(N * 2 + 1, BIT, zero++, 1);
			else add_BIT(N * 2 + 1, BIT, zero--, 1);
			sum += sum_BIT(BIT, zero);
		}
		if (sum >= n) l = m;
		else r = m - 1;
	}
	printf("%d\n", d[l].key);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4384
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    println(s.take(3))
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 35952
K, N = map(int,input().split())
A = [0]*N
tmp = input().split()
for a in range(N):
    A[a] = int(tmp[a])

diff = [0]*N
for a in range(N):
    
    if a == N-1:
        diff[a] = K-A[N-1]+A[0]
    else:
        diff[a] = A[a+1]-A[a]

print(K-max(diff))

Measured memory_bytes: 26100
def main():
    A, B, C, D = map(int, input().split())
    mod = 998244353

    dp = [[0]*(D+2) for i in range(C+2)]
    dp[A][B] = 1
    for i in range(A, C+1):
        for j in range(B, D+1):
            ret = dp[i][j]
            if i-A == j-B == 1:
                ret -= (i-1)*(j-1)
            else:
                ret -= dp[i-1][j-1]*(j-1)*(i-1)
            ret %= mod
            dp[i][j] = ret
            dp[i+1][j] += ret * j
            dp[i][j+1] += ret * i

    print(dp[-2][-2])


main()


Measured memory_bytes: 136724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define For(i, s, e) for(ll i = s;i <= e;i++)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int n,k;cin>>n>>k;
    int kosuu[n+1];
    rep(i,n+1) {
        kosuu[i] = 0;
    }
    rep(i,k) {
        int d;
        cin >> d;
        rep(j,d) {
            int a;
            cin>>a;
            kosuu[a]++;
        }
    }
    int ans = 0;
    For(i,1,n) {
        if(kosuu[i] == 0) ans++;
    }
    cout << ans;
}

Measured memory_bytes: 3636
// D.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>

using namespace std;

set<int> e[100001];
set<int> leaves;
set<int> hl[100001];

int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		e[a].insert(b);
		e[b].insert(a);
	}
	bool first = false;
	for (int i = 1; i <= n; ++i) {
		if (e[i].size() == 1) {
			leaves.insert(i);
			hl[*e[i].begin()].insert(i);
			if (hl[*e[i].begin()].size() >= 2) {
				first = true;
			}
		}
	}
	bool f = true;
	while (f && !first && leaves.size() > 0) {
		f = false;
		set<int> nl;
		int n;
		for (int l : leaves) {
			int p = *e[l].begin();
			if (e[p].size() != 2) {
				nl.insert(l);
			} else {
				f = true;
				int a = *e[p].begin();
				int b = *e[p].rbegin();
				if (a == l) {
					a = b;
				}
				e[a].erase(p);
				if (e[a].size() == 1) {
					nl.insert(a);
					p = *e[a].begin();
					hl[p].insert(a);
					if (hl[p].size() >= 2) {
						first = true;
					}
				}
			}
		}
		leaves = nl;
	}
	cout << (first ? "First" : "Second") << endl;
	return 0;
}


Measured memory_bytes: 23680
#include<iostream>
using namespace std;
int N_MAX=100000;
int main()
{
  int n,k,i,t,res=500000000;
  int x[N_MAX];
  cin >> n >> k;
  for(i=0;i<n;i++)
    cin >> x[i];
  for(i=0;i<n-k+1;i++){
    if(x[i+k-1]<=0)
      t=-x[i];
    else if(x[i]>=0)
      t=x[i+k-1];
    else if(x[i+k-1]>-x[i])
      t=x[i+k-1]-2*x[i];
    else
      t=2*x[i+k-1]-x[i];
    if(t<res)
      res=t;
  }
  cout << res << endl;
  return 0;
}

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

int main() {
  int n; cin >> n;
  for(int i = 1; i <= 9; ++i) {
    for(int j = 1; j <= 9; ++j) {
      if(n == (i * j)) {
        cout << "Yes" << endl;
        exit(0);
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main() {
 UL N,Q; scanf("%u%u",&N,&Q);
 queue<pair<string,UL>> G;
 rep(n,N){
  char buf[11]; UL T; scanf("%s%u",buf,&T);
  G.push({string(buf),T});
 }
 UL time=0;
 while(G.size()){
  auto q=move(G.front()); G.pop();
  if(q.second<=Q){
   time+=q.second;
   printf("%s %u\n",q.first.c_str(),time);
  }
  else{
   time+=Q;
   q.second-=Q;
   G.push(move(q));
  }
 }
 return 0;
}



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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using ll = long long;
const ll MOD = 1e9 + 7;

int n;
// A, C, G, T
ll dp[4][4][4][105];

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n;
	
	for (int i = 0; i < 4; ++i) dp[i][i][i][1] = 1;
	
	for (int i = 1; i < n; ++i) { 
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				for (int l = 0; l < 4; ++l) {
					if (!dp[j][k][l][i]) continue;
					for (int m = 0; m < 4; ++m) {
						if (k == 0 && l == 2 && m == 1) continue;
						if (k == 2 && l == 0 && m == 1) continue;
						if (j == 0 && k == 3 && l == 2 && m == 1) continue;
						if (j == 0 && k == 2 && l == 3 && m == 1) continue;
						if (j == 0 && k == 2 && l == 2 && m == 1) continue;
						if (k == 0 && l == 1 && m == 2) continue;
						dp[k][l][m][i + 1] += dp[j][k][l][i];
						dp[k][l][m][i + 1] %= MOD;
					}
				}
			}
		}
	}
	
	ll ans = 0;
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				ans = (ans + dp[i][j][k][n]) % MOD;
			}
		}
	}
	
	cout << ans;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    string s,t;cin>>s>>t;
	sort(been(s));
	sort(been(t),greater<char>());
	if(s<t)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    double a,b;
    cin >>a >> b;
    printf("%.10lf\n", a*b/(a+b));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, l;
    cin >> n >> l;
    vector<string> vec(n);
    REP(i, n) cin >> vec.at(i);
    sort(ALL(vec));
    for (auto elem : vec) {
        cout << elem;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
count = 0
k = 0
index = [1,2,3]

for i in [1,2,3]:
    if s[0] == s[i]:
        count = count + 1
        k = i
        index.remove(k)
        
if count == 1:
    if s[index[0]] == s[index[1]]:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <cstring>

#define nl '\n'

using namespace std;

int n, m, a, b;

queue<pair <int, int> > Q; //distance, node
int dist[200005];
vector<int> G[200005];

int main(){

    cin >> n >> m;

    for(int i = 0; i < m; i++){
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int SOURCE = 1;

    memset(dist, -1, sizeof(dist));

    Q.push(make_pair(0, SOURCE));

    while(!Q.empty()){
        int d = Q.front().first, u = Q.front().second;
        Q.pop();
        if(dist[u] != -1) continue;
        dist[u] = d; //the shortest distance to node u is d
        for(int i = 0; i < G[u].size(); i++){
            Q.push(make_pair(d+1, G[u][i]));
        }
    }

    if(dist[n] == 2){
        cout << "POSSIBLE";
    } else{
        cout << "IMPOSSIBLE";
    }


}

//g++ -std=c++14 comp.cpp -o b; ./b.exe
//g++ -std=c++14 comp.cpp && ./a.out

Measured memory_bytes: 14192
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
using namespace std;

double bmi(double w, double h) {
    return (w / (h * h) * 10000);
}

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector< pair<double, int> > diff;
        for (int a = 0; a < n; a++) {
            int i, h, w;
            cin >> i >> h >> w;
            diff.push_back(pair<double, int>(abs(bmi((double)w, (double)h)-22.0), i));
        }
        cout << min_element(diff.begin(), diff.end())->second << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#define ll long long
#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin>>s;
    for(int i=0; i<s.size()-1; i++){
        if(s[i]==s[i+1]){
            cout<<(i+1)<<" "<<(i+2);
            return 0;
        }
    }
    for(int i=0; i<s.size(); i++){
        if(s[i]==s[i+2]){
            cout<<(i+1)<<" "<<(i+3);
            return 0;
        }
    }
    cout<<"-1 -1";




    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  rep(k,b){
    rep(i,a)cout<<0;
    rep(i,w-a)cout<<1;
    cout<<endl;
  }
  rep(k,h-b){
    rep(i,a)cout<<1;
    rep(i,w-a)cout<<0;
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>

using namespace std;


void Solution()
{
    double a,b;
    
    while(cin>>a>>b)
    {
        if(a < 35.5 && b < 71)
        {
            cout<<"AAA"<<endl;
        }
        else if(a < 37.5 && b < 77)
        {
            cout<<"AA"<<endl;
        }
        else if(a < 40 && b < 83)
        {
            cout<<"A"<<endl;
        }
        else if(a < 43 && b < 89)
        {
            cout<<"B"<<endl;
        }
        else if(a < 50 && b < 105)
        {
            cout<<"C"<<endl;
        }
        else if(a < 55 && b < 116)
        {
            cout<<"D"<<endl;
        }
        else if(a < 70 && b < 148)
        {
            cout<<"E"<<endl;
        }
        else
        {
            cout<<"NA"<<endl;
        }
    }
}

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

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<double,double> pii;
const int N = 2e5+5;
const int M = 2e5+5;
const int Mod = 1e8;
#define pi acos(-1)
#define INF 1e8
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
int a[15][15],b[15],n,m,x,ans = INF;
int check()
{
	for(int i=1;i<=m;++i) 
	{
		if(b[i] < x) return 0;
	}
	return 1;
}
void dfs(int x,int sum)
{
	if(check()) ans = min(ans,sum);
	if(x > n) return ;
	for(int i=1;i<=m;++i) b[i] += a[x][i];
	dfs(x+1,sum+a[x][0]);
	for(int i=1;i<=m;++i) b[i] -= a[x][i];
	dfs(x+1,sum);
}
int main()
{
	sddd(n,m,x);
	for(int i=1;i<=n;++i)
		for(int j=0;j<=m;++j) sd(a[i][j]);
	dfs(1,0);
	if(ans == INF) printf("-1\n");
	else pr(ans);
	//system("pause");
	return 0;
}

Measured memory_bytes: 3828
from collections import defaultdict

def main():
    num = int(input())
    data = list(input())

    count_dic = defaultdict(int)

    for i in range(num):
        count_dic[data[i]] += 1

    count_list = list(count_dic.values())

    ans = 1
    for ele in count_list:
        ans *= ele + 1

    mod = 10 ** 9 + 7
    print((ans - 1) % mod)





if __name__ == '__main__':
    main()

Measured memory_bytes: 4340
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n; cin >> n;
    string s,t; cin >> s >> t;
    string res = "";
    for (int i = 0; i < 2 * n; i++) {
        if (i % 2) res += t[i / 2];
        else res += s[i / 2];
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.nextLine();
        if((s.charAt(0)==s.charAt(1)&&s.charAt(2)==s.charAt(3)&&s.charAt(0)!=s.charAt(3))||(s.charAt(0)==s.charAt(2)&&s.charAt(1)==s.charAt(3)&&s.charAt(2)!=s.charAt(3))||(s.charAt(0)==s.charAt(3)&&s.charAt(1)==s.charAt(2)&&s.charAt(2)!=s.charAt(3))){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(ll i=a;i<=b;i++)
#define maxn 200002
#define pb push_back
#define X first
#define Y second
#define mod 1000000007
#define base 17
using namespace std;

ll N;
ll a[maxn];
ll before[maxn];
main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    cout.tie(NULL);   
    cin >> N;
    For(i,1,N) cin >> a[i];
    a[0] = (1<<25) - 1;    
    For(i,1,N){
    	if(a[i-1]) before[i] = i-1;
    	else before[i] = before[i-1];
	}	
	ll ans = 0;
	For(i,1,N){
		ll ind = i;
		ll add = ind - before[ind];
		ind = before[ind] + 1;
		ll R = a[i];
		while(ind > 0){
			ll cnt = ind - before[ind];
			add += cnt-1;			
			ind = before[ind];
			if(ind <1) break;			
			if((R&a[ind]) == 0 ){
				add += 1;
				R ^= a[ind];
			}	else	{
				break;
			}			
		}
		ans += add;
//		cout << add << " ";
	}
	cout << ans;
}

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

#define mod(cans) cans%10**9+7;
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin,(a).end
#define rall(a) (a).rbegin,(a).rend
#define st(s) size_t size = s.length();
#define prians(Answer) cout<<Answer<<"\n";
#define make_pair m_p;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;

int main()
{
    int n;
    cin>>n;
    int v[n],c[n];
    cin_pl(n,v);
    cin_pl(n,c);
    int ans=0;
    rep(i,n)
    {
        if(v[i]-c[i]>0)
        {
            ans+=v[i]-c[i];
        }
    }
    prians(ans);
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

 class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintStream out = System.out;
		String[] str = in.readLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);

		if (a < 1 || b < 1 || Math.pow(10, 9) < a || Math.pow(10, 9) < b) {
			throw new RuntimeException("error: Range over");
		}
		int d = a / b;
		int r = a % b;
		double f = a / (double) b;
		out.printf("%d %d %.5f", d, r, f);
	}
}

Measured memory_bytes: 17132
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a > b)
        cout << "a > b" << endl;
    else if (a < b)
        cout << "a < b" << endl;
    else 
        cout << "a == b" << endl;

 

}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d/%d/%d",&a,&b,&c);
	if(a>2019) printf("TBD\n");
	if(a==2019){
		if(b>4) {printf("TBD\n");return 0;}
		if(b==4&&c>30) {printf("TBD\n");return 0;}
	}
	printf("Heisei\n");
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
key=[]
cost=[]
for i in range(0,M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    s=sum(2**(c[j]-1) for j in range(0,b))
    key.append(s)
    cost.append(a)

node=2**N

dp=[[10**10 for i in range(0,node)] for j in range(0,M)]

for i in range(0,M):
    dp[i][node-1]=0
#i:何番までか j:手に入れた鍵
for i in range(0,M):
    for j in range(1,node):
        k=node-1-j
        if i==0:
            if k|key[0]==node-1:
                dp[0][k]=cost[0]
        else:
            dp[i][k]=min(dp[i-1][k],dp[i-1][k|key[i]]+cost[i])

if dp[M-1][0]>=10**10:
    print(-1)
else:
    print(dp[M-1][0])

Measured memory_bytes: 79192