akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region mod
const int p = 1e9 + 7; //10^9 + 7
struct mint
{
    ll x;
    mint(ll x = 0) : x(x % p) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += p - a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= p;
        return *this;
    }

    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const
    {
        if (t == 0)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    mint inv() const
    {
        return pow(p - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
};

struct comb
{
    vector<mint> fact, invs;
    comb(int n) : fact(n + 1), invs(n + 1)
    {
        assert(n < p);

        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;

        invs[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            invs[i - 1] = invs[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * invs[n - k] * invs[k];
    }
};
#pragma endregion

int main()
{
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    int x = r2 - r1, y = c2 - c1;
    comb c(r2 + c2 + 2);
    mint ans = 0;
    rep(i, x + 1)
    {
        ans += c(r2 - i + c2 + 1, r2 - i + 1);
        ans -= c(r2 - i + c1, r2 - i + 1);
    }
    cout << ans.x << endl;

    return 0;
}

Measured memory_bytes: 31488
#include<stdio.h>

int main(void)
{
  int flag=0;
  int A,B,C,D;
  
  scanf("%d %d %d %d",&A,&B,&C,&D);
  
  while(A>0)
  {
    C=C-B;
    if(C<=0){
      flag=1;
      break;
    }
    A=A-D;
  }
  if(flag)
    printf("Yes");
  else
    printf("No");
  
  return 0;
}

Measured memory_bytes: 1732
#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, K;
  cin >> N >> K;

  vector<int> P(N);
  rep(i, N) cin >> P[i];
  sort(P.begin(), P.end());

  int ans = 0;
  rep(i, K) ans += P[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            var ret = false;
            
            for (int i = T.Length - 1; i >= 0; i--)
            {
                var take = T.Substring(T.Length - 1, 1);
                T = T.Substring(0, T.Length - 1);
                T = T.Insert(0, take);
                if (S == T)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long int

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

int main(void)
{
  ll a, b;
  scanf("%lld %lld", &a, &b);

  ll an = (a * b) / gcd(a, b);
  printf("%lld\n", an);
  return 0;
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li n,x,t;

    cin>>n>>x>>t;

    cout<<((n+x-1)/x)*t;
}

int main()
{    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
using namespace std;

#define int long long

signed main() {
    int n, k; cin >> n >> k;
    int ans = k * pow(k - 1, n - 1);
    cout << ans << endl;
}


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

int main(){
  int n,i;
  cin>>n;
  double a[n],kotae=0;
  for(i=0;i<n;i++){
    cin>>a[i];
    kotae+=1/a[i];
  }
  cout<<1/kotae;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,q,a) for(long long i=q; i<a; i++)
#define ll long long
#define pb push_back
#define mod 1000000007
#define oo 666666666666666
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll n;
    cin>>n;
    ll dp[n+1]={};
    ll pref[n+1]={};
    if(n<3)cout<<0<<endl;
    else
    {
        f(i,3,n+1)
        {
            pref[i]=(pref[i-1]+dp[i-3])%mod;
            dp[i]=(pref[i]+1)%mod;
        }
        cout<<dp[n]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mset(x, y) memset((x), (y), sizeof(x))
#define sz(x) ((int)(x).size())
#define rep(i, a, b) for(i = a; i < b; i++)
#define per(i, a, b) for(i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define cerr cout
#define endl '\n'
using namespace std;

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ld eps = 1e-7;
const ll mod = 1000000007;
const ll N = 998244353;

ll binpow(ll b, ll p){ ll ans = 1; while(p > 0){if(p & 1) ans = (ans * b) % mod; b = (b * b) % mod; p >>= 1;}return ans;}
ll modinv(ll x){return binpow(x, mod - 2);}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, i, j, k;
	cin >> n;
	vl a(n);
	ll ans = 0;
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n)
	{
		rep(j, i + 1, n)
		{
			rep(k, j + 1, n)
			{
				if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k] && a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i])
					ans++;
			}
		}
	}
	cout << ans;
}

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



int main(){
    string s;
    cin>>s;
    string mae1="",usiro1="",mae2="",usiro2="",all_usiro="";

    bool ans=true;


    

    for(int i=0;i<s.size()/2;i++){
        mae1.push_back(s[i]);
    }

    for(int i=((s.size()+3)/2)-1;i<s.size();i++){
        mae2.push_back(s[i]);
    }

 for(int i=0;i<s.size();i++){
        all_usiro.push_back(s[i]);
    }

    reverse(s.begin(),s.end());
    
  
    if(s!=all_usiro)ans=false;
      for(int i=0;i<s.size()/2;i++){
        usiro1.push_back(mae1[i]);
    }
   reverse(mae1.begin(),mae1.end());

    if(mae1!=usiro1)ans=false;
   for(int i=0;i<mae2.size();i++){
        usiro2.push_back(mae2[i]);
    }
     reverse(mae2.begin(),mae2.end());
  
    if(mae2!=usiro2)ans=false;


    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    

  

}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a;
    int b;
    int c;
    cin >> a >> b >> c;
    int point = 3;
    if(a == b){
        point -= 1;
    }
    if(b == c){
        point -= 1;
    }
    if(c == a){
        point -= 1;
    }
    if(point == 0){
        point = 1;
    }
    cout << point << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
  n = int(input())
  a = list(map(int, input().split()))
  d = [0]*n
  for i in range(n):
    if i+a[i] < n: d[i+a[i]] += 1
  ans = 0
  for i in range(n):
    if i-a[i] >= 0: ans += d[i-a[i]]
  print(ans)
main()

Measured memory_bytes: 32248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 4000010
#define md 1000000007

ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
/*inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}*/
void dfs(int s,int par,bool vis[],vll v[]){
	if(vis[s])return ;
	vis[s]=1;
	for(int i=0;i<v[s].size();i++){
		int u=v[s][i];
		if(u!=par&&!vis[u])
		dfs(u,s,vis,v);
	}
}


int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	vll v[n+1];
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	bool vis[n+1];int q=0;
	mem(vis,false);
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			q++;
			dfs(i,i,vis,v);
		}	
	}
	cout<<q-1<<endl;
}



