akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
  
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(int a, int m)
{
    int g = gcd(a, m);
   
    {
        // If a and m are relatively prime, then modulo inverse
        // is a^(m-2) mode m
      
             return power(a, m-2, m);
    }
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
//void spf(ll num)
//{
//    fore(i,0,num+1)arr[i]=i;
//    for(ll i=2;i<=num;i+=2)
//    {
//        arr[i]=2;
//    }
//    for(ll i=3;i<=num;i+=2)
//    {
//        if(arr[i]==i)
//        for(ll j=i;j<=num;j+=i)
//        {
//           if(arr[j]==j) arr[j]=i;
//        }
//    }
//}

 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    ll n,k;cin>>n>>k;
    ll a[1000005]={0};
    fore(i,0,n)cin>>a[i];
    sort(a,a+n);
    ll plus=0,minus=0;
    ll fac[1000006];
    fac[1]=fac[0]=1;
    for(ll i=2;i<1000005;i++)
    {
        fac[i]=(fac[i-1]*i)%MOD;
    }
    
    
    for(ll i=k-1;i<n;i++)
    {
        plus += (((((fac[i]*modInverse(fac[k-1],MOD))%MOD)*(modInverse(fac[i-(k-1)],MOD)))%MOD)*a[i])%MOD;
        plus%=MOD;
    }
    for(ll i=n-k;i>=0;i--)
    {
        
        minus += (((((fac[n-i-1]*modInverse(fac[k-1],MOD))%MOD)*(modInverse(fac[n-i-(k)],MOD)))%MOD)*a[i])%MOD;
        minus%=MOD;
       // cout<<((((fac[n-i]*modInverse(fac[k-1],MOD))%MOD)*(modInverse(fac[n-i-(k-1)],MOD)))%MOD)<<endl;
     //   cout<<a[i]<<endl;
    }
    cout<<(plus-minus)%MOD<<endl;
    return 0;
    }


Measured memory_bytes: 15872
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define LLIandI pair<long long int , int>
#define ll long long

ll int N,L;
ll int a[100003];
int main(){
    scanf("%lld %lld",&N,&L);
    ll int maxa=0;
    ll int maxi=0;
    rep(i,N){
        scanf("%lld",&a[i]);
        if(i>0&&a[i]+a[i-1]>maxa){
            maxa=a[i]+a[i-1];maxi=i-1;
        }
    }
    if(maxa<L){
        printf("Impossible\n");
        return 0;
    }
    printf("Possible\n");
    rep(i,N-1){
        if(i<maxi)printf("%d\n",i+1);
        if(i>=maxi)printf("%d\n",N-1-i+maxi);
    }
}


