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


int main() {
    int n,x,t;
    cin>>n>>x>>t;
    long long a=0;
    a = (n*t)/x;
    while(true){
        if(a%t==0){
            break;
        }else{
            a+=1;
        }
    }
    cout<<a<<endl;
   
    
    
    
    return 0;
}



Measured memory_bytes: 3624
n,k=map(int,input().split())
amari=n%k
if n==0:
    print(0)
    exit()

elif n%k==0:
    print(0)
    exit()


else:
    print(min(amari,k-amari))

'''    
while n > abs(n-k):
    n=abs(n-k)
print(n)
'''

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


typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;

bool I_func( int L1, int R1, int L2, int R2);
bool N_func( int L1, int R1, int L2, int R2);


int L1, L2, R1, R2;

bool I_func( int L1, int R1, int L2, int R2 ){
    bool res = false;
    if( L1 < 5 ){
        if( L2 < 5 ) res |= N_func( L1, R1, L2+L1, R2 );
        if( R2 < 5 ) res |= N_func( L1, R1, L2, R2+L1 );
    }
    if( R1 < 5 ){
        if( L2 < 5 ) res |= N_func( L1, R1, L2+R1, R2 );
        if( R2 < 5 ) res |= N_func( L1, R1, L2, R2+R1 );
    }
    return res;
}

bool N_func( int L1, int R1, int L2, int R2 ){
    bool res = true;
    if( L2 < 5 ){
        if( L1 < 5 ) res &= I_func( L1+L2, R1, L2, R2 );
        if( R1 < 5 ) res &= I_func( L1, R1+L2, L2, R2 );
    }
    if( R2 < 5 ){
        if( L1 < 5 ) res &= I_func( L1+R2, R1, L2, R2 );
        if( R1 < 5 ) res &= I_func( L1, R1+R2, L2, R2 );
    }
    return res;
}

int main(){
    
    cin>>L1>>R1;
    cin>>L2>>R2;
    
    if( I_func( L1, R1, L2, R2 ) ){
        puts("ISONO");
    }
    else{
        puts("NAKAJIMA");
    }
    
    
    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const long long mod = 998244353;
long long dp[N] = {};
long long sum[N] = {};
int L[20] = {}, R[20] = {};
int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
        cin >> L[i] >> R[i];
    dp[1] = sum[1] = 1;
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= m; j++)
            dp[i] = (dp[i] + sum[max(0, i - L[j])] - sum[max(0, i - R[j] - 1)]) % mod;
        sum[i] = (sum[i - 1] + dp[i]) % mod;
    }
    dp[n] %= mod;
    if (dp[n] < 0) dp[n] += mod;
    cout << dp[n] << '\n';
    return 0;
}

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

const int N = 1e5 + 10;

int cnt[N], rec[N];

int main(){
	int n, m, x, y, ans;
	scanf("%d %d",&n,&m);
	memset(rec, 0, sizeof(rec));
	rec[1] = 1;
	for (int i = 1; i <= n; i++) cnt[i] = 1;
	for (int i = 1; i <= m; i++){
		scanf("%d %d",&x,&y);
		if (rec[x]) rec[y] = 1;
		cnt[x]--; cnt[y]++;
		if (!cnt[x]) rec[x] = 0;
	}
	ans = 0;
	for (int i = 1; i <= n; i++){
		if (rec[i]) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        if (n >= 10) {
            System.out.print(r);
        } else {
            System.out.print(r+ 100*(10-n));
        }
    }
}


