akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
int main()
{
    std::string s;
    int k;

    std::cin >> s >> k;
    std::vector<std::string> Ans(k, "ああああ");
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 1; i + j <= s.size(); ++j) {
            bool flag_1 = false;
            for (int l = 0; l < k; ++l) {
                if (Ans.at(l).compare(s.substr(i, j)) == 0) {
                    break;
                } else if (Ans.at(l).compare(s.substr(i, j)) > 0) {
                    Ans.insert(Ans.begin() + l, s.substr(i, j));
                    break;
                } else {
                    if (l == k - 1) {
                        flag_1 = true;
                        //std::cout << "null" << std::endl;
                    }
                    //std::cout << Ans[k - 1] << std::endl;
                }
            }
            if (flag_1) {
                break;
            }
        }
    }
    std::cout << Ans[k - 1] << std::endl;
}

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

int ans[500][500][64];
ul out[500][500];
void solve() {
	int n; cin >> n;
	vector<int> s(n),u(n);
	vector<ul> t(n),v(n);
	rep(i, n)cin >> s[i];
	rep(i, n)cin >> u[i];
	rep(i, n)cin >> t[i];
	rep(i, n)cin >> v[i];
	rep(i, 64) {
		vector<int> h(n), w(n);
		vector<bool> abh(n), abw(n);
		rep(j, n) {
			bool b = false;
			if (t[j] & ((ul)1 << i))b = true;
			h[j] = b;
			if (s[j] == 0) {
				if (b) {
					abh[j] = true;
				}
			}
			else {
				if (!b) {
					abh[j] = true;
				}
			}

			b = false;
			if (v[j] & ((ul)1 << i))b = true;
			w[j] = b;
			if (u[j] == 0) {
				if (b){
					abw[j] = true;
				}
			}
			else {
				if (!b) {
					abw[j] = true;
				}
			}
		}
		rep(j, n)rep(k, n) {
			if (h[j] == w[k])ans[j][k][i] = h[j];
			else {
				if (abh[j] && abw[k]) {
					cout << -1 << "\n"; return;
				}
				else if (abh[j]) {
					ans[j][k][i] = h[j];
				}
				else if (abw[k]) {
					ans[j][k][i] = w[k];
				}
				else {
					ans[j][k][i] = 2;
				}
			}
		}
		rep(_, 3) {
			rep(j, n)if (!abh[j]) {
				bool exi = false;
				rep(k, n) {
					if (ans[j][k][i] == h[j])exi = true;
				}
				if (exi) {
					rep(k, n) {
						if (ans[j][k][i] == 2) {
							ans[j][k][i] = w[k];
						}
					}
				}
			}
			rep(j, n)if (!abw[j]) {
				bool exi = false;
				rep(k, n) {
					if (ans[k][j][i] == w[j])exi = true;
				}
				if (exi) {
					rep(k, n) {
						if (ans[k][j][i] == 2) {
							ans[k][j][i] = h[k];
						}
					}
				}
			}
		}
		vector<bool> exi2h(n), exi2w(n);
		rep(j, n)rep(k, n)if (ans[j][k][i] == 2) {
			exi2h[j] = exi2w[k] = true;
		}
		vector<int> indh, indw;
		rep(j, n) {
			if (exi2h[j])indh.push_back(j);
			if (exi2w[j])indw.push_back(j);
		}
		if (indh.size() && indw.size()) {
			if (indh.size() == 1 || indw.size() == 1) {
				cout << -1 << "\n"; return;
			}
			int ch = h[indh[0]];
			int cw = w[indw[0]];
			int tmp = 0;
			rep(j, indh.size()) {
				rep(k, indw.size()) {
					
					if (tmp == k) {
						ans[indh[j]][indw[k]][i] = ch;
					}
					else {
						ans[indh[j]][indw[k]][i] = cw;
					}
				}
				tmp++;
				if (tmp == indw.size())tmp = 0;
			}
		}
		rep(j, n)if (!abh[j]) {
			bool exi = false;
			rep(k, n) {
				if (ans[j][k][i] == h[j])exi = true;
			}
			if (!exi) {
				cout << -1 << "\n"; return;
			}

		}
		rep(j, n)if (!abw[j]) {
			bool exi = false;
			rep(k, n) {
				if (ans[k][j][i] == w[j])exi = true;
			}
			if (!exi) {
				cout << -1 << "\n"; return;
			}
		}
	}
	rep(i, 64) {
		ul u = (ul)1 << i;
		rep(j, n)rep(k, n) {
			if (ans[j][k][i]) {
				out[j][k] |= u;
			}
		}
	}
	rep(i, n){
		rep(j, n) {
			if (j > 0)cout << " ";
			cout << out[i][j];
		}
		cout << "\n";
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 70108
n, a, b = map(int, input().split())
 
MOD = 10 ** 9 + 7
 
def comb(n, r):
    ret = 1
    for i in range(r):
        ret *= n - i
        ret *= pow(i+1, MOD-2, MOD)
        ret %= MOD
 
    return ret % MOD
    
 
ans = pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)
ans %= MOD
print(ans)

Measured memory_bytes: 40288
package main

import (
	"fmt"
	"math"
)

var A, B, C int

func main() {
	fmt.Scan(&A, &B, &C)

	if A == B {
		fmt.Println(C)
	} else if A == C {
		fmt.Println(B)
	} else {
		fmt.Println(A)
	}
}

/*  ----------------------------------------  */

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}
type SortBy []XY

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].x == a[j].x {
		return a[i].y > a[j].y
	}
	return a[i].x > a[j].x
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n=0;
    string s;
    cin>>s;
    rep(i,s.length()){
        if(s[i]=='x') n++;
    }
    YES(n<=7);
    return  0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