Measured memory_bytes: 1536
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def main():
    a = int(input())
    b = int(input())
    h = int(input())
    print(int((a+b)*h/2))
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 38892
#include<iostream>
using namespace std;
void swap(int& a, int& b) {
  int t = a;
  a = b;
  b = t;
}
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b) swap(a ,b);
  cout << (a < c && c < b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#132
N,K = map(int, input().split())
MOD_BY = 7 + 10**9

##############################################
#https://tane-no-blog.com/976/
mod = pow(10, 9) + 7

def comb(N, x):
    #n*(n-1)*…*(n-1+1)を計算
    numerator = 1
    for i in range(N-x+1, N+1):
        numerator = numerator * i % mod
        
    #a!を計算
    denominator = 1
    for j in range(1, x+1):
        denominator = denominator * j % mod
        
    #最後の項 a!**((10**9+7)-2)を計算
    d = pow(denominator, mod-2, mod)
    return numerator * d
##############################################

ans = 0

for i in range(1,K+1):
    #青球のグループ分けの個数
    #(K-1)C(i-1)
    #bxbxbxbxbxbxb …xから分割数-1を選ぶ
    
    #赤玉への挿入箇所の個数
    #(N-K+1)C(i)
    #xrxrxrxrxrx …xから分割数分を選ぶ
    ans = comb(K-1,i-1)*comb(N-K+1,i)%MOD_BY
    print(ans) 

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main(){
    fast;
    int h,w;
    cin>>h>>w;
    char ans[h][w];
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>ans[i][j];
    int arr[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
           arr[i][j]=0;
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++){
            if(ans[i][j]=='#'){
                if(i-1>=0)
                {
                    arr[i-1][j]++;
                    if(j+1<w)
                        arr[i-1][j+1]++;
                    if(j-1>=0)
                        arr[i-1][j-1]++;
                }
                if(j-1>=0)
                    arr[i][j-1]++;
                if(i+1<h)
                {
                    arr[i+1][j]++;
                    if(j+1<w)
                        arr[i+1][j+1]++;
                    if(j-1>=0)
                        arr[i+1][j-1]++;
                }
                if(j+1<w)
                    arr[i][j+1]++;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
        	if(ans[i][j]=='.')
	            cout<<arr[i][j];
	        else
	        	cout<<'#';
            cout<<endl;
    }
    

    return 0;
}


Measured memory_bytes: 3644
import Control.Monad

main :: IO ()
main = do
  mn <- getLine
  if mn == "0 0"
    then return ()
    else do
      let ls = map read $ words mn
      putStrLn $ solve ls
      main

solve :: [Int] -> String
solve [m,n] = toStr (gojohou ((max m n),(min m n),0))
  where
    gojohou :: (Int,Int,Int) -> (Int,Int,Int)
    gojohou (ma,mi,c)
      | r == 0 = (mi,r,c+1)
      | otherwise = gojohou (mi,r,c+1)
      where
        r = ma `mod` mi
    toStr :: (Int,Int,Int) -> String
    toStr (i,_,c) = (show i) ++ " " ++ (show c)

Measured memory_bytes: 4056
N, K = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map {|i| i.to_i - 1 }

idx = 0

m = { 0 => 0 }

ans = nil

(1..K).each do |i|
  idx = A[idx]

  if m[idx]
    c = i - m[idx]
    r = K - i
    ans = m.keys[m[idx]..-1][r % c]
    break
  end

  m[idx] = i
end

if ans
  puts ans + 1
else
  puts idx + 1
end


Measured memory_bytes: 38140
#include <iostream>

using namespace std;

int main()
{
    int s[200002];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
     int min=s[0];
     int ans=0;
     for(int i=0;i<n;i++)
     {
         if(s[i]<=min)
         {
             ans++;
             min=s[i];
         }
     }
     cout<<ans;
}


Measured memory_bytes: 1024
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }

template<class T>
class UnDirectedGraph {
public:
	class Edge {
	public:
		int to;
		T cost;

		Edge(int t, T c) : to(t), cost(c) {}

		bool operator<(const Edge& right) const {
			return cost == right.cost ? to < right.to : cost < right.cost;
		}
	};

	vector<vector<Edge>> G;
	int V;

	UnDirectedGraph(int n = 0) {
		resize(n);
	}

	void resize(int n) {
		V = n;
		G.resize(n);
	}

	void addEdge(int from, int to, T cost = 0) {
		int v = max(from, to);
		if (v >= V)
			resize(v + 1);
		G[from].push_back(Edge(to, cost));
		G[to].push_back(Edge(from, cost));
	}

	vector<int> visit;
	int col = 0;
	void dfs(int s) {
		//vector<int> visit(V);
		visit.resize(V);
		col++;
		calcDfs(visit, s);
	}

	void calcDfs(vector<int>& visit, int s) {
		if (visit[s])
			return;

		//visit[s] = 1;
		visit[s] = col;
		for (int i = 0; i < G[s].size(); ++i) {
			calcDfs(visit, G[s][i].to);
		}
	}

	vector<int> bfs(int s) {
		vector<int> dist(V);
		queue<int> que;

		fill(dist.begin(), dist.end(), -1);
		dist[s] = 0;
		que.push(s);
		while (!que.empty()) {
			int from = que.front();
			que.pop();
			for (int i = 0; i < G[from].size(); ++i) {
				int to = G[from][i].to;
				if (dist[to] != -1)
					continue;
				dist[to] = dist[from] + 1;
				que.push(to);
			}
		}

		return dist;
	}
};

int main() {
	int n, m, from, to;
	cin >> n >> m;
	UnDirectedGraph<int> g(n);
	while (m--) {
		cin >> from >> to;
		g.addEdge(from, to);
	}
	
	for (int i = 0; i < n; ++i)
		g.dfs(i);

	int q;
	cin >> q;
	while (q--) {
		cin >> from >> to;
		if (g.visit[from] == g.visit[to])
			yes();
		else
			no();
	}

	return 0;
}

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

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

struct Node
{
    int node, len;
    Node() {node = len = 0;}
    Node(int node, int len) {this -> node = node, this -> len = len;}
};
typedef vector<Node> vg;

#define MAX 1
#define NON 0
#define MOD 1000000007

#define FOR(type, i, a, b) for(type i = a; i < b; i++)
#define FORR(type, i, b, a) for(type i = b; i > a; i--)
#define FORE(type, i, a, b) for(type i = a; i <= b; i++)
#define FORRE(type, i, b, a) for(type i = b; i >= a; i--)

#define testBit(n, bit) ((n >> bit) & 1)
#define flipBit(n, bit) (n ^ (1ll << bit))
#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int s, w; cin >> s >> w;
    if (w >= s) cout << "un";
    cout << "safe";
}