Measured memory_bytes: 35848
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

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

	if((4 * x - y) >= 0 && (4 * x - y) % 2 == 0 && (y - 2 * x) >= 0 && (y - 2 * x) % 2 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<vector<int>> a(N, vector<int>(3));
	rep(i, N) {
		rep(j, 3) cin >> a[i][j];
	}

	vector<vector<int>> dp(N+1, vector<int>(3, 0));
	for(int i = 1; i < N+1; i++) {
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				if(j == k) continue;
				dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i-1][j]);
			}
		}
	}

	int ans = 0;
	rep(j, 3) ans = max(ans, dp[N][j]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13972
#include<stdio.h>
int main(void)
{
    int n,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
       if(i*i>n) {printf("%d\n",(i-1)*(i-1)); 
                  break;
       }
       else if(i*i==n){printf("%d\n",i*i);
                      break;
       }
       return 0;
}

Measured memory_bytes: 128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int a, b, c, d, e, k; cin >> a >> b >> c >> d >> e >> k;

	int dist = abs(a - e);
	if (dist > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double S = scan.nextDouble();
		double a = 100;
		int c = 1;
		while(true) {
			a=Math.floor(a*1.01);
			if(S<=a) {
				break;
			}
			c++;
		}
		System.out.println(c);
	}
}


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

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

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

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ansA = 0, ansB = 0, ansC = 0;
    int ans;

    ansA = a * x + b * y;
    ansB = 2 * c * max(x, y);
    ans = min(ansA, ansB);
    if (x >= y) {
        ansC = 2 * c * min(x, y) + a * (x - y);
    } else {
        ansC = 2 * c * min(x, y) + b * (y - x);
    }
    ans = min(ans, ansC);

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) { pa[x] = y; }
}
#define Yes "Yay!"
#define No ":("
int gcd(int x, int y) {
	if (x < y) { return gcd(y, x); }
	if (y == 0) { return x; }
	return gcd(y, x%y);
}
int solve(int x, int y) {
	int ans = rui(2, x) + rui(2, y)+p-1;
	ans %= p;
	int g1 = gcd(x, y);
	ans += rui(2, g1) + p - 2;
	ans %= p;
	return ans;
}
signed main() {
	int h, w, t; cin >> h >> w >> t;
	int gh = gcd(h, t);
	int gw = gcd(w, t);
	int ans1 = solve(h/gh, w/gw);
	ans1 = rui(ans1, gh);
	ans1 = rui(ans1, gw);
	cout << ans1 << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
#define INF (1<<30)
using namespace std;


/*
	i:???????????°(0..N)	j:??????
	dp[i][j] = ???????????¢???????????????	??????????????§????????????????°???????
	dp[0][0] = 0	?????????(0???????????????????????????????????????????????????
*/
int main() {
	cin.tie(0); ios::sync_with_stdio(false);

	ll N, W; cin >> N >> W;
	ll V = 0;
	vector<ll> v(N), w(N);
	for (int i = 0; i < N;i++) {
		cin >> v[i] >> w[i];
		V = max(V, v[i]);
	}
	vector<vector<ll>> dp(N + 1, vector<ll>(N*V + 1));
	fill(dp[0].begin(), dp[0].end(), INF);
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= N*V;j++) {
			if (j - v[i] < 0) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
		}
	}
	for (int i = V*N; i >= 0;i--) {
		if (dp[N][i] <= W) {
			cout << i << endl; return 0;
		}
	}
}

Measured memory_bytes: 10752
#include<bits/stdc++.h>
typedef long long  ll ;
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define bug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}


int main() {
    fast()
    ll x;
    cin>>x;
   int n=200000;
vector<int> is_prime(n+1, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i * i <= n; i++) {
    if (is_prime[i]) {
        for (int j = i * i; j <= n; j += i)
            is_prime[j] = false;
    }
}
for(int i=x;true;i++){
    if(is_prime[i]){
        cout<<i<<endl;
        break;
    }
}

}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long

using namespace std;


int main() {
  ll x, y; cin >> x >> y;
  ll temp = y / x;
  int ans = 0;
  while ((ll)pow(2, ans) <= temp) {
    ans++;
  }
  cout << ans << endl;
  
  
}


Measured memory_bytes: 384
a,b,c=gets.chomp.split(" ").map(&:to_i)
k=gets.to_i
while a >= b && k > 0 do
    b *= 2
    k -= 1
end
while b >= c && k > 0 do
    c *= 2
    k -= 1
end

if a<b && b<c
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 14336
# coding: utf-8
# Your code here!

class Node:
    def __init__(self, id):
        self.id = id
        self.parent = -1
        self.sibling = -1
        self.children = []
        self.depth = 0
        self.height = 0
        self.ntype = None
    
    def __str__(self):
        return 'node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.\
            format(self.id, self.parent, self.sibling, len(self.children), self.depth, self.height, self.ntype)
        
N = int(input())

nodes = [Node(i) for i in range(N)]

# 親子関係解決
for i in range(N):
    id, l, r = [int(i) for i in input().split()]
    deg = 0
    if l >= 0 and r >= 0:
        nodes[id].children += [l, r]
        nodes[l].parent = id
        nodes[l].sibling = r
        nodes[r].parent = id
        nodes[r].sibling = l
        nodes[id].ntype = 'internal node'
    elif l >= 0:
        nodes[l].parent = id
        nodes[id].children.append(l)
        nodes[id].ntype = 'internal node'
    elif r >= 0:
        nodes[r].parent = id
        nodes[id].children.append(r)
        nodes[id].ntype = 'internal node'
    else:  
        nodes[id].ntype = 'leaf'

# rootノード検索
root = -1
for i in range(N):
    if nodes[i].parent == -1:
        root = i
        nodes[i].ntype = 'root'
        break

