akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		StringBuilder stdout = new StringBuilder();
		String x = sc.next();
		String y = sc.next();
		int flag = Integer.valueOf(x,16).compareTo(Integer.valueOf(y,16));
		switch(flag){
			case -1:
				stdout.append("<");
				break;
			case 0:
				stdout.append("=");
				break;
			case 1:
				stdout.append(">");
				break;
		}
		System.out.println(stdout);
	}
}


Measured memory_bytes: 23892
K,N = map(int,input().split())
a = list(map(int,input().split()))
d = []
for i in range(N):
    if i == 0:
        d.append(a[0]+K-a[N-1])
    else:
        d.append(a[i]-a[i-1])
print(sum(d)-max(d))

Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int  long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
 
bool sortby(const pair<pair<string,int>,int> &a, 
              const pair<pair<string,int>,int> &b) 
{ 
    if(a.first.first==b.first.first)
        return (a.first.second > b.first.second); 
    else
        return(a.first.first < b.first.first);
}  
 
void solve(){
    int x,y;
    string a,b,c;
    cin>>a>>b>>x>>y>>c;
    if(c==a) x--;
    else y--;
    cout<<x<<" "<<y;
    
}
 
signed main(){
    //IOS;
    //freopen("input.txt", "r" , stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
     //   cout<<" * "<<t<<"\n";
    }
//    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	ll x, y; cin >> x >> y;
	
	ll ans = 0;
	
	if (x == y) ans = 0;
	else if (x == 0) {
		ans += abs(y);
		ans += (y != abs(y));
	}
	else if (x > 0) {
		if (-x < y && y < x) {
			ans++; // 反転
			ans += -abs(y) + x;
			ans += (y != -abs(y));
		}
		else {
			ans += abs(y) - x;
			ans += (y != abs(y));
		}
	}
	else { // xが負
		if (x < y && y < -x) {
			ans += -abs(y) - x;
			ans += (y != -abs(y));
		}
		else {
			ans++;
			ans += abs(y) + x;
			ans += (y != abs(y));
		}
	}
	
	
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{

	int c[101] = {0};
	c[0] = 0;
	int N;

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> c[i];
	}

	for (int i = 1; i <= N; i++) {
		for (int k = 1; k < N; k++) {
			if (c[i] > c[k]) { swap(c[i], c[k]); }
		}
	}


	int ans = 0;

	for (int i = 1; i <= N; i++) {
		if (i % 2 == 1) { 
			ans += c[i];
		}
		else {
			ans = ans - c[i];
		}
	}
	
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
/*
 * じょえチャンネルを応援します！
 * https://www.youtube.com/watch?v=gPFr7q7eLL8
 */
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	ulong res = 1;
	ulong tmp = 1;
	while(N >= tmp) {
		tmp *= K;
		res++;
	}
	(res-1).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll dp[305][305][305];
vector<i_i> rule[305];
int N, M;

//int counter[305];
vector<int> in(3);

inline void f(int R, int G, int B) {
    //cout << "f " << R << " " <<G << " " << B<< endl;
    in[0] = R;
    in[1] = B;
    in[2] = G;
    sort(in.begin(), in.end());
    for(int i = 0; i < rule[in[2]].size(); i++) {
        //counter[maxi]++;
        //counter++;
        int l = rule[in[2]][i].first;
        int x = rule[in[2]][i].second;
        if(l <= in[0]) x--;
        if(l <= in[1]) x--;
        if(x != 1) {
            dp[R][G][B] = 0;
            return;
        }
    }
    dp[R][G][B] %= mod;
    int maxi = in[2];
    //cout << R << " " << G << " " << B << " " << dp[R][G][B] << endl;
    dp[maxi + 1][G][B] = (dp[maxi + 1][G][B] + dp[R][G][B]);
    dp[R][maxi + 1][B] = (dp[R][maxi + 1][B] + dp[R][G][B]);
    dp[R][G][maxi + 1] = (dp[R][G][maxi + 1] + dp[R][G][B]);
    return;
}