int read(char *s){
    R int len=0;R char ch;while(((ch=getc())>'9'||ch<'0'));
    for(s[++len]=ch;(ch=getc())>='0'&&ch<='9';s[++len]=ch);
    return s[len+1]='\0',len;
}
double readdb()
{
    R double x=0,y=0.1,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(x=ch-'0';(ch=getc())>='0'&&ch<='9';x=x*10+ch-'0');
    for(ch=='.'&&(ch=getc());ch>='0'&&ch<='9';x+=(ch-'0')*y,y*=0.1,ch=getc());
    return x*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
    if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=105;
typedef long long ll;
char s[N];int t[N],n,k;ll res,sum;
int main(){
	scanf("%s%d",s+1,&k),n=strlen(s+1);
	fp(i,1,n)t[i]=s[i];
	fp(i,2,n)if(t[i]==t[i-1])++res,t[i]=2333;
	if(t[n]==t[1]){
		fp(i,1,n)t[i]=s[i];t[1]=2333,++sum;
		fp(i,2,n)if(t[i]==t[i-1])++sum,t[i]=2333;
		if(t[n]==2333)return printf("%lld\n",res*((k+1)>>1)+sum*(k>>1)),0;
		return printf("%lld\n",res+sum*(k-1)),0;
	}
	res*=k;
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll m,n,i;
    cin >> n >> m;
    ll a[n],sum=0, cnt=0;
    for(i=0;i<n;i++) {
    	cin >> a[i];
    	sum+=a[i];
    }
    for(i=0;i<n;i++) {
    	if((double)a[i] >= ((double)sum/(4*m))) cnt++;
    }
    if(cnt>=m) cout << "Yes";
    else cout << "No";
    cout << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int N;
	bool zero=false,ansF=true;
	long long int A,ans=1;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A;
		if(A==0){zero=true;break;}
		if(ans>1000000000000000000/A)ansF=false;
		if(ansF)ans*=A;
		
	}
	if(zero)cout<<0;
	else if(ansF)cout<<ans;
	else cout<<-1;
	return 0;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int x = 0;
    for(int i=1 ; i<4 ; i++){
      if(s.charAt(i)==s.charAt(i-1)){
        x = 1;
      }
    }
    if(x==1){
      System.out.println("Bad");
    }else{
      System.out.println("Good");
    }
  }
}


Measured memory_bytes: 21844
class UnionFind:
    def __init__(self, n=1):
        self.parent = [i for i in range(n)]
        self.rank = [0] * n
    
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.parent[y] = x
    
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

N, M = map(int, input().split())
p = list(map(int, input().split()))
uf = UnionFind(N)
for i in range(M):
  x, y = map(int, input().split())
  uf.union(x-1, y-1)

for i in range(N):
  uf.find(i)

ans = 0
for _p in p:
  ans += uf.is_same(_p-1, p[_p-1]-1)

print(ans)

Measured memory_bytes: 13812
#include <iostream>
#include <vector>
#include <queue>
#define N_MAX 100000
typedef long long ll;
using namespace std;

