akhauriyash/Code-Regression huggingface dataset:
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}

signed main (){
    string s;cin>>s;
    string ans="NO";
    rep(i,0,7){
        if(s.substr(0,i)+s.substr(s.size()-7+i)=="keyence"){
            ans="YES";
        }
    }
    cout<<ans<<endl;

}
/*
*/


Measured memory_bytes: 256
def q3():
    n = int(input())
    boss_list = [int(i) for i in input().split(" ")]

    sub_count = {}
    for boss_number in boss_list:
        if boss_number in sub_count:
            sub_count[boss_number] += 1
        else:
            sub_count[boss_number] = 1
    
    for i in range(1, n+1):
        if i in sub_count:
            print(sub_count[i])
        else:
            print(0)
        

q3()

Measured memory_bytes: 33664
#include<bits/stdc++.h>
#define REP(i,n,N) for(ll i=(n);i<(ll)(N);i++)
#define p(s) cout<<(s)<<endl;
typedef long long ll;
using namespace std;

ll calc(ll k,ll l,ll r) {
	ll F=(r-1)/3-(l-1)/3;
	ll B=(r-1)/5-(l-1)/5;
	ll FB=(r-1)/15-(l-1)/15;
	ll ret=k*((r-l)-(F+B)+FB)+(F+B)*4;//num + (Fizz or Buzz)
	return ret;
}

ll C(ll n) {
	ll ret=0;
	string S=to_string(n);
	REP(i,1,S.size()) {
		ret+=calc(i,pow(10,i-1),pow(10,i));
	}
	ret += calc(S.size(),pow(10,S.size()-1),n+1);
	return ret;
}
int main() {
	ll s;
	cin>>s;
	ll lb=0, ub=1e18;
	while(ub-lb>1) {
		ll mid=(lb+ub)/2;
		if(C(mid)<=s) {
			lb=mid;
		}
		else ub=mid;
	}
	string str;
	REP(i,lb,lb+40) {
		if(str.size()>40)	break;
		if(i%15==0) str+="FizzBuzz";
		else if(i%3==0) str+="Fizz";
		else if(i%5==0) str+="Buzz";
		else str+=to_string(i);
	}
	cout<<str.substr(s-C(lb-1)-1,20)<<endl;
	return 0;
}

Measured memory_bytes: 3408
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}
long long h, w, a, b;

long long solve();

int main() {
  smodfact();
  cin >> h >> w >> a >> b;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, bf = 0, now;
  for(long long i = b; i < w; ++i) {
    now = calccomb(h - 1 - a + i, i) - bf;
    while(now < 0) now += N;
    ans += now * calccomb(a + w - 1 - i, a) % N;
    ans %= N;
    bf = calccomb(h - 1 - a + i, i);
  }
  return ans;
}

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

#define NIL -1

typedef struct node{
  int p, r, l;
}Node;

Node T[25];

void Preorder(int i){
  if(i == NIL)  return;
  printf(" %d",i);
  Preorder(T[i].l);
  Preorder(T[i].r);
}

void Inorder(int i){
  if(i == NIL)  return;
  Inorder(T[i].l);
  printf(" %d",i);
  Inorder(T[i].r);
}

void Postorder(int i){
  if(i == NIL)  return;
  Postorder(T[i].l);
  Postorder(T[i].r);
  printf(" %d",i);
}

int main(){
  int n, i, v, l, r, root;

  scanf("%d",&n);
  for(int i=0 ; i<n ; i++){
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
  }

  for(int i=0 ; i<n ; i++){
    scanf("%d%d%d",&v ,&l ,&r );
    T[v].l = l;
    T[v].r = r;
    if(l != NIL)    T[l].p = v;
    if(r != NIL)    T[r].p = v;
  }
  for (int i=0 ; i<n ; i++)
    if (T[i].p == NIL) root = i;

  printf("Preorder\n");
  Preorder(root);
  printf("\nInorder\n");
  Inorder(root);
  printf("\nPostorder\n");
  Postorder(root);
  puts("");
  return 0;
}



Measured memory_bytes: 2144
#include<stdio.h>
#include<cmath>
#include<iostream>
using namespace std;