int main() {
    //cout.precision(10);
    cin >> N >> M;
    //cout << N << " " << M << endl;
    for(int i = 1; i <= M; i++) {
        int l, r, x;
        cin >> l >> r >> x;
        rule[r].push_back({l, x});
    }
    dp[0][0][0]++;
    f(0, 0, 0);
    //cout << N << endl;
    for(int maxi = 1; maxi <= N; maxi++) {
        //cout << maxi << endl;
        f(maxi, 0, 0);
        f(0, maxi, 0);
        f(0, 0, maxi);
        for(int maxi2 = 1; maxi2 < maxi; maxi2++) {
            for(int i = 0; i < maxi2; i++) {
                f(maxi, maxi2, i);
                f(maxi, i, maxi2);
                f(maxi2, maxi, i);
                f(maxi2, i, maxi);
                f(i, maxi, maxi2);
                f(i, maxi2, maxi);
            }
        }
    }
    ll ans = 0;
    ans = (ans + dp[N][0][0] + dp[0][N][0] + dp[0][0][N]) % mod;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < i; j++) {
            ans = (ans + dp[N][i][j] + dp[N][j][i] + dp[i][N][j] + dp[i][j][N] + dp[j][N][i] + dp[j][i][N]) % mod;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 221440
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int N=200009;
int n,T,m=33;
pair <int,int> a[N];
bool comp(pair <int,int> a,pair <int,int> b){
	return b.f*(a.s+1)<a.f*(b.s+1);
}
int32_t main(){
	if(fopen("input.txt", "r"))
	freopen("input.txt", "r", stdin),
	freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	cin >> n >> T;
	vector <int> v;
	v.push_back(0);
	for(int i=0;i<n;i++){
		cin >> a[i].f >> a[i].s;
		if(a[i].f==0)v.push_back(a[i].s+1);
	}
	sort(a,a+n,comp);
	sort(v.begin(),v.end());
	for(int i=1;i<v.size();i++)
		v[i]+=v[i-1];
	int dp[m],ans=0;
	memset(dp,-1,sizeof dp);
	dp[0]=0;
	for(int j=0;j<n;j++){
		if(!a[j].f)break;
		int tm[m];
		memset(tm,-1,sizeof tm);
		for(int i=0;i<m-1;i++){
			if(dp[i]==-1)continue;
			int t=dp[i]+1;
			t+=t*a[j].f+a[j].s;
			if(t<=T)
				tm[i+1]=t;
		}
		for(int i=0;i<m;i++){
			if(tm[i]==-1)continue;
			if(dp[i]==-1)dp[i]=tm[i];
			else dp[i]=min(dp[i],tm[i]);
		}
	}
	for(int i=0;i<m;i++){
		if(dp[i]==-1)continue;
		int t=T-dp[i];
		int x=upper_bound(v.begin(),v.end(),t)-v.begin();
		ans=max(ans,x-1+i);
	}
	cout << ans;
}

Measured memory_bytes: 5104
#include <iostream>
#include <string.h>
#include <math.h>

using namespace std;

int main(void)
{
  long N;
  int K;

  cin >> N >> K;

  int ans;

  for (int i = 0; i < 1000; i++) {
      //cout << (long) pow(K, i) << endl;
      //cout << N / (long) pow(K, i) << endl;
      //cout << "---" << endl;
      if (N / (long) pow(K, i) == 0) {
          ans = i;
          break;
      }
  }

  //cout << ceil((logl(N) / logl(K)));

  cout << ans << endl;

  return 0;
}


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

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

    int total_sum = 0;
    for (int i = 0; i <= N; ++i) {
        int number = i;
        int sum = 0;

        while (number != 0) {
            sum += number % 10;
            number = number / 10;
        }

        if (sum >= A && sum <= B) {
            total_sum += i;
    
        }
    }
    cout << total_sum << endl;
}

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