int main() {
    int N;
    ll sum_max[N_MAX+1], sum_min[N_MAX+1], a[N_MAX*3];
    priority_queue<ll, vector<ll>, greater<ll> > q_max;
    priority_queue<ll> q_min;
    cin >> N;
    for(int i=0; i<N*3; i++) {
        cin >> a[i];
    }
    for(int i=0; i<N; i++) q_max.push(a[i]);
    for(int i=N*2; i<N*3; i++) q_min.push(a[i]);
    sum_max[0] = 0;
    for(int i=0; i<N; i++) sum_max[0] += a[i];
    // cout << "sum_max : " << sum_max[0] << ',';
    for(int i=1; i<=N; i++) {
        ll min_a = q_max.top();
        if(a[N-1+i] > min_a) {
            q_max.pop();
            q_max.push(a[N-1+i]);
            sum_max[i] = sum_max[i-1] - min_a + a[N-1+i];
        } else {
            sum_max[i] = sum_max[i-1];
        }
        // cout << sum_max[i] << ',';
    }
    // cout << endl;
    sum_min[0] = 0;
    for(int i=N*2; i<N*3; i++) sum_min[0] += a[i];
    // cout << "sum_min : " << sum_min[0] << ',';
    for(int i=1; i<=N; i++) {
        ll max_a = q_min.top();
        if(a[N*2-i] < max_a) {
            q_min.pop();
            q_min.push(a[N*2-i]);
            sum_min[i] = sum_min[i-1] - max_a + a[N*2-i];
        } else {
            sum_min[i] = sum_min[i-1];
        }
        // cout << sum_min[i] << ',';
    }
    // cout << endl;
    ll ans = sum_max[0] - sum_min[N];
    for(int i=1; i<=N; i++) {
        if(ans < sum_max[i] - sum_min[N-i]) ans = sum_max[i] - sum_min[N-i];
    }
    cout << ans << endl;
    return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n), b(n+1), c(n+1);
	rep(i, n) cin >>a[i];
	
	rep(i, n) b[i+1] = gcd(b[i], a[i]);
	repr(i, n-1,0) c[i] = gcd(c[i+1], a[i]);
	
	ll ans = 0;
	rep(i, n) ans = max(ans, gcd(b[i], c[i+1]));
	cout << ans <<"\n";
	
	
	
	
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
using namespace std;
int main()
{ 
    int n;
    cin>>n;
    string s;
    cin>>s;
    char check;
    int cnt=n;
    for(int i=0;i<n;i++){
        if(check==s[i]){
            cnt--;
        }
        else{
            check=s[i];
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 512
// Priority_Queue.cs

using System;
using System.Collections.Generic;
using System.Text;

class Priority_Queue {
	public static void Main() {

		StringBuilder str_b = new StringBuilder();
		string[] str = new string[2];
		var<int> list = new List<int>();
		while(true) {

			str = Console.ReadLine().Split(' ');

			if(str[0][0] == 'i') {
				int no = list.Count;
				list.Add(int.Parse(str[1]));

				while(true) {
					if(no == 0) {
						break;
					}

					int id = (no - 1) / 2; 
					if(list[no] > list[id]) {
						int temp = list[no];
						list[no] = list[id];
						list[id] = temp;
					}

					no = id;

				}

				} else if(str[0] == "end") {
					break;
					} else if(str[0] == "extract") {
						str_b.AppendLine(list[0].ToString());
						int no = list.Count - 1;
						list[0] = list[no];
						list.RemoveAt(no);
						int c = 0;
						for(int i = 0; (i = 2 * c + 1) < no;) {
							if((i != no - 1) && (list[i] < list[i + 1])) {
								i++;
							}

							if(list[c] < list[i]) {
								int temp = list[i];
								list[i] = list[c];
								list[c] = temp;
							}
							c = i;
						}
					}

				}
				Console.Write(str_b);
			}
		}

Measured memory_bytes: 31228
a = input()
if a == "SUN":
  print(7)
elif a == "MON":
  print(6)
elif a == "TUE":
  print(5)
elif a == "WED":
  print(4)
elif a == "THU":
  print(3)
elif a == "FRI":
  print(2)
elif a == "SAT":
  print(1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    stack<int> box1;
    box1.push(0);
    vector<int> box2(N);
    int res = 0;
    for(int i = 0; i < N; i++){
        cin >> box2[i];
    }
    
    for(int i = 0; i < N; i++){
        if(box1.top() + 1 == box2[i]){
            box1.push(box2[i]);
        }else{
            res+=1;
        }
    }
    
    if(res == N){
        cout << -1;
    } else if(res == 0){
        cout << 0;
    } else{
        cout << res;
    }
}

Measured memory_bytes: 1792
N, K = map(int, input().split())
B = [[0]*(2*K+1) for  _ in range(2*K+1)]
B2 = [[0]*(2*K+1) for  _ in range(2*K+1)]
for _ in range(N):
    a, b, c = input().strip().split()
    a, b, c = int(a), int(b), 1 if c == 'B' else 0
    x, y = (a+K*c)%(2*K), b%(2*K)
    if x > K-1 and y > K-1:
        x, y = x-K, y-K
    if x < K and y > K-1:
        x, y = x+K, y-K
    B[x+1][y+1] += 1
    B2[(x+K)%(2*K)+1][y+1] += 1
R = [[0]*(2*K+1) for  _ in range(2*K+1)]
R2 = [[0]*(2*K+1) for  _ in range(2*K+1)]
for i in range(1, 2*K+1):
    for j in range(1, 2*K+1):
        R[i][j] = R[i-1][j] + R[i][j-1] - R[i-1][j-1] + B[i][j]
        R2[i][j] = R2[i-1][j] + R2[i][j-1] - R2[i-1][j-1] + B2[i][j]
r = 0
for i in range(K):
    for j in range(K):
        t1 = R[2*K][j] + R[i+K][K] - R[i][K] - 2*R[i+K][j] + 2*R[i][j]
        r = max(r, t1)
        t1 = R2[2*K][j] + R2[i+K][K] - R2[i][K] - 2*R2[i+K][j] + 2*R2[i][j]
        r = max(r, t1)
print(r)


Measured memory_bytes: 166024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
//const ll mod=1e9+7;
const ll mod=998244353;
const ll inf=5e18;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

//階乗,factで初期化
vector<ll> tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

//nCk 繰り返し高速
ll comb(ll n, ll k) {
  return tfact.at(n)*mpow(tfact.at(k),mod-2)%mod*mpow(tfact.at(n-k),mod-2)%mod;
}

int main() {
  ll n,k,a,b;
  cin >> n >> a >> b >> k;
  fact(n);
  ll ans=0;
  for(ll i=0;i<=n;i++) {
    ll j=(k-i*a);
    if(j%b==0&&j>=0&&j/b<=n) {
      j/=b;
      ans=(ans+comb(n,i)*comb(n,j)%mod)%mod;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 78336
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;

namespace AtCoder
{
    class AtCoderrrrrr
    {
        static void Main(string[] args)
        {
            string A = ReadLine();
            string B = ReadLine();
            string ans = "EQUAL";
            if (A.Length>B.Length)
            {
                ans = "GREATER";
            }
            else if (A.Length<B.Length)
            {
                ans = "LESS";
            }
            else
            {
                //線形探索
                for (int i = 0; i < A.Length; i++)
                {
                    int a = int.Parse(A[i].ToString());
                    int b = int.Parse(B[i].ToString());
                    if (a>b)
                    {
                        ans = "GREATER";
                        break;
                    }
                    else if (a<b)
                    {
                        ans = "LESS";
                        break;
                    }                    
                }
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
import sys
from operator import itemgetter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, *PY = map(int, read().split())
    city = [(p, y, i) for i, (p, y) in enumerate(zip(*[iter(PY)] * 2))]

    city.sort(key=itemgetter(1))

    counter = [0] * (N + 1)
    ans = [0] * M
    for p, y, i in city:
        counter[p] += 1
        ans[i] = f"{p:>06}{counter[p]:>06}"

    print(*ans, sep='\n')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 37328
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<chrono>
#include<algorithm>
#include<functional>
#include<cstdlib>
#include<numeric>
#include<queue>
#include<stack>
using namespace std;
typedef unsigned long long ull;
int main()
{
	std::string s;
	cin >> s;
	bool flag = false;
	for (char c : s)
	{
		if (c == '7') {
			flag = true;
			break;
		}
	}
	if (flag)
	{
		std::cout << "Yes";
	}
	else
		std::cout << "No" << std::endl;
}

Measured memory_bytes: 3628
import numpy as np
n, k = map(int, input().split())
a_list = list(map(int, input().split()))

#並べえても結果は変わらない
s = k
for i in range(1, n+1):
    if s >= n:
        print(i)
        break
    else:
        s += (k - 1)


Measured memory_bytes: 24976
#include <iostream>

using namespace std;

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

	if(n == 1)
	{
		cout << 1 << endl;
	}
	else if(n >= 2 && n < 4)
	{
		cout << 2 << endl;
	}
	else if(n >= 4 && n < 8)
	{
		cout << 4 << endl;
	}
	else if(n >= 8 && n < 16)
	{
		cout << 8 << endl;
	}
	else if(n >= 16 && n < 32)
	{
		cout << 16 << endl;
	}
	else if(n >= 32 && n < 64)
	{
		cout << 32 << endl;
	}
	else if(n >= 64 && n <= 100)
	{
		cout << 64 << endl;
	}
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a), end(a)

int main(void) {
    cout << std::fixed;
    cout << std::setprecision(8);

    int N;
    cin >> N;
    vector<pair<int, int>> pos(N);
    REP(i, N) cin >> pos[i].fi >> pos[i].se;
    vector<int> p(N);
    REP(i, N) p[i] = i;
    ll t = 1;
    REP(i, N) t *= i + 1;
    double ans = 0;
    do {
        double dist = 0;
        for (int i = 1; i < N; i++) {
            pair<int, int> from = pos[p[i - 1]];
            pair<int, int> to = pos[p[i]];
            dist += sqrt((from.fi - to.fi) * (from.fi - to.fi) +
                         (from.se - to.se) * (from.se - to.se));
        }
        ans += dist / t;
    } while (next_permutation(ALL(p)));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int cnt[10][10]; // 先頭がiで末尾がjの数値の数

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

    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        cnt[s[0] - '0'][s.back() - '0']++;
    }

    long long ans = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            ans += (long long)cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> books[10];
int main(){
      int n,k,i,j,tm1,tm2;
      cin >> n >> k;
      for(i=0;i<n;i++){
            cin >> tm1>>tm2;
            books[tm2].push_back(tm1);
      }
      for(i=0;i<=10;i++)sort(books[i].begin(),books[i].end());

      long long dp[15][2005];

      for(i=0;i<=10;i++)for(j=0;j<=k;j++)dp[i][j]=-1;
      dp[0][0] = 0;
      for(i=0;i<10;i++){
            for(j=0;j<=k;j++){
                  if(dp[i][j]==-1)continue;
                        int ct = 0;
                        for(int x=1;x<=books[i+1].size();x++){
                              if(j+x>k)break;
                              ct += books[i+1][books[i+1].size()-x];
                              dp[i+1][j+x] = max(dp[i+1][j+x],dp[i][j]+ct+(x-1) * x);
                        }
                        dp[i+1][j]=max(dp[i+1][j],dp[i][j]);

            }

      }
      /*for(i=0;i<10;i++){
            for(j=0;j<=k;j++)  cout << dp[i][j]<<' ';
            cout << endl;
      }
*/
      cout << dp[10][k]<<endl;

}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    string s;
    cin >> s;

    for (size_t i = 0; i < s.size(); i++) {
        if (i % 2 == 0) {
            if (s.at(i) == 'L') {
                cout << "No";
                return 0;
            }
        } else {
            if (s.at(i) == 'R') {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 3652
import numpy as np
n = int(input())
p = []
ex = [1]
for i in range(8):
    ex.append(ex[i]*(i+1))

for i in range(n):
    p.append(list(map(int,input().split())))
l = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        l[i][j] = np.sqrt((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)
su = 0
ne = 1
for i in range(n):
    su = su + sum(l[i]) -l[i][i]
    ne = ne*(i+1)
print(ex[n-1]*2*(su/2)/ne)


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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            string[] line = Console.ReadLine().Trim().Split(' ');
            var gacha = Array.ConvertAll(line, int.Parse);
            if (gacha.Count(x => x >= 2) == 0) Console.WriteLine("NA");
            else Console.WriteLine(gacha.Count(x => x != 0) + 1);
        }
    }
}

Measured memory_bytes: 11492
import sys
import os
import math
import string
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    abc = il()
    abc = sorted(abc)
    print('Yes' if abc[2] == (abc[0]+abc[1]) else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3896
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

int main(){
    int N, T;
    cin >> N >> T;
    int t[200000];
    for(int i=0;i<N;i++)
        cin >> t[i];
    int X = T;
    for(int i=1;i<N;i++){
        if(t[i] < (t[i-1] + T))//重なっている場合
            X += T - (t[i-1] + T - t[i]);
        else
             X += T;
    }
    cout << X << endl;
    return 0;
}

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

int main() {
  int N,n ,t;
  cin >> N;
  n= N;
  t=0;
  for (int i=0; i<9; i++){
    if(n >=10){
    t += n % 10;
  	n = n/10;
    }
    else{
      t += n;
      break;
    }
  }
  if (N % t == 0 )
    cout << "Yes" <<endl;
  else
    cout << "No" <<endl;
}

Measured memory_bytes: 256
s = list(input())
n = len(s)
a = ['1']+['0']*(n-1)
b = ['0']+['1']*(n-1)

for i in range(1,n):
    if a[i-1] == '1':
        a[i] = '0'
    elif a[i-1] == '0':
        a[i] = '1'

    if b[i-1] == '1':
        b[i] = '0'
    elif b[i-1] == '0':
        b[i] = '1'

difA = 0
difB = 0

for j in range(n):
    if a[j] != s[j]:
        difA += 1

    if b[j] != s[j]:
        difB += 1

ans = min(difA,difB)

print(ans)

Measured memory_bytes: 6292
S = list(input())
N = len(S)

i = 0
ans = 0
T = list(reversed(S))
bc_cnt = 0
bc = False
for i in range(N):
    t = T[i]
    if bc:
        if t == "A":
            ans += bc_cnt
        elif t == "C" and i < N - 1 and T[i + 1] == "B":
            bc_cnt += 1
        elif t == "B" and T[i-1] == "C":
            continue
        else:
            bc_cnt = 0
            bc = False

    elif t == "C" and i < N - 1 and T[i + 1] == "B":
        bc = True
        bc_cnt += 1
print(ans)


Measured memory_bytes: 6820
#include<bits/stdc++.h>
using namespace std;
int main () {
  int a[3];
  scanf ("%d%d%d",&a[0],&a[1],&a[2]);
  sort(a,a+3);
  printf (a[0] == 5 && a[1] == 5 && a[2] == 7 ? "YES\n" : "NO\n");
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <functional>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define clr(a,b) memset((a),b,sizeof(a))
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

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

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N = (int)2e5+77;

ll n,m,k,x,y;
vi a[N];
ll sub[N],d[N];
ll par[N];
vi path;
ll s,f;

void dfs(ll u, ll p){
    d[u] = d[p] + 1;
    sub[u] = 1;
    par[u] = p;
    for(auto v : a[u]){
        if(v==p) continue;
        dfs(v,u);
        sub[u]+=sub[v];
    }
}

int main() {
    fast;
    cin>>n;
    forn(i,n-1){
        cin>>x>>y;
        a[x].pb(y);
        a[y].pb(x);
    }
    
    dfs(1,0);
    
    x = n;
    s = sub[n];
    y = n;
    while(par[x]!=1){
        //        cout<<x<<endl;
        x = par[x];
        path.pb(x);
    }
    for(int i=0;i<sz(path)/2;i++){
        //        cout<<path[i]<<" "<<s<<endl;
        s += sub[path[i]];
        s -= sub[y];
        y = path[i];
    }
    
    //    cout<<s<<endl;
    f = n-s;
    if(s >= f) cout<<"Snuke\n";
    else  cout<<"Fennec\n";
    
    return 0;
}

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

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

    int i,j,tmp,minj;
    int A[n];
    int counter = 0;

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

    for(i=0; i<n-1; i++){
        minj = i;
        for(j=i; j<n; j++){
            if(A[j]<A[minj]) minj = j;
        }
        if(i!=minj){
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            counter++;
        }
    }

    for(i=0; i<n-1; i++){
        cout << A[i] << ' ';
    }
    cout << A[n-1] << endl;
    cout << counter << endl;

    return 0;
}


Measured memory_bytes: 3096
//#include <algorithm>
//#include <iostream>
//#include <cstring>
//#include <cstdlib>
//#include <cstdio>
//#include <cmath>
//#include <queue>
//#include <set>
//#include <map>
//#define N 1005

#include <bits/stdc++.h>

using namespace std;

int num[100005];

bool comp(int a, int b)
{
    return a > b;
}
int main()
{
    int n;
    scanf("%d", &n);

    for(int i = 0; i < n ; i++)
    {
        scanf("%d", &num[i]);
    }

    sort(num, num + n, comp);

    int a = 0, b = 0, a1 = 0, b1 = 0;

    for(int i = 1; i < n;)
    {
        if(num[i] == num[i - 1] && a1 == 0)
        {
            a1 = 1;
            a = num[i];
            i += 2;
        }
        else if(a1 == 1 && num[i] == num[i - 1] && b1 == 0)
        {
            b = num[i];
            b1 = 1;
            i += 2;
        }
        else if(a1 == 1 && b1 == 1)
        {
            break;
        }
        else
            i++;
    }
    cout <<(long long ) a * b << endl;
    return 0;
}


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

int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  string S;
  cin >> S;

  vector<int> a(N, 0);
  for (int i = 1; i < N; i++) {
    if (S.at(i - 1) == 'A' && S.at(i) == 'C') a.at(i)++;
  }

  vector<int> sum(N + 1, 0);
  for (int i = 0; i < N; i++) {
    sum.at(i + 1) = sum.at(i) + a.at(i);
  }

  for (int i = 0; i < Q; i++) {
    int left = 0, right = 0;
    scanf("%d%d", &left, &right);
    printf("%d\n", sum.at(right) - sum.at(left));
  }
  return 0;
}

Measured memory_bytes: 1792
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    let x: i32 = read();
    let mut count = 0;
    for i in 0..a+1 {
        for j in 0..b+1 {
            let y = x - (500 * i + 100 * j);
            if 0 <= y && y <= 50 * c && y % 50 == 0 {
                count += 1;
            }
        }
    }
    println!("{}", count);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
ll pw[22];
std::vector<pair<ll,ll> > vtr[22];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll L;
	cin>>L;
	std::vector<ll> v;
	pw[0]=1;
	for(ll i=1;i<=20;i++)
		pw[i]=2*pw[i-1];
	ll z=L;
	while(z)
	{
		v.pb(z%2);
		z/=2;
	}
	ll tot = sz(v);
	ll m=0;
	for(ll i=tot;i>1;i--)
	{
		vtr[i-1].pb({i,pw[tot-i]});
		vtr[i-1].pb({i,0});
		m+=2;
	}
	ll csum = 0;
	for(ll i=sz(v)-1;i>=0;i--)
	{
		if(v[i]==1 && csum)
		{
			vtr[1].pb({tot-i,csum});
			m++;
		}
		if(v[i])
			csum+=pw[i];
	}
	cout<<tot<<" "<<m<<"\n";
	for(ll i=1;i<=tot;i++)
		for(auto u:vtr[i])
			cout<<i<<" "<<u.ff<<" "<<u.ss<<"\n";
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int N;
    string S;
    cin >> N >> S;

    int cnt[26];

    int j = 0;
    bool is_left = false;
    bool is_right = false;
    int ans = 0;
    int tmp_ans = 0;
    for(int i = 1; i < N; i++){
        
        tmp_ans = 0;
        for(char c = 'a'; c <= 'z'; c++){
            is_left = false;
            is_right = false;
            for(int j = 0; j < i; j++){
                if(S[j] == c){
                    is_left = true;
                }
            }
            for(int j = i; j < N; j++){
                if(S[j] == c){
                    is_right = true;
                }
            }

            if(is_left && is_right){
                tmp_ans++;
            }

            
        }
        chmax(ans, tmp_ans);

    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <climits>
#include <cmath>
#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
using namespace std;
int main(int, char**)
{
	int N, M;
	cin >> N >> M;
	vector<int> k(M), p(M);
	vector<vector<int>> s(M);
	for (int i = 0; i < M; ++i)
	{
		cin >> k[i];
		s[i] = vector<int>(k[i]);
		for (int j = 0; j < k[i]; ++j)
		{
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < M; ++i)
	{
		cin >> p[i];
	}

	int count = 0;
	for (int i = 0; i < (1 << N); ++i)
	{
		vector<int> tmp(M);
		for (int j = 0; j < N; ++j)
		{
			if ((i >> j) & 1)
			{
				for (int k = 0; k < M; ++k)
				{
					if (find(s[k].begin(), s[k].end(), j + 1) != s[k].end())
					{
						++tmp[k];
					}
				}
			}
		}

		int l;
		for (l = 0; l < M; ++l)
		{
			if ((tmp[l] & 1) != p[l])	break;
		}
		if (l == M)
		{
			++count;
		}
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];

    vector<int> v_odd(100001);
    vector<int> v_even(100001);
    rep(i,100001)
    {
        v_odd[i] = v_even[i] = 0;
    }

    rep(i,n)
    {
        if(i%2==0)
            v_even[v[i]]++;
        else
            v_odd[v[i]]++;
    }

    unordered_map<int,int> max_even;
    unordered_map<int,int> second_even;
    rep(i,100001)
    {        
        if(max_even.empty() || v_even[i] > max_even.begin()->second)
        {
            second_even.clear();
            for(auto m:max_even)
                second_even.insert(m);
            max_even.clear();
            max_even.insert({i,v_even[i]});
        }
        else if(v_even[i] == max_even.begin()->second)
        {
            max_even.insert({i,v_even[i]});
        }
        else if(second_even.empty() || v_even[i] > second_even.begin()->second)
        {
            second_even.clear();
            second_even.insert({i,v_even[i]});
        }
    }

    unordered_map<int,int> max_odd;
    unordered_map<int,int> second_odd;
    rep(i,100001)
    {        
        if(max_odd.empty() || v_odd[i] > max_odd.begin()->second)
        {
            second_odd.clear();
            for(auto m:max_odd)
                second_odd.insert(m);
            max_odd.clear();
            max_odd.insert({i,v_odd[i]});
        }
        else if(v_odd[i] == max_odd.begin()->second)
        {
            max_odd.insert({i,v_odd[i]});
        }
        else if(second_odd.empty() || v_odd[i] > second_odd.begin()->second)
        {
            second_odd.clear();
            second_odd.insert({i,v_odd[i]});
        }
    }

    if(max_odd.size()>1 || max_even.size()>1)
    {
        int ret = (n/2 - max_odd.begin()->second) + (n/2 - max_even.begin()->second);
        cout << ret << endl;
    }
    else if(max_odd.begin()->first != max_even.begin()->first)
    {
        int ret = (n/2 - max_odd.begin()->second) + (n/2 - max_even.begin()->second);
        cout << ret << endl;
    }
    else
    {
        int ret_odd = (n/2 - max_odd.begin()->second) + (n/2 - second_even.begin()->second);
        int ret_even = (n/2 - second_odd.begin()->second) + (n/2 - max_even.begin()->second);
        cout << min(ret_odd,ret_even) << endl;
    }
    

    return 0;
}

Measured memory_bytes: 12964
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cassert>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int dir[] = {1, 0, -1, 0, 1};

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

    auto in = [=](const int h, const int w) {
        return h >= 0 and h < H and w >= 0 and w < W;
    };

    vector<vector<char>> field(H, vector<char>(W));
    pii s;
    pii g;
    vector<pii> sol;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> field[i][j];
            if (field[i][j] == '@') {
                s = make_pair(i, j);
                field[i][j] = '.';
            } else if (field[i][j] == '%') {
                g = make_pair(i, j);
                field[i][j] = '.';
            } else if (field[i][j] == '$') {
                sol.push_back(make_pair(i, j));
                field[i][j] = '.';
            }
        }
    }
    constexpr int INF = 1 << 30;
    vector<vector<int>> dist(H, vector<int>(W, INF));
    queue<pair<pii, int>> q;
    dist[g.first][g.second] = 0;
    q.push(make_pair(g, 0));
    while (not q.empty()) {
        const auto p = q.front();
        q.pop();
        for (int d = 0; d < 4; d++) {
            const int newy = p.first.first + dir[d];
            const int newx = p.first.second + dir[d + 1];
            if (in(newy, newx) and field[newy][newx] == '.' and dist[newy][newx] == INF) {
                dist[newy][newx] = p.second + 1;
                q.push(make_pair(make_pair(newy, newx), p.second + 1));
            }
        }
    }
    for (const auto& pos : sol) {
        if (dist[s.first][s.second] >= dist[pos.first][pos.second]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;


    return 0;
}

Measured memory_bytes: 3528
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long  long
#define INF 0x3f3f3f3f
#define pll pair<long long , long long>
const int MAX=5e5+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int vis[MAX];
int cnt =0;
void dfs(int u){
    vis[u]=1;
    cnt = cnt + 1;
    for(auto v:adj[u])
    {
        if(vis[v])
            continue;
        dfs(v);
    }
}
int main() 
{
    int n , m;
    cin>>n>>m;
    set<pair<int , int > > st;
    while(m--){
        int x, y;
        cin>>x>>y;
        if(st.find({min(x, y) , max(x, y)})!=st.end())
            continue;
        adj[x].push_back(y);
        adj[y].push_back(x);
        st.insert({min(x, y) , max(x,y)});
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            dfs(i);
            ans = max(ans , cnt);
            cnt = 0;
        }
    }
    cout<<ans;


}


Measured memory_bytes: 37932
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int frag=0;
		for(int i=A;i<=B;i++) {
			if(i%K==0) {
				frag=1;
			}
		}
		if(frag==0)
			System.out.println("NG");
		else
			System.out.println("OK");
	}
}


Measured memory_bytes: 35760
def main():
    a , b = map(int,input().split())
    n = int(str(a)+str(b))
    start =  0
    end = n 
    while start <= end :
        mid = (start+end)//2 
        if mid**2 == n :
            print('Yes')
            return True
        if mid**2 > n:
            end = mid - 1 
        else:
            start = mid + 1 
    print('No')
main()

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

signed main() {
	string s; cin >> s;
	if (s <= "2019/04/30")cout << "Heisei" << endl;
	else cout << "TBD" << endl;
}

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

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		int strN = 2; // 文字列を何行受け取るか
		for (int i = 0; i < strN; i++) {
			line += br.readLine() + " ";
		}
		String[] param = line.split(" ");
		AtoZString(param);

	}

	static void AtoZString(String[] param) { //1行、文字列中のAからZまでの文字列で最大のものの文字数を出力[0]
		int max = 0;
		int count = 0;

		for(int i = 0; i < param[1].length(); i++){
			if(param[1].charAt(i) == 'I'){
				count++;
				if(max < count) max = count;
			} else if(param[1].charAt(i) == 'D'){
				count--;
			}
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 21332
n,k=map(int,input().split())
ab=[[0,0] for i in range(n)]
for i in range(n):
  ab[i][0],ab[i][1]=map(int,input().split())
ab.sort()
y=0
for i in range(n):
  y+=ab[i][1]
  if y>=k:
    break
  
print(ab[i][0])

Measured memory_bytes: 20036
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int curr = 0;
		long sum = 0;
		
		int nums[] = new int[N + 2];
		nums[0] = 0;
		
		for (int i = 0; i < N; i++) {
			int next = in.nextInt();
			nums[i + 1] = next;
			sum += (long) Math.abs(next - curr);
			curr = next;
		}
		nums[N + 1] = 0;
		sum += (long) Math.abs(0 - curr);
		
		for (int i = 0; i < N; i++) {
			int skipIndex = i + 1;
			long dist = sum
					- Math.abs(nums[skipIndex - 1] - nums[skipIndex])
					- Math.abs(nums[skipIndex] - nums[skipIndex + 1])
					+ Math.abs(nums[skipIndex - 1] - nums[skipIndex + 1]);
			
			System.out.println(dist);
		}
	}
}

Measured memory_bytes: 62068
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN

bool isPrime(int n){
  if(n<2) return 0;
  for(int i=2 ; i*i<=n ; i++){
    if(n%i==0) return 0;
  }
  return 1;
}

void solve(){
  int n; cin>>n;
  map<int,int> m;
  int r=0;
  for(int i=0,u ; i<n ; i++) cin>>u,m[u]++,r=max(r,u);
  int cnt[r+1];
  for(int i=0 ; i<=r ; i++) cnt[i]=1;
  for(auto x:m){
    for(int j=x.f,i=2 ; j*i<=r ; i++){
      cnt[j*i]=0;
    }
  }
  //for(int i=0 ; i<=r ; i++) cout<<cnt[i]<<' ';LOL
  int ans=0;
  for(auto x:m){
    if(x.s>1) continue;
    ans+=cnt[x.f];
  }
  cout<<ans;LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  solve();
  return 0;
}


Measured memory_bytes: 23832
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

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

    int n,k; cin>>n>>k;
    vector<int> a(n+1,0);
    rep(i,n){
        int tmp; cin>>tmp;
        a.at(i+1)=a.at(i)+tmp;
    }

    vector<int> vec(n*(n+1)/2);
    int pl=0;
    rep(i,n){
        for(int j=i+1; j<=n; j++){
            vec.at(pl)=a.at(j)-a.at(i);
            pl++;
        }
    }

    int ans=0;
    for(int i=39; i>=0; i--){
        vector<int> tmp;
        rep(j,vec.size()){
            if(((int)1<<i)&vec.at(j)){
                tmp.push_back(vec.at(j));
            }
        }
        if(tmp.size()>=k){
            ans+=(int)1<<i;
            vec=tmp;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 5368
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
using namespace std;

int top, S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];
    cin >> s;
    while(!cin.eof()){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            push(atoi(s));
        }
    cin >> s;
    }
    cout << pop() << endl;
    return 0;
}



Measured memory_bytes: 3104