Measured memory_bytes: 3640
import io.Source.stdin

object Main{
  def main(args: Array[String]){
    for(line <- stdin.getLines().toList){
      val sum = line.map{c => c.toString.toInt}.foldLeft(0)((acc, a) => acc + a)

      if (sum != 0){
        println(sum)
      }
    }
  }
}

Measured memory_bytes: 44300
#include<iostream>
using namespace std;
int main(){
  int n,cnt[3]={0},a;
  string ans;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    if(a%2==0){
      if(a%4==0){
        cnt[0]++;
      }else {
        cnt[1]++;
      }
    }else{
      cnt[2]++;
    }
  }
  if(cnt[1]>=1){
    if(cnt[0]>=cnt[2])ans="Yes";
    else ans="No";
    }else{
    if(cnt[0]>=cnt[2]-1)ans="Yes";
    else ans = "No";
  }
  cout << ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int l=c%b;
  for(int i=1;i<=b;i++){
    
    if((i*a)%b==l){
      cout<<"YES";
      return 0;
    }
  }
  cout<<"NO";
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int m;
	std::cin >> m ;
	int carry = 0;
	int sum = 0;
	rep(i,m) {
		int d,c;
		std::cin >> d >> c;
		if(carry==0) {
			sum+= c-1;
			if(d*c>9) sum+=(d*c-10)/9+1;
		}
		else {
			sum+=c;
			if(d*c+carry>9) sum+=(d*c+carry-10)/9+1;
		}
		int count = 0;
		if(d*c+carry>9) count+=(d*c+carry-10)/9+1;
		carry = (d*c+carry+count)%10;
		debug(carry,sum);
	}
	print(sum);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int max(int a,int b){
    if(a>=b){
        return a;
    }else{
        return b;
    }
}
int mini(int a,int b){
    if(a>=b){
        return b;
    }else{
        return a;
    }
}
int main(){
    int n,m,i,l,r,lm=0,rm;
    scanf("%d %d",&n,&m);
    rm=n+1;
    for(i=0;i<m;i++){
        scanf("%d %d",&l,&r);
        lm=max(l,lm);
        rm=mini(r,rm);
    }
    int gt=rm-lm+1;
    if(gt<0)gt=0;
    printf("%d\n",gt);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

LL val_a[MAXN << 2], val_b[MAXN << 2];
int n, m, a[MAXN], b[MAXN];

inline void Build(int x, int l, int r)
{
	if (l == r)
		return (void)(val_a[x] = a[l], val_b[x] = b[l]);
	int mid = l + r >> 1;
	Build(x << 1, l, mid), Build(x << 1 | 1, mid + 1, r);
	val_a[x] = max(val_a[x << 1] + val_a[x << 1 | 1], val_b[x << 1] + val_b[x << 1 | 1]);
	val_b[x] = max(val_b[x << 1] + val_a[x << 1 | 1], val_a[x << 1] + val_b[x << 1 | 1]);
}

inline void Modify(int x, int l, int r, int p)
{
	if (l == r)
		return (void)(val_a[x] = a[l], val_b[x] = b[l]);
	int mid = l + r >> 1;
	if (p <= mid)
		Modify(x << 1, l, mid, p);
	else
		Modify(x << 1 | 1, mid + 1, r, p);
	val_a[x] = max(val_a[x << 1] + val_a[x << 1 | 1], val_b[x << 1] + val_b[x << 1 | 1]);
	val_b[x] = max(val_b[x << 1] + val_a[x << 1 | 1], val_a[x << 1] + val_b[x << 1 | 1]);
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read();
	for (int i = 1; i <= n << 1; i ++)
		a[i] = Read();
	for (int i = 1; i <= n << 1; i ++)
		b[i] = Read();
	if (n == 1)
	{
		while (m --)
		{
			int p = Read(), x = Read(), y = Read();
			a[p] = x, b[p] = y;
			printf("%d\n", a[1] + a[n << 1]);
		}
		return 0;
	}
	Build(1, 2, (n << 1) - 1);
	while (m --)
	{
		int p = Read(), x = Read(), y = Read();
		a[p] = x, b[p] = y;
		if (p > 1 && p < n << 1)
			Modify(1, 2, (n << 1) - 1, p);
		printf("%lld\n", a[1] + a[n << 1] + val_a[1]);
	}
	return 0;
}


Measured memory_bytes: 13952
n = int(input())
P = list(map(int, input().split()))
ans = 0
streak = 0
for i in range(1, n):
    #print (P[i])
    if P[i-1] >= P[i]:
        streak += 1
    else:
        ans = max(ans, streak)
        streak = 0
ans = max(ans, streak)
print (ans)

Measured memory_bytes: 20380
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const ll M = 1000000007;

int main () {
  ll x;
  cin >> x;
  ll ans = (x/11) * 2;
  ll amari = x%11;
  if (amari == 0) {
  } else if (amari <= 6) {
    ans++;
  } else {
    ans++; ans++;
  }
  cout << ans << endl;
}


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

int main()
{
    long long N, K;
    cin>>N>>K;
    vector<long long> A(N);
    for (long long &a: A)
        cin>>a;

    //for (int i=0; i<N; i++)
    //{
    //    int c = 0;
    //    int s = 0;
    //    for (int j=i; j<N; j++)
    //    {
    //        s += A[j];
    //        if (s%K==j-i+1)
    //            c++;
    //    }
    //    cout<<" "<<c;
    //}
    //cout<<endl;

    map<long long, long long> M;
    long long x = 0;
    for (int i=0; i<min(N, K-1); i++)
    {
        x += A[i]-1;
        x %= K;
        M[x]++;
    }

    long long ans = 0;
    long long y = 0;
    for (int i=0; i<N; i++)
    {
        ans += M[y];
        y += A[i]-1;
        y %= K;
        M[y]--;

        if (min(N, K-1)+i<N)
        {
            x += A[min(N, K-1)+i]-1;
            x %= K;
            M[x]++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 14336
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	vector<lli> a(3, 0), b(3, 0);
	cin >> a[0] >> a[1] >> a[2];
	rep(i, 3) if(a[0]%2 == 1) {cout << '0' << endl; return 0;}
	lli n = accumulate(a.begin(), a.end(), 0ll);
	
	rep(i, 3){
		lli c = a[i]*3 - n;
		if(c == 0){	b[i] = LINF; continue;}
		while(c%2 == 0){	
			c /= 2;
			b[i]++;
		}
	}
	
	lli ans = *min_element(b.begin(), b.end());
	cout << (ans == LINF?-1:ans) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int main(){
  int n,i,j,temp,minj,flag,count=0;
  int A[N];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    minj=i;
    for(j=i+1;j<n;j++){
      if(A[j]<A[minj])	minj=j;
    }
    if(A[i]>A[minj]){
      temp=A[i];
      A[i]=A[minj];
      A[minj]=temp;
      count++;
    }
  }
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
S=input()
tgt="keyence"
res=S==tgt
for i in range(8):
    T = ''
    if 0<i: T+=S[:i]
    if i<7: T+=S[i-7:]
    #print(T)
    if T==tgt:
        res=True
print("YES" if res else "NO")


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main(){
    long long int n,m;
    cin>>n>>m;
    long long int a[n][m];
    long long int d[n][m];
    for (long long int i=0;i<n;i++){
        string s;
        cin>>s;
        for (long long int j=0;j<m;j++){
            if (s[j]=='.'){
                a[i][j]=1;
            }
            else{
                a[i][j]=0;
            }
        }
    }
    for (long long int i=0;i<n;i++){
        for (long long int j=0;j<m;j++){
            if (a[i][j]==0){
                d[i][j]=0;
            }
            else if(i==0 && j==0){
                d[i][j]=a[i][j];
            }
            else if(i==0){
                d[i][j]=d[i][j-1];
            }
            else if(j==0){
                d[i][j]=d[i-1][j];
            }
            else{
                d[i][j]=(d[i-1][j]+d[i][j-1])%1000000007;
            }
        }
    }
    /*for (long long int i=0;i<n;i++){
        for(long long int j=0;j<m;j++){
            cout<<d[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<d[n-1][m-1]<<endl;
}



Measured memory_bytes: 15872
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,a,b,c,d,e;
  cin>>n;
  a=n%10;
  b=((n-n%10)/10)%10;
  c=((n-n%100)/100)%10;
  d=((n-n%1000)/1000)%10;
  e=((n-n%10000)/10000)%10;
  if(a!=0) cout<<a+b+c+d+e;
  else if(b!=0) cout<<b+c+d+e+9;
  else if(c!=0) cout<<c+d+e+9;
  else if(d!=0) cout<<d+e+9;
  else if(e!=0) cout<<e+9;
  else cout<<10;
}

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

int main() {
	int d, newd, s = 0;
	while (cin >> d) {
		s = 0;
		newd = d;
		while (newd < 600) {
			s += d * pow(newd, 2);
			newd += d;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;


#define INF 1e+9



int main(){

  int n,m;
  cin >> n >> m;
  vector<int> c(m+1,0);
  for(int i=1; i<=m; i++)
    cin >> c[i];


 
  vvi dp(m+2,vi(n+1,INF));  // dp[i][j]: i???????????????????????§??§???j??????????????????????????????????°??????°
  dp[0][0] = 0;
  for(int i=0; i<=m; i++){
		for(int j=0; j<=n; j++){
			  //if(dp[i][j] != INF){ // dp[i][j] ????????????
					dp[i+1][j] = min(dp[i][j], dp[i+1][j]); // i?????????????????????????????????
					if(j+c[i] > n) continue;
					dp[i][j+c[i]] = min(dp[i][j]+1,dp[i][j+c[i]]); //i???????????????????????´????????????
					dp[i+1][j+c[i]] = min(dp[i][j]+1,dp[i+1][j+c[i]]); //i???????????????????????´????????????
					//}
		}
  }
  cout << dp[m][n] << endl;
  

  

}

Measured memory_bytes: 5492
s = gets.chomp

result = true

s.length.times do |t|
  ss = s[t]

  if (t + 1).odd?
    result = false and break unless ['R', 'U', 'D'].include?(ss)
  else
    result = false and break unless ['L', 'U', 'D'].include?(ss)
  end
end

puts result ? 'Yes' : 'No'


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

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

        int count = Integer.MAX_VALUE;

        if (x <= y) {
            count = Math.min(count, y - x);
        }

        x = x * (-1);

        if (x <= y) {
            count = Math.min(count, y - x + 1);
        }

        y = y * (-1);
        if (x <= y) {
            count = Math.min(count, y - x + 2);
        }

        x = x * (-1);
        if (x <= y) {
            count = Math.min(count, y - x + 1);
        }
        System.out.println(count);

    }

}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
	ll N;
	cin >> N;
	rep(i,0,50000) {
		if (i * 108 / 100 == N) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const ll N = 123456;

int a[N];

const ll mod = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    rep(i , 1 , n) cin >> a[i];

    int cnt = 0;
    rep(i , 1 , n - 2) {
        vector < int > s;
        s.push_back(a[i]);
        s.push_back(a[i + 1]);
        s.push_back(a[i + 2]);
        sort(s.begin() , s.end());

        if(s[1] == a[i + 1]) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String a = stdIn.next();
		
		if (a.contains("9")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21712
using System;
class Program
{
    static void Main()
    {
        var x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var dir = new char[12] { 'U', 'R', 'D', 'L', 'L', 'U', 'R', 'D', 'R', 'D', 'L', 'U' };
        var len = new int[12]
        {
          x[3] - x[1], x[2] - x[0],
          x[3] - x[1], x[2] - x[0],
          1, x[3] - x[1] + 1, x[2] - x[0] + 1,1,
          1, x[3] - x[1] + 1, x[2] - x[0] + 1,1
        };
        for (int i = 0; i < 12; i++)
        {
            Console.Write(new string(dir[i],len[i]));
        }
        Console.WriteLine();
    }
}

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

Measured memory_bytes: 600
// AtCoder124-1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include<stdio.h>
#include<string.h>
#include<stdlib.h>


int main()
{
	int a, b, c;
	int sum = 0;
	char input[10001];
	char temp;

	fgets(input, 10000, stdin);
	 a = atoi(strtok(input, " "));
	 b = atoi(strtok(NULL," "));
	sum=a+b;
	if (a+(a - 1) > sum) {
		 sum= a+(a - 1);
	}
	if (b+(b - 1) > sum) {
		sum= b+(b - 1);
	}
	printf("%d", sum);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

// long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a;
// }

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

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

    string ans = "No";
    if(S == "hi" || S == "hihi" || S == "hihihi" || S == "hihihihi" || S == "hihihihihi"){
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

vector<int> prime;    
bool is_prime[2000000];//is_prime[i]==1??????i????´???°

int sieve(int n) {//n??\???????´???°?????°?????????
	int p = 0;
	for (int i = 0; i <= n; i++)is_prime[i] = 1;
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime.push_back(i);
			for (int j = 2 * i; j <= n; j += i)is_prime[j] = 0;
		}
	}
	return p;
}

int n;

int main() {
	sieve(1300000);
	while (cin >> n&&n) {
		if (is_prime[n]) {
			cout << 0 << endl;
			continue;
		}
		rep(i, prime.size() - 1) {
			if (prime[i] < n&&n < prime[i + 1]) {
				cout << prime[i + 1] - prime[i] << endl;
				break;
			}
		}
	}
}

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

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

    string S = "UNRESTORABLE";

    int start = 0;
    vector<string> match_results;

    bool containded = false;
    rep(i, Sd.size() - T.size() + 1)
    {
        containded = true;
        rep(j, T.size())
        {
            if (Sd.at(i + j) != T.at(j) && Sd.at(i + j) != '?')
            {
                containded = false;
            }
        }

        if (containded)
        {
            string match_result = (Sd.substr(0, i) + T + Sd.substr(i + T.size(), Sd.size()));
            replace(match_result.begin(), match_result.end(), '?', 'a');
            match_results.push_back(match_result);
        }
    }

    if (match_results.size() > 0)
    {
        sort(match_results.begin(), match_results.end());
        S = match_results.at(0);
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
double r;

const int OFFSET = 100;
vector<pair<int, int> > events[200];
int phs[200];
int nhs[200];
int main() {
  while (scanf("%lf %d", &r, &n) > 0 && r > 0) {
    MEMSET(phs, 0);
    MEMSET(nhs, 0);
    REP(i, 200) { events[i].clear(); }
    REP(i, n) {
      int x1, x2, y;
      scanf("%d %d %d", &x1, &x2, &y);
      events[x1 + OFFSET].push_back(make_pair(y, 1));
      events[x2 + OFFSET].push_back(make_pair(y, -1));
    }
    multiset<int> ys;
    for (int i = -50; i <= 50; i++) {
      int py = 0;
      if (ys.size() != 0) { py = *ys.rbegin(); }
      FORIT(it, events[i + OFFSET]) {
        int y = it->first;
        int inout = it->second;
        if (inout == 1) {
          ys.insert(y);
        } else {
          ys.erase(ys.find(y));
        }
      }
      int ny = 0;
      if (ys.size() != 0) { ny = *ys.rbegin(); }
      phs[i + OFFSET] = py;
      nhs[i + OFFSET] = ny;
    }
    double ans = 1e+10;
    for (int i = -r; i <= r; i++) {
      double h = min(phs[i + OFFSET], nhs[i + OFFSET]);
      if (i == -r) { h = nhs[i + OFFSET]; }
      if (i ==  r) { h = phs[i + OFFSET]; }
      double t = h + r - sqrt(r * r - i * i);
      ans = min(ans, t);
    }
    printf("%.8f\n", ans);
  }
}

Measured memory_bytes: 1252
import sys
sys.setrecursionlimit(10 ** 5 + 10)

N, A, B, C = [int(i) for i in input().split()]

ans = list()
l = list()

for n in range(N):
    l.append(input())

def dfs(i, a, b, c):
    if i == N:
        return True

    ss = l[i]
    if ss == 'AB':
        if a == 0 and b == 0:
            return False
        if b > 0 and dfs(i + 1, a + 1, b - 1, c):
            ans.append('A')
            return True
        if a > 0 and dfs(i + 1, a - 1, b + 1, c):
            ans.append('B')
            return True
    if ss == 'AC':
        if a == 0 and c == 0:
            return False
        if c > 0 and dfs(i + 1, a + 1, b, c - 1):
            ans.append('A')
            return True
        if a > 0 and dfs(i + 1, a - 1, b, c + 1):
            ans.append('C')
            return True
    if ss == 'BC':
        if b == 0 and c == 0:
            return False
        if c > 0 and dfs(i + 1, a, b + 1, c - 1):
            ans.append('B')
            return True
        if b > 0 and dfs(i + 1, a, b - 1, c + 1):
            ans.append('C')
            return True
    return False

dfs(0, A, B, C)

if len(ans) > 0:
    print('Yes')
    for x in reversed(ans):
        print(x)
else:
    print('No')

Measured memory_bytes: 109980
n = int(input())
ans = []

if n % 2 == 0:
    temp = n + 1
else:
    temp = n

for i in range(1, n):
    for j in range(i+1, n+1):
        if i + j != temp:
            ans.append((i, j))

print(len(ans))
for a in ans:
    print(a[0], a[1])

Measured memory_bytes: 3996
N,K,Q=map(int,input().split())
QL=[0]*Q
NL=[K-Q]*N
for i in range(Q):
  QL[i]=int(input())-1
  NL[QL[i]]+=1
for i in range(N):
  print('Yes' if NL[i]>0 else 'No')

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

using namespace std;
// #define int long long
mt19937 rnd(time(0));
typedef long long ll;
typedef long double ld;

// #define _GLIBCXX_DEBUG
#define f first
#define s second
#define pb push_back
#define pii pair<int, int> 
#define vi vector<int>

void solve(){
	#define int ll
	ll a, b;
	cin >> a >> b;
	if (a > b)
		swap(a, b);
	vi x;
	for (int i = 1; i <= sqrtl(b); ++i) {
		if (a % i == 0 && b % i == 0) {
			x.pb(i);
		}
		if (b % i == 0 && a % (b / i) == 0 && b % (b / i) == 0) {
			x.pb(b / i);
		}
	}
	sort(x.begin(), x.end());
	x.resize(unique(x.begin(), x.end()) - x.begin());
	int ans = 0;
	for (int i = 0; i < x.size(); ++i) {
		bool ok = 1;
		for (int j = 2; j <= sqrtl(x[i]); ++j) {
			ok &= (x[i] % j != 0);
		}
		ans += ok;
	}
	// cout << ans << endl;
	cout << ans << endl;
}

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


Measured memory_bytes: 384
n = int(raw_input())
 
def dfs(u,t):
    global graph
    global found
    global timestamp
 
    if u in found: return t
    found.add(u)
    timestamp[u] = [-1,-1]
    timestamp[u][0] = t
    t += 1
    for v in graph[u]:
        t = dfs(v,t)
    timestamp[u][1] = t
    t += 1
    return t
 
graph = [[] for i in range(n)]
found = set()
timestamp = {}
 
for i in range(n):
    entry = map(int,raw_input().strip().split(' '))
    u = entry[0]
    u -= 1
    for v in entry[2:]:
        v -= 1
        graph[u].append(v)
 
 
t = 1
for i in range(n):
    t = dfs(i,t)
 
for i in timestamp:
    print i+1,timestamp[i][0],timestamp[i][1]

Measured memory_bytes: 6500
x,y,a,b,c,=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p=p[:x]
q=q[:y]
ans=p+q+r
ans.sort(reverse=True)
print(sum(ans[:x+y]))

Measured memory_bytes: 29376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int N, X, Y;
    cin >> N >> X >> Y;
    --X;
    --Y;
    //int a[2010][2010];
    //
    vector<vector<int>> a(N, vector<int>(N, 0));
    rep(i, N - 1)
    {
        for (int j = i + 1; j < N; j++) {

            a[i][j] = j - i;
            //        cout << a[i][j] << ' ';
        }
        //  cout << endl;
    }


    rep(i, N - 1)
    {
        for (int j = i + 1; j < N; j++) {
            /*            if (i <= X && j >= Y) {
                a[i][j] = X - i + Y - j + 1;
            } else if (i <= X && j <= Y) {
                a[i][j] = min(a[i][j], X - i + 1 + Y - j);
            } else if (X <= i && Y <= j) {
                a[i][j] = min(a[i][j], i - X + 1 + j - Y);
            }
        }*/
            //cout << endl;
            a[i][j] = min(j - i, abs(X - i) + 1 + abs(Y - j));
        }
    }

    map<int, ll> mp;
    rep(i, N - 1)
    {
        for (int j = i + 1; j < N; j++) {
            //cout << a[i][j] << endl;

            mp[a[i][j]]++;
        }
    }

    REP(i, N - 1)
    {
        cout << mp[i] << endl;
    }
}


Measured memory_bytes: 16128
//file_name:ABC53_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    int a[n] = {};
    int count[100100] = {};
    rep(i,n){
        scanf("%d",&a[i]);
        count[a[i]]++;
    }


    int ans = n;
    int eat = 0;


    rep(i,100100){
        if(count[i]>1){
            eat += count[i]-1;
        }
    }
    if(eat%2==1)eat++;

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



Measured memory_bytes: 1024
#include<iostream>
#include<vector>

using namespace std;



int main(){
	int in;
	int prime[60001] = {};

	vector<int> p;
	int i, j;
	for (i = 2; i*i < 60000; i++){
		if (prime[i] == 0){
			for (j = 2; i*j <= 60000; j++){
				prime[i*j] = 1;
			}
		}
	}
	for (i = 1; i < 60001; i++){
		if (prime[i] == 0){
			p.push_back(i);
		}
	}



	while (cin >> in){
		for (i = 1; in >= p[i]; i++);
		if (p[i - 1] == in){
			cout << p[i - 2] << " " << p[i] << endl;
		}
		else{
			cout << p[i - 1] << " " << p[i] << endl;
		}
	}
}

Measured memory_bytes: 1512
#include<stdio.h>

int main(){
    int c[3],i,sum,cnt;
    while(scanf("%d %d %d",&c[0],&c[1],&c[2])!=EOF){
        sum=c[0]+c[1];
        cnt=0;
        for(i=1;i<11;i++){
            if(i==c[0]||i==c[1]||i==c[2])continue;
            if(sum+i>20)break;
            cnt++;
        }
        if(cnt>=4)puts("YES");
        else puts("NO");
    }
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,M;
ll A[101010];
ll i, j, k;

ll gcd(ll p,ll q){
    if(q==0)
        return p;
    return gcd(q, p % q);
}


int main(){
    scanf("%lld%lld", &N,&M);
    
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    ll a = 1;
    fornum(i,0,N){
        ll g = gcd(a, A[i]);
        a = a * A[i] / g;
        if(a/2>M){
            printf("0");
            return 0;
        }
    }
    
    fornum(i,0,N){
        if(a/A[i]%2==0){
            printf("0");
            return 0;
        }
    }
    a /= 2;
    printf("%lld", (M + a) / a / 2);

    return 0;
}

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

long long cmb2(long long n) {
	long long ans;
	ans = n * (n - 1) / 2;
	return ans;
}

int cmp(const void* p, const void* q) {
	return strcmp((char*)p, (char*)q);
}

int main(void) {
	int n;
	char s[100000][11];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%s", s[i]);

	for (int i = 0; i < n; i++)
		qsort(s[i], 10, sizeof(char), cmp);

	qsort(s, n, sizeof(char) * 11, cmp);

	long long same = 1, ans = 0;
	for (int i = 0; i < n; i++) {
		if (strcmp(s[i], s[i + 1]) == 0)
			same++;
		else {
			ans += cmb2(same);
			same = 1;
		}
	}

	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int N,A,B,C,X;
  vector<int> y;
  while(1){
    int flag=0,index=0;
    cin>>N>>A>>B>>C>>X;
    if(N==0)
      break;
    y.resize(N);

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

    for(int i=0;i<=10000;i++){
      if(X==y[index]){
        if(index==N-1){
          flag=1;
          cout<<i<<endl;
          break;
        }
        index++;
      }
      X=(A*X+B)%C;
    }

    if(flag==0)
      cout<<-1<<endl;
  }
}



Measured memory_bytes: 3156
# include "bits/stdc++.h"
 
using namespace std;
 
#define endl "\n"
typedef long long int ll;
#define f first
#define s second
 
inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}
 
//DEBUG
#define BR cerr<<endl
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
 
ll INF = 1e10;
int MOD = 1e9+7;

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

int main(){
	#ifndef ONLINE_JUDGE
        freopen("inputf.in", "r", stdin);
    #endif
    fastio();

    int x;
    cin >> x;

    if(x == 1){
    	cout << 2;
    	return 0;
    }

    while(!isPrime(x)){
    	++ x;
    }

    cout << x;

    return 0;
}

/*

*/

Measured memory_bytes: 3652
s = int(input())
a = [s] + [0]*1000000

def f(n):
  if n % 2 == 0:
    return n//2
  else:
    return 3*n+1
  
for i in range(1000000):
  a[i+1] = f(a[i])
  
def solve(s,a):
  memo = []
  for i in range(len(a)):
    if a[i] in memo:
      return i+1
    else:
      memo.append(a[i])
  return -1

print(solve(s,a))

Measured memory_bytes: 18676
use itertools::Itertools;
use itertools_num::ItertoolsNum;
use proconio::input;
use std::iter::once;
use superslice::Ext;

fn main() {
    input!(n: usize, m: usize, k: u64, a: [u64; n], b: [u64; m]);
    let a = once(0).chain(a.into_iter()).cumsum().collect_vec();
    let b = once(0)
        .chain(b.into_iter())
        .cumsum()
        .chain(once(std::u64::MAX))
        .collect_vec();
    println!(
        "{}",
        a.into_iter()
            .filter(|&x: &u64| x <= k)
            .enumerate()
            .map(|(i, x)| { i + b.upper_bound(&(k - x)) - 1 })
            .max()
            .unwrap()
    );
}


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

int main(){
	int n,ans = 1E9+7, k;
	cin >>n;
	vector<long> x(n);
	for(int i = 0; i < n; i++) {
		cin >> x[i];
	}
  	sort(x.begin(), x.end());
  	for(int i = x[0]; i <= x[n-1]; i++) {      
 		k=0;
      	for(int j = 0; j < n; j++) {
        	k += (i-x[j])*(i-x[j]);
        }
      	ans = min(ans, k);
    }
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
using namespace std;



int main() {
	long long n,m=0,a=0,r=0,c=0,h=0;
	vector<string> s(114514);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i][0] == 'M') {
			m++;
		}
		else if (s[i][0] == 'A') {
			a++;
		}
		else if (s[i][0] == 'R') {
			r++;
		}
		else if (s[i][0] == 'C') {
			c++;
		}
		else if (s[i][0] == 'H') {
			h++;
		}
	}
	cout << m * a*r+ m * a*c + m * a*h + m *r*c + m *r*h + m *c*h +  a*r*c +  a*r*h + a*h*c + r*c*h;
	return 0;
}





Measured memory_bytes: 6272