int main(){
    int n, s;
    double score[1000];
    while(1){
        cin >> n;
        if(n == 0)break;
        int sum=0;
        double avg;
        for(int i= 0; i<n; i++){
            cin >> s;
            score[i] = s;
            sum += s;
        }
        avg = (double)sum / (double)n;
        double sigma = 0;
        for(int i=0 ; i < n; i++){
            sigma += pow(score[i]-avg, (double)2);
        }
        printf("%.10lf\n" , sqrt(sigma/n));
    }
    
    return 0;
}


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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	string s;
	cin>>s;
	int mx=0,cnt=0;
	forn(i,0,3){
		if (s[i]=='R'){
			cnt++;
		}
		else{
			mx=max(mx,cnt);
			cnt=0; 
		}
	}
	mx=max(mx,cnt);
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 3644
package main

import "fmt"

func main() {
	var n, m int

	fmt.Scan(&n, &m)

	a := 1900*m + 100*(n-m)
	e := a * pow(2, m)

	fmt.Println(e)
}

func pow(x int, y int) int {
	r := 1
	for i := 0; i < y; i++ {
		r *= x
	}
	return r
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

public static class Program
{
    public class Process
    {
        public string name;
        public int time;
    }

    public static void Main()
    {
        var lineList = Console.ReadLine().Split(' ');
        int n = int.Parse(lineList[0]);
        int q = int.Parse(lineList[1]);
        //Queueクラスの作成<要素の型>
        var queue = new Queue<Process>();
        for (int i = 0; i < n; i++)
        {
            lineList = Console.ReadLine().Split(' ');
            //普通のクラスのインスタンス
            var process = new Process()
            {
                name = lineList[0],
                time = int.Parse(lineList[1])
            };
            //要素を追加
            queue.Enqueue(process);
        }
        int time = 0;
        while (queue.Count > 0)
        {
            var process = queue.Dequeue();
            if (process.time <= q)
            {
                time += process.time;
                Console.WriteLine(string.Format("{0} {1}", process.name, time));
            }
            else
            {
                time += q;
                process.time -= q;
                queue.Enqueue(process);
            }
        }
    }
}


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

#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define point pair<int,int>

int N, K;
int mem[200010];

signed main()
{
    cin >> N >> K;
    rep(i, N)cin >> mem[i];
    rep(j, min(K, 100LL))
    {
        int tmp[400010] = {0};
        rep(i, N)
        {
            tmp[max(i - mem[i], 0LL)]++;
            tmp[i + mem[i] + 1]--;
        }
        rep(i, N)if(i)
            tmp[i] += tmp[i - 1];

        rep(i, N)mem[i] = tmp[i];
    }

    rep(i, N)
    {
        if(i)cout << " ";
        cout << mem[i];
    }cout << endl;

    return 0;
}


Measured memory_bytes: 8300
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
T = set()
for i in range(1, 2 ** n):
    total = 0
    for j in range(n):
        if i >> j & 1:
            total += A[j]
    T.add(total)
for m in M:
    if m in T:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 5644
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

max_a = max(a for a, _ in ab)
dp = [0] * (h + max_a)

for i in range(-max_a, h+max_a):
    if i <= 0:
        dp[i] = 0
    else:
        dp[i] = min(dp[i-a] + b for a, b in ab)
print(min(dp[h:]))

Measured memory_bytes: 3668
import java.util.*;

class Main{
    public static void main(String[] args){
        boolean[] IsSosu = new boolean[1000000];
        Arrays.fill(IsSosu, true);
        IsSosu[0] = IsSosu[1] = false;
        
        for(int i=2;i<=1000;i++){
            if(!(IsSosu[i]))
                continue;
            else{
                for(int j=i*2; j<1000000; j += i){
                    IsSosu[j] = false;
                }
            }
        }
        int[] SosunoKosu = new int[1000000];
        SosunoKosu[0] = 0;
        for(int i=1;i<SosunoKosu.length;i++){
            int plus = IsSosu[i]?1:0;
            SosunoKosu[i] = SosunoKosu[i-1] + plus;
        }
        
        
        Scanner sc = new Scanner(System.in);
        int n;
        while(sc.hasNext()){
            n = sc.nextInt();
            System.out.println(SosunoKosu[n]);
        }
    }
}

Measured memory_bytes: 26992
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
#define rep(i,n) for(int i=0;i<n;i++)


int main(void){

int a1,a2,a3;
cin>>a1>>a2>>a3;


int ans = a1+a2+a3;

if(ans<22) cout<<"win"<<endl;
else cout <<"bust"<<endl;


}








Measured memory_bytes: 256
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main {
  def decompose(n:Int) = {
    val a = new ArrayBuffer[(Int,Int)]
    for(i<-1 to Math.sqrt(n).toInt) {
      if(n%i==0)
        a += ((i,n/i))
    }
    a.toArray
  }
  def main(args:Array[String]) = {
    var s = "0 0"
    while({s=readLine.trim;s} != "0 0") {
      val n = s.split(" ").map(_.toInt)
      val x = decompose(n(0))
      val y = decompose(n(1))
      var min = Int.MaxValue
      for(i<-x) {
        for(j<-y) {
          val z = Array(i._1,i._2,j._1,j._2).sorted
          val sum = (z(1)-z(0))*(z(1)-z(0)) + (z(2)-z(1))*(z(2)-z(1)) + (z(3)-z(2))*(z(3)-z(2))
          if(sum<min) min = sum
        }
      }
      println(min)
    }
  }
}

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

const int inf = 1e9 + 7;
const int mod = 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}