Measured memory_bytes: 11224
import sys

def main():
    _,S = open(0).read().split()
    s1 = S[:int(len(S)*3/4)+1]

    maxLen = 0
    lenS1 = len(s1)
    for i in range(lenS1):
        for j in range(i+1+maxLen,lenS1):
            # print(s1[i:j], S[j:], j,i)
            if len(s1[i:j]) > len(S[j:]):
                break
            if s1[i:j] in S[j:]:
                maxLen = j-i
            else:
                break

    print(maxLen)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.util.*;class Main{public static void main(String[]g){int n[]=new int[5],i;for(Scanner S=new Scanner(System.in);S.hasNext();){for(i=0;i<5;)n[i++]=S.nextInt();for(Arrays.sort(n);i-->0;)System.out.print(n[i]+(1>i?"\n":" "));}}}


Measured memory_bytes: 26280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

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

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a >= 13) {
			out.println(b);
		}else if(a >= 6 && a <= 12){
			out.println(b/2);
		}else{
			out.println(0);
		}
 	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
	
	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 20308
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

N, M = map(int,input().split())
UFT = UnionFind(N)
bridges = []
for _ in range(M):
    A, B = map(int,input().split())
    bridges.append((A-1, B-1))
bridges.reverse()

ans = [N * (N-1) // 2]
for i in range(M-1):
    temp = ans[-1]
    A, B = bridges[i]
    if not UFT.same(A, B):
        temp -= UFT.size(A) * UFT.size(B)
        UFT.union(A, B)
    ans.append(temp)

ans.reverse()
for a in ans:
    print(a)

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

int main() {
	
	int a,b ;
	cin >> a >> b ;
	int temp  = 1 ;
	int ans = 0;
	
	while(temp < b)
	{
		temp += (a-1) ;
		ans++ ;
	}
	
	cout << ans ;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1000000000
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 100001

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
int N, A[MAX_N];
int c[MAX_N];

int solve()
{
  int ans = 1;

  if (N % 2 == 0) {
    for (int i = 0; i < N; i++) {
      if (i % 2 == 0) {
        if (c[i] != 0) return -1;
      } else {
        if (c[i] != 2) return -1;
        else ans = mod(ans * 2);
      }
    }
  } else {
    if (c[0] != 1) return -1;
    for (int i = 1; i < N; i++) {
      if (i % 2 == 0) {
        if (c[i] != 2) return -1;
        else ans = mod(ans * 2);
      } else {
        if (c[i] != 0) return -1;
      }
    }
  }
  return ans;
}

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

  for (int i = 0; i < N; i++) {
    c[A[i]]++;
  }

  int ans = solve();

  if (ans == -1) {
    cout << 0 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin>>n;
  	vector<int> d(110);
  	rep(i,0,n-1)cin>>d[i];
  	int ans = 0;
  	rep(i,0,n-2)rep(j,i+1,n-1)ans+=d[i]*d[j];
  	cout<<ans<<endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef pair<double, double> dd;
const double PI = acos(-1);
dd getCoord(double x, double ang){
	return {x *cos(2*PI*ang), x*sin(2*PI*ang)};
}
int main(){
	cout<<fixed<<setprecision(10);
	double eps=1e-10;
	double a,b,h,m; cin>>a>>b>>h>>m;
	double hour = (h*60.0+m)/(12.0*60.0);
	double minute = m / 60.0;
	dd hc = getCoord(a,hour);
	dd mc = getCoord(b,minute);
	double dx = hc.first - mc.first;
	double dy= hc.second - mc.second;
	cout<<sqrt((dx*dx)+(dy*dy))<<endl;
	return 0;
}

Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    ll mod = 1e9+7;
    ll n;
    cin >> n;

    ll tot = 1;
    for(int i = 0; i < n; i++){
        tot = (tot * 10) % mod;
        tot = tot % mod;
    }
    //cout << "tot: " << tot << endl;
    
    ll no0 = 1;
    for(int i = 0; i < n; i++){
        no0 = (no0 * 9) % mod;
        no0 = no0 % mod;
    }
    
    //cout << "no0: " << no0 << endl;
    
    ll no09 = 1;
    for(int i = 0; i < n; i++){
        no09 = (no09 * 8) % mod;
        no09 = no09 % mod;
    }
    
    ll a = (no0 * 2) % mod;
    a = a % mod;
    ll b = (a - no09) % mod;
    b = b % mod;
    if(b < 0) b += 1e9+7;
    ll ans = (tot - b) % mod;
    ans = ans % mod;
    if(ans < 0) ans += 1e9+7;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s = ":(";
  int n; cin >> n;
  for(int i = 0; i < 60000; ++i){
    if((int)((double)i * 1.08) == n){
      s = to_string(i);
      break;
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
//#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}

ll calc(ll x) {
    return x * x * x * x * x;
}

int main(void) {
    FAST_IO;
    
    ll x;
    cin >> x;
    int flag = 0;
    for (int i = -200; i <= 200; i++) {
        for (int j = -200; j <= 200; j++) {
            if (calc(i) - calc(j) == x) {
                cout << i << " " << j << endl;
                flag = 1;
                break;
            }
        }
        if (flag) break;
    }
    
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>

using namespace std;

int main() {
  int n,m,t[200],p[200],x[200],sum = 0;
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> t[i];
    sum += t[i];
  }
  cin >> m;
  for(int i = 0; i < m; i++) 
    cin >> p[i] >> x[i];

  int z[200];
  for(int i = 0; i < m; i++) {
    z[i] = sum - t[p[i]-1] + x[i];
    cout << z[i] << endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,m; cin >> n >> m;
    int c; cin >> c;
    VI b(m); VIin(b);
    int ans = 0;
    rep(i,n){
        int sum = c;
        VI a(m); VIin(a);
        rep(j,m){
            sum += a[j] * b[j]; 
        }
        if(sum > 0) ans++;
    }
    ANS;

    return 0;
}

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

int main(){
	ios::sync_with_stdio(0);
	multiset < int > arr; int N; cin >> N;
	for(int i = 1 ; i <= N ; ++i){
		int a; cin >> a;
		auto t = arr.lower_bound(a);
		if(t != arr.begin()) arr.erase(--t);
		arr.insert(a);
	}
	cout << arr.size();
	return 0;
}


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

int main()
{
    string S, T;
    cin >> S >> T;

    map<char, char> m;
    vector<bool> used('z' + 1, false);
    for (unsigned int i = 0; i < S.size(); i++)
    {
        char Si = S.at(i), Ti = T.at(i);
        if (m.count(Si) > 0)
        {
            char Tj = m.at(Si);
            if (Ti != Tj)
            {
                cout << "No" << endl;
                return 0;
            }
        }
        else
        {
            if (used.at(Ti))
            {
                cout << "No" << endl;
                return 0;
            }
            m[Si] = Ti;
            used.at(Ti) = true;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mt make_tuple
#define mp make_pair
#define hell 1000000007
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();
#define g(a,b) get<a>(b)
#define vt(a) vector<a>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repi(i,a,b) for(ll i=b-1;i>=a;i--)
#define fi first
#define se second

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//to delete an element
//s.erase(s.find_by_order(s.order_of_key(ele)));
//where s is the name of the ordered_set
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef MY_PROJECT
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    IOS
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    ll ntc=1;
    //cin>>ntc;
    rep(tc,1,ntc+1)
    {
        //cout<<"Case #"<<tc<<": ";
        ll n;
        cin>>n;
        ll minuss=0;
        for(int i=0;i<n-1;i++)
        {
            ll u,v;
            cin>>u>>v;
            if(u>v)
                swap(u,v);
            minuss=minuss+u*(n-v+1);
        }
        ll tot=0;
        for(ll i=1;i<=n;i++)
        {
            tot=tot+i*(n-i+1);
        }
        tot=tot-minuss;
        cout<<tot;
    }
    return 0;
}


Measured memory_bytes: 3648
s=[input() for i in range(3)]
l=[len(s[i]) for i in range(3)]
abc=[0,0,0]
now=0
while abc[now]!=l[now]:
    s_sub=s[now][abc[now]]
    abc[now]+=1
    now=(0 if s_sub=="a" else 1 if s_sub=="b" else 2)
print("A" if now==0 else "B" if now==1 else "C")

Measured memory_bytes: 3064
#include <stdio.h>

#define FOUND_1 0x01
#define FOUND_4 0x02
#define FOUND_7 0x04
#define FOUND_9 0x08
#define FOUND_ALL (FOUND_1|FOUND_4|FOUND_7|FOUND_9)

int main()
{
	int input[4];
	int flag = 0x00;

	if (scanf("%d %d %d %d", &input[0], &input[1], &input[2], &input[3]) == EOF)
	{
		return 0;
	}

	for (int i = 0; i < 4; i++)
	{
		if (input[i] == 1)
		{
			flag |= FOUND_1;
		}
		if (input[i] == 4)
		{
			flag |= FOUND_4;
		}
		if (input[i] == 7)
		{
			flag |= FOUND_7;
		}
		if (input[i] == 9)
		{
			flag |= FOUND_9;
		}
	}

	if (flag == FOUND_ALL)
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 128
def r(k):
    if k == -1:
        return 0, 0
    if k == 0:
        return 0, 1
    else:
        low, high = r(k - 1)
        d = pow(-2, k)
        if d < 0:
            return low + d, high
        else:
            return low, high + d


def solve(N):
    if N == 0:
        return "0"
    ar = []
    for k in range(50, -1, -1):
        low1, high1 = r(k - 1)
        low2, high2 = r(k)
        if not (low1 <= N <= high1) and low2 <= N <= high2:
            ar.append("1")
            N -= pow(-2, k)
        else:
            ar.append("0")
    ans = "".join(ar)
    ans = ans[ans.find("1"):]
    return ans


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


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;

int N, K;
bitset<10> use;

int dfs(int d = 0, int now = 0)
{
	if (d == 6 || now >= N)
	{
		return (now >= N ? now : INT_MAX);
	}
	int res = INT_MAX;
	for (int i = 0; i < 10; i++)
	{
		if (!use[i]) continue;
		res = min(res, dfs(d + 1, now * 10 + i));
	}
	return res;
}

void solve()
{
	cin >> N >> K;
	for (int k = 0; k < K; k++)
	{
		int x; cin >> x;
		use[x % 10] = 1;
	}
	use.flip();
	cout << dfs() << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())
ls = ["3", "5", "7"]
cnt = 0
for i in range(3, len(str(n)) + 1):
    for j in itertools.product(ls, repeat=i):
        if "3" in j and "5" in j and "7" in j:
            t = ""
            for k in j:
                t += k
            if 1 <= int(t) <= n:
                cnt += 1
print(cnt)


Measured memory_bytes: 41964
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=1e4+5;

int main(){
	lli N;
	cin>>N;
	lli a[MAX], b[MAX];
	rep(i,N)cin>>a[i];
	rep(i,N)cin>>b[i];
	
	lli s[MAX],t[MAX];
	rep(i,N){
		if(a[i]>=b[i]){
			s[i]=0;
			t[i]=a[i]-b[i];
		}
		else if((b[i]-a[i])%2==0){
			s[i]=(b[i]-a[i])/2;
			t[i]=0;
		}
		else{
			s[i]=(b[i]+1-a[i])/2;
			t[i]=1;
		}
	}
	lli asum=0,bsum=0,ssum=0,tsum=0;
	rep(i,N){
		asum+=a[i];
		bsum+=b[i];
		ssum+=s[i];
		tsum+=t[i];
	}
	lli count=bsum-asum;
	if(count>=ssum&&count>=tsum)cout<<"Yes";
	else cout<<"No";
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; i++) cin >> B.at(i);

  int ans = 0;

  int A;
  for (int i = 0; i < N; i++) {
    int sum;
    for (int j = 0; j < M; j++) {
      cin >> A;
      sum += A * B.at(j);
    }
    if (sum + C > 0) ans++;
    sum = 0;
  }

  cout << ans << endl;
}

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

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

  int n, k, x, y;
  cin >> n >> k >> x >> y;

  int ans = 0;
  ans += x * min(n, k);
  ans += max(0, y * (n - k));

  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
#include<cmath>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;







int main(){
	int N,K; cin >> N >> K;
	ll ans = 0;
	repr(b,1,N+1){
		int p = N/b;
		int r = N%b;
		ans += (ll)max(b-K,0)*(ll)p + max(r-K+1,0);
	}
	if(K == 0) ans -= N;
	cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

//Union_Find (with Potential)
const ll int_max = 1e18;
const ll max_n = 1000005;
ll ufpar[max_n], ufrank[max_n], ufnum[max_n], ufpot[max_n];
//初期化忘れるな！
void init(ll n){
	rep(ii,0,n){
		ufpar[ii] = ii;
		ufrank[ii] = 0;
		ufnum[ii] = 1;
		ufpot[ii] = 0;
	}
}
ll ufind(ll x){
	if(ufpar[x] == x) {
		return x;
	} else {
		ll umm = ufind(ufpar[x]);
		ufpot[x] += ufpot[ufpar[x]];
		return ufpar[x] = umm;
	}
}
ll weight(ll x){
	ufind(x);
	return ufpot[x];
}
//ポテンシャルを y - x = w に
bool unite(ll x, ll y, ll w){
	w += weight(x);
	w += weight(y);
	x = ufind(x);
	y = ufind(y);
	if(x == y) return false;
	if(ufrank[x] < ufrank[y])
		swap(x,y), w = -w;
	if(ufrank[x] == ufrank[y]) ufrank[y]++;
	ufpar[y] = x;
	ufnum[x] += ufnum[y];
	ufnum[y] = 0;
	ufpot[y] = w;
	return true;
}
//xとyを含む連結成分を併合
void unite(ll x, ll y){ unite(x, y, 0); }
//xとyが同じ連結成分か
bool usame(ll x, ll y){
	return ufind(x) == ufind(y);
}
//xを含む連結成分のサイズ
ll usz(ll x){
	return ufnum[ufind(x)];
}
//y-x ポテンシャルの差
ll udiff(ll x, ll y){
	if(!usame(x, y)) return int_max;
	return ufpot[y] - ufpot[x];
}

int main() {
    // your code goes here
    ll n,m,cn[200005]={0},ans=0;
    cin >> n >> m;
    init(n);
    rep(i,1,m){
        ll a,b;
        cin >> a >> b;
        unite(a,b);
    }
    rep(i,1,n){
        cn[ufind(i)]++;
    }
    rep(i,1,n){
        chmax(ans,cn[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11452
#!/usr/bin/env python

def GCD(x,y):
    while y!=0:
        tmp=y
        y=x%y
        x=tmp
    return x

if __name__ == "__main__":
    x,y=list(map(int,input().split()))
    if x<y:
        tmp=x
        x=y
        y=tmp
    print(GCD(x,y))

Measured memory_bytes: 6724
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  int n = s.length();
  int ans = 1;
  int flag = 1;
  for(int i=1;i<n;i++){
      
      if(i == n - 2 && s[i] == s[i + 1]){
          ans++;
          break;
      }
      else if(s[i] == s[i - 1] && flag == 1){
        i++;
        flag = 0;
        ans++;
    }
    else{
        ans++;
        flag = 1;
    }
  }
  
  if(n == 2 && s[0] == s[1]){
      cout << 1 << endl;
  }
  else{
  cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
use std::vec::Vec;
use std::collections::VecDeque;

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


fn bfs(n: usize, root: usize, to: &Vec<Vec<(usize, i64)>>) -> Vec<i64> {
  // n is number of node
  // root is start node
  // res is legth of root
  let mut res = vec![-1; n];

  let mut q: VecDeque<usize> = VecDeque::new();
  q.push_back(root);
  res[root] = 0;

  while !q.is_empty() {
    let a: usize = match q.pop_front() {
      Some(i) => i,
      None => 1,
    };
    for &(i, w) in &to[a] {
      if res[i] != -1 {
        continue;
      }
      else {
        res[i] = (res[a] + w) % 2;
        q.push_back(i);
      }
    }
  }
  return res;
}


fn main() {
    let n: usize = read();
    let mut to: Vec<Vec<(usize, i64)>> = vec![Vec::new(); n];
    for _ in 0..n-1 {
      let a: Vec<usize> = read_vec();
      to[a[0] - 1].push((a[1] - 1, a[2] as i64));
      to[a[1] - 1].push((a[0] - 1, a[2] as i64));
    }
    let v: Vec<i64> = bfs(n, 0, &to);

    for e in v {
      println!("{}", e);
    }

}


Measured memory_bytes: 14716
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1132&lang=jp
// 解説AC（http://www.deqnotes.net/acmicpc/1981/）
// ICPC:国内予選2004D
// Circle and Points


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;
using pdd = pair<double, double>;

double my_dist(pdd a, pdd b){
  return (a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n;
  while(cin >> n, n){
    vector<pdd> points(n);
    for(pdd &i: points) cin >> i.first >> i.second;
    int ans = 0;
    for(int i = 0; i < n; i++){
      for(int j = i+1; j < n; j++){
        double mid_dist = my_dist(points[i], points[j]);
        if(mid_dist > 4.0) continue;
        int cnt = 0; double x, y;
        pdd mid = {(points[i].first+points[j].first)/2.0, (points[i].second+points[j].second)/2.0};
        double alpha, beta, a, b, c;
        alpha = (points[i].second - points[j].second) / (points[j].first - points[i].first);
        beta = mid.first - alpha * mid.second;
        a = alpha * alpha + 1.0;
        b = 2.0 * (alpha * beta - alpha * points[i].first - points[i].second);
        c = (beta - points[i].first) * (beta - points[i].first) + points[i].second*points[i].second - 1.0;
        y = (-b + sqrt(b*b - 4 * a * c)) / (2.0 * a);
        x = alpha * y + beta;
        for(int k = 0; k < n; k++){
          if(my_dist({x, y}, points[k]) <= 1.0001) cnt++;
        }
        ans = max(ans, cnt);
        cnt = 0;
        // x = mid.first - sqrt(c_m_dist/(1.0 + alpha * alpha));
        // y = mid.second - alpha * sqrt(c_m_dist / (1.0 + alpha * alpha));
        y = (-b - sqrt(b*b - 4 * a * c)) / (2.0 * a);
        x = alpha * y + beta;
        for(int k = 0; k < n; k++){
          if(my_dist({x, y}, points[k]) <= 1.0001) cnt++;
        }
        ans = max(ans, cnt);
      }
    }
    cout << max(1, ans) << endl;
  }
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



Measured memory_bytes: 3196
#include <stdio.h>

int main(void) {
	char S[100];
	scanf("%s", S);
	int a = S[0] - '0';
	int b = S[1] - '0';
	a = 10 * a + b;
	b = S[2] - '0';
	a = 10 * a + b;
	b = S[3] - '0';
	a = 10 * a + b;

		int A = a / 100 * 100;
		if (A > 1200) {
			if (a - A > 0 && a - A < 13)printf("YYMM\n");
			else printf("NA\n");
		}
		else if (A > 0) {
			if (a - A > 0 && a - A < 13)printf("AMBIGUOUS\n");
			else printf("MMYY\n");
		}
		else if (A == 0 && a - A > 0 && a - A < 13)printf("YYMM\n");
		else printf("NA\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, k;
	string s;
	cin >> n >> s >> k;
	k--;

	for (int i = 0; i < n; i++) {
		if (s[i] != s[k]) {
			s[i] = '*';
		}
	}

	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
using namespace std;

int f[10][10];
int n,ans;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x=i;
		while(x>=10)x/=10;
		f[x][i%10]++;
	}
	for(int j=1;j<=n;j++)
	{
		int x=j;
		while(x>=10)x/=10;
		ans+=f[j%10][x];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
ans = 2018
for x in range(L, min(R, L+2019)):
    for y in range(L+1, min(R+1, L+2019)):
        ans = min(ans, (x*y)%2019)
        if ans == 0:
            print(0)
            quit()
print(ans)

Measured memory_bytes: 3060
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 long long int cnt(int kk,int a,int m)
 {
   long long int step=0;
   do
   {
     kk=(kk*a)%m;
     step++;          
   }while(kk!=1);
   return step;    
 }
 
 long long int gcd(int a,int b)
 {
   return b==0 ? a:gcd(b,a%b);     
 }
 
 long long int lcm(int a,int b)
 {
   return a/gcd(a,b)*b;       
 }
 
 int main()
 {
   int a1,m1,a2,m2,a3,m3;
   while(cin>>a1>>m1>>a2>>m2>>a3>>m3)
   {
     int step;
     long long int step_final;
     if(a1==0&&a2==0&&a3==0&&m1==0&&m2==0&&m3==0) break;
     else
     {
       int x=1;
       int y=1;
       int z=1;
       long long int step_x=cnt(x,a1,m1);
       long long int step_y=cnt(y,a2,m2);
       long long int step_z=cnt(z,a3,m3);
       step_final=lcm(step_x,lcm(step_y,step_z));      
     }                         
     cout<<step_final<<endl;         
   }
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3000
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[int(2e5)+1]={0};
	set<int> s;
	for(int i = 0,j; i<n; i++)
	{
		cin>>j;
		a[j]++;
		s.insert(j);
	}
	int ans = 0;
	if(s.size()>k)
	{
		set<ar<int,2> > g;
		for(int i = 1; i<200001; i++)
			if(a[i])
				g.insert({a[i],i});
		while(g.size()>k)
		{
			auto y = *g.begin();
			g.erase(y);
			ans += y[0];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19840
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
flg=False
if x in a and y in a:
  flg=True
elif x in b and y in b:
  flg=True
elif x==2 and y==2:
  flg=True
print("Yes" if flg else "No")  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<=9&&b<=9){
    cout<<a*b<<endl;
  }else{
    cout<<-1<<endl;
  }
 
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int N, X, Y;
vector<int> dist, ans;
Graph G(N);
void bfs(int n) {
    queue<int> que;
    que.push(n);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto nv : G[v]) {
            if (dist[nv] != -1) {
                continue;
            }

            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
}

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

    G.assign(N + 1, vector<int>{});
    G[X].push_back(Y);
    G[Y].push_back(X);
    for (int i = 1; i <= N - 1; i++) {
        G[i].push_back(i + 1);
        G[i + 1].push_back(i);
    }

    ans.assign(N + 1, 0);
    dist.assign(N + 1, -1);
    for (int v = 1; v <= N; v++) {
        dist.assign(N + 1, -1);
        dist[v] = 0;
        bfs(v);
        for (int k = 1; k <= N; k++) {
            ans[dist[k]]++;
        }
    }

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

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

namespace AtTest.ABC_150
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            string s = Read();
            s = s.Replace("ABC", "a");
            WriteLine((n - s.Length) / 2);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const mod = 10^^9 + 7;

long calc(string s) {
    auto dp = new long[][](s.length + 1, 4);
    dp[0][0] = 1;

    for (int i = 1; i <= s.length; i++) {
        long factor = s[i-1] == '?' ? 3 : 1;
        for (int j = 0; j <= 3; j++) {
            dp[i][j] = (dp[i-1][j] * factor) % mod;
        }

        auto c = s[i-1];
        if (c == 'A' || c == '?')
            dp[i][1] = (dp[i][1] + dp[i-1][0]) % mod;
        if (c == 'B' || c == '?')
            dp[i][2] = (dp[i][2] + dp[i-1][1]) % mod;
        if (c == 'C' || c == '?')
            dp[i][3] = (dp[i][3] + dp[i-1][2]) % mod;
    }

    return dp[s.length][3];
}

void main() {
    string s = read!string;
    writeln(calc(s));
}


Measured memory_bytes: 11928
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, K, P[200000] = {}, cnt = 0, box = 0;
set<ll> s;
bool flag = false;

int main() {
	cin >> N >> K;
	ll ans = N - K + 1;
	rep(i, N) {
		cin >> P[i];
		if (i > 0) {
			if (P[i] > P[i - 1]) {
				cnt++;
				if (cnt >= K - 1 && !flag) {
					box++;
					flag = true;
				}
			}
			else {
				cnt = 0;
				flag = false;
			}
		}
		if (i >= K) {
			auto it1 = s.begin();
			auto it2 = s.end();
			it2--;
			if (*it1 > P[i - K] && *it2 < P[i])ans--;
			s.erase(P[i - K + 1]);
		}
		if (i > 0)s.insert(P[i]);
	}
	ans -= max((ll)0,box - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136