def nfs(node, dep):
    node.depth = dep
    
    if not node.children:
        node.height = 0
        return 0
    
    for child in node.children:
        h = nfs(nodes[child], dep+1)
        node.height = max(node.height, h+1)
    
    return node.height

nfs(nodes[root], 0)

for node in nodes:
    print(node)




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

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

// Graph
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

string f(ll N)
{
  if (N == 0)
    return "";
  N--;
  return f(N / 26) + string(1, 'a' + N % 26);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  cout << f(N) << endl;
  return 0;
}


Measured memory_bytes: 3644
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc143/tasks/abc143_d
//lower_boundとupper_boundの説明
//https://qiita.com/ganariya/items/33f1326154b85db465c3
//条件式の変形が鍵
//変数を固定して考える＝for文を考える
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
using namespace std;
 
int N;
int L[2000];

int ans = 0;
 
void solve(){
	sort(L,L+N);//昇順にソート
	// for(int i=0;i<N;i++){
	// 	cout<<L[i]<<' ';
	// }
	//cout<<endl;
	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N;j++){
			int mini = L[j]-L[i];
			int maxi = L[j]+L[i];
			int lower_index = upper_bound(L,L+N,mini)-L;//もしminiを配列Lに挿入したかったらどこに挿入したらいいかを返す
			lower_index = max(lower_index,j);
			int upper_index = lower_bound(L,L+N,maxi)-L;//もしmaxiを配列Lに挿入したかったらどこに挿入したらいいかを返す
			ans+=(upper_index - lower_index -1);
			// cout << L[i] <<' '<< L[j] <<endl;
			// cout << "lower_index=" <<  lower_index << endl;
			// cout << "upper_index=" <<  upper_index << endl;
		}
	}
}
 
int main(){
	cin>>N;
	for(int i=0;i<N;i++) cin>>L[i];

	solve();

	cout<<ans;
	return 0;
}

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

ma = a[0]
for i in range(1, n):
    ma^=a[i]
ans = []
for i in range(n):
    ans.append(ma^a[i])
#print(ans)
ans1 = [str(a) for a in ans]
print(" ".join(ans1))

Measured memory_bytes: 112760
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    if(a * b % 2 == 0)
        cout << "No";
    else
        cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int n, k;
int a[100005], b[100005];
int solve(int shift, int size, int pos){
	if(size == 0) return 1;
	int mid = (2*shift + a[size] - 1)/2;
	if(pos == shift) return 0;
	else if(pos < mid) return solve(shift + 1, size - 1, pos);
	else if(pos == mid) return b[size - 1] + 1;
	else if(pos < shift + a[size] - 1)return b[size - 1] + 1 + solve(mid + 1, size - 1, pos);
	else return b[size];
}
signed main(){
	a[0] = 1, b[0] = 1;
	for(int i = 1 ; i <= 50 ; i ++)
		a[i] = 2*a[i - 1] + 3, b[i] = 2*b[i - 1] + 1;
	
	cin >> n >> k;
	//cout << a[n] << " " << b[n] << endl;
	cout << solve(1, n, k);
}


Measured memory_bytes: 256
inpl = lambda: list(map(int,input().split()))
N = int(input())
A = inpl()
ans = 1
bound = 10**18
A.sort(reverse=True)
if A[-1] == 0:
    print(0)
else:
    for a in A:
        ans *= a
        if ans > bound:
            print(-1)
            break
    else:
        print(ans)


