akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


vector<string> split(string str, string delim)
{
    vector<string> result;
    int cutAt;
    while( (cutAt = str.find_first_of(delim)) != str.npos )
    {
        if(cutAt > 0)
        {
            result.push_back(str.substr(0, cutAt));
        }
        str = str.substr(cutAt + 1);
    }
    if(str.length() > 0)
    {
        result.push_back(str);
    }
	return result;
}


int main()
{
	string line;
	while(getline(cin, line))
	{
		vector<string> vs = split(line, " ");

		stack<double> c;

		rep(i, vs.size())
		{
			if(vs[i] == "+")
			{
				double b = c.top(); c.pop();
				double a = c.top(); c.pop();
				c.push(a + b);
			}
			else if(vs[i] == "-")
			{
				double b = c.top(); c.pop();
				double a = c.top(); c.pop();
				c.push(a - b);
			}
			else if(vs[i] == "*")
			{
				double b = c.top(); c.pop();
				double a = c.top(); c.pop();
				c.push(a * b);
			}
			else if(vs[i] == "/")
			{
				double b = c.top(); c.pop();
				double a = c.top(); c.pop();
				c.push(a / b);
			}
			else c.push(atoi(vs[i].c_str()));
		}

		printf("%.6f\n", c.top());
	}
}

Measured memory_bytes: 0
t = input()
for _ in[0]*int(input()):
    cmd = input().split()
    if len(cmd) > 3:
        head, a, b, rt = cmd
    else:
        head, a, b = cmd
    a = int(a)
    b = int(b)

    if head == 'print':
        pt = t[a:(b+1)]
        print(pt)
    if head == 'reverse':
        t = t[:a] + ''.join(list(reversed(t[a:(b+1)]))) + t[(b+1):]
    if head == 'replace':
        t = t[:a] + rt + t[(b+1):]



Measured memory_bytes: 5616
n,m = gets.split(' ').map(&:to_i)
a = gets.split(' ').map(&:to_i).sort
minVote = a.sum / (4.0*m)
answer = true
m.times do |i|
    compare = a.pop
    answer = false if compare < minVote
end

puts answer ? 'Yes' : 'No'

Measured memory_bytes: 14276
import itertools
n = int(input())
t_p = tuple(map(int, input().split()))
t_q = tuple(map(int, input().split()))

l_p = list(itertools.permutations(range(1, n + 1), n))

print(abs((l_p.index(t_p) + 1) - (l_p.index(t_q) + 1)))