inline int mul(int a, int b) {
  return (a * (ll) b) % mod;
}

inline int pw(int x, int n) {
  int res = 1;
  while (n > 0) {
    if (n % 2) {
      res = mul(res, x);
      n--; 
    } else {
      x = mul(x, x);
      n /= 2;
    }
  }
  return res;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <int> h(n + k, 0);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector <int> dp(n + k, inf);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

double a;

int main()
{
  while((cin >> a) && a){
    double res = 0.0;
    a *= 3.0;
    rep(i, 10){
      if(i & 1) a *= 2.0;
      else      a /= 3.0;
      res += a;
    }
    printf("%.15f\n", res);
  }

  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int A, B;

int main()
{
    cin >> A >> B;
    int a = A * B;
    int b = 2 * a;
    int c = 3 * a;
    if (a & 1 || b & 1 || c & 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
  string S;
  cin >> S;
  if(S.at(2)==S.at(3) && S.at(4)==S.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    int a,b;
    cin>>a>>b;
    if(a-2*b<=0){
        cout<<0;
    }else{
        cout<<a-2*b;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
D = [[int(x) for x in input().split()] for _ in range(n)]
print('Yes' if any(a[0] == a[1] and b[0] == b[1] and c[0] == c[1] for a, b, c in zip(D, D[1:], D[2:])) else 'No')


Measured memory_bytes: 9176
using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;

namespace problem
{
    class Test
    {
        static void Main()
        {
            var s = Console.ReadLine().Split();
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);

            if (a < b && b < c) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
map<int, int> ans;
map<int, vector<int>> g;
int main()
{
    string s;
    cin >> s;
    if (s.size() % 2 == 1)
    {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < s.size(); i += 2)
    {
        if (s[i] != 'h' || s[i + 1] != 'i')
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-12 10:58:30

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	int a, b, t;
	cin >> a >> b >> t;
	int cur = 0, sum = 0;
	for(int i = 1; ; ++i){
		cur = i*a;
		if(cur <= t)	sum += b;
		else	break; 
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

# 入力
N = int(input())
A = list(map(int, input().split()))

# dp[s]: A_1 + ... + A_i = s となるような i の個数
dp = defaultdict(int, {0: 1})
# 和
s = 0
# 解
ans = 0
# 各iについて、 A_1 + ... + A_i = A_1 + ... + A_j となるような 0 <= j < N の個数を求める
for a in A:
    s += a
    ans += dp[s]
    dp[s] += 1

# 出力
print(ans)


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

using namespace std;

typedef long long ll;

const ll mod=1e9+7;
const ll maxn=5e5+5;

int a[maxn];
int n;
int val(int x){
	int ans=0;
	for(int i=0;i<n;i++){
		ans+=(x-a[i])*(x-a[i]);
	}
	return ans;
}

int main(){
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
	}
	int l=0,r=200;
	while(l<r){
		int lmid=(2*l+r)/3,rmid=(2*r+l+2)/3;
		if(val(lmid)<val(rmid)){
			r=rmid-1;
		}
		else l=lmid+1;
	}
	printf("%d",val(l));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    int a=0,b=1;
    int c;
    cin>>n;
    for (int i=0;i<=n;i++) {
        c=a+b;
        a=b;
        b=c;
    }
    cout<<a<<endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>

using namespace std;

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

	int nd[10][10];

	for (int i =0; i<n; i++){
		for (int j =0; j<d; j++){
			cin >> nd[i][j];
		}
	}

	int count = 0;


	for (int i = 0; i < n; i++){
		for (int p = i + 1; p < n; p++){
			double kyori = 0;
			double kei = 0;
			for (int j = 0; j < d; j++){
				kei += pow((nd[i][j] - nd[p][j]), 2);

				//if (i == n - 1){
				//	kei += pow((nd[i][j] - nd[0][j]), 2);
				//}
				//else{
				//	kei += pow((nd[i][j] - nd[i + 1][j]), 2);
				//}
			}
			kyori = sqrt(kei);
			//cout << kyori << endl;
			if (ceil(kyori) != floor(kyori)) {
				
			}
			else {
				++count;
			}
		}
	}

	cout << count << endl;

	system("pause");
	return 0;
}

Measured memory_bytes: 504
from sys import stdin
from itertools import accumulate
from collections import Counter

input = stdin.readline
N, M = map(int, input().split())
A = [0] + list(map(int, input().split()))
acc = list(map(lambda x: x % M, accumulate(A)))
ans = 0
for n in Counter(acc).values():
    ans += n*(n-1)//2
print(ans)


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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;
struct UnionFind{
	static const int Usize = 1001;
	int par[Usize];
	void init(int n){
		for(int i = 0; i <= n; i++) par[i] = i;
	}
	int find(int x){
		if(par[x] == x) return x;
		else{
			return par[x] = find(par[x]);
		}
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	void uni(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(x < y) par[y] = x;
		else par[x] = y;
		return;
	}
};

int main(){
	int n, m;
	P in[50];
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> in[i].first >> in[i].second;
	}
	int cnt = 0;
	for(int i = 0; i < m; i++){
		UnionFind uf;
		uf.init(n+1);
		for(int j = 0; j < m; j++){
			if(i == j) continue;
			uf.uni(in[j].first, in[j].second);
		}
		if(!uf.same(in[i].first, in[i].second))
			cnt++;
	}

	cout <<cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll h = 1e6;
    ll l = 0;
    while(h - l > 1)
    {
        ll mid = (h + l) >> 1;
        ll num = 0;
        for(int i = 0; i < n; i++)
        {
            num += n - (lower_bound(a.begin(), a.end(), mid-a[i]) - a.begin());
        }
        if(num >= m)
        {
            l = mid;
        }
        else
        {
            h = mid;
        }
    }
    ll v = l;
    vector<ll> s(n+1);
    for(int i = n-1; i >= 0; i--)
    {
        s[i] = s[i+1] + a[i];
    }
    ll num = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        ll pos = lower_bound(a.begin(), a.end(), v - a[i]) - a.begin();
        ans += s[pos];
        num += n - pos;
        ans += a[i] * (n-pos);
    }
    ans -= (num-m) * v;
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
          
bool comp(pair<string, int> a, pair<string, int> b){
    return a.S < b.S;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;
    cin >> n;
    int cnt = 0;
    int ans = 10000;
    for(int i = 0; i < n ; ++i){
        int x;
        cin >> x;
        while(x % 2 == 0){
            x =  x / 2;
            cnt ++;
        }
        ans = min(ans,cnt);
        cnt = 0;
    }
    cout << ans;
}


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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	int n;
	cin >> n;
	int a[n];
	int b[n];
	int c[n - 1];
	int sum = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n; i++){
		cin >> b[i];
		sum += b[i];
	}
	for(int i = 0; i < n - 1; i++){
		cin >> c[i];
	}
	for(int i = 1; i < n; i++){
		int d = a[i];
		int e = a[i - 1];
		if(d == e + 1){
			sum += c[a[i - 1] - 1];
		}
	}
 	cout << sum << endl;
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> path[n];
  rep(i,0,n-1){
    int a,b;
    cin>>a>>b;
    path[a-1].push_back(b-1);
    path[b-1].push_back(a-1);
  }
  int f[n];
  int s[n];
  rep(i,0,n){
    f[i]=-1;
    s[i]=-1;
  }
  f[0]=0;
  s[n-1]=0;
  queue<int> q;
  q.push(0);
  while(q.size()){
    int r=q.front();
    q.pop();
    for(int p:path[r]){
      if(f[p]==-1){
        f[p]=f[r]+1;
        q.push(p);
      }
    }
  }
  q.push(n-1);
  while(q.size()){
    int r=q.front();
    q.pop();
    for(int p:path[r]){
      if(s[p]==-1){
        s[p]=s[r]+1;
        q.push(p);
      }
    }
  }
  int fe=0,sn=0;
  rep(i,0,n){
    if(f[i]<=s[i]) fe++;
    else sn++;
  }
  if(fe<=sn) cout<<"Snuke"<<endl;
  else cout<<"Fennec"<<endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>



using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a)

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef  long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const double EPS = 1e-7;
const int MAX = 20 * 1000 + 47;
const int MAS = 1e5 * 3;
const int MOD = 1000 * 1000 * 1000 + 7;

double DIST(double x1, double x2, double y1, double y2)
{
    return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
vector<vector<int > > g(MAS);
bool used[MAS];
VI dist(MAS);
VI in(MAS);
void dfs(int v)
{
    used[v] = true;
    for (int b : g[v])
    {
        in[b] --;
        dist[b] = max(dist[b], dist[v] + 1); 
        if (in[b] == 0)
        {
            dfs(b);
        }
    }


}


int main()
{
    int n, m;
    cin >> n >> m; 
 
    rep(i,m)
    {
        int x, y;
        cin >> x >> y;
        --x, --y; 
        g[x].PB(y);
        in[y] ++;
    }
    rep(i, n)
    {
        if (!used[i] && in[i] == 0 )
        {
            dfs(i); 
        }
    }
    int ans = 0; 
    rep(i,n)
    {
        ans = max(ans, dist[i]); 
    }
    cout << ans; 


}










Measured memory_bytes: 16000
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=200010;
int n;
char s[N];
int v[30][N],f[N],g[N],c[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') ch=getchar(),o=-1;
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void add(int x,int f) {
    while(x<=n) c[x]+=f,x+=(x&-x);
}
inline int query(int x) {
    int ret=0;
    while(x) ret+=c[x],x-=(x&-x);
    return ret;
}
int main() {
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++) {
	s[i]-='a';
	add(i,1),v[s[i]][++g[s[i]]]=i;
    }
    int cnt=0,flg=0;
    long long ans=0;
    for(int i=0;i<26;i++)
	if(g[i]&1) ++cnt;
    if(cnt>1) return puts("-1"),0;
    for(int i=1;i<=n;i++) {
	if(f[s[i]]>=g[s[i]]) continue;
	int x=v[s[i]][++f[s[i]]],y=v[s[i]][g[s[i]]--];
	ans+=flg;
	if(x==y) flg=1;//ans+=(query(n)-query(i))>>1;
	else ans+=query(n)-query(y);
	add(y,-1);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 21760
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t="";
    cin >> s;
    rep(i,s.size()){
        if(i%2==0){
            t+=s[i];
        }
    }
    cout << t << endl;
}

Measured memory_bytes: 3728
#include<cstdio>
typedef long long ll;
int main(){
	ll n,a,b,c,d;
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	b -= a;
	n--;
	bool flag = false;
	for(int i=0;i<=n;i++) if(b>=c*i-d*(n-i)&&b<=d*i-c*(n-i)) flag = true;
	if(flag) printf("YES\n");
	else printf("NO\n");
}


Measured memory_bytes: 128
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 50010
#define M5 200009
#define M6 2000009
#define M 1000000007
#define inf LLONG_MAX
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<ll,ll> P;
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
ll fac[M6],not_prime[M6];
ll power(ll x,ll n){
    if(x==0) return 0;
    if(n==0) return 1;
    /*while(n){
        if(n%2) x=(((x*x)%M)*x)%M; 
        else x=(x*x)%M;
        n/=2;
    }*/
    if(n%2 == 0) return power((x*x),n/2);
    else return (x*power((x*x),(n-1)/2));
}
void fact(){
    fac[0]=1;
    for(ll i=1;i<M6;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<M6;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=M6;i+=p) not_prime[i]=1;
        }
    }
}
ll modi(ll a, ll m){
    ll m0 = m, t, q; ll x0 = 0, x1 = 1;
    if (m == 1) return 0;
    while (a > 1){  q = a / m; t = m; m = a % m, a = t;t = x0;x0 = x1 - q * x0; x1 = t;}
    if (x1 < 0) x1 += m0;return x1;
}
ll n,m,ar[M6];
int main(){
    buf; 
    //sieve(); 
    //fact();
    ll i,j,k,test,flag,t1,t2,ans; string s;
    //cin>>test;
    test=1;
    while(test--){
    	cin>>s;
    	ans=0;
    	for(i=1;i<3;i++) if(s[i]==s[i-1]) ans++;
    	if(ans==2) {cout<<"Yes"; return 0;}
    	ans=0;
    	for(i=2;i<4;i++) if(s[i]==s[i-1]) ans++;
    	if(ans==2) cout<<"Yes";
    	else cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int n;
    cin>>n;

    vector<int> bukas(n);

    for (int i = 1; i < n; i++)
    {
        int a;
        cin>>a;

        bukas[a - 1]++;
    }

    for (int i = 0; i < n; i++)
    {
        cout << bukas[i]<<endl;
    }
}


Measured memory_bytes: 4784
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int min = 0;
		for(int i = 0; i < N; i++) {
			int c = sc.nextInt();
			int t = sc.nextInt();
			if(t <= T) {
				if(min == 0) {
					min = c;
				}else{
					min = Math.min(min, c);
				}
			}
		}

		if(min == 0) {
			System.out.println("TLE");
		}else {
			System.out.println(min);
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
 cin>>N;
 if(N<=999){
     if(N<10){
         if(N==2||N==4||N==5||N==7||N==9){
             cout<<"hon";
         }
         if(N==0||N==1||N==6||N==8){
             cout<<"pon";
         }
         if(N==3){
             cout<<"bon";
         }
     }
     if(N>=10){
         if(N%10==2||N%10==4||N%10==5||N%10==7||N%10==9){
             cout<<"hon";
         }
          if(N%10==0||N%10==1||N%10==6||N%10==8){
             cout<<"pon";
         }
          if(N%10==3){
             cout<<"bon";
         }
     }
 }
return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    rep(i, n){
        int h;
        cin >> h;
        if (k <= h){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#Grid1
mod=10**9+7
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
dp=[[0]*(w) for i in range(h)]
for i in range(w):
    if a[0][i]==".":
        dp[0][i]=1
    else:
        break
for i in range(h):
    if a[i][0]==".":
        dp[i][0]=1
    else:
        break
for i in range(1,h):
    for j in range(1,w):
        if a[i][j]=="#":
            dp[i][j]=0
        else:
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod
print(dp[h-1][w-1])

Measured memory_bytes: 87280
D, G = map(int, input().split())

G = G//100

problems = []

for i in range(D):
    p, c = map(int, input().split())
    problems.append((p, c//100))

ans = 10000

for i in range(1 << D):
    score = 0
    num = 0
    for j in range(D):
        comp = 1 << j
        if i & comp:
            score += (j+1) * problems[j][0] + problems[j][1]
            num += problems[j][0]
    if score < G:
        for k in range(D-1, -1, -1):
            comp = 1 << k
            if not i & comp:
                for l in range(problems[k][0]-1):
                    score += k + 1
                    num += 1
                    if score >= G:
                        break
                else:
                    continue
                break
    if score >= G and ans > num:
        ans = num

print(ans)


Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	vvint vv;
	initvv(vv,n,n);
	rep(i,n){
		rep(j,n){
			char t;
			cin>>t;
			vv[i][j] = (t=='#'?1:0);
		}
	}
	vint cc(n);
	int cnt = 0;
	rep(i,n){
		rep(j,n){
			cc[i]+=vv[i][j];
		}
		if(cc[i]==n) cnt++;
	}
	vint dd(n);
	bool ok = false;
	rep(i,n){
		rep(j,n){
			dd[j]+=vv[i][j];
			if(vv[i][j]) ok=true;
		}
	}
	if(!ok){
		cout<<-1<<endl;
		return;
	}
	int dcnt = 0;
	rep(i,n){
		if(dd[i]==n) dcnt++;
	}
	if(cnt){
		cout<<n-dcnt<<endl;
		return;
	}
	int ans = INF;
	rep(i,n){
		if(dd[i]==0){
			mins(ans, n-cc[i] + 1 + n - dcnt);
		}
		else{
			mins(ans, n-cc[i] + n - dcnt);
		}
	}
	if(ans==INF) ans=-1;
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 1280
# -*- coding:utf-8 -*-

def chess(H,W,m):
    c = ''
    count = 0
    if m % 2 == 0:
        for i in range(H):
            if count % 2 == 0:
                c += '#'
            else:
                c += '.'
            count += 1
        print(c)

    if m % 2 == 1:
        for i in range(H):
            if count % 2 == 0:
                c += '.'
            else:
                c += '#'
            count += 1
        print(c)        
            
data = []
while True:
    try:
        di = input()
        if di == '0 0':
            break
        data.append(di)
    except:
        break

for i in range(len(data)):
    x = data[i]
    W,H = map(int,x.split())

    for l in range(W):
        chess(H,W,l)
    print('')

Measured memory_bytes: 7728
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a <= c && b >= c || a >= c && b <= c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, s);
  string ss = "";
  each(x, s) {
    if (x == 'B') {
      if (ss.size()) ss.pop_back();
    } else {
      ss += x;
    }
  }
  print(ss);
}


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

int main(){
  int N, T;
  cin >> N >> T;
  int p[N];
  int sub, max=0, min, cnt=0;
  cin >> p[0];
  min=p[0];
  for(int i=1; i<N; i++){
    cin >> p[i];
    if(p[i]<min) min=p[i];
    sub = p[i] - min;
    if(max<sub){
      max = sub;
      cnt = 1;
    }else if(max==sub&&max!=0){
      cnt++;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 640
int main(){
  int n,i;
  double x1,y1,x2,y2,x3,y3,x4,y4;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
    x2=x2-x1;
    y2=y2-y1;
    x4=x4-x3;
    y4=y4-y3;
    if(x2==0||x4==0){
      if(x2==0&&x4==0){
	printf("YES\n");
      }
      else{
	printf("NO\n");
      }
    }
    else{
      if(y2/x2==y4/x4){
	printf("YES\n");
      }
      else{
	printf("NO\n");
      }
    }
  }
  return 0;
}

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

int main(){
  
  cout << fixed << setprecision(12);
  
  int a, b;
  cin>>a>>b;


  cout<< a / b <<" ";
  cout<< a % b <<" ";
  cout<<(double)a / b <<endl;

  return 0;
}


Measured memory_bytes: 3260
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.math.BigInteger;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());
            BigInteger b = BigInteger.valueOf(x);

            // 出力
            if (isPrime(x)) {
                out.println(b.nextProbablePrime());
            } else {
                out.println(x);
            }

        }

        public static boolean isPrime(int num) {
            if (num < 2) return true;
            else if (num == 2) return false;
            else if (num % 2 == 0) return true;

            double sqrtNum = Math.sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2) {
                if (num % i == 0) {
                    return true;
                }
            }
            return false;
        }

    }
}



Measured memory_bytes: 36280
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <limits>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define FORCLS(i,a,b) for(int i = (a); i <= (b); i++)
#define REPCLS(i,n) FORCLS(i,1,n)
// For debug
#ifdef _DEBUG
#define DD(x) cerr << #x << ":" << x << endl;
#define DDA(ary) \
cerr << #ary << ":" << endl;\
for (auto v : ary) { cerr << v << ","; }\
cerr << endl;
#else
#define DD(x)
#define DDA(ary)
#endif

using IntType = long long;
IntType n, k;
IntType solve1 () {
	IntType ret = 0;
	REPCLS(i, n - 2) {
		int cnt = 0;
		REPCLS(j, 5) {
			IntType a = 7 * i + j - 7;
			IntType sum = (9 * a + 72) % 11;
			if (sum == k) cnt++;
		}
		ret  += cnt;
	}
	return ret;
}
int cnts[12];
IntType solve2() {
	int yMax = (n - 2 < 11) ? n - 2 : 11;
	int xMax = 5;
	if (n <= 2) {
		cout << 0 << endl;
		return 0;
	}


	REPCLS(i, yMax) {
		int cnt = 0;
		REPCLS(j, xMax) {
			IntType a = 7 * i + j - 7;
			IntType sum = (9 * a + 72) % 11;
			if (sum == k) cnt++;
		}
		cnts[i] = cnt;
	}
	IntType cntSum = 0;
	REPCLS(i, yMax) {
		cntSum += cnts[i];
	}
	IntType r = (n - 2) / 11;
	IntType q = (n - 2) % 11; q = (q == 0) ? 11 : q;
	IntType ans = (r * cntSum);
	REPCLS(i, q) {
		ans += cnts[i];
	}
	return ans;
}
int main() {
	cin >> n >> k;
	IntType ans;
	if (n <= 100) {
		ans = solve1();
	}
	else {
		ans = solve2();
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int r,g,b;
	cin >> r >> g >> b;
	if((100*r+10*g+b)%4 == 0)
		cout << "YES" << endl;
	
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll cost[4][33];

int main(){cout<<fixed<<setprecision(10);
		   //前処理O(n^2*c)
           //色の選び方O(c*3)
           int n,C;
           cin>>n>>C;
           vector<vin> d(C+1,vin(C+1));
           rep(i,1,C+1)rep(j,1,C+1)cin>>d[i][j];
           vector<vin> c(n,vin(n));
           rep(i,0,n)rep(j,0,n)cin>>c[i][j];
           int pp=0;
            rep(i,1,C+1){
            rep(j,0,n){
             rep(k,0,n){
               pp=d[c[j][k]][i];
               if((j+k)%3==0){
                 cost[0][i]+=pp;
               }
               else if((j+k)%3==1){
                 cost[1][i]+=pp;
               }
               else{
                 cost[2][i]+=pp;
               }
             }
            }
           }
           
           ll ans=inf;
           rep(i,1,C+1){
            rep(j,1,C+1){
             rep(k,1,C+1) {
               if(i==j||j==k||i==k)continue;
              ll cnt=cost[0][i]+cost[1][j]+cost[2][k];
               chmin(ans,cnt);
             }
            }
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 4540
import collections
import sys

n = int(input())
vn = list(map(int,input().split()))
vnodd = collections.Counter(vn[1::2]).most_common()
vneven= collections.Counter(vn[0::2]).most_common()
vnodd.append([0,0])
vneven.append([0,0])

if vnodd[0][0] != vneven[0][0]:
  print(n - (vnodd[0][1] + vneven[0][1]))
else:
  print(min(n-vnodd[0][1]-vneven[1][1], n-vnodd[1][1]-vneven[0][1]))


Measured memory_bytes: 20572
#include<cstdio>
int a[110000],f[10];
int main()
{
	int n,k,x;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&x);
		f[x]=1;
	}
	for(int i=1;i<=100000;i++)
	{
		x=i;
		while(x)
		{
			if(f[x%10]) {a[i]=1;break;}
			x/=10;
		}
	}
	for(int i=n;i<=100000;i++)
	if(!a[i]) {printf("%d\n",i);break;}
	return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

var searched []bool
var count int

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	maxw, _ := strconv.Atoi(stringLineScan())
	w := make([]int, n+1)
	v := make([]int, n+1)
	for i := 1; i <= n; i++ {
		w[i], _ = strconv.Atoi(stringLineScan())
		v[i], _ = strconv.Atoi(stringLineScan())
	}
	dp := make([][]int, n+1)
	INF := 1000000000000
	for i := 0; i <= n; i++ {
		x := make([]int, 100001)
		for j := 1; j <= 100000; j++ {
			x[j] = INF
		}
		dp[i] = x
	}
	ans := 0
	for i := 1; i <= n; i++ {
		for j := 1; j <= 100000; j++ {
			if v[i] > j {
				dp[i][j] = dp[i-1][j]
			} else {
				dp[i][j] = smaller(dp[i-1][j-v[i]]+w[i], dp[i-1][j])
				if dp[i][j] <= maxw && j > ans {
					ans = j
				}
			}
		}
	}
	fmt.Println(ans)
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


Measured memory_bytes: 82432