int main() {
	int N, i = 0, j, k, sum = 0;
	cin >> N;
	while(true){
		if(i == 0){
			j = 1; k = 10;
		} else {
			j *= 10;
			k *= 10;
		}
		
		if(N % k == N){
			sum += N / j;
			break;
		} else {
			sum += N % k / j;
		}
		i++;
	}
	if(N % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;


int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int k; cin >> k;
    int a, b; cin >> a >> b;
    FOR(i, a, b + 1)
    {
        if (i % k == 0)
        {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";

    return 0;
}


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

using i64 = int64_t;

int main(){
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(s == u)a--;
    else b--;
    cout << a << " " << b << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

namespace comb {
	ll fact[500001];
	ll fact_inv[500001];
	const ll MOD = 1000000007;

	ll modpow(ll a, ll b) {
		ll base = 1, kakeru = a;
		while (b > 0) {
			if (b & 1)base *= kakeru, base %= MOD;
			kakeru *= kakeru, kakeru %= MOD;
			b >>= 1;
		}
		return base;
	}

	void setup() {
		fact[0] = 1, fact[1] = 1;
		for (int i = 2; i <= 500000; i++) {
			fact[i] = (fact[i - 1] * i) % MOD;
		}

		fact_inv[500000] = modpow(fact[500000], MOD - 2);

		for (int i = 499999; i >= 0; i--) {
			fact_inv[i] = fact_inv[i + 1] * (i + 1);
			fact_inv[i] %= MOD;
		}

	}

	ll combination(int a, int b) {
		if (a - b < 0)return 0;
		ll ret = fact[a];
		ret *= fact_inv[b], ret %= MOD;
		ret *= fact_inv[a - b], ret %= MOD;
		return ret;
	}

	ll permutation(int a, int b) {
		if (a - b < 0)return 0;
		ll ret = fact[a];
		ret *= fact_inv[a - b], ret %= MOD;
		return ret;
	}

	ll homogeneous(int a, int b) {
		return combination(a + b - 1, b);
	}

}

int main() {
	ll n, k;
	cin >> n >> k;
	comb::setup();

	ll ans = 0;
	for (int i = 0; i <= min(k, n - 1); i++) {
		ll tmp = comb::combination(n, i);
		tmp *= comb::homogeneous(n - i, i);
		tmp %= comb::MOD;
		ans += tmp;
		ans %= comb::MOD;
	}
	cout << ans % comb::MOD << endl;
	return 0;
}

Measured memory_bytes: 8192
import functools
def primes(n):

    prime_list = list(range(n+1))
    prime_list[1] = 0
    for i in range(2, int(n)+1):
        if prime_list[i] != 0:
            for j in range(2*i, n+1, i):
                prime_list[j] = 0

    return [i for i in prime_list if i != 0]

def solve(n):

    prime_list = primes(n)
    powers = []
    for p in prime_list:
        tmp = 0
        a = p
        while a <= n:
            tmp += n // a
            a *= p
        powers.append(tmp)

    ans = functools.reduce(
        lambda acc, x: (acc*(x+1)) % (10**9+7), powers, 1)

    return ans

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

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

int main()
{
  int n;
  cin>>n;
  int h[n],c[n];

  for(int i=0; i<n; i++) cin>>h[i];
  c[0]=0;
  if(n>=2) c[1]=abs(h[1]-h[0]);
  for(int i=2; i<n; i++)
  {
      c[i]=min((c[i-1]+abs(h[i]-h[i-1])) , (c[i-2]+abs(h[i]-h[i-2])) );
  }
  cout<<c[n-1]<<"\n";
}


Measured memory_bytes: 4308
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n;
int f(vp in){
	int t=0;
	int sum=0;
	vi a(n),b(n);
	rep(i,n)a[i]=in[i].first,b[i]=in[i].second;
	sort(all(a));
	sort(all(b));
//	cout<<endl;
//	rep(i,n)cout<<a[i]<<" ";cout<<endl;
//	rep(i,n)cout<<b[i]<<" ";cout<<endl;
	rep(i,n){
		if(i%2==0){
			if(a[n-1-i/2]-t<0)break;
			sum+=a[n-1-i/2]-t;
			t=a[n-1-i/2];
		}else{
			if(t-b[i/2]<0)break;
			sum+=t-b[i/2];
			t=b[i/2];
		}
//		cout<<sum<<" "<<t<<endl;
	}
//	rep(i,n)cout<<in[i].first<<" "<<in[i].second<<endl;
//	cout<<t<<endl;
	sum+=abs(t);
	return sum;
}
signed main(){
	cin>>n;
	vp in(n);
	rep(i,n)cin>>in[i].first>>in[i].second;
	int out=f(in);
	rep(i,n)in[i].first*=-1,in[i].second*=-1;
	rep(i,n)swap(in[i].first,in[i].second);
	out=max(out,f(in));
	cout<<out<<endl;
}











Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int a[100005];

int main(){
	int n,k,i,ans=0;
	cin>>n>>k;
	for(i=1;i<=n;i++)
		cin>>a[i];
	n-=k,ans++;
	if(n%(k-1)) ans+=n/(k-1)+1;
	else ans+=n/(k-1);
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 3960
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n,x = LI()
    a = LI()
    r = 1
    t = 0
    for c in a:
        t += c
        if t <= x:
            r += 1

    return r


print(main())



Measured memory_bytes: 6096
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

class UnionFind
{
    vector<int> par;

public:
    UnionFind(int n) : par(n, -1) {}

    int root(int x)
    {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    inline bool same(int u, int v)
    {
        return root(u) == root(v);
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    akari<int> frd(n);
    while (m--)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        frd[a]++, frd[b]++;
        uf.merge(a, b);
    }
    akari<int> ans(n);
    for (int i = 0; i < n; i++)
    {
        ans[i] = uf.size(i) - frd[i] - 1;
    }
    while (k--)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (uf.same(a, b))
        {
            ans[a]--, ans[b]--;
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << (i == n - 1 ? '\n' : ' ');
    }
}

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


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  vector<int> res(s.size()+1);
  rep(i, s.size()) {
    if (s[i] == '<')
      res[i+1] = res[i]+1;
  }
  for (int i = s.size()-1; i >= 0; i--) {
    if (s[i] == '>')
      chmax(res[i], res[i+1]+1);
  }
  ll ans = 0;
  rep(i, res.size())
    ans += res[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2844
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int i=0,j=0;
	for(int l=0;l<s.length()-1;l++)
	{
		if(s[l]==s[l+1])
		{
			i=l+1;
			j=l+2;
		}
	}
	for(int p=0;p<s.length()-2;p++)
	{
		if(s[p]==s[p+2])
		{
			i=p+1;
			j=p+3;
		}
	}
	if(i==0 && j==0)
	{
		i=-1;
		j=-1;
	}
	cout<<i<<" "<<j<<endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

struct edge{
	int to, fee;
};

struct state{
	int used;
	int pos;
	int sum;
	
	bool operator< (const state &s) const{
		return s.sum < sum;
	}
};

int n;
vector<vector<edge> > G;

int solve(){
	vector<vector<int> > d(3, vector<int>(n + 1, 1000000000));
	
	priority_queue<state> pq;
	pq.push((state){0, 1, 0});
	d[0][1] = 0;
	
	while(!pq.empty()){
		state st = pq.top();
		pq.pop();
		if(d[st.used][st.pos] != st.sum){ continue; }

		if(st.pos == n && st.used != 1){ return st.sum; }

		for(int i = 0; i < G[st.pos].size(); ++i){
			int t = G[st.pos][i].to;
			int c = st.sum;
			int u = st.used;
			if(u == 1){
				u = 2;
			}
			else{
				c += G[st.pos][i].fee;
			}

			if(d[u][t] > c){
				d[u][t] = c;
				pq.push((state){u, t, c});
			}

			if(u == 0){
				if(d[1][t] > st.sum){
					d[1][t] = st.sum;
					pq.push((state){1, t, st.sum});
				}
			}
		}
	}
	return -1;
}

int main(){
	int m, a, b, c;
	while(scanf("%d%d", &n, &m), n){
		G.assign(n + 1, vector<edge>());
		for(int i = 0; i < m; ++i){
			scanf("%d%d%d", &a, &b, &c);
			G[a].push_back((edge){b, c});
			G[b].push_back((edge){a, c});
		}
		
		printf("%d\n", solve());
	}
}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    REP(i, S.size()) {
        if ((i + 1) & 1) {
            T += S[i];
        }
    }
    cout << T << endl;
}

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

char s[12],t[12];
int rotate[10][10];
int n,ans;

void solve(int idx,int cost){
	if(idx == n) ans = cost;
	if(cost >= ans) return;

	int i,j,r;

	if(s[idx] == t[idx]){
		solve(idx+1,cost);
	}
	else{
		for(i=idx;i<n;i++){
			r = rotate[s[idx]][t[idx]];
			for(j=idx;j<=i;j++) s[j] = (s[j] + 10 + r) % 10;
			solve(idx+1,cost+1);
			for(j=idx;j<=i;j++) s[j] = (s[j] + 10 - r) % 10;
		}
	}
}

int main(void){
	int i,j,d,x;

	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			d = j - i;
			x = abs(d);
			if(j < i && x > 10-x)
				d = 10-x;
			else if(j > i && x > 10-x)
				d = -(10-x);

			rotate[i][j] = d;
		}
	}

	while(scanf("%d",&n),n){
		scanf("%s%s",s,t);
		for(i=0;i<n;i++){
			s[i] -= '0';
			t[i] -= '0';
		}

		ans = 999999999;
		solve(0,0);
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 416
function main(input) {
    var inputs = input.split("\n");
    var N = parseInt(inputs[0], 10);
    var S = inputs[1];
    var _S = "";
    for(var i=0;i<S.length;i++) {
        var ts = S.charCodeAt(i);
        ts += N;
        if(ts > 90) {
            ts -= 26;
        }
        _S += String.fromCharCode(ts);
    }
    console.log(_S);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

using ll = long long;

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

    int a, b;
    cin >> a >> b;

    int num_coins = 0;
    if (a <= b) { num_coins += b; --b; }
    else { num_coins += a; --a; }

    if (a <= b) { num_coins += b; --b; }
    else { num_coins += a; --a; }

    cout << num_coins << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, u, v;
    ll d[200005] = {}, z = 0;
    vector<int> g[200005] = {};
    cin >> n;
    for (int i = 1; i < n; i++) cin >> u >> v, g[u].push_back(v), g[v].push_back(u);
    for (int i = 1; i <= n; i++) sort(g[i].begin(), g[i].end());
    for (int i = 1; i <= n; i++) {
        d[i] = d[i - 1] + i;
        for (int j : g[i]) if (j < i) d[i] -= j;
        z += d[i];
    }
    cout << z;
}


Measured memory_bytes: 16584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)


int main(){

	ll N,K,count=0,ans=100001;
	cin >> N >> K;
	vector<ll> a(N),counta(100001,0);
	FOR(i,0,N)cin >> a[i];

	ll l=0,r=1;
	counta[a[0]]++;
	if(1<=a[0] && a[0]<=K)count++;

	FOR(i,0,N){
		while(count<K && r<N){
			counta[a[r]]++;
			if(counta[a[r]]==1 && 1<=a[r] && a[r]<=K)count++;
			r++;
		}
		if(count==K)ans=min(ans,r-l);
		counta[a[l]]--;
		if(counta[a[l]]==0 && 1<=a[l] && a[l]<=K)count--;
		l++;
	}
	if(ans==100001)ans = 0;
	cout << ans << endl;
	
}


Measured memory_bytes: 4424
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll k,a,b,res;  
  cin >> k >> a >> b;
  
  if(a <= b && k > a)
    res = -1;
  else if(a <= b && k <= a)
    res = 1;
  else{
    ll one = k/(a-b);
    if((k%(a-b)) != 0)
      one++;
    one *= 2;
    ll two = (k-b)/(a-b);
    if(((k-b)%(a-b)) != 0)
      two++;
    two = 2*two -1;
    ll three = (k+b)/(a-b);
    if(((k+b)%(a-b)) != 0)
      three++;
    three = 2*three +1;
    res = min(one,two);
    res = min(res,three);
  }
  cout  << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N,tmp_1,tmp,tmpans=0,ans=0;cin>>N;
  cin>>tmp_1;
  REP(i,0,N-1){
    cin>>tmp;
    if(tmp_1>=tmp){
      tmpans++;
    }
    else{
      ans=max(ans,tmpans);
      tmpans=0;
    }
    tmp_1=tmp;
  }
  ans=max(tmpans,ans);
  print(ans)
  
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i, j, cnt, t=0, H, W;
  char a[100][100];
  scanf("%d%d", &H, &W);
  for(i=0;i<H-t;++i) {
    cnt=0;
    for(j=0;j<W;++j) {
      scanf(" %c", &a[i][j]);
      if(a[i][j] == '.') cnt++;
    }
    if(cnt == W){
      --i;
      ++t;
    }
    cnt=0;
  }
  H -= t;
  t = 0;
  char ans[100][100];
  for(i=0;i<W-t;++i) {
    for(j=0;j<H;++j) {
      ans[j][i] = a[j][i+t];
      if(ans[j][i] == '.') cnt++;
    }
    if(cnt == H){
      --i;
      ++t;
    }
    cnt=0;
  }
  W -= t;
  for(i=0;i<H;++i){
    for(j=0;j<W;++j){
      printf("%c", ans[i][j]);
    }
    putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 128
h, w = map(int, input().split())
table = [list(input()) for _ in range(h)]

mx = [0, 1, 0, -1]
my = [1, 0, -1, 0]
for i in range(h):
    for j in range(w):
        if table[i][j] == "#":
            for k in range(4):
                tx, ty = j + mx[k], i + my[k]
                if 0 <= tx < w and 0 <= ty < h and table[ty][tx] == "#":
                    break
            else:
                print("No")
                exit(0)
print("Yes")



Measured memory_bytes: 9144
import itertools
n, m, x = map(int, input().split())
table = [tuple(map(int, input().split())) for _ in range(n)]
ans = []
for i in range(1,n+1):
    for cap in itertools.combinations(table, i):
        money = 0
        a = [0] * m
        for j in cap:
            money += j[0]
            for k in range(m):
                a[k] += j[k+1]
        if not len([l for l in a if l < x]):
            ans.append(money)
if not ans:
    print(-1)
else:
    print(min(ans))

Measured memory_bytes: 68680
#include<bits/stdc++.h>
#define       inf                  1<<30
#define       p5                   100007
#define       p6                   1000007
#define       PI                   acos(-1)
#define       M                    1000000007
#define       sc                   scanf
#define       ss                   second
#define       ff                   first
#define       pf                   printf
#define       scin(x)              sc("%d",&(x))
#define       scin2(x,y)            sc("d",&(x),&(y))
#define       READ(f)              freopen(f, "r", stdin)
#define       WRITE(f)             freopen(f, "w", stdout)
#define       ll                   long long
#define       ull                  unsigned long long
#define       pii                  pair < int, int>
#define       pp                  pair < ll, ll>
#define       pq                   priority_queue
#define       pb                   push_back
#define       FastRead             ios_base::sync_with_stdio(0);cin.tie(0)
//int month[]={31,28,31,30,31,30,31,31,30,31,30,31};
//int dx[5] = {1, -1, 0, 0 };
//int dy[5] = {0, 0, 1, -1};
using namespace std;
int dp[p5+2];
int main()
{
	int n,i,j,k;
	cin>>n>>k;
	int ar[n];
	for(i=1;i<=n;i++){
        cin>>ar[i];
	}
	if(n<=k){
        cout<<abs(ar[1]-ar[n])<<endl;
        return 0;
	}

	for(i=2;i<=k+1;i++){
        dp[i]=abs(ar[1]-ar[i]);
	}
	for(i=k+2;i<=n;i++){
            int mi=INT_MAX;
            for(j=1;j<=k;j++){
                int x=abs(ar[i]-ar[i-j]);
                mi=min(mi,x+dp[i-j]);
            }
            dp[i]=mi;
	}
	cout<<dp[n]<<endl;

	return 0;
}
//C%sE91971@%#@
//ssl%honeypod%
//https://prosenc.blogspot.com/2016/



Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

int m, a[7], b[7];
int n;
long dp[8][2000];

long rec(int x, long y){ //x番目のカードについて考える, 今の合計はy
	if(dp[x][y]>=0) return dp[x][y];
	
	long ret=0;
	
	if(y>n) return 0;
	else if(y==n) return 1;
	else if(x==m) return 0;
	else{
		for(int i=0; i<=b[x]; ++i) ret+=rec(x+1, y+i*a[x]);
	}
	
	return dp[x][y]=ret;
}

int main(){
	while(1){	
		scanf(" %d", &m);
		if(m==0) break;
		for(int i=0; i<m; ++i) scanf(" %d %d", &a[i], &b[i]);
		
		int g;
		scanf(" %d", &g);
		for(int i=0; i<g; ++i){
			scanf(" %d", &n);	
			memset(dp, -1, sizeof(dp));
			printf("%ld\n", rec(0, 0));
		}
			
	}
}

Measured memory_bytes: 1320
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main()
{
    long long n,i;
     cin>>n;
     long long m;
     long long  s[n],a[n+5]={0};
     for(i=0;i<n;i++)
     {
         cin>>s[i];
         a[s[i]]++;
     }
     m=0;
     //map<int,int>f;

         for(i=0;i<n+5;i++)
         {
             m+=(a[i]*(a[i]-1))/2;
         }
         for(i=0;i<n;i++)
         {
             cout<<m-a[s[i]]+1<<endl;
         }
    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

long long N, M;
std::vector<std::vector<int>> graph;
std::vector<int> color_vec;

// paint color
// 一つでも矛盾があれば, falseを伝搬して欲しい
// falseを伝搬するやつ
// 根本的なfalseのベースケース
// If bipartite graph, return ture.
int black = 0;

bool dfs(int target_node, int color) {
  color_vec[target_node] = color;
  for (auto e: graph[target_node]) {
    if (color_vec[e] == color) {
      return false;
    }
    if (color_vec[e] == 0 && !dfs(e, -color)) {
      return false;
    }
  }
  return true;
}

int main() {
  std::cin >> N >> M;
  graph.assign(N, std::vector<int>());
  color_vec.assign(N, 0);
  for (int i = 0; i < M; ++i) {
    int A, B;
    std::cin >> A >> B;
    --A;
    --B;
    graph[A].push_back(B);
    graph[B].push_back(A);
  }
  if (dfs(0, 1)) {
    black = std::count(color_vec.begin(), color_vec.end(), 1);
    std::cout << black*(N-black) - M << std::endl;
  } else {
    std::cout << N*(N-1)/2 - M << std::endl;
  }
}


Measured memory_bytes: 6528
import math
n = int(input())
x = (-1+math.sqrt(1+8*n))/2
if not x.is_integer():
  print ('No')
  exit (0)
x = int(x)
ans = []
k = 1
for i in range(x+1):
  a = []
  for j in range(x):
    if j >= i:
      a.append(k)
      k +=1
    else:
      a.append(ans[j][i-1])
  ans.append(a)
print ('Yes')
print (x+1)
for i in range(x+1):
  print (x,*ans[i]) 

Measured memory_bytes: 47068
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <vector>
using namespace std;

int h;
int A[500000];

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

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

void maxHeapfy(int i) {
    if (i >= h) {
        return;
    }
    int l_i = 2 * i + 1;
    int r_i = 2 * i + 2;
    int max_i = i;
    if (l_i < h && A[i] < A[l_i]) {
        max_i = l_i;
    }
    if (r_i < h && A[max_i] < A[r_i]) {
        max_i = r_i;
    }

    if (max_i != i) {
        swap(A + i, A + max_i);
        maxHeapfy(max_i);
    }
}

void buildMaxHeap() {
    for (int i = h / 2 - 1; 0 <= i; i--) {
        maxHeapfy(i);
    }
}

void printMaxHeap() {
    for (int i = 0; i < h; i++) {
        cout << " " << A[i];
    }
    cout << endl;
}

int main() {
    cin >> h;
    store();
    buildMaxHeap();
    printMaxHeap();

    return 0;
}


Measured memory_bytes: 5040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(true){
        c = c - b;
        if(c <= 0 ){
            cout << "Yes" << endl;
            break;
        }
        a = a - d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int ans,n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i+=2)
	{
		int num=0;	
		for(int j=1;j<=i;j++)
			if(i%j==0)
				num++;
		if(num==8)
			ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define maxn 500005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

map <ull,int> p;
ull b[maxn],inv[maxn],ans;
int len,n;
char s[maxn];

inline ull pw(ull a,ull b)
{
	ull ans=1,base=a;
	while(b)
	{
		if(b&1) ans=(ans*base);
		base=(base*base); b>>=1;
	}
	return ans;
}

int main()
{
	//freopen("t1.out","w",stdout);
	ull x=0-1; ull y=pw(233,x-1); //cout<<x*y<<endl;
	n=read(); scanf("%s",s+1); b[0]=1; inv[0]=1; inv[1]=7204522363551799129; len=strlen(s+1);
	for(int i=1;i<=maxn-5;i++) b[i]=b[i-1]*233;
	for(int i=2;i<=maxn-5;i++) inv[i]=inv[i-1]*7204522363551799129;
	ll ed=0,nw=250000;
	for(int i=1;i<=len;i++)
	{
		if(s[i]=='+') ed=(ed+b[nw]);
		else if(s[i]=='-') ed=(ed-b[nw]);
		else if(s[i]=='>') nw++;
		else if(s[i]=='<') nw--; p[ed]++;
	}
	ll tmp=0; nw=250000; ans=0;
	for(int i=1;i<=len;i++)
	{
		ll p2=ed;
		if(nw>=250000) p2=(p2*b[nw-250000]);
		else p2=(p2*inv[250000-nw]);
		ans+=p[(tmp+p2)];
		if(s[i]=='+') tmp=(tmp+b[nw]);
		else if(s[i]=='-') tmp=(tmp-b[nw]);
		else if(s[i]=='>') nw++;
		else if(s[i]=='<') nw--;
		p[tmp]--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 39552
get~~m:g/\d+/;$!=lines;
for 0..$0-$1 X 0..$0-$1 ->($i,$j) {
	my$f=1;
	{$f=0,last if !$![$i+$_].substr-eq($![$0+$_],$j)} for ^$1;
    exit !say "Yes" if $f
}
say "No"

Measured memory_bytes: 80364
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

  int64_t A, B;
  char op;
  cin >> A >> op >> B;

  if(op == '+')
    cout << A + B << endl;
  else if(op == '-')
    cout << A - B << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct a{
    int x,y,z;
};
int main(){
    int l;
    cin>>l;
    int n=1;
    while((1<<n)<=l)++n;
    --n;
    vector<a> v;
    rep(i,n)v.push_back({i+1,i+2,0});
    rep(i,n)v.push_back({i+1,i+2,(1<<i)});
    int ret=(1<<n);
    int res=l-ret;
    for(int i=n-1;i>=0;i--){
        if((1<<i)&res){
            v.push_back({i+1,n+1,ret});
            ret+=(1<<i);
        }
    }
    cout<<n+1<<" "<<v.size()<<endl;
    for(auto e:v)cout<<e.x<<" "<<e.y<<" "<<e.z<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string> 
#include <map>
#include <iomanip>
#include <list>
#include <stack>

using namespace std;


typedef int INT;
#define int long long

INT main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << a[n - 1] << " ";
	int b, c;
	b = a[n - 1] / 2;
	c = b;
	if (a[n - 1] % 2 == 1)
		c = b + 1;
	int mmax = -1, r = -1;
	for (int i = 0; i < n - 1; i++)
	{
		if (abs(c - a[i]) < mmax || mmax == -1)
		{
			mmax = abs(c - a[i]);
			r = a[i];
		}
		if (abs(b - a[i]) < mmax || mmax == -1)
		{
			mmax = abs(b - a[i]);
			r = a[i];
		}
	}
	cout << r;


	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000000000000000000;
const char END = '\n';


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll X, Y;
	cin >> X >> Y;
	ll i = 1;
	bool flag = true;
	if (X%Y == 0)
		flag = false;
	else {
		while (1) {
			X *= i;
			if (X >= MAX) {
				flag = false;
				break;
			}
			if (X%Y != 0)
				break;
			i++;
		}
	}
	if (flag == true)
		cout << X << END;
	else
		cout << -1 << END;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    int num = 3;
    vector<int> prime;
    while(1) {
        if ( prime.size() == n ) break;
        int cnt = 0;
        for ( int i = 2; i <= num; i++ ) {
            if ( num % i == 0 ) ++cnt;
        }
        if ( cnt == 1 && num % 5 == 1 ) {
            prime.push_back(num);
        }
        ++num;
    }
    rep(i, prime.size()) cout << prime[i] << " ";
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,k=0,l,x;
    scanf("%lld",&n);
    x=n+1;
    for(i=0; i<n; i++)
    {
        scanf("%lld",&j);
        if(j<x)
        {
            k++;
            x=j;
        }
    }
    printf("%lld\n",k);
    return 0;
}


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

bool flag = false;
void solve(int i, long long n, long long a, long long b, long long c, vector<string>& choices, string& arr)
{
    if(flag) return;
    else if(a<0 || b<0 || c<0) return;
    else if(i == n && a >= 0 && b >= 0 && c >= 0)
    {
        flag = true;
        cout << "Yes\n";
        for(auto x : arr) cout << x << "\n";
        return;
    }
    else
    {
        if(choices[i][0] == 'A' && choices[i][1] == 'B')
        {
            arr.push_back('A');
            solve(i+1,n,a+1,b-1,c,choices,arr);
            arr.pop_back();
            arr.push_back('B');
            solve(i+1,n,a-1,b+1,c,choices,arr);
            arr.pop_back();
        }
        else if(choices[i][0] == 'A' && choices[i][1] == 'C')
        {
            arr.push_back('A');
            solve(i+1,n,a+1,b,c-1,choices,arr);
            arr.pop_back();
            arr.push_back('C');
            solve(i+1,n,a-1,b,c+1,choices,arr);
            arr.pop_back();
        }
        else
        {
            arr.push_back('B');
            solve(i+1,n,a,b+1,c-1,choices,arr);
            arr.pop_back();
            arr.push_back('C');
            solve(i+1,n,a,b-1,c+1,choices,arr);
            arr.pop_back();
        }
    }
}

int main()
{
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    long long n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<string> choices;
    string s;
    for(int i=0; i<n; i++)
    {
        cin >> s;
        choices.push_back(s);
    }
    string arr;
    solve(0,n,a,b,c,choices,arr);
    if(!flag) cout << "No\n";
    return 0;
}

Measured memory_bytes: 18976
N = int(input())
s = []
ans = 0
x = dict()
for i in range(N):
    s.append(input())
    if s[i] in x:
        x[s[i]] += 1
    else:
        x[s[i]] = 1
M = int(input())
t = []
for i in range(M):
    t.append(input())
    if t[i] in x:
        x[t[i]] -= 1

for idx in x:
    ans = max(ans,x[idx])
print(ans)

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

using ll = long long;

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

    vector<string> s;
    for (int i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        s.push_back(tmp);
    }

    sort(s.begin(), s.end());

    s.push_back("");

    vector< pair<string, int> > res;
    int count = 0;
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] == s[i + 1]) {
            count++;
        } else {
            res.push_back(make_pair(s[i], count));
            count = 0;
        }
    }

    int maxCount = 0;
    for (int i = 0; i < res.size(); i++) {
        maxCount = max(res[i].second, maxCount);
    }

    for (int i = 0; i < res.size(); i++) {
        if (res[i].second == maxCount) {
            cout << res[i].first << endl;
        }
    }

    return 0;
}


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

const int INF = 0x3f3f3f3f;

int main()
{
	int x;
	cin >> x;
	int ans = x = 0;
	char c;
	while(cin >> c) {
		if(c == 'D') --x;
		else ++x;
		ans = max(x, ans);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define dbg(x)
#endif

#define ff first
#define ss second

int main(){
    std::ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vi arr(2 * n);
    for (int i = 0; i < 2 * n; i++) cin >> arr[i];
    sort(arr.begin(), arr.end());
    int res = 0;
    for (int i = 0; i < 2 * n; i += 2){
        res += arr[i];
    }
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 256
def bubble_sort(List):
	cnt=0
	l=len(List)
	for i in range(l):
		for j in range(l-1,i,-1):
			if List[j]<List[j-1]:
				temp=List[j]
				List[j]=List[j-1]
				List[j-1]=temp
				cnt+=1
	return cnt
def main():
	N=input()
	N_List=map(int,raw_input().split())
	cnt=bubble_sort(N_List)
	for k in range(len(N_List)):
		N_List[k]=str(N_List[k])
	print(" ".join(N_List))
	print(cnt)

if __name__=='__main__':
	main()

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

typedef long long ll;
//loop
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//STL
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

void Main() {
    string s;
    cin >> s;
    replace(ALL(s), ',', ' ');
    cout << s << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	Main();
	return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> a(M + 1), b(M + 1);
    vector<ll> c[M + 1];
    vector<bool> flag(N, false);
    for (int i = 1; i <= M; ++i)
    {
        cin >> a[i] >> b[i];
        REP(j, b[i])
        {
            int tmp;
            cin >> tmp;
            c[i].push_back(tmp);
        }
    }

    ll dp[(1 << N)];
    ll MAX = 1e9;
    REP(j, (1 << N)) dp[j] = MAX;
    dp[0] = 0;
    for (int i = 1; i <= M; ++i)
    {
        int now = 0;
        REPV(iter, c[i]) now = now | (1 << (*iter - 1));
        for (int j = 0; j <= (1 << N) - 1; ++j)
        {
            dp[j | now] = min(dp[j | now], dp[j] + a[i]);
        }
    }

    if (dp[(1 << N) - 1] == MAX) dp[(1 << N) - 1] = -1;
    cout << dp[(1 << N) - 1] << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
int n,k,t,a[100001],x,y,z;
int x_answer(int t,int n,int x)
{
	if ((t-k)%(k-1)==0) x+=(t-k)/(k-1);
	else x+=(t-k)/(k-1)+1;
	if ((n-t)%(k-1)==0) x+=(n-t)/(k-1);
	else x+=(n-t)/(k-1)+1;
	return x;
}
int z_answer(int t,int n,int z)
{
	if ((t-1)%(k-1)==0) z+=(t-1)/(k-1);
	else z+=(t-1)/(k-1)+1;
	if ((n-t-k+1)%(k-1)==0) z+=(n-t-k+1)/(k-1);
	else z+=(n-t-k+1)/(k-1)+1;
	return z;
}
int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		if (a[i]==1) t=i;
	}
	//cout<<min(x_answer(t,n,x),z_answer(t,n,z))+1;
	if ((n-k)%(k-1)==0) cout<<(n-k)/(k-1)+1;
	else cout<<(n-k)/(k-1)+2;
	//system("pause");
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

vector< pair<int, int> > graph[100010];
int vertex[100010];

void dfs(int before_index, int index, int len){
//    cerr << before_index << " " << index << " " << len <<endl;
    if(vertex[index] != 0) {
        return;
    }

    if(len%2==1){
        if(vertex[before_index] == 1){
            vertex[index] = 2;
        }else{
            vertex[index] = 1;
        }
    }else{
        vertex[index] = vertex[before_index];
    }
    for(auto d: graph[index]){
        dfs(index, d.second, d.first);
    }
}

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


    for(int i = 0; i < n-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        graph[u].push_back(make_pair(w, v));
        graph[v].push_back(make_pair(w, u));
    }

//    for(int i = 0; i < n; i++){
//        for(auto d: graph[i]){
//            cerr << d.first << " " << d.second << "  ";
//        }
//        cerr << endl;
//    }

    vertex[1] = 2;
    for(auto d: graph[1]){
        dfs(1, d.second, d.first);
    }
    for(int i = 1; i <= n; i++){
        cout << vertex[i]%2 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 7552