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

using namespace std;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) (int)a.size()
#define fi first
#define se second
#define ar array

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int > pii;
const ll MOD =1e9+7;

void solve(){
	string s,t ; cin >> s >> t;
	map<char,char>mp1,mp2;
	for(int i = 0; i < sz(s); ++i){
		if(mp1.count(s[i]) && mp1[s[i]]!= t[i]){
			cout<<"No";return;
		}
		if(mp2.count(t[i]) && mp2[t[i]]!= s[i]){
			cout<<"No";return;
		}
		mp1[s[i]]=t[i];
		mp2[t[i]]=s[i];
	}
	cout<<"Yes";
}
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		solve();
		cout <<'\n';
	}
}


Measured memory_bytes: 3804
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println(a * b % 2 == 0 ? "Even" : "Odd");
    }
}

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

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

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int A, B; cin >> A >> B;

    if (A == B) {
        cout << "Draw";
    } else if (A != 1 && B != 1) {
        cout << ((A > B) ? "Alice" : "Bob");
    } else {
        cout << ((A == 1) ? "Alice" : "Bob");
    }

}


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

using namespace std;
using i64 = long long;

int main(){
    i64 n,k,ans{};
    cin>>n>>k;
    i64 a[n];
    for(i64 i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(i64 i=0;i<k;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;;
    for (int i=0; i<n; i++){
        cin >> v.at(i);
        if(i%2 == 0 && v.at(i) % 2 == 1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>


int main(void)
{
	int x, y, i;
	while(1)
	{
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0) break;
		if (x > y) {
			i = x;
			x = y;
			y = i;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
vector<int> g[N];
int dp[N], n, m;
int calc(int u) {
	int &ret = dp[u];
	if (ret != -1)
		return ret;
	ret = 0;
	for (int i = 0; i < g[u].size(); ++i)
		ret = max(ret, calc(g[u][i]) + 1);
	return ret;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
	}
	memset(dp, -1, sizeof(dp));
	int mx = -1;
	for (int i = 0; i < n; ++i)
		mx = max(mx, calc(i));
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main(){
  char C;
  cin >> C;
  string S="abcdefghijklmnopqrstuvwxyz";
  for (int i=0;i<S.length();i++){
    if (C==S[i]){
      cout << S[i+1];
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

using namespace std;

#define li long long int
#define ld long double
const int MX1=1e5+5;
const int MX2=1e6+5;
const li inf=4e18;
const li mod=1e9+7;

li power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;
a=(a*a)%mod;b/=2;}return res;}

li mmi(li a){return power(a,mod-2);}

li cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}

void solve(){
	int a,b,k;
	set<int> st;
	cin>>a>>b>>k;
	for(int i=a;i<=min(b,a+k-1);i++){
		st.insert(i);
	}
	for(int i=b;i>=max(a,b-k+1);i--){
		st.insert(i);
	}
	for(auto it:st){
		cout<<it<<"\n";
	}
}

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pi;
const int maxn=305;
const int M=998244353;
int _,ans,dp[maxn][maxn],n,T,a[maxn],m,sum[maxn],S,s1[maxn][maxn],s2[maxn*2][maxn];
char s[maxn];
void add(int &x,int y){
    x+=y; if(x>=M) x-=M;
}
void precalc(){
    memset(s1,0,sizeof(s1));
    memset(s2,0,sizeof(s2));
    for (int j=0;j<=T;j++)
    for (int k=0;k<=S;k++)
        s1[j][k]=s2[j+k][k]=dp[j][k];
    for (int k=1;k<=S;k++)
    for (int j=0;j<=T;j++) add(s1[j][k],s1[j][k-1]);
    for (int j=0;j<=S+T;j++)
    for (int k=1;k<=S;k++) add(s2[j][k],s2[j][k-1]);
}
int main(){
    cin >> s >> T; n=strlen(s);
    m=1;
    for (int i=0;i<n;i++) {
        if (s[i]=='1') a[m]++; else m++;
    }
    //for (int i=1;i<=m;i++)cout<<a[i]<<' ';cout<<endl;
    dp[0][0]=1;
    for (int i=1;i<=m;i++) sum[i]=sum[i-1]+a[i]; S=sum[m]; T=min(S,T);
    //cout<<S<<' '<<T<<endl;
    for (int i=1;i<=m;i++){
        precalc();
        memset(dp,0,sizeof(dp));
        for (int j=0;j<=T;j++)
        for (int k=sum[i];k<=S;k++){
            dp[j][k]=s1[j][k-a[i]];
            add(dp[j][k],s2[j+k-a[i]][k]);
            add(dp[j][k],M-s2[j+k-a[i]][k-a[i]]);
        }
    }
    for (int j=0;j<=T;j++) add(ans,dp[j][S]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5216
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main(){
  string a,b;
  cin >>a;
  cin >>b;

  if(a.length() == b.length()){
    int memo=100;
    for(int i=0;i<a.length();i++){
      if(a[i] != b[i]){
        memo = i;
        break;
      }
    }
    if(memo == 100) cout << "EQUAL" << endl;
    else if(int(a[memo])>int(b[memo])) cout << "GREATER" << endl;
    else if(int(a[memo])<int(b[memo])) cout << "LESS" << endl;
  }
  else{
    if(a.length()>b.length()) cout << "GREATER" << endl;
    else cout << "LESS" << endl;

  }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

int main() {
    string s;
    cin >> s;
    if(s[0] == 'A') cout << "T";
    else if(s[0] == 'T') cout << "A";
    else if(s[0] == 'C') cout << "G";
    else if(s[0] == 'G') cout << "C";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
typedef pair<int, int> P;
int bfs();
int INF=1000000;
int h,w,n;
int sx,sy;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int d[1111][1111];
int ans=0;
char life='0';
char mapp[1111][1111];
int main(){

  cin>>h>>w>>n;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>mapp[i][j];
      if(mapp[i][j]=='S'){
	sy=i;
	sx=j;
      }      
    }
  }
  for(int i=1;i<n+1;i++){
    life++;
    ans+=bfs();
  }
  cout<<ans<<endl;
}
int bfs(){
  queue<P> que;
  que.push(P(sy,sx));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      d[i][j]=INF;
    }
  }
  d[sy][sx]=0;
  while(que.size()){
    P p=que.front();
    que.pop();
    if(mapp[p.first][p.second]==life){
      sy=p.first;
      sx=p.second;
      break;
    }
    for(int i=0;i<4;i++){
      int ny=p.first+dy[i];
      int nx=p.second+dx[i];
      if(0<=nx && nx<w && 0<=ny && ny<h && mapp[ny][nx]!='X' && d[ny][nx]==INF){
	que.push(P(ny,nx));
	d[ny][nx]=d[p.first][p.second]+1;
      }
    }
  }
  return d[sy][sx];
}

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

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

    int max = 1 << 30;
    for (int i = 1; i < N; i++)
    {
        int A = i;
        int B = N - A;
        int Ad = 0, Bd = 0;
        while (A != 0)
        {
            Ad += A % 10;
            A /= 10;
        }
        while (B != 0)
        {
            Bd += B % 10;
            B /= 10;
        }
        if (Ad + Bd < max)
        {
            max = Ad + Bd;
        }
    }
    cout << max;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int xyz=234;
int n;cin>>n;
    n%=10;
    switch(n){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:cout<<"hon";break;
        case 0:
        case 1:
        case 6:
        case 8:cout<<"pon";break;
        case 3:cout<<"bon";break;
    }

      return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int a,b,c,d; cin>>a>>b>>c>>d;
  cout << max(0,min(b,d)-max(a,c)) << endl;
}

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


Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    var weatherStr = reader.next()
    var maxLen = 0
    var count = 0

    repeat(weatherStr.length){
        if(weatherStr[it] == 'R'){
            count++
        }
        else {
            if(count > maxLen){
                maxLen = count
            }
            count = 0
        }
    }
    if(count > maxLen){
        maxLen = count
    }
        
    println(maxLen)
}

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

a.sort(reverse = True)
ans = 0
b = a.copy()
b = list(set(b))
b.sort(reverse = True)
c = [0]*len(b)
j = 0
c[j] = 1
for i in range(1,n):
    if a[i-1] == a[i]:
        c[j] +=1
    else:
        j+=1
        c[j] +=1
for i in range(len(b)):
    if c[i] >= 4:    
        
        ans = b[i]*b[i]
        break
    elif c[i] >= 2:
        for j in range(i+1,len(b)):
            if c[j] >= 2:
                ans = b[i]*b[j]
                break
        break
print(ans)

Measured memory_bytes: 20636
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"


int32_t main()
{
	IOS;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<n;i++)
	{
		int f[26]={},f1[26]={},ct=0;
		for(int j=0;j<i;j++)
		{
			f[s[j]-'a']=1;

		}
		for(int j=i;j<n;j++)
		{
			f1[s[j]-'a']=1;
		}
		for(int j=0;j<26;j++)
		{
			if(f[j]&&f1[j])
				ct++;
		}
		ans=max(ans,ct);
	}
	cout<<ans;

 	return 0;
} 


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
 
class Main {
    	public static void main(String[] args) {
        	Scanner sc = new Scanner(System.in);
        	int num = Integer.parseInt(sc.nextLine());
 
        	Dice[] dices = new Dice[num];
        	boolean flag = true;
 
        	loop: for (int i = 0; i < num; i++) {
            		dices[i] = new Dice(sc.nextLine());
            		for (int j = 0; j < i; j++) {
                		if (dices[i].equals(dices[j])) {
                    			flag = false;
                    			break loop;
                		}
            		}
        	}
        	System.out.println(flag ? "Yes" : "No");
    	}
}
 
class Dice {
    	int[] x = new int[6];
 
   	Dice(String s) {
        	String[] y = s.split(" ");
        	for (int i = 0; i < 6; i++) {
            		x[i] = Integer.parseInt(y[i]);
        	}
    	}

    	public void roll(char c) {
        	int temp;
        	switch (c) {
		        case 'E':
		            temp = x[0];
		            x[0] = x[3];
		            x[3] = x[5];
		            x[5] = x[2];
		            x[2] = temp;
		            break;
		        case 'N':
		            temp = x[0];
		            x[0] = x[1];
		            x[1] = x[5];
		            x[5] = x[4];
		            x[4] = temp;
		            break;
		        case 'W':
		            temp = x[0];
		            x[0] = x[2];
		            x[2] = x[5];
		            x[5] = x[3];
		            x[3] = temp;
		            break;
		        default:
		            temp = x[0];
		            x[0] = x[4];
		            x[4] = x[5];
		            x[5] = x[1];
		            x[1] = temp;
		            break;
        	}
    	}
 
    	public boolean equals(Dice d) {
        	char[] c = { 'E', 'E', 'E', 'N', 'W', 'W', 'W', 'S' };
        	boolean flag = false;
        	loop: for (int i = 0; i < 24; i++) {
            		if (Arrays.equals(x, d.x)) {
                		flag = true;
                		break loop;
            		}
            		d.roll(c[i % 8]);
        	}
        	return flag;
    	}
}

Measured memory_bytes: 21080
import itertools
N, M, Q = map(int, input().split())

K= [list(map(int, input().split())) for i in range(Q)]#二次配列

ans = 0
for A in itertools.combinations_with_replacement([i for i in range(1, M + 1)], N):
    ans1 = 0
    for i in range(Q):
        a, b, c, d = K[i]#各数字に配列の値を代入する
        if (A[b - 1] - A[a - 1] == c):
            ans1 += d
        ans = max(ans, ans1)
print(ans)

Measured memory_bytes: 9108
#include<stdio.h>
int main(){
  int a,b;
  int w,n;
  int x=0;
  int z=0;
  scanf("%d",&w);
  int tate[30]={0};
  for(x=1;x<=w;x++){
    tate[x-1]=x;
  }
  scanf("%d",&n);
  for(x=0;x<n;x++){
    scanf("%d,%d",&a,&b); 
    z=tate[a-1];
    tate[a-1]=tate[b-1];
    tate[b-1]=z;
  }
  for(x=0;x<w;x++){
    printf("%d\n",tate[x]);
  }
  return 0;
}

Measured memory_bytes: 596
h, w = gets.split.map(&:to_i)
ch, cw = gets.split.map(&:to_i)
dh, dw = gets.split.map(&:to_i)

c = [?., ?#]
s = Array.new(h+3) {Array.new(w+3, c[1])}
h.times {|i| s[i+1][1,w+1] = gets.chars}

move = [[1,0], [-1,0], [0,1], [0,-1]]
warp = (-2..2).to_a.product((-2..2).to_a) - move - [[0,0]]

init = 1 << 30
d = Array.new(h+3) {Array.new(w+3, init)}
d[ch][cw] = 0
t = [[ch, cw]]

(0..).each do |k|
    break if t.empty? || d[dh][dw] < init
    u = []

    while (x,y = t.pop)
        move.each do |i,j|
            xx = x + i
            yy = y + j
            if s[xx][yy] == c[0] && d[xx][yy] > k
                d[xx][yy] = k
                t << [xx, yy]
            end
        end

        warp.each do |i,j|
            xx = x + i
            yy = y + j
            if s[xx][yy] == c[0] && d[xx][yy] > k + 1
                d[xx][yy] = k + 1
                u << [xx, yy]
            end
        end
    end

    t = u
end

p d[dh][dw] == init ? -1 : d[dh][dw]


Measured memory_bytes: 110632
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

const int N = 3;
vi A;
vb done;
int ans;
void dfs(int n, int i, int res) {
    if (n >= N) {
        ans = min(ans, res);
        return;
    }

    done[i] = true;

    REP(j,N) {
        if (done[j]) continue;

        dfs(n + 1, j, res + abs(A[j] - A[i]));
    }

    done[i] = false;
}


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

    A = vi(N); REP(i, N) cin >> A[i];

    ans = INF;
    REP(i, N) {
        done = vb(N, false);
        dfs(1, i, 0);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int S,a,b,c,d;
   cin>>S;
   a=S/1000;
   b=(S-a*1000)/100;
   c=(S-a*1000-b*100)/10;
   d=S-a*1000-b*100-c*10;
	if((a==b)||(b==c)||(c==d)){cout<<"Bad"<<endl;
	}else{cout<<"Good"<< endl;}
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y,z;
	cin >> x>> y;
    string ans;
    if(x*y%2==0)ans="Even";
    else ans = "Odd";
      cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#include<fstream>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

void dfs(ll p, ll r, vector<vector<ll>>& adj, vector<vector<bool>>& cnct) {
	cnct[r][p]=true;
	REP(i,(ll)adj[p].size()) {
		dfs(adj[p][i],r,adj,cnct);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];
	vector<ll> prim;
	FOR(i,1,51) {
		bool d=true;
		for(ll j=2; j<i; j++) {
			if(i%j==0) d=false;
		}
		if(d) prim.pb(i);
	}
	REP(i,n) {
		if(a[i]<b[i]) {
			cout<<-1<<endl;
			return 0;
		}
	}
	bitset<51> ans(0);
	vector<vector<ll>> adj(51);
	vector<vector<ll>> hoge(51);
	REP(j,51) {
		for(ll k=1; k<51; k++) {
			if(k<=j) hoge[j].pb(j%k);
		}
	}
	REP(j,51) {
		sort(ALL(hoge[j]));
		hoge[j].erase(unique(ALL(hoge[j])),hoge[j].end());
	}
	vector<vector<bool>> cnctne(51,vector<bool>(51,false));
	REP(j,51) dfs(j,j,hoge,cnctne);
	bool piyo=true;
	REP(j,n) {
		if(!cnctne[a[j]][b[j]]) piyo=false;
	}
	if(!piyo) {
		cout<<-1<<endl;
		return 0;
	}

	for(ll i=50; i>=1; i--) {
		vector<vector<ll>> tmp(51);
		REP(j,51) REP(k,(ll)adj[j].size()) tmp[j].pb(adj[j][k]);
		REP(j,51) {
			for(ll k=1; k<i; k++) {
				if(k<=j) tmp[j].pb(j%k);
			}
		}
		REP(j,51) {
			sort(ALL(tmp[j]));
			tmp[j].erase(unique(ALL(tmp[j])),tmp[j].end());
		}
		vector<vector<bool>> cnct(51,vector<bool>(51,false));
		REP(j,51) dfs(j,j,tmp,cnct);
		bool f=true;
		REP(j,n) {
			if(!cnct[a[j]][b[j]]) f=false;
		}
		if(!f) {
			ans[i]=1;
			REP(j,51) {
				if(i<=j) adj[j].pb(j%i);
			}
		}
	}
	cout<<ans.to_ullong()<<endl;
}



Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	sort(all(a));
	printyn(a[n - 1] < accumulate(a.begin(), a.end() - 1, 0));


	Please AC;
}

Measured memory_bytes: 256
def solve(n):
    t = [int(input()) for _ in range(n)]
    t0 = t[0]
    for t1 in t[1:n]:
        t0 = lcm(t0, t1)
    return t0


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


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


if __name__ == '__main__':
    n = int(input())
    print(solve(n))


Measured memory_bytes: 3060
a = int(input())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
D1,D2,D3,D00 = 0., 0., 0., 0.
for i in range(a):
    D1 += abs(x[i] - y[i])
    D2 += abs(x[i] - y[i])**2
    D3 += abs(x[i] - y[i])**3
    if D00 < abs(x[i] - y[i]):
        D00 = abs(x[i] - y[i])
print(D1)
print(D2**(1/2))
print(D3**(1/3))
print(D00)



Measured memory_bytes: 5648
# -*- coding: utf-8 -*-
# 整数の入力
#a = int(input())
# スペース区切りの整数の入力
#b, c = map(int, input().split())
# 文字列の入力
#s = input()
# 出力
#print("{} {}".format(a+b+c, s))

import numpy as np

h, n = map(int, input().split())
inf=2*10**9
a = np.full(n,inf, int)
b = np.full(n,inf, int)
for i in range(0, n):
  a[i], b[i] = map(int, input().split())

dp=np.full(10001,0,int)
dp[0]=0

for i in range(1,h+1):
  dp[i]=(dp[i-a]+b).min()

print(dp[h])



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

using namespace std;

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

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

	int n = 5;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int k;
	cin >> k;


	for(int i = 0; i < n; ++i){
		for(int j = i+1; j < n; ++j){
			if(abs(a[i]-a[j]) > k){
				ppp(":(");
				return 0;
			}
		}
	}

	ppp("Yay!");




    return 0;
}


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

int main() {
    int n, a, b;

    cin>>n>>a>>b;
    int diff = abs(a - b);

    if(a < b) {
        if(diff & 1) cout<<"Borys"<<endl;
        else cout<<"Alice"<<endl;
    }
    else {
        if(diff & 1) cout<<"Alice"<<endl;
        else cout<<"Borys"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import collections
from collections import deque
n,k= map(int, input().split())
t= [list(map(int, input().split())) for i in range(n)]
q=deque()
ans=0
r=[0]*(n+1)

t.sort(key=lambda x:x[1],reverse=True)

for i in range(k):
    ans += t[i][1]
    if r[t[i][0]]==0:
        r[t[i][0]]=1
    else:
        q.append(t[i][1])
v=sum(r)
ans+=v**2
cnt=ans


for i in range(k,n):
    if r[t[i][0]]==0 and len(q)!=0:
        r[t[i][0]]=1
        x=q.pop()
        cnt+=t[i][1]+2*v+1-x
        v+=1
        ans=max(cnt,ans)
print(ans)

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

main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    if(a == c) cout<<1<<endl;
    else cout<<2<<endl;
  }
  else if (a==c){
    cout<<2<<endl;
  }
  else if (b==c){
    cout<<2<<endl;
  }
  else cout<<3<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int, string>;

int main() {
  int N, A;
  cin >> N;
  set<int> S;
  for (int i=0; i<N; i++) {
    cin >> A;
    S.insert(A);
  }
  if ((int)S.size()==N) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

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

int main() {
	int N, X;
	cin >> N >> X;
	vector<int>Num(N);
	for (int n = 0;n<N;++n) {
		cin >> Num[n];
	}
	int ans = 0;
	for (int n = 0; n < N; ++n) {
		ans = gcd(ans,abs(X-Num[n]));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

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

bool isPrime[2 * 100105];
vector<int> primes;

int N, P;
void solve() {
    vector<int> vec;
    // cout << primes.size() << endl;
    int idx = upper_bound(all(primes), N) - primes.begin();
    // cout << "idx = " << idx << endl;
    for (int i = idx; i < idx + P; i++) {
        for (int j = idx; j < idx + P; j++) {
            if (primes[i] > primes[j]) continue;
            // if (primes[i] == 3) cout << primes[i] << " + " << primes[j] << endl;
            vec.push_back(primes[i] + primes[j]);
        }
    }
    sort(all(vec));
    // rep(i, P) cout << i << ": " << vec[i] << endl;
    cout << vec[P - 1] << endl;
}
int main() {
    rep(i, 2 * 100105) isPrime[i] = true;
    isPrime[0] = isPrime[1] = false;
    rep(i, 2 * 100105) if (i > 1) {
        if (isPrime[i]) {
            for (int j = i * 2; j < 2 * 100105; j += i) isPrime[j] = false;
        }
    }
    rep(i, 2 * 100105) if (isPrime[i]) primes.push_back(i);
    while (cin >> N >> P, P != -1) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3464
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			boolean flg = false;
			for(int i = 0; i < 100; i++){
				for(int j = 0; j < 100; j++){
					int sum = i * 4 + j * 7;
					if(sum == n){
						flg = true;
						break;
					}
				}
				if(flg) break;
			}
			System.out.println(flg ? "Yes" : "No");
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 23764
#pragma GCC optimize("O3")
 
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll n,k;
vector<ll> pos,neg,revPos,revNeg;
 
ll findCnt(ll mid,vector<ll> &arr)
{
    int first,second;
    first=0;
    second=sz(arr)-1;
    ll tot=0;
    while(first<second)
    {
        while(first!=second && arr[first]*arr[second]>=mid)
            second--;
        tot+=second-first;
        first++;
    }
    return tot;
}
 
ll findBetweenCnt(ll mid)
{
    int first,second;
    first=second=0;
    ll tot=0;
    while(first!=sz(revNeg))
    {
        while(second!=sz(pos) && neg[first]*pos[second]>=mid)
            second++;
        tot+=sz(pos)-second;
        first++;
    }
    return tot;
}
 
ll findLess(ll mid)
{
    return findCnt(mid,pos)+findCnt(mid,revNeg)+findBetweenCnt(mid);
}
 
ll binSearch()
{
    ll l,h;
    l=-1e18;
    h=1e18;
    ll res=-1;
    while(l<=h)
    {
        ll mid=l+(h-l)/2;
        if(findLess(mid)<=k-1)
        {
            res=mid;
            l=mid+1;
        }
        else
            h=mid-1;
    }
    return res;
}
 
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cin >> n >> k;
    F0R(i,n)
    {
        int elem;
        cin >> elem;
        if(elem<0)
        {
            revNeg.pb(elem);
            neg.pb(elem);
        }
        else
        {
            revPos.pb(elem);
            pos.pb(elem);
        }
    }
    SORT(neg);
    SORT(pos);
    SORT(revPos);
    REV(revPos);
    SORT(revNeg);
    REV(revNeg);
    cout << binSearch();
 
    return 0;
}


Measured memory_bytes: 3720
import java.io.*;
import java.util.*;

class Main
{
	public static void main(String[] args) throws IOException
	{
		Scan in = new Scan();
		Print out = new Print();
		int n = in.scanInt();
		int m = in.scanInt();
		int[] h = new int[n];

		for(int i=0; i<n; i++) {
			h[i] = in.scanInt();
		}

		Map<Integer, Integer> map = new HashMap<>();

		for(int i=0; i<m; i++) {
			int u = in.scanInt();
			int v = in.scanInt();
			if(!map.containsKey(u)) {
				map.put(u, Integer.MIN_VALUE);
			}
			if(!map.containsKey(v)) {
				map.put(v, Integer.MIN_VALUE);
			}

			map.put(u, Math.max(map.get(u), h[v-1]));
			map.put(v, Math.max(map.get(v), h[u-1]));
		}

		int answer = 0;

		for(int i=0; i<n; i++) {
			if(!map.containsKey(i+1)) {
				answer++;
				continue;
			}
			if(h[i] > map.get(i+1)) {
				answer += 1;
			}
		}
		out.println(answer);
		out.close();
	}
}

class Scan
{
	private byte[] buf=new byte[1024];
	private int index;
	private InputStream in;
	private int total;
	public Scan()
	{
		in=System.in;
	}
	public int scan()throws IOException
	{
		if(total<0)
			throw new InputMismatchException();
		if(index>=total)
		{
			index=0;
			total=in.read(buf);
			if(total<=0)
				return -1;
		}
		return buf[index++];
	}
	public int scanInt()throws IOException
	{
		int integer=0;
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n))
		{
			if(n>='0'&&n<='9')
			{
				integer*=10;
				integer+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}
	public double scanDouble()throws IOException
	{
		double doub=0;
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		int neg=1;
		if(n=='-')
		{
			neg=-1;
			n=scan();
		}
		while(!isWhiteSpace(n)&&n!='.')
		{
			if(n>='0'&&n<='9')
			{
				doub*=10;
				doub+=n-'0';
				n=scan();
			}
			else throw new InputMismatchException();
		}
		if(n=='.')
		{
			n=scan();
			double temp=1;
			while(!isWhiteSpace(n))
			{
				if(n>='0'&&n<='9')
				{
					temp/=10;
					doub+=(n-'0')*temp;
					n=scan();
				}
				else throw new InputMismatchException();
			}
		}
		return doub*neg;
	}
	public String scanString()throws IOException
	{
		StringBuilder sb=new StringBuilder();
		int n=scan();
		while(isWhiteSpace(n))
			n=scan();
		while(!isWhiteSpace(n))
		{
			sb.append((char)n);
			n=scan();
		}
		return sb.toString();
	}
	private boolean isWhiteSpace(int n)
	{
		if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
			return true;
		return false;
	}
}

class Print
{
	private final BufferedWriter bw;
	public Print()
	{
		this.bw=new BufferedWriter(new OutputStreamWriter(System.out));
	}
	public void print(Object object)throws IOException
	{
		bw.append(""+object);
	}
	public void println(Object object)throws IOException
	{
		print(object);
		bw.append("\n");
	}
	public void println()throws IOException
	{
		bw.append("\n");
	}
	public void close()throws IOException
	{
		bw.close();
	}
}

Measured memory_bytes: 63708
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=2e5+5;
ll mod=1e9+7;

ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}
pair<int,int>arr[N];
int main()
{
    FIO
    priority_queue<int,vector<int>,greater<int>> q;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        q.push(x);
    }
    for(int i=0;i<m;i++)
        cin>>arr[i].second>>arr[i].first;
    sort(arr,arr+m);
   for(int i=m-1;i>=0;i--)
   {
       if(q.top()>=arr[i].first)
        break;
       while(q.top()<arr[i].first&&arr[i].second>0)
       {
           q.pop();
           q.push(arr[i].first);
           arr[i].second--;
       }
   }
   ll ans=0;
   while(q.size())
    ans+=q.top(),q.pop();
   cout<<ans;






    return 0;
}

Measured memory_bytes: 4548
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Comparator;

public class Main {
    static void dijkstra(ArrayList<Node> nodes, int start){
        Comparator<Node> comparator = new NodeCostComparator();
        PriorityQueue<Node> pq      = new PriorityQueue<Node>(10, comparator);
        nodes.get(start).cost = 0;
        pq.add(nodes.get(start));
        
        while (!pq.isEmpty()){
        	Node done_node = pq.poll();
        	for (int i = 0; i < done_node.edge_to.size(); i++){
        		int to 	 	 = done_node.edge_to.get(i);
        		int cost 	 = done_node.edge_cost.get(i);
        		int new_cost = done_node.cost + cost;
        		int to_cost  = nodes.get(to).cost;
        		if (to_cost < 0 || new_cost < to_cost){
        			nodes.get(to).cost = new_cost;
        			if (!pq.contains(nodes.get(to))){
        				pq.add(nodes.get(to));
        			}
        		}
        	}
        }
    }
    static void print_results(ArrayList<Node> nodes){    
        for (int i = 0; i < nodes.size(); i++){
            int cst = nodes.get(i).cost;
            if (cst == -1){
                System.out.println("INF");
            }else{
                System.out.println(cst);
            }
        }
    }
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int V = Integer.parseInt(line[0]);
        int E = Integer.parseInt(line[1]);
        int r = Integer.parseInt(line[2]);
        ArrayList<Node> nodes = new ArrayList<Node>();
        for (int i = 0; i < V; i++){
            ArrayList<Integer> edge_to   = new ArrayList<Integer>();
            ArrayList<Integer> edge_cost = new ArrayList<Integer>();
            Node node = new Node(-1, edge_to, edge_cost);
            nodes.add(node);
        }
        
        for (int i = 0; i < E; i++){
            String[] line2 = br.readLine().split(" ");
            int s = Integer.parseInt(line2[0]);
            int t = Integer.parseInt(line2[1]);
            int d = Integer.parseInt(line2[2]);
            nodes.get(s).edge_to.add(t);
            nodes.get(s).edge_cost.add(d);
        }
        dijkstra(nodes, r);
        print_results(nodes);
    }
}
class NodeCostComparator implements Comparator<Node>{
    @Override
    public int compare(Node x, Node y){
        int value = x.cost - y.cost;
        if (value < 0){
            return -1;
        }
        if (value > 0){
            return 1;
        }
        return 0;
    }
}

class Node{
    int cost = -1;
    ArrayList<Integer> edge_to   = new ArrayList<Integer>();
    ArrayList<Integer> edge_cost = new ArrayList<Integer>();
    
    Node(int cost, ArrayList<Integer> edge_to, ArrayList<Integer> edge_cost){
        this.cost       = cost;
        this.edge_to    = edge_to;
        this.edge_cost  = edge_cost;
    }
}

Measured memory_bytes: 139104
/************************************************
* Author        :RunningTime
* Created Time  :2017/4/29 20:30:38
* File Name     :D.cpp
 ************************************************/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 1e2 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
vector<int> a[4];
ll pre[4][N];
int n, W;

bool cmp(int x, int y) {
    return x > y;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> W;
    int w1, w, v;
    cin >> w1 >> v;
    a[0].push_back(v);
    for (int i=2; i<=n; ++i) {
        cin >> w >> v;
        a[w-w1].push_back(v);
    }
    for (int i=0; i<4; ++i) {
        sort(a[i].begin(), a[i].end(), cmp);
        for (int j=0; j<a[i].size(); ++j) {
            pre[i][j] = a[i][j];
            if (j) pre[i][j] += pre[i][j-1];
        }
    }
    ll ans = 0;
    for (int i=0; i<=a[1].size(); ++i) if ((ll)i*(w1+1) <= W)
        for (int j=0; j<=a[2].size(); ++j) if ((ll)i*(w1+1) + (ll)j*(w1+2) <= W) 
            for (int k=0; k<=a[3].size(); ++k) if ((ll)i*(w1+1) + (ll)j*(w1+2) + (ll)k*(w1+3) <= W) {
                int sw = i*(w1+1) + j*(w1+2) + k*(w1+3);
                int c = min((int)a[0].size(), (W - sw) / w1);
                ll sv = 0;
                if (c) sv += pre[0][c-1];
                if (i) sv += pre[1][i-1];
                if (j) sv += pre[2][j-1];
                if (k) sv += pre[3][k-1];
                ans = max(ans, sv);
            }
    cout << ans << '\n';
    return 0;
}


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

int main(){
    int cnt = 0;
    long long n;
    long long s = 1,t;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; ++i){
        if (a.at(i) == 0){
            s = 0;
            cnt = 2;
            break;
        }
        t = s;
        s = s * a.at(i);
        if (s > 1000000000000000000 || t > s) cnt = 1;
    }
    if (cnt == 2) s = 0;
    if (cnt == 1) s = -1;
    cout << s << endl;
}

Measured memory_bytes: 4020
from collections import Counter
N = int(input())

l = []
for i in range(N):
    l.append(input())

c = Counter(l)
maxcnt = c.most_common()[0][1]

l1 = []
for e,n in c.most_common():
    if n == maxcnt:
        l1.append(e)
l1.sort()
for w in l1:
    print(w)

Measured memory_bytes: 45036
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;

int main(){
	int n,t,x,y,flag=1;
	cin >> n;
	for(int i = 0; i<n;i++){
		scanf("%d %d %d",&t,&x,&y);
		if(t%(x+y)!=0 && (t-x-y)%2!=0 || t<(x+y)) flag=0;
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
}

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

#define Art Code
#define Artist Shivam Gupta
#define MoT This Art belongs to Artist
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FoR(i,s,x) for(i=s-1;i>=x;i--)
#define ForE(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define mod 1000000007
#define MAX 200005

vl(vll) out;
vll in, outs, ans;


void doit(ll n) {
    for(auto r:out[n]) {
        ans[r]=max(ans[r],ans[n]+1);
        in[r]--;
        if(!in[r]) doit(r);
    }
}


int main() {
    FASTIO;
    ll t=1, i, j, k, l;
    // cin>>t;
    W(t--) {
        ll n, m;
        cin>>n>>m;
        out.resize(n+1);
        ans.resize(n+1);
        in.resize(n+1);
        For(i,0,m) cin>>j>>k, out[j].pb(k), in[k]++;
        Fore(i,1,n) if(!in[i]) outs.pb(i);
        for(auto r:outs) doit(r);
        pr(*max_element(all(ans)));
        nl;
    }
    return 0;
}

Measured memory_bytes: 14692
# B 
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
s=si()
n=len(s)
for i in range(n):
    for j in range(n-i+1):
        t=s
        t=t[:j]+t[j+i+1:]
        if t=='keyence':
            print('YES')
            exit()
print('NO')




Measured memory_bytes: 3060
#include<utility>
#include<iostream>
#include<deque>
#include<cmath>
#include<algorithm>
#include<string>
int main(void)
{
	std::deque<int> A;
    int q,d,x,cmd;
    std::cin >> q;
    for(int i = 0; i < q; i++)
    {
        std::cin >> cmd;
        switch(cmd)
        {
            case 0:
              std::cin >> d;
              if(d == 0)
              {
                std::cin >> x;
                A.push_front(x);
              }else
              {
                std::cin >> x;
                A.push_back(x);
              }
                break;

            case 1:
                std::cin >> x;
                std::cout << A[x] <<std::endl;
                break;
            case 2:
                std::cin>>d;
                if(d == 0)
                {
                  A.pop_front();
                }else
                {
                  A.pop_back();
                }
                break;
        }
    }

    return 0;
}



Measured memory_bytes: 4600
#include <stdio.h>

int main(){
  int ans=-1;
  int A,B;
  scanf("%d %d",&A,&B);
  for(int i=1;i<=20000;i++){
    if((i*8)/100==A && (i*10)/100==B){
      ans=i;
      break;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;


int main(){
  int a,b;
  cin >> a >> b;
  int ans = a+b;
  ans = max(ans,a-b);
  ans = max(ans,a*b);
  cout << ans << endl;
  return 0;
}

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

int main() {
    int a,b;
    cin >> a >>b;
    int c;
    cin >> c;
    int k=0;
    int ans;
    for(int i=a;i>=1;i--){
        if(a%i==0&&b%i==0){
            k++;
            ans = i;
        }
        if(k==c) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
df = "<^>v".find

def solve():
    H, W = map(int, readline().split())
    if H == 0:
        return False
    MP = [readline().strip() for i in range(H)]
    x = y = 0
    used = [[0]*W for i in range(H)]
    used[0][0] = 1
    while 1:
        i = df(MP[y][x])
        if i == -1:
            write("%d %d\n" % (x, y))
            return True
        dx, dy = dd[i]
        x += dx; y += dy
        if used[y][x]:
            write("LOOP\n")
            return True
        used[y][x] = 1
while solve():
    ...


Measured memory_bytes: 5676
/**
*    author:  souzai32
*    created: 15.08.2020 17:20:33
**/

#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
typedef long long ll;
using namespace std;

int main() {

    int n;
    cin >> n;
    string s;
    cin >> s;
    int left=0, right=0;
    rep(i,n){
        if(s.at(i)=='(') left++;
        if(s.at(i)==')'){
            if(left) left--;
            else right++;
        }
    }
    string front,back;
    rep(i,right) front.push_back('(');
    rep(i,left) back.push_back(')');
    s=front+s+back;
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;


int main(){
    int n, t;
    cin >> n >> t;
    int ans = mod;
    rep(i, n) {
        int c, x;
        cin >> c >> x;
        if (x>t) continue;
        ans = min(ans, c);
    }
    if (ans==mod) {
        cout << "TLE" << endl;
        return 0;
    }
    
    
    
    cout << ans << endl;
    return 0;
}


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

template<class INT>
std::vector<INT> factorize(INT n){
    std::vector<INT> res;
    for (INT i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (i * i != n)
                res.push_back(n / i);
        }
    }
    return res;
}

int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> A(n);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    auto F = factorize(accumulate(A.begin(), A.end(), 0));
    sort(F.begin(), F.end(), greater<int>());

    for (const auto &f: F){
        vector<int> B(n);
        for (int i = 0; i < n; i++)
            B[i] = A[i] % f;
        if (accumulate(B.begin(), B.end(), 0, [&](const auto &l, const auto &r){return l + min(r, f - r);}) / 2 > k)
            continue;
        const auto S = accumulate(B.begin(), B.end(), 0);
        const auto i = S / f;
        nth_element(B.begin(), B.begin() + (n - i), B.end());
        if (max(accumulate(B.begin(), B.begin() + (n - i), 0), S - accumulate(B.begin() + (n - i), B.end(), 0)) <= k){
            printf("%d\n", f);
            return 0;
        }
    }

    puts("0");
}

Measured memory_bytes: 256