Measured memory_bytes: 84796
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int N,T;
    cin >> N >> T;
    vector<int> t(N);
    rep(i,N){
        cin >> t[i];
    }
    int ans=T;
    rep(i,N-1){
        ans+=min(T,t[i+1]-t[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main() {
	int banyak[15], a;
	memset(banyak, 0, sizeof banyak);
	for (int i = 0; i < 3; i++) {
		scanf("%d", &a);
		banyak[a]++;
	}
	if ((banyak[5] == 2) && (banyak[7] == 1))
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>

using namespace std;

bool prime(int x){
 if(x==2)return true;
 if(x==3)return true;
 if(x==5)return true;
 if(x % 2 == 0)return false;
 for(int i = 3;i < x;i+=2)
  if(x % i == 0)return false;
 return true;
}

int main(){
 int n;
 while(cin >> n, n){
  for(int i = n-2;i >= 0;i--){
  if(prime(i) && prime(i + 2)){
   cout << i << " " << i+2<< endl;
  break;
  }
 }
 }
 return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int W, H;
bool wall[31][31][31][31];//yx-yx
int dist[31][31];
typedef pair<int, int> pint;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int bfs(){
    rep(i, 31) rep(j, 31) dist[i][j] = INF;
    dist[0][0] = 1;
    queue<pint> que;
    que.push(pint(0, 0));
    while(!que.empty()){
        pint now = que.front(); que.pop();
        int cx = now.first, cy = now.second;
        if(cy == H - 1 && cx == W - 1) return dist[cy][cx];
        rep(i, 4){
            int nx = cx + dx[i], ny = cy + dy[i];
            if(nx < 0 || ny < 0 || W <= nx || H <= ny) continue;
            if(wall[cy][cx][ny][nx] || dist[ny][nx] != INF) continue;
            dist[ny][nx] = dist[cy][cx] + 1;
            que.push(pint(nx, ny));
        }
    }
    return 0;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> W >> H && W){
        memset(wall, 0, sizeof(wall));
        int t;
        rep(i, W - 1){
            cin >> t;
            if(t) wall[0][i + 1][0][i] = wall[0][i][0][i + 1] = true;
        }
        REP(i, 1, H){
            rep(j, W){
                cin >> t;
                if(t) wall[i][j][i - 1][j] = wall[i - 1][j][i][j] = true;
            }
            rep(j, W - 1){
                cin >> t;
                if(t) wall[i][j + 1][i][j] = wall[i][j][i][j + 1] = true;
            }
        }
        cout << bfs() << endl;
    }
    return 0;
}

Measured memory_bytes: 2128
import bisect
import sys
import math
input = sys.stdin.readline
N, M, V, P = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

K = A[-P]
R = bisect.bisect_left(A, K)
RL = bisect.bisect_right(A, K)
L = bisect.bisect_left(A, K - M)
ans = N - R
table = [0]*N
for i in range(L, R):
    table[i] = K - A[i]
table2 = [0]*N
for i in range(L, R):
    table2[i] = table2[i-1] + table[i]

X = table2[R-1]

for i in range(L, R):
    # print("i:", i, P+i, V > P+i)
    if V > P+i:
        v = V - (P+i)
        D = N-P - i
        # print(A[i], v*M, -(v*M - (X - table2[i])))
        if (-((-(v*M - (X - table2[i]))) // D)) + K <= A[i]+M:
            ans += 1

    else:
        ans += 1

print(ans)


Measured memory_bytes: 15788
#include <iostream>
using namespace std;
int main(void)
{ 
  char a,b;
   cin >> a >> b;
  int ai = (int)a - 'A';
  int bi = (int)b - 'A';
  if(ai > bi)
    cout << ">" << endl;
  else if(ai < bi)
   cout << "<" << endl;
 else
  cout << "=" << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


void tes(ll A) {
	for (int i = 63; i >= 0; i--) {
		printf("%d", A >> i & 1);
	}
	printf("\n");
}


char S[2000020];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	fread(S, 1, 2000020, stdin);

	char* c = S, ct;
	int N = 0;
	
	while ((ct = *c++) >= '0') N = N * 10 + ct - '0';

	int L = 0, R = 2000001;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (*(c + M) >= ' ') L = M;
		else R = M;
	}

	if (*c == '0') {
		printf("0\n");
		return 0;
	}

	int zero = 0;
	int n = R / 8 + 1;
	for (char* d = c; d < c + R - 8; d += 7) {
		ll tmp = *(ll*)(d);
		tmp += 0x1010101010101010;
		tmp ^= 0xcfcfcfcfcfcfcfcf;

		ll tmp2 = tmp + 0x0001000100010001 & 0x3000300030003000;
		if ((tmp2 << 1 ^ tmp2) & 0x2020202020202020) {
			printf("0\n");
			return 0;
		}
		tmp2 = tmp + 0x0000010001000100 & 0x0030003000300000;
		if ((tmp2 << 1 ^ tmp2) & 0x2020202020202020) {
			printf("0\n");
			return 0;
		}
	}

	for (char* d = c + min(0, R - 10); d < c + R; d++) {
		if (*d == ' ' && *(d + 1) == '0') {
			printf("0\n");
			return 0;
		}
	}

	if (R >= N * 2 + 18) {
		printf("-1\n");
		return 0;
	}

	ll kotae = 1;
	auto owa = c + R;
	while (c < owa) {
		ll tmp = *(ll*)(c);
		if (tmp != 0x2031203120312031) {
			ll k = 0;
			while ((ct = *c++) >= '0') k = k * 10 + ct - '0';
			if (ll(1e18) / kotae < k) {
				printf("-1\n");
				return 0;
			}
			else kotae *= k;
		}
		else c += 8;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3336
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <cmath>
#include <string>

using namespace std;

int main(void) {
    int h,w;
    char map[52][52] = {0};
    cin >> h >> w;
    string buf;
    for(int i = 0;i < h;i++) {
        cin >> buf;
        for(int ii = 0;ii < w;ii++) {
            if(buf[ii] == '#')
                map[i+1][ii+1] = 1;
        }
    }
    for(int i = 1;i <= h;i++) {
        for(int ii = 1;ii <= w;ii++) {
            if(map[i][ii] && !(map[i+1][ii] | map[i-1][ii] | map[i][ii-1] | map[i][ii+1])) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 1001

void Length(char *X, char *Y){
  int c[N][N];
  int i, j, m, n;
  m = strlen(X);
  n = strlen(Y);
  for(i = 1; i <= m; i++) c[i][0] = 0;
  for(j = 0; j <= n; j++) c[0][j] = 0;
  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(X[i-1] == Y[j-1]) c[i][j] = c[i-1][j-1] + 1;
      else if(c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
      else c[i][j] = c[i][j-1];
    }
  }
  printf("%d\n",c[m][n]);
}

int main(){
  int i, n;
  char X[N], Y[N];
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%s%s", X, Y);
    Length(X, Y);
  }
  return 0;
}

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

int main() {
	int N,M,X;
	int answer = 100000000;
	cin >> N >> M >> X;
	int data[N][M+1];
	for(int i=0;i<N;i++){
		for(int j=0;j<M+1;j++){
			cin >> data[i][j];
		}
	}
	for(int bit=0;bit<(1<<N);bit++){
		vector<int>S;
		for(int i=0;i<N;i++){
			if(bit & (1<<i)){
				S.push_back(i);
			}
		}
		int flag = 0;
		for(int j=1;j<M+1;j++){
			int sum=0;
			for(int i=0;i< S.size();i++){
				sum += data[S.at(i)][j];
			}
			if(sum < X){
				flag = 1;
				break;
			}
		}
		if(flag == 0){
			int mix=0;
			for(int i=0;i<S.size();i++){
				mix += data[S.at(i)][0];
			}
			answer = min(mix,answer);
		}
	}
	if(answer == 100000000){
		cout << "-1" << endl;
	}
	else{
		cout << answer << endl;
	}
}


Measured memory_bytes: 3624
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	if(a + k - 1 < b - k + 1)
	{
		for(int i = a; i <= a + k - 1; i++)
			printf("%d\n", i);
		for(int i = b - k + 1; i <= b; i++)
			printf("%d\n", i);
	}
	else
	{
		for(int i = a; i <= b; i++)
			printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
using namespace std;

long long dp[101][4][4][4];
int mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    //0: A, 1: T, 2: G, 3: C
    for(int a = 0; a < 4; a++) {
        for(int b = 0; b < 4; b++) {
            for(int c = 0; c < 4; c++) {
                dp[3][a][b][c] = 1;
            }
        }
    }

    dp[3][0][2][3] = 0;
    dp[3][2][0][3] = 0;
    dp[3][0][3][2] = 0;

    for(int i = 0; i < n; i++) {
        for(int a = 0; a < 4; a++) {
            for(int b = 0; b < 4; b++) {
                for(int c = 0; c < 4; c++) {
                    for(int d = 0; d < 4; d++) {
                        if (b == 0 && c == 2 && d == 3) continue;
                        if (b == 2 && c == 0 && d == 3) continue;
                        if (b == 0 && c == 3 && d == 2) continue;
                        if (a == 0 && b == 2 && d == 3) continue;
                        if (a == 0 && c == 2 && d == 3) continue;
                        dp[i+1][b][c][d] += dp[i][a][b][c];
                        dp[i+1][b][c][d] %= mod;
                    }
                }
            }
        }
    }


    int ans = 0;
    for(int a = 0; a < 4; a++) {
        for (int b = 0; b < 4; b++) {
            for (int c = 0; c < 4; c++) {
                ans += dp[n][a][b][c];
                ans %= mod;
            }
        }
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main()
{
	char k[10];
	scanf("%s",k);
	if(k[0] == k[strlen(k)-1])
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n") ;
	} 
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{

    int n,m,k;
    int[][] c;
    int[] shop;
    int[] d;

    void solve(){
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
        c = new int[n][n];
        for(int i=0; i<n; i++) Arrays.fill(c[i],-1);
        for(int i=0; i<m; i++){
            int a = sc.nextInt()-1;
            int b = sc.nextInt()-1;
            int l = sc.nextInt();
            c[a][b] = l;
            c[b][a] = l;
        }

        shop = new int[k];
        for(int i=0; i<k; i++) shop[i] = sc.nextInt()-1;

        d = new int[n];
        Arrays.fill(d,-1);
        dijkstra();

        int max = 0;
        for(int i=0; i<n; i++){
            if(d[i]==-1) continue;
            for(int j=i+1; j<n; j++){
                if(c[i][j]==-1 || d[j]==-1) continue;
                int d1 = d[i], d2 = d[j];
                int cc = c[i][j];
                while(cc>0){
                    if(d1<d2) d1++;
                    else d2++;
                    cc--;
                }
                max = Math.max(max,Math.max(d1,d2));
            }
        }

        System.out.println(max);
    }

    void dijkstra(){
        //pos, cost
        PriorityQueue<int[]> 
            q = new PriorityQueue<int[]>(n, new Comparator<int[]>(){
                    public int compare(int[] a, int [] b){
                        return a[1] - b[1];
                    }
                });
        for(int i=0; i<k ;i++) q.add(new int[]{shop[i],0});

        while(q.size()>0){
            int[] qq = q.poll();
            int pos = qq[0], cost = qq[1];

            if(d[pos]!=-1) continue;
            d[pos] = cost;

            for(int i=0; i<n; i++){
                if(c[pos][i]==-1) continue;
                q.add(new int[]{i,cost+c[pos][i]});
            }
        }
    }

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

Measured memory_bytes: 139672
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep0(i, n)cin >> a[i];
    sort(all(a));
    ll cnt = 0;
    rep0(i, n - 1)if(a[i] == a[i + 1])++cnt;
    if(cnt % 2 == 0)pf(n - cnt);
    else pf(n - cnt - 1);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define numa(x,a) for(auto x: a)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define pf push_front
#define sec second
#define sz(x) ((int)(x).size())
#define ALL( c ) (c).begin(), (c).end()
#define gcd(a,b) __gcd(a,b)
#define mem(x,n) memset(x,n,sizeof(x))
#define endl "\n"
using namespace std;
template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){}
template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); }
template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; }
template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; }
#define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; }
#define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); }
#define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); }
#define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); }
using ll = long long;



int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  const string A = "CODEFESTIVAL2016";
  string S;
  cin >> S;
  int ans = 0;
  rep(i,sz(A)){
    ans += A[i] != S[i];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<vector>
#include<map>
#include<climits>
#include<set>
#include<queue>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<bitset>
#include<cstring>
#include<list>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
#define REP(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) REP(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(typeof(c)::iterator i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back

ll dp[1000001];
int main(){
    int n;cin>>n;vl a(n);rep(i,n)cin>>a[i];
    int m;cin>>m;vl b(m),c(m);rep(i,m)cin>>b[i];rep(i,m)cin>>c[i];

    rep(i,n)dp[a[i]]+=a[i];
    rep(i,1000000)dp[i+1]+=dp[i];
    //rep(i,10)cout<<dp[i]<<" ";cout<<endl;
    rep(i,m){
        if(dp[b[i]]>=c[i])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a == 7 && b == 5 && c == 5){
		printf("YES");
	}
	else if(a == 5 && b == 5 && c == 7){
		printf("YES");
	}
	else if(a == 5 && b == 7 && c == 5){
		printf("YES");
	}
	else{
		printf("NO");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef long long ll;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	V<V<P>> e(n, V<P>(0));
	rep(i, n - 1) {
		int u, v, w;
		cin >> u >> v >> w;
		u--;v--;w = 2 - (w % 2);
		e[u].push_back(make_pair(v, w));
		e[v].push_back(make_pair(u, w));
	}
	
	priority_queue<P> pq;
	pq.push(make_pair(0,0));
	V<int> dist(n, INF);
	dist[0] = 0;

	while (!pq.empty()) {
		int sv = pq.top().second;pq.pop();

		rep(i, e[sv].size()) {
			int gv = e[sv][i].first;
			int d = dist[sv] + e[sv][i].second;
			if (dist[gv] > d) {
				dist[gv] = d;
				pq.push(make_pair(d,gv));
			}
		}
	}

	rep(i, n)cout << dist[i] % 2 << endl;

}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int N, A, B, C;
vector<int> l(8);
int inf = pow(10, 9);

// DFS: depth first search 深さ優先探索
// 現在のindex i と現在の竹の長さa, b, c
// コストを返す関数
int dfs(int now, int a, int b, int c)
{
    if (now == N)
    {
        if (min({a, b, c}) > 0)
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
        else
            return inf;
    }
    int m0 = dfs(now + 1, a, b, c);
    int m1 = dfs(now + 1, a + l.at(now), b, c) + 10;
    int m2 = dfs(now + 1, a, b + l.at(now), c) + 10;
    int m3 = dfs(now + 1, a, b, c + l.at(now)) + 10;

    return min({m0, m1, m2, m3});
}

int main()
{
    cin >> N >> A >> B >> C;

    REP(i, N)
    {
        cin >> l.at(i);
    }

    cout << dfs(0, 0, 0, 0);
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = "1" + input() + "1"
arr = []
cnt = 0
flg = 1
for s in S:
    if s == "1" and 1 - flg:
        flg = 1
        arr.append(cnt)
        cnt = 1
    elif s == "0" and flg:
        flg = 0
        arr.append(cnt)
        cnt = 1
    else:
        cnt += 1
arr.append(cnt)
csum = [0] * (len(arr)+1)
for i in range(len(arr)):
    csum[i + 1] = csum[i] + arr[i]
ans = 0
tmp = 0
for i in range(0, len(csum), 2):
    l = i
    r = min(i + 2*K + 1, len(csum) - 1)
    tmp = csum[r] - csum[l] - (r == len(csum) - 1) - (l == 0) - (l == 1)
    ans = max(ans, tmp)
if len(csum) == 2:
    print(csum[1] - 2)
else:
    print(ans)


Measured memory_bytes: 8040
n = int(input())
w = []
for i in range(n):
    w.append(input())

def chk_shiri(w):
    for i in range(n - 1):
        if w[i][-1] == w[i + 1][0]:
            continue
        else:
            return False
    return True
    
if len(w) != len(set(w)):
    print('No')
elif chk_shiri(w):
    print('Yes')
else:
    print('No')
    
    
    

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    for(int i = 0; i < N ; i++) cin >> v[i];
    sort(v.begin(), v.end(), greater<int>());

    int ans = 0;
    for(int i = 0; i < K; i++) ans += v[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

	int ans = 0;
	for (int i = 1; i<n; i++) {
		int cnt = 0;

		for (char c = 'a'; c <= 'z'; c++) {
			bool left = false, right = false;

			for (int j = 0; j<i; j++)
				if (s[j] == c)
					left = true;

			for (int j = i; j<n; j++)
				if (s[j] == c)
					right = true;

			if (left&&right)
				cnt++;
		}

		if (ans<cnt)
			ans = cnt;
	}

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

ll par[1000000];

void init(ll N){
    rep(i,N) par[i] = -1;
}

ll find(int a){
    if(par[a] < 0) return a;
    else{
        return par[a] = find(par[a]);
    }
}

void unite(int a, int b){
    a = find(a);
    b = find(b);
    if(a == b) return;
    else{
        if(par[a] > par[b]) swap(a,b);
        par[a] += par[b];
        par[b] = a;
    }
}

ll size(int A) {
    return -par[find(A)];
}

bool same(int a, int b){
    return find(a) == find(b);
}

int main(){
    ll N,M;
    cin >> N >> M;
    vector<pair<int,int>> edges(M);
    rep(i,M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        edges[i] = {a,b};
    }
    ll ans = N*(N-1)/2;
    vector<ll> ANS(M);
    ANS[M-1] = ans;
    init(N);
    for(int i = M-1; i > 0; i--){
        int a = edges[i].first;
        int b = edges[i].second;
        if(!same(a,b)) ans -= size(a)*size(b);
        unite(a,b);
        ANS[i-1] = ans;
    }
    rep(i,M) cout << ANS[i] << endl;
}

Measured memory_bytes: 5580
from sys import exit, stdin
N = int(stdin.readline().rstrip())
XYH = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
for x, y, h in XYH:
    for cx in range(101):
        for cy in range(101):
            if h == 0:
                continue
            else:
                H = h + abs(cx-x) + abs(cy-y)
                if all([th == max(H-abs(cx-tx)-abs(cy-ty), 0) for tx, ty, th in XYH]):
                    print(cx, cy, H)
                    exit()

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

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

	int M;
	scanf("%d",&M);
	int k[M];
	int g[M];
	for(int i=0;i<M;i++){
		scanf("%d%d",&k[i],&g[i]);
	}
	
	int p[n+M];
	for(int i=0;i<n;i++){
		p[i] = h[i]*60+m[i];
	}
	for(int i=n;i<n+M;i++){
		p[i] = k[i-n]*60+g[i-n];
	}
	sort(p, p+n+M);

	int z=-114514;
	for(int i=0;i<n+M;i++){
		int min=p[i]%60;
		if(z!=p[i]){
		if(i==0){
		if(min<10) printf("%d:0%d", int(p[i]/60),min);
		if(min>=10) printf("%d:%d", int(p[i]/60),min);
		}else{
		if(min<10) printf(" %d:0%d", int(p[i]/60),min);
		if(min>=10) printf(" %d:%d", int(p[i]/60),min);	
		}
		}
		if(i==n+M-1) printf("\n");	
		z=p[i];
	}		
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<pair<int, int>>R(N), B(N);
	rep(i, N)cin >> R[i].second >> R[i].first;
	rep(i, N)cin >> B[i].first >> B[i].second;
	sort(R.begin(), R.end(), greater<pair<int, int>>());
	sort(B.begin(), B.end());
	rep(i, N)swap(R[i].first, R[i].second);
	vector<vector<int>>num(N);
	vector<pair<int, int>>num2(N);
	bool flag[100] = {};
	int cnt = 0;
	rep(i, N) {
		int x = B[i].first, y = B[i].second;
		rep(j, N) {
			if (R[j].first < x&&R[j].second < y&&flag[j] == 0) {
				cnt++;
				flag[j]++;
				break;
			}
		}
	}


	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
  ll N,T;
  cin>>N>>T;
  vll t(N);
  for (ll i=0;i<N;i++) cin>>t[i];
  ll ans=T;
  for (ll i=0;i<N-1;i++) {
    ll x=t[i]+T-t[i+1];
    ans += T-max((ll)0,x);
  }
  cout<<ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	string S;
	cin >> S;
	if(S == "SUN")cout << "7" << endl;
	if(S == "MON")cout << "6" << endl;
	if(S == "TUE")cout << "5" << endl;
	if(S == "WED")cout << "4" << endl;
	if(S == "THU")cout << "3" << endl;
	if(S == "FRI")cout << "2" << endl;
	if(S == "SAT")cout << "1" << endl;

	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  map<string,int>m;
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    m[s]+=1;
  }
  cout<<"AC"<<" x "<<m["AC"]<<"\n";
  cout<<"WA"<<" x "<<m["WA"]<<"\n";
  cout<<"TLE"<<" x "<<m["TLE"]<<"\n";
  cout<<"RE"<<" x "<<m["RE"];
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main{
	public static int[][][] dp;

	public static boolean[] primes(int n){
		boolean[] primes = new boolean[n+1];
		Arrays.fill(primes, true);
		primes[0] = primes[1] = false;
		for(int i=2;i<=n;i++){
			if(primes[i]){
				for(int j=i*2;j<=n;j+=i){
					primes[j] = false;
				}
			}
		}
		return primes;
	}

	public static int dfs(int i,int n,int k,ArrayList<Integer> p){
		if(n == 0){
			if(k == 0) return 1;
			else return 0;
		}
		else if(k == 0) return 0;
		if(dp[i][n][k] != -1) return dp[i][n][k];

		int res = 0;
		for(int j=i;p.get(j)<=n;j++){
			res += dfs(j+1,n-p.get(j),k-1,p);
		}
		return dp[i][n][k] = res;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		boolean[] flg = primes(1200);
		ArrayList<Integer> p = new ArrayList<Integer>();
		for(int i=0;i<flg.length;i++) if(flg[i]) p.add(i);

		int size = p.size();
		dp = new int[size][1121][15];
		for(int i=0;i<size;i++) for(int j=0;j<1121;j++) for(int k=0;k<15;k++) dp[i][j][k] = -1;

		while(true){
			int n=sc.nextInt(), k=sc.nextInt();
			if(n==0 && k==0) break;
			System.out.println(dfs(0,n,k,p));
		}
	}
}

Measured memory_bytes: 28000
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] arr = new int[3];
		for(int i=0;i<3;i++) {
			arr[i]=sc.nextInt();
		}
		Arrays.sort(arr);
		if(arr[0] == 5 &&
		arr[1] == 5 &&
		arr[2] == 7) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
    char a,b,c,d;
    int ans=0;
    cin>>a>>b>>c>>d;
    if(a=='+')ans++;
    else ans--;
    if(b=='+')ans++;
    else ans--;
    if(c=='+')ans++;
    else ans--;
    if(d=='+')ans++;
    else ans--;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>

using namespace std;

double dis(int xj, int yj, int xi, int yi){
    int xd = (xi - xj)*(xi - xj);
    int yd = (yi - yj)*(yi - yj);
    int dis_pow = xd + yd;
    return sqrt((double)dis_pow);
}

int main(){
    int n;
    double cnt, sum, ans;
    cnt = sum = 0;
    cin >> n;
    vector<pair<int, int>>  point(n);
    vector<int> line(n);
    for(int i=0; i<n; i++){
        int x, y;
        cin >> x >> y;
        pair<int, int> p(x, y);
        point[i] = p;
        line[i] = i;
    }

    do{
      for(int i=0; i<n-1; i++){
          pair<int, int> p_pre;
          pair<int, int> p_next;
          p_pre = point[line[i]];
          p_next = point[line[i+1]];
          sum += dis(p_pre.first, p_pre.second, p_next.first,
                     p_next.second);
      }
      cnt += 1.0;
    }while(next_permutation(line.begin(), line.end()));

    ans = sum/cnt;
    printf("%f\n", ans);
    return 0;
}


Measured memory_bytes: 256