Measured memory_bytes: 8052
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

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

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  cin >> h;
  vector<int> dp(N);
  dp[1] = abs(h[0] - h[1]);
  for (int i = 1; i < N - 1; i++) {
    dp[i + 1] =
        min(dp[i] + abs(h[i + 1] - h[i]), dp[i - 1] + abs(h[i + 1] - h[i - 1]));
  }
  cout << dp[N - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int n[4],m=0;
    cin>>n[0]>>n[1]>>n[2]>>n[3];
    for(int i=0;i<4;i++){
        if(n[i]==1){
            m++;
            break;
        }
    }
    for(int i=0;i<4;i++){
        if(n[i]==7){
            m++;
            break;
        }
    }
    for(int i=0;i<4;i++){
        if(n[i]==9){
            m++;
            break;
        }
    }
    for(int i=0;i<4;i++){
        if(n[i]==4){
            m++;
            break;
        }
    }
    if(m==4){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
}


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

int main(){
  ll n,x;
  cin >> n >> x;
  
  vector<ll> v(n), w(n);
  
  for(ll i=0; i<n; i++){
    ll z;
    cin >> z;
    v[i] = z;
  }
  
  for(ll i=0; i<n; ) w[i] = v[i] + v[++i];
  
  ll ans = 0;
  for(ll i=0; i<n-1; i++){
    if(w[i] > x){
      ans += w[i] - x;
      w[i+1] -= min(v[i+1], w[i] - x);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <map>
#include <vector>

using namespace std;

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    map<int, int> m;

    for (int i = 0; i < N; i++)
    {
        int A;
        if (scanf("%d", &A) < 1) return 0;
        m[A]++;
    }

    printf("%d\n", m.size() % 2 ? m.size() : m.size() - 1);
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<math.h>

typedef struct P { double x, y; } Point;

void koch(int n, Point a, Point b){
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;
  
  if( n == 0 ) return;

  s.x = ( 2.0 * a.x + 1.0 * b.x ) / 3.0;
  s.y = ( 2.0 * a.y + 1.0 * b.y ) / 3.0;
  t.x = ( 1.0 * a.x + 2.0 * b.x ) / 3.0;
  t.y = ( 1.0 * a.y + 2.0 * b.y ) / 3.0;
  u.x = ( t.x - s.x ) * cos(th) - ( t.y - s.y ) * sin(th) + s.x;
  u.y = ( t.x - s.x ) * sin(th) + ( t.y - s.y ) * cos(th) + s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n-1, t, b);
}

int main(){
  Point a, b;
  int n;

  scanf("%d", &n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;
}



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

int main(void) {
	int n, l;
	cin >> n >> l;

	vector<string> str(n);
	for (int i = 0; i < n; ++i)
		cin >> str[i];

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

	for (int i = 0; i < n; ++i)
		cout << str[i];
	cout << '\n';
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#ifdef LOCAL
mt19937 rng(unsigned(70));
#else
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
#define rand rng


int main() {
	// fios;
	ll x;
	cin >> x;
	ll p = 100;
	int y = 0;
	while(p < x) {
		y++;
		p = p * (1.01);
	}
	cout << y << endl;
}

Measured memory_bytes: 3684
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

c = 0
l = float('inf')
result = 0
for i in range(N):
    t = T[i]
    if t > l:
        result += 1
        l = float('inf')
        c = 0
    if c == 0:
        l = t + K
    c += 1
    if c == C:
        result += 1
        l = float('inf')
        c = 0
if c != 0:
    result += 1
print(result)


Measured memory_bytes: 7484
n,k=map(int,input().split())
s=input()
g=0
for i in range(n):
    if i!=0:
        if s[i-1]==s[i] and s[i]=="L":
            g+=1
    if i!=n-1:
        if s[i+1]==s[i] and s[i]=="R":
            g+=1
print(min(n-1,g+2*k))

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

vector<string> st2;

int bk=0;
int res;
int main()
{
    int h,w,kk;
    cin>>h>>w>>kk;
    for(int i=0;i<h;i++)
    {
        string ww;
        cin>>ww;
        for(int j=0;j<ww.size();j++)
        {
            if(ww[j]=='#')
                bk++;
        }
        st2.push_back(ww);
    }
    //cout<<bk<<" "<<kk<<endl;
    for(int i=0;i<=(int)(pow(2,h)-1);i++)
        for(int j=0;j<=(int)(pow(2,w)-1);j++)
        {
            //printf("%d %d\n",i,j);
            int  ans=bk;
            vector<string> st(st2);
            for(int x=0;x<h;x++)
                if((i>>x)&1) 
                {
                    for(int z=0;z<w;z++)
                    {
                        if(st[x][z]=='#')
                        {
                            ans--;
                            st[x][z]='@';   
                        }
                    }
                }
            for(int y=0;y<w;y++)
                if((j>>y)&1) 
                {
                    for(int z=0;z<h;z++)
                    {
                        if(st[z][w-y-1]=='#')
                            ans--;
                    }
                }
            
            if(ans==kk)
            {
                //printf("%d %d\n",i,j);
                res++;
            }
        
        }
    cout<<res<<endl;
}

Measured memory_bytes: 4108
#include <stdio.h>
#include <string.h>
int main(){    
int m, h;    
char cards[256], temp[256], result[256];    
int i, j=0, len;    
while(1){        
scanf("%s", cards);        
len=strlen(cards);       
if(strcmp(cards, "-")==0&&len==1)break;        
scanf("%d", &m);        
for(;m>0;m--){            
scanf("%d", &h);            
strcpy(temp, cards);            
for(i=0;i<h;i++){                
cards[len-h+i]=temp[i];            }           
 for(i=0;i<len-h;i++){                
cards[i]=temp[i+h];            }        }        
for(i=0;i<len;i++){            
result[j++]=cards[i];        }        
result[j++]='\n';    }    
result[j]='\0';    
printf("%s", result);    
return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define READ(i, j) FOR(i, 0, j, 1)
#define RREAD(i, j) RFOR(i, j, 0, 1)



void solve() 
{
    int n;
    cin>>n;
    int count = 0;
    int countmax = 0;
    for(int i = 0; i<n; i++)
    {
        int a,b;
        cin>>a>>b;
        if(a==b)
        {
            count++;
        }
        else
        {
            countmax = max(count,countmax);
            count = 0;
        }
        
    }
    if(count!=0)
    {
       countmax = max(count,countmax); 
    }

    if(countmax>=3)
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int tc = 1; 
    //cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}


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

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int n,t;
int a[100000];

void solve(){
	int m=a[0];
	int dif=0;
	rep(i,n){
		chmin(m,a[i]);
		chmax(dif,a[i]-m);
	}
	m=a[0];
	int minc=1,maxc=0;
	int ans=0;
	rep(i,n){
		if(m>a[i]){
			m=a[i];
			ans+=min(maxc,minc);
			minc=1;
			maxc=0;
		}
		if(a[i]-m==dif) maxc++;
		if(a[i]==m) minc++;
	}
	ans+=min(maxc,minc);
	cout<<ans<<endl;
}

int main(){
	cin>>n>>t;
	rep(i,n) {
		cin>>a[i];
	}
	solve();
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}
ll judgeprime(ll n){
    ll a,i;
    a=sqrt(n);
    if(a%2==0) a--;
    for(i=a;i>2;i-=2){
        if(n%i==0) break;
    }
    if(i==1) return 1;
    return 0;
}

int main(void){
    ll n;
    scanf("%lld",&n);
    if(n==2){
        printf("2\n");
        return 0;
    }
    if(n%2==0) n++;
    while(1){
        // printf("%lld ",n);
        if(judgeprime(n)==1) break;
        n+=2;
    }
    printf("%lld\n",n);
    return 0;
}


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

int main(){
  std::vector<std::string> gifts;
  std::string gift;
  
  int n;
  std::cin >> n;
  
  while (std::cin >> gift) gifts.push_back(gift);
  
  std::sort(gifts.begin(), gifts.end());
  
  std::string prev = "";
  int count = 0;
  
  for (int i = 0; i < n; i++){
    if (prev != gifts[i]){
      count++;
      prev = gifts[i];
    }
  }
  
  std::cout << count;
  
  return 0;
}

Measured memory_bytes: 11576
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int n,k;cin >> n >> k;
    int a[n],f[n];
    rep(i,n)cin >> a[i];
    rep(i,n)cin >> f[i];
    sort(a,a+n);
    sort(f,f+n);
    reverse(f,f+n);
    int bot = -1;
    int top = 1e15;
    while(top - bot > 1){
        int mid = (top + bot)/2;
        auto ok = [&](int mid){
            int ret = 0;
            rep(i,n){
                ret += max(0ll,a[i] - mid/f[i]);


            }
            return ret <= k;


        };
        if(ok(mid))top = mid;
        else bot = mid;
    }
    cout << top << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int a[1000],b[1000],c[1000],d[1000];
int n,m,q;
long long s[100];
long long ans;
void check()
{
    long long sm=0;
 for(int i=0;i<q;i++)
 {
 if(s[b[i]]-s[a[i]]==c[i]) sm+=d[i];
 }
    ans=max(ans,sm);
}

void seq(int i,int k)
{
 if(i==n+1) {/*for(int p=1;p<=n;p++) cout<<s[p]<<" ";cout<<endl;*/check();return ;}
 for(int j=1;j<=m;j++)
 {
  if(j>=k){s[i]=j;seq(i+1,j);}
 }

}

int main ()
{

    cin>>n>>m>>q;
    for(int i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];
    seq(1,1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3644
import sys
l = sys.stdin.readline().strip()

h, w = map(int, l.split())

if h == 1 or w == 1:
    print(1)
else:
    if h % 2 == 0:
        print((h // 2) * w)
    else:
        column0 = h // 2 + 1
        column1 = h // 2
        if w % 2 == 0:
            res = h * (w//2)
        else:
            res = column0 * (w//2 + 1) + column1*(w//2)
        print(res)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    string n;cin >>n;
    string ans="ABC"+n;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,M,ans=0;
  cin>>N>>M;
  ll S[N+1],T[M+1],DP[N+1][M+1];
  RREP(i,N) cin>>S[i];
  RREP(i,M) cin>>T[i];
  REP(i,N+1){
    REP(j,M+1){
      DP[i][j]=0;
    }
  }
  
  DP[0][0]=1;
  REP(i,N+1){
    REP(j,M+1){
      if(i>=1 && j>=1 && S[i]==T[j]) DP[i][j]+=DP[i-1][j-1];
      if(i>=1) DP[i][j]+=DP[i-1][j];
      if(j>=1) DP[i][j]+=DP[i][j-1];
      if(i>=1 && j>=1) DP[i][j]-=DP[i-1][j-1];
      DP[i][j]%=MOD;
      if(DP[i][j]<0) DP[i][j]+=MOD;
    }
  }
  
  co(DP[N][M]);
  return 0;
}

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

signed main(void)
{
	int num; cin >> num;
	int ans = num;
	for (int i = 2; i*i <= num; ++i)
		if (num % i == 0)
		{
			ans = ans / i * (i - 1);
			while (num % i == 0)
				num /= i;
		}
	if (num > 1)
		ans = ans / num * (num - 1);
	cout << ans << endl;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
long long getGCD(long long  a,long long  b){
    long long  temp;
    if(a < b){
      temp = a;
      a = b;
      b = temp;
    }
    if(a%b == 0){
        return b;
    }else{
        return getGCD(b,a%b);
    }
}
long long doLCM(long long * array,int size){
    long long  x,y,num=array[0],i,gcd;
    for(i=0;(i+1)<size;i++){
        x=num;
        y=array[i+1];
        gcd = getGCD(x,y);
    num = x/gcd * y/gcd * gcd;
    }
    return num;
}
int main()
{
    int n;
    long long array[105];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>array[i];
    long long result = doLCM(array,n);
    printf("%lld\n",result);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int S, W;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S >> W;

	if (S <= W) cout << "unsafe" << endl;
	else cout << "safe" << endl;
}







Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000000000

int main(){
  int N,M;
  cin>>N>>M;
  vector<pair<int,int>> ab(M);
  for(int i=0;i<M;i++){
    cin>>ab.at(i).first>>ab.at(i).second;
    ab.at(i).first--;
    ab.at(i).second--;
  }
  sort(ab.begin(),ab.end());
  priority_queue<int,vector<int>,greater<int>> pq;
  int ans=0;
  for(int i=0;i<M;i++){
    int a=ab.at(i).first;
    int b=ab.at(i).second;
    int nb=1000000001;
    if(!pq.empty()){
      nb=pq.top();
    }
    if(nb<=a){
      ans++;
      while(!pq.empty()){
        pq.pop();
      }
    }
    pq.push(b);
  }
  ans++;
  cout<<ans<<endl;
}


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

int main(void) {
    int  N, h[100], zero_num, not_zero, cnt = 0;
    char b[400];
    if (scanf("%3d ", &N) != EOF) {
        if (fgets(b, 400, stdin) != NULL) {
            h[0] = atoi(strtok(b, " "));
            for (int i = 1; i < N; i++) {
                h[i] = atoi(strtok(NULL, " "));
            }
            while (1) {
                not_zero = 0;
                zero_num = 0;
                for (int i = 0; i < N; i++) {
                    if (h[i] != 0) {
                        if (h[i] >= 1) {
                            h[i] -= 1;
                            not_zero = 1;
                        } else {
                            break;
                        }
                    } else {
                        zero_num += 1;
                        if (not_zero) {
                            break;
                        }
                    }
                }
                if (zero_num == N) break;
                cnt++;
            }
            printf("%d", cnt);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-9
#define PI 2 * acos (0.0)
using namespace std;

bool bi[100005];
char ch[100005];

string S[4];

int main()
{

   
    int a,b,c,d,e,x,y,z;

    scanf("%s", ch);

    int N = strlen(ch);

    S[0] = "dream";
    S[1] = "dreamer";
    S[2] = "erase";
    S[3] = "eraser";

    for(a = 0; a < 4; a++)
    {
        for(b = 0; b < min(N, (int)S[a].size()); b++)
        {
            if(ch[b] != S[a][b])
            {
                break;
            }
        }
        if(b == S[a].size())
        {
            bi[b - 1] = true;
        }
    }

    for(a = 1; a < N; a++)
    {
        if(!bi[a - 1])
        {
            continue;
        }
        for(b = 0; b < 4; b++)
        {
            if(a + S[b].size() - 1 >= N)
            {
                continue;
            }
            for(c = 0; c < S[b].size(); c++)
            {
                if(ch[a+c] != S[b][c])
                {
                    break;
                }
            }
            if(c == S[b].size())
            {
                bi[ a+c-1 ]=true;
            }
        }
    }
    if(bi[N-1])
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 384
/* src: (6 lines)

A, B, H, M = inputInt(), inputInt(), inputInt(), inputInt()
M /= 60.0
H = (H + M) / 12.0
dx = cos(M * 2 * M_PI) * B - cos(H * 2 * M_PI) * A
dy = sin(M * 2 * M_PI) * B - sin(H * 2 * M_PI) * A
printf("%.20f\n", sqrt(dx*dx+dy*dy))

*/

//#define NDEBUG

#include <cassert>
#include <vector>
#include <deque>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

const char*inputCLineOrWord(int mode){static char buf[2097152];static int bufLen=sizeof(buf);static int bufPos=sizeof(buf);static bool canReadFlag=true;static bool crFlag=false;static bool enterFlag=false;if(canReadFlag&&(enterFlag?bufLen<=bufPos:(int)sizeof(buf)<=bufPos+bufPos)){if(0<bufLen-bufPos){memmove(buf,buf+bufPos,bufLen-bufPos);bufLen-=bufPos;}else{bufLen=0;}char*result=fgets(buf+bufLen,sizeof(buf)-bufLen,stdin);canReadFlag=(result!=NULL);if(result!=NULL){int n=strlen(result);enterFlag=(n!=(int)sizeof(buf)-1-bufLen||(1<=bufLen+n&&buf[bufLen+n-1]=='\n'));bufLen+=n;}bufPos=0;}if(mode==0){int pos=bufPos;while(true){char c=buf[pos];if(c==32){buf[pos++]='\0';break;}else if(c==10){if(crFlag){crFlag=false;if(bufPos==pos){pos=++bufPos;continue;}}buf[pos++]='\0';break;}else if(c==13){crFlag=true;buf[pos++]='\0';break;}else if(c==0){break;}++pos;}const char*ret=buf+bufPos;bufPos=pos;while(true){char c=buf[bufPos];if(c==32||c==10||c==13){++bufPos;}else{break;}}return ret;}else if(mode==1){int pos=bufPos;while(true){char c=buf[pos];if(c==10){if(crFlag){crFlag=false;if(bufPos==pos){pos=++bufPos;continue;}}buf[pos++]='\0';break;}else if(c==13){crFlag=true;buf[pos++]='\0';break;}else if(c==0){break;}++pos;}const char*ret=buf+bufPos;bufPos=pos;if(crFlag){while(true){char c=buf[bufPos];if(c==13){++bufPos;crFlag=false;break;}else{break;}}}return ret;}else if(mode==2){return bufLen<=bufPos?NULL:buf+bufPos;}assert(false);return NULL;}const char*inputCWord(){return inputCLineOrWord(0);}int inputInt(){return atoi(inputCWord());}
// generated code (by mmlang) :

int A;
int B;
double H;
double M;
double dx;
double dy;

int main() {
    {
        const auto & $c1 = inputInt();
        const auto & $c2 = inputInt();
        const auto & $c3 = inputInt();
        const auto & $c4 = inputInt();
        tie(A, B, H, M) = tuple<int, int, int, int>($c1, $c2, $c3, $c4);
    }
    M /= 60.0;
    H = (H + M) / 12.0;
    dx = cos(M * 2 * M_PI) * B - cos(H * 2 * M_PI) * A;
    dy = sin(M * 2 * M_PI) * B - sin(H * 2 * M_PI) * A;
    printf("%.20f\n", sqrt(dx * dx + dy * dy));
    return 0;
}


Measured memory_bytes: 2440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;

#define int long long

signed main() {
    int a, b, n;
    cin >> a >> b >> n;

    if(b > n) {
        int faxb = floor(a * n / b);
        int afxb = a * floor(n / b);
        int ans = faxb - afxb; 
        cout << ans << endl;
        return 0;   
    }

    int faxb = floor(a * (b - 1) / b);
    int afxb = a * floor((b - 1) / b);
    int ans = faxb - afxb;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3552
package main

import (
	"fmt"
	"math/big"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	a := make([]int64, n)
	
	for i := range a {
		fmt.Scan(&a[i])
		if a[i] == 0 {
			fmt.Println(0)
			return
		}
	}
	
	max := big.NewInt(1e18)
	ans := big.NewInt(1)
	for i := range a {
    	ans.Mul(ans, big.NewInt(a[i]))
		if ans.Cmp(max) == 1 {
        	fmt.Println(-1)
        	return
		}
	}
	fmt.Println(ans)
}

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

int main()
{

int A1,A2,A3;

cin >>A1>>A2>>A3;
   
 if(A1+A2+A3>=22) {
cout <<"bust"<<endl;
 }
 else{
 cout<<"win"<<endl;        
}
    
}

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

int main() {
    int n, ans = 0;  cin >> n;
    int a[n];
    rep(i,n)  cin >> a[i];

    while (true) {
        bool flag = false;
        rep(i,n) {
            if (a[i] % 2 != 0)  flag = true;
        }
        if (flag)  break;

        rep(i,n)  a[i] /= 2;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2345;
int upto[maxn][maxn], sz[maxn], k;
vector<int> e[maxn], nvals[maxn][maxn];
int get_upto(int u, int v, int k){
	if(k < 0) return 0;
	return lower_bound(nvals[u][v].begin(), nvals[u][v].end(), k + 1) - nvals[u][v].begin();
}
int best(int u, int v, int dist){
	if(dist > k) return 0;
	int can = min(dist, k - dist);
	int tot = 0;
	vector<pair<int,int> > mvs;
	for(int nxt : e[u]) if(nxt != v){
		int up = get_upto(nxt, u, can - 1);
		mvs.push_back({nxt, up});
		tot += up;
	}
	int res = 0;
	for(auto mv : mvs){
		int ntot = tot - mv.second;
		res = max(res, ntot + best(mv.first, u, dist + 1));
	}
	return res + 1;
}
void push(int u, int v, int d, int x, int y){
	nvals[x][y].push_back(d);
	for(int nxt : e[u]) if(nxt != v) push(nxt, u, d + 1, x, y);
}
vector<pair<int,int> > eds;
int main(){
	int n; cin >> n >> k;
	for(int i = 0; i < n - 1; i++){
		int x, y; 
		cin >> x >> y;
	       	eds.push_back({x, y});	
		e[x].push_back(y); 
		e[y].push_back(x);
	}
	for(auto e : eds){
		push(e.first, e.second, 0, e.first, e.second);
		sort(nvals[e.first][e.second].begin(), nvals[e.first][e.second].end());
		swap(e.first, e.second);
		push(e.first, e.second, 0, e.first, e.second);
		sort(nvals[e.first][e.second].begin(), nvals[e.first][e.second].end());
	}
	int res = 0;
	for(int i = 1; i <= n; i++) {
		res = max(res, best(i, 0, 0));
	}
	cout << n - res << endl;
	return 0;
}


Measured memory_bytes: 151296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	set<int> cnt;
	rep(i,n){
		int a;
		cin>>a;
		cnt.insert(a);
	}
	if(n==(int)cnt.size()) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, P[int(1e5+5)];

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

  int ans = 0;
  for (int i = 1; i <= N; i++){
    if (i != P[i]) continue;
    ans++;
    if (i + 1 == P[i + 1]){
      swap(P[i], P[i + 1]);
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 998244353;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll rep_power_modM(ll a, ll n, ll M = MOD){
	if(n == 0)return 1;
	if(n%2 == 0){ll tmp = rep_power_modM(a,n/2,M); return tmp*tmp%M;}
	return a*rep_power_modM(a,n-1,M)%M;
}

int main(){
	ll N, M, K;
	cin >> N >> M >> K;
	COMinit();
	ll ans = 0;
	for(ll nk = 0; nk <= K; ++nk){
		ans += COM(N-1, nk) * M  % MOD * rep_power_modM(M-1, N - nk - 1) % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N,M,P;
using Edge = pair<int, ll>;
vector<vector<Edge> > G;

const ll INF = 1LL<<60;


int main() {
    cin >> N >> M >> P;
    G.resize(N);
    REP(i,M){
        int a,b,c;
        cin >> a >> b >> c; --a; --b;
        G[a].push_back(make_pair(b,c-P));
    }
    
    vector<ll> from(N,-INF),to(N);
    from[0] = 0;
    ll ma = - ( 1LL << 60 );
    
    REP(i,10000){
        REP(j,N) to[j] = from[j];
        REP(x,N) if(from[x] > -(1LL<<60)) {
            for ( auto e: G[x] ){
                to[e.first] = max(to[e.first],from[x]+e.second);
                if ( i > 5010 and to[e.first] > from[e.first] ) to[e.first] = 1LL<<60;
            }
        }
        ma = max(ma,to[N-1]);
        swap(from,to);
    }
    
    ma = max(ma,0LL);
    if ( ma >= 1LL<<50 ) ma = -1;
    cout << ma << endl;
    
    return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define equals(a,b) (abs(a-b)<1e-9)

int main() {
	int n; cin >> n;
	vector<double> x(n), y(n);
	for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];
	bool f = !(n & 1);
	double px = (x[0] + x[n / 2]) / 2, py = (y[0] + y[n / 2]) / 2;
	for (int i = 1; i < n / 2; ++i) {
		if (!equals(px, (x[i] + x[n / 2 + i]) / 2)) f = false;
		if (!equals(py, (y[i] + y[n / 2 + i]) / 2)) f = false;
	}
	if (f) printf("%.10f %.10f\n", px, py);
	else cout << "NA" << endl;

	return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
vector<int> to[200005];
const int MAX=1000000000;
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    vector<int> dist(200005,MAX);
    dist[0]=0;
    while(q.size()!=0){
        int c=q.front();q.pop();
        for(int item:to[c]){
            if(dist[item]==MAX){
                dist[item]=dist[c]+1;
                q.push(item);
            }
        }        
    }
    string ans;
    if(dist[n-1]==2){
        ans="POSSIBLE";
    }else{
        ans="IMPOSSIBLE";
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13168
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
// #define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];
int pos[N];
vector<int> v[N];

int n;

int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 

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

void solve()
{
	int n;
	cin >> n;
	for(int i = n; i <= 1e6; i++)
	{
		if(prime(i))
		{
			cout << i << endl;
			return;
		}
	}
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 6400
n = int(input())
card = [[x for x in input().split()] for _ in range(n)]
pat = [[False for _ in range(13)] for _ in range(4)]
for pic, num in card:
    if pic=='S':
        pat[0][int(num)-1] = True
    elif pic=='H':
        pat[1][int(num)-1] = True
    elif pic=='C':
        pat[2][int(num)-1] = True
    elif pic=='D':
        pat[3][int(num)-1] = True

for i, row in enumerate(pat):
    for j, val in enumerate(row):
        if val:
            continue
        else:
            if i==0:
                print('S', j+1)
            elif i==1:
                print('H', j+1)
            elif i==2:
                print('C', j+1)
            elif i==3:
                print('D', j+1)


Measured memory_bytes: 5620
import java.util.*;

public class Main {
	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		Main soln = new Main();
		System.out.println((soln.jdg(a,b,c))? "YES":"NO");
	}

	private boolean jdg(int a, int b, int c) {
		if(c==0) return true;
		if(a==100) return false;
		int end = 101;
		for(int i=0; i<end; i++) {
			if((b*i+c)%a==0) return true;
		}
		return false;
	}
}

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

int main(void) {
	char str[100001];
	int len;
	int l, r;
	int i;
	
	scanf("%s", str);
	len = strlen(str);
	
	l = r = -1;
	for (i = 0; i < len - 1; i++) {
		if (str[i] == str[i + 1]) {
			l = i + 1;
			r = i + 2;
		}

		if (i + 2 < len) if (str[i] == str[i + 2]) {
			l = i + 1;
			r = i + 3;
		}
	}
	
	printf("%d %d\n", l, r);
	
	
  return 0;
}

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

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

    if (N % 2 == 0) {
        long long res = 0;
        for (int i = 0; i < N/2 - 1; ++i) res += A[i] * 2;
        res += A[N/2 - 1];
        res -= A[N/2];
        for (int i = N/2 + 1; i < N; ++i) res -= A[i] * 2;
        cout << res << endl;
    }
    else {
        long long res1 = 0;
        for (int i = 0; i < N/2 - 1; ++i) res1 += A[i] * 2;
        res1 += A[N/2 - 1] + A[N/2];
        for (int i = N/2 + 1; i < N; ++i) res1 -= A[i] * 2;
        
        long long res2 = 0;
        for (int i = 0; i < N/2; ++i) res2 += A[i] * 2;
        res2 -= A[N/2] + A[N/2 + 1];
        for (int i = N/2 + 2; i < N; ++i) res2 -= A[i] * 2;
        cout << max(res1, res2) << endl;
    }
}

Measured memory_bytes: 4048
from collections import defaultdict

H,W,M = map(int,input().split())
bomb = [[0,0] for _ in range(M)]
bomb_d = defaultdict(int)

for i in range(M):
    bomb[i] = list(map(int,input().split()))
    bomb[i][0] -= 1
    bomb[i][1] -= 1
    bomb_d[tuple(bomb[i])] = 1


dh = [0]*H
dw = [0]*W

for i in range(M):
    dh[bomb[i][0]] += 1
    dw[bomb[i][1]] += 1

Maxh = max(dh)
Maxw = max(dw)

h_p = []
w_p = []

for i in range(H):
    if dh[i] == Maxh:
        h_p.append(i)
for i in range(W):
    if dw[i] == Maxw:
        w_p.append(i)

f = 0
for h in h_p:
    for w in w_p:
        if bomb_d[(h,w)] != 1:
            f = 1
            break
    else:
        continue
    break

if f == 0:
    print(Maxh+Maxw-1)
else:
    print(Maxh+Maxw)













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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    long long B = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        B ^= A[i];
    }
    for (int i = 0; i < N; ++i) cout << (B^A[i]) << endl;
}

Measured memory_bytes: 4776
#include "bits/stdc++.h"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int f[3] = {0};
    for(char c : s){
        int d = (int)(c - 'a');
        f[d]++;
    }
    sort(f, f+3);
    if( f[2] - f[0] > 1 ){
        cout << "NO\n";
    }
    else
        cout << "YES\n";

    return 0;
}












Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <map>
#include <sstream>
#define ll long long
using namespace std;
// ver..(1.1)
string ent="\n";
string space=" ";
int main(){
   ios_base::sync_with_stdio(false);
   ll n;
   cin >> n;

   if(n%2==1)  cout << 0 << ent;
   else{
      n/=2;

      ll total=0;
      ll divisor=5;
      while(divisor<=n){
         total+=n/divisor;
         divisor*=5;
      }
      cout << total << ent;
   }
}
/*
f(2)  = 1 * (2^1)
f(4)  = 2 * 1 * (2^2)
f(6)  = 3 * 2 * 1 * (2^3)
f(8)  = 4 * 3 * 2 * 1 * (2^4)
f(10) = 5 * 4 * 3 * 2 * 1 * (2^5)
.
.
.
*/

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int w,n;
  int i=1,j,k;
  int max_value[1001][1001];
  int value,weight;

  while(1){
    cin>>w;
    if(w==0)break;
    cin>>n;
   
    rep(j,1001)
      rep(k,1001)
      max_value[j][k]=-1;

    max_value[0][0]=0;

    for(j=1;j<=n;j++){
      scanf("%d,%d",&value,&weight);
      for(k=0;k<=w;k++){
	//cout<<j<<" "<<k<<endl;
	if(max_value[j-1][k]<0)
	  continue;
       	//cout<<j<<" "<<k<<endl;
	max_value[j][k]=max(max_value[j][k],max_value[j-1][k]);//j????????????????????\?????????
	
	//cout<<" "<<j<<" "<<k<<endl;
	int a,b;
	/*
	cout<<"debug"<<endl;
	rep(a,n+1){
	  rep(b,w+1)
	    printf(" %2d",max_value[a][b]);
	  cout<<endl;
	}
	*/
       
	if(k+weight<=w)
	  max_value[j][k+weight]=max(max_value[j][k+weight],max_value[j-1][k]+value);//??\??????
	/*
	cout<<"debug"<<endl;
	rep(a,n+1){
	  rep(b,w+1)
	    printf(" %2d",max_value[a][b]);
	  cout<<endl;
	}
	*/
      }
    }


    cout<<"Case "<<i<<":"<<endl;

    int max=0;
    int maxi=w+1;

    for(j=n;j>=0;j--){
      for(k=w;k>=0;k--)
	//	cout<<max_value[j][k]<<" ";
	if(max_value[j][k]>=max && maxi>k){
	  max=max_value[j][k];
	  maxi=k;
	  //	  cout<<"maxi"<<k<<endl;
	}
      //	cout<<endl;
    }
    cout<<max<<endl;
    cout<<maxi<<endl;
    i++;
  }
}

Measured memory_bytes: 5156