akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){

    int H,W;
    cin>>H>>W;
    vector<vector<char>> S(H+2,vector<char>(W+2,'.'));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            char a;
            cin>>a;
            S.at(i+1).at(j+1)=a;
        }
    }
    bool ans=true;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S.at(i+1).at(j+1)=='#'){
                if(S.at(i).at(j+1)=='.'&&S.at(i+2).at(j+1)=='.'&&S.at(i+1).at(j)=='.'&&S.at(i+1).at(j+2)=='.') ans=false;
                
            }
        }
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

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

	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
import java.util.*;

class Main {

    static public int solve(int N, int M) {
        return M*(M-1)/2 + N*(N-1)/2;
    }

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        sc.close();

        System.out.println(solve(N, M));

    }
}

Measured memory_bytes: 22868
a,b,c,d = map(int,input().split())
ff = 1
while a>0 or c>0:
  if a <= 0 or c<= 0:
        break
  if ff%2 == 0:
        a = a-d
        ff = ff+1
  else:
     c =c-b
     ff = ff+1
if a<=0:
    print("No")
else:
    print("Yes")
  

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p,n) for(int i=p;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define endl "\n"
#define mp make_pair
#define pb push_back
#define M 1000000007
ll mod(ll x){
return ((x%M + M)%M);
}
ll add(ll a,ll b){
return mod(mod(a)+mod(b));
}
ll mul(ll a,ll b){
return mod(mod(a)*mod(b));
}

// ....................................................................................
int dp[100001][3];
int ans(vector<vector<int>>&v,int x,int n){
    if(n==0)
    return 0;
    if(dp[n][x]!=-1)
    return dp[n][x];
    if(x==0){
        return dp[n][x] = max(ans(v,1,n-1)+v[n-1][x],ans(v,2,n-1)+v[n-1][x]);
    }
    else if(x==1){
         return dp[n][x] = max(ans(v,0,n-1)+v[n-1][x],ans(v,2,n-1)+v[n-1][x]);   
    }
    else
     return dp[n][x] = max(ans(v,1,n-1)+v[n-1][x],ans(v,0,n-1)+v[n-1][x]);
}
int main()
{
    FIO
    ll t;
    t=1;
    // cin>>t;
    while(t--)
    {
     int n;
     cin>>n;
     vector<vector<int>>v;
     for(int i=0;i<n;i++){
         vector<int>temp;
         int x,y,z;
         cin>>x>>y>>z;
         temp.pb(x);
         temp.pb(y);
         temp.pb(z);
         v.pb(temp);
     }
     memset(dp,-1,sizeof(dp));
     cout<<max(ans(v,0,n),max(ans(v,1,n),ans(v,2,n)));
    }
}

Measured memory_bytes: 16040
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll solve(ll n) {
  if (n == 1)
    return 1;
  if (n == 0)
    return 0;

  return 1 + 2 * solve(n / 2);
}

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

  ll n;
  cin >> n;
  cout << solve(n) << en;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int k;
    int n;
    int dk=1;
  
    cin >> n >> k;
  
	for (int i=0; i<n; i++) {
        if(dk*2 <= dk+k) {
          dk = dk * 2;
        } else {
          dk = dk + k; 
        }
    }
  
   cout << dk << endl;
  
}

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

//def
#define debug(x) cout << #x << ": " << x << '\n'
#define out(x) cout << x << '\n'
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__;               // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);

bool seen[200005];
int a[200005];
int depth[200005];
int ans = INF;
ll k;

void dfs(int s, int d) {
    if (seen[s]) {
        int si = d - depth[s];
        k = (k - depth[s]) % si + depth[s];
        return;
    }

    if (d == k + 1) {
        ans = s + 1;
        return;
    }

    seen[s] = true;
    depth[s] = d;
    dfs(a[s], d + 1);
}

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

    int n;
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;

    dfs(0, 1);
    rep(i, n) if (k == depth[i]) {
        ans = a[i] + 1;
    }

    out(ans);
    return 0;
}


Measured memory_bytes: 5408
#include <stdio.h>
#include <math.h>
int main()
{
    int n,sum=0;
    scanf("%d",&n);
    int ch[55];
    for(int i=0;i<n;i++)
        scanf("%d",&ch[i]);
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum=sum+ch[i]*ch[j];
        }
    }
    printf("%d\n",sum);
    return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

LL P[52] = {0}; //T[i]はレベルiハンバーガのパティの枚数
LL B[52] = {0}; //T[i]はレベルiハンバーガのパンの枚数
LL T[52] = {0}; //T[i]はレベルiハンバーガのパティ+パンの枚数

void init(){
	P[0] = 1;
	B[0] = 0;
	T[0] = 1;

	LL b = 2;
	for(int i=1; i<=50; i++){
		b *= 2;
		P[i] = b - 1;
		B[i] = b - 2;
		T[i] = P[i] + B[i];
	}
}

//level n ハンバーガの下x層に含まれるパティの枚数を返す
LL f(int n, LL x){
	if(x <= 0 || n < 0){
		return 0;
	}
	if(x == 1){
		if(n == 0){
			return 1;
		}
		else{
			return 0;
		}
	}
	LL t = T[n] / 2;
	if(x <= t){
		return f(n-1, x-1);
	}
	else if(x == t+1){
		return P[n-1] + 1;
	}
	else{
		return P[n-1] + 1 +  f(n-1, x - (t+1));
	}
}

LL N, X;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> X;

	init();
	LL ans = f(N, X);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define Mod 998244353
using namespace std;

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
    ll t;
    cin>>t;
    t=t%10;
    if(t==3)
    cout<<"bon";
    else if(t==0 or t==1 or t==6 or t==8)
    cout<<"pon";
    else
    cout<<"hon";
}

Measured memory_bytes: 3648
#include<stdio.h>

void swap(int *x,int *y){
	int z;
	z = *x;
	*x = *y;
	*y =z;
}

void selectionSort(int A[], int N){
	int i,j;
	int minj;
	int count=0;
	for(i=0;i<N;i++){
		minj=i;
		for(j=i; j<N;j++){
			if(A[j]<A[minj]) minj = j;
		}
		if(i != minj){
			swap(&A[i],&A[minj]);
			count++;
		}
	}
	for(j=0; j<N-1; j++){
		printf("%d ",A[j]);
	}
	printf("%d\n",A[j]);
	printf("%d\n",count);
}

int main(void)
{
	int N;
	scanf("%d",&N);
	int Num[N];
	int i;
	for(i=0;i<N;i++) scanf("%d",&Num[i]);
	selectionSort(Num,N);
	return 0;
}

Measured memory_bytes: 1812
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#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 <utility>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> edges(n);
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            v--;
            edges[u].push_back(v);
        }
    }

    vector<int> ds(n, -1);
    ds[0] = 0;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto v : edges[u]) {
            if (ds[v] >= 0) {
                continue;
            }
            ds[v] = ds[u] + 1;
            q.push(v);
        }
    }

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

Measured memory_bytes: 1220
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
s_d = ""
for i in range(len(s)) :
    s_d += s[i]
t_d = ""
for i in range(len(t)) :
    t_d += t[i]
print("Yes" if s_d < t_d else "No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define N 2000
#define maxn (N + 10)
#define maxm (maxn * 2)
#define pb push_back
#define lc (id * 2)
#define rc (id * 2 + 1)
typedef long long ll;
const ll INF = (1e8);
const ll mod = (998244353);
int main(){
    char a;scanf("%c",&a);
    if(a >= 'A' && a <= 'Z'){
        printf("A\n");
    }
    else{
        printf("a\n");
    }
    return 0;
}

Measured memory_bytes: 3760
import sys
input=sys.stdin.readline
n=int(input())
a=[int(j) for j in input().split()]
ans=0
ind=[0]*(n+1)
for i in range(n):
    ind[a[i]]=i+1
l=[0]+list(range(n+1))
r=list(range(1,n+2))+[n+1]
for i in range(1,n+1):
    l1=l[ind[i]]
    l0=l[l1]
    r0=r[ind[i]]
    r1=r[r0]
    ans+=((l1-l0)*(r0-ind[i])+(r1-r0)*(ind[i]-l1))*i
    l[r0]=l1
    r[l1]=r0

print(ans)

Measured memory_bytes: 20116
#include <stdio.h>
#include <string.h>
 
typedef struct { int x1, x2; } TABA;
TABA taba[2][10005]; int sz;
int k1, k2;
 
int split(int x)
{
    int s, i, k;
 
    for (s = 0, i = 0; ; i++) {
        k = taba[k1][i].x2 - taba[k1][i].x1 + 1;
        if (s + k == x) return i;
        if (s + k > x) break;
        s += k;
    }
    memmove(taba[k1]+i+1, taba[k1]+i, sizeof(TABA)*(sz-i)), sz++;
    x = (x-s)+taba[k1][i].x1-1;
    taba[k1][i].x2 = x, taba[k1][i+1].x1 = x+1;
    return i;
}
 
void shuffle(int x, int y)
{
    int i, j, s;
 
    i = split(x), j = split(y);
    s = 0;
    memcpy(taba[k2],   taba[k1]+j+1, sizeof(TABA)*(sz-j-1)); s += sz - j - 1;
    memcpy(taba[k2]+s, taba[k1]+i+1, sizeof(TABA)*(j-i));    s += j-i;
    memcpy(taba[k2]+s, taba[k1],     sizeof(TABA)*(i+1));
    k1 = k2, k2 = !k2;
}
 
int main()
{
    int n, m, p, q, r, x, y;
    int i, ans;
 
    while (scanf("%d", &n) && n > 0) {
        scanf("%d%d%d%d", &m, &p, &q, &r);
        taba[0][0].x1 = 1, taba[0][0].x2 = n, k1 = 0, k2 = 1, sz = 1;
        while (m-- > 0) {
            scanf("%d%d", &x, &y);
            shuffle(x, y);
        }
        x = 0; if (p > 1) x = split(p-1) + 1;
        y = split(q);
        for (ans = 0, i = x; i <= y; i++) {
            if (taba[k1][i].x1 > r) continue;
            if (taba[k1][i].x2 <= r) ans += taba[k1][i].x2 - taba[k1][i].x1 + 1;
            else                     ans += r - taba[k1][i].x1 + 1;
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 2136
x = int(input())

total = ((x)*(x+1))//2

hm3 = x//3

total = total -((hm3)*(3+(hm3*3)))//2

hm5 = x//5

total = total -((hm5)*(5+(hm5*5)))//2

hm15 = x//15

total = total + ((hm15)*(15+(hm15*15)))//2

print(total)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MOD = 1000000007;
using mint = Fp<MOD>;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string L; cin >> L;
  mint ans = 0;
  ll num = 0;
  REP(i,L.size()){
    int len = int(L.size()) - i - 1;
    if(L[i]=='1'){
      ans += modpow(mint(2), num) * modpow(mint(3), len);
      num++;
    }    
  }
  ans += modpow(mint(2), num);
  cout << ans << endl;
  return 0;
}


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

const int N = 5005;

int dp1[N];
long long dp2[N * N];
int a[5];
int b[5];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= 3; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= 3; i++) {
		cin >> b[i];
	}
	a[0] = b[0] = 1;
	for (int i = 0; i <= 3; i++) {
		for (int j = a[i]; j < N; j++) {
			dp1[j] = max(dp1[j], dp1[j - a[i]] + b[i]);
		}
	}
	for (int i = 0; i <= 3; i++) {
		for (int j = b[i]; j < N * N; j++) {
			dp2[j] = max(dp2[j], dp2[j - b[i]] + a[i]);
		}
	}
	cout << dp2[dp1[n]];
	return 0;
}


Measured memory_bytes: 196096
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=[None]*n
    B=[None]*n
    for i in range(n):
        A[i],B[i]=map(int,input().split())

    if(A==B):
        print(0)
        return
    print(sum(A)-min(b for a,b in zip(A,B) if(a>b)))
resolve()

Measured memory_bytes: 42716
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


int main() {
	vector<int> a(6);
	vector<int> x(4);
	rep(i, 6) {
		cin >> a[i];
	}
	rep(i, 6) {
		x[a[i]-1]++;
	}
	rep(i, 4) {
		if (x[i] == 3) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define mod 1000000007
using namespace std;
int n;
int a[10005];
int p[10005][1005];
int ha[1005];
int ok[10005];
map<int,bool> other;
vector<int> ooo;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++){
        int now=a[i];
        for(int j=2;j<=1000;j++)
            while(now%j==0)
                now/=j,p[i][j]++;
        if(now!=1) other[now]=1,ok[i]=now;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=1000;j++)
            ha[j]=max(ha[j],p[i][j]);
    }
    for(map<int,bool>::iterator it=other.begin();it!=other.end();it++)
        ooo.pb(it->fi);
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll now=1;
        ll add[1005];
        memset(add,0,sizeof(add));
        for(int j=1;j<=1000;j++)
            add[j]=ha[j]-p[i][j];
        for(int j=1;j<=1000;j++)
            for(int k=1;k<=add[j];k++)
                now=now*(long long)j%mod;
        for(int j=0;j<ooo.size();j++)
            if(ok[i]!=ooo[j])
                now=now*(long long)ooo[j]%mod;
        //cout<<now<<endl;
        ans=(ans+now)%mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 39936
#include <iostream>
using namespace std;
int main(){
	int N,W;
	cin>>N>>W;
	int v[N],w[N];
	for(int i=0;i<N;i++){
		cin>>v[i]>>w[i];
	}
	
	int DP[N+1][W+1];

	for(int i=0;i<W+1;i++){
		for(int j=0;j<N+1;j++){
			DP[j][i]=0;
		}
	}

	for(int i=1;i<=N;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i-1]){
				DP[i][j]=DP[i-1][j];
			}
			else{
				if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1]){
					DP[i][j]=DP[i-1][j];
				}
				else{
					DP[i][j]=DP[i-1][j-w[i-1]]+v[i-1];
				}
			}
		}
	}
	cout<<DP[N][W]<<endl;

	return 0;
}

Measured memory_bytes: 7020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

//Start from Here
int main(){
    int N;
    cin>>N;
    int a, b, c;
    a=N%10;
    b=((N-a)/10)%10;
    c=(N-a-10*b)/100;
    if(a==7||b==7||c==7){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

class UnionFind:
    def __init__(self, n):
        # 初期状態は全要素が根なので、親は自分自身
        self.par = [i for i in range(n+1)]
        # 集団の要素数(size)を格納する(初期は全て1)
        self.size = [1] * (n+1)
    
    # 根を検索する関数
    def find(self, x):
        # 根までたどったらその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索過程で親を書き換える(圧縮経路)
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    # 結合(unite)する関数
    def unite(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        # サイズを比較し、小さい方を大きい方に繋げる
        if self.size[x] < self.size[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
           
    # 同じグループに属するかを判定する関数
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    # 要素が属する木のサイズを返す関数
    def get_size(self, x):
        return self.size[self.find(x)]
    
    # グループ数を返す関数
    def group_sum(self):
        c = 0
        for i in range(len(self.par)):
            if self.find(i) == i:
                c += 1
        return c


def main():
    V,E,*stw = map(int, read().split())

    Edges = []
    for s, t, w in zip(*[iter(stw)]*3):
        Edges.append((s, t, w))
    
    Edges.sort(key=lambda x: x[2])
    
    uf = UnionFind(V)
    ans = 0
    for s, t, w in Edges:
        if uf.is_same(s, t):
            continue
        else:
            ans += w
            uf.unite(s, t)

    print(ans)
   

if __name__ == "__main__":
    main()


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

int main() {
    int N, W; cin >> N >> W;
    vector<pair<int, int>> wv(N);
    REP(i, 0, N) cin >> wv[i].first >> wv[i].second;

    int max_v = 100000;
    ll dp[N + 1][max_v + 1];
    REP(i, 0, N + 1) {
        REP(j, 0, max_v + 1) {
            dp[i][j] = INT32_MAX;
        }
    }
    dp[0][0] = 0;

    REP(i, 0, N) {
        REP(j, 0, max_v + 1) {
            if (j >= wv[i].second) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - wv[i].second] + wv[i].first);
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        }
    }

    int ans;
    REP(i, 0, max_v + 1) {
        if (dp[N][i] <= W) ans = i;
    }

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

Measured memory_bytes: 79104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  ll a;
  cin>>a;
  ll tmp=1;
  ll ans=1;
  repf(i,2,40){
    tmp=i*i;
    if(tmp<=a){
      while(1){
        tmp*=i;
        if(tmp>a){
          ans=max(ans,tmp/i);
          break;
        }
      }
    }
  }
  op(ans);
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

template<typename T>
struct Segtree {
    int n;
    T e;
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree() {}

    Segtree(int n_input, Func f_input, T e_input) {
        initialize(n_input, f_input, e_input);
    }

    void initialize(int n_input, Func f_input, T e_input) {
        f = f_input;
        e = e_input;
        n = 1;
        while (n < n_input) n <<= 1;
        dat.resize(2 * n - 1, e);
    }

    void update(int k, T a) {
        k += n - 1;
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    T get(int k) {
        return dat[k + n - 1];
    }

    T between(int a, int b) {
        return query(a, b + 1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return e;
        if (a <= l && r <= b) return dat[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
};

using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<P> LR(N);
    rep(i, N) {
        int l, r;
        cin >> l >> r;
        LR[i] = {l, r + 1};
    }
    sort(LR.begin(), LR.end());

    Segtree<int> Lmax(N, [](int a, int b) { return max(a, b); }, -1e9);
    Segtree<int> Rmin(N, [](int a, int b) { return min(a, b); }, 1e9 + 1);
    rep(i, N) {
        Lmax.update(i, LR[i].first);
        Rmin.update(i, LR[i].second);
    }

    int ans = 0;
    // 1区間孤立
    rep(i, N) {
        // i番目の区間だけを選ぶ
        int res1 = LR[i].second - LR[i].first;

        // i番目以外の区間の共通部分
        int l = max(Lmax.between(0, i - 1), Lmax.between(i + 1, N - 1));
        int r = min(Rmin.between(0, i - 1), Rmin.between(i + 1, N - 1));
        int res2 = max(0, r - l);
        ans = max(ans, res1 + res2);
    }

    // 左端ソートしてある境目で二分
    for (int i = 1; i < N; i++) {
        int res1 = Rmin.between(0, i - 1) - Lmax.between(0, i - 1);
        int res2 = Rmin.between(i, N - 1) - Lmax.between(i, N - 1);
        int res = max(0, res1) + max(0, res2);
        ans = max(ans, res);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    vi num(100000+1, 0);
    rep(i,n){
        if(a.at(i)!=0){
            num.at(a.at(i)-1)++;
        }
        num.at(a.at(i))++;
        num.at(a.at(i)+1)++;
    }
    sort(num.begin(), num.end(), greater<>());
    cout << num.at(0) << endl;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    //最初は全てが根であるとして初期化
    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    // xとyの木を併合
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }
    
     // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main(void){
    int n, m;
    cin >> n >> m;
    
    UnionFind tree(n);
    rep(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        tree.unite(x-1, y-1);
    }
    
    vector<int> s(n, 0);
    rep(i, n) s[tree.root(i)] = 1;
        
    cout << accumulate(s.begin(), s.end(), 0) << endl;
}

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

using namespace std;
typedef long long int lli;
//const int MAX=;



int main(){
	lli a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c-1)cout<<b+c;
	else{
		cout<<a+b+b+1;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = INF;
int main()
{
ll n ;
cin >> n ;
vector<vector<ll>> v(n, vector<ll>(3,0) );
rep(i,n)cin >> v[i][0];
rep(i,n)cin >> v[i][1];
rep(i,n) v[i][2]=i;
rep(i,1LL<<n){
  if(__builtin_popcountll(i)!=(n+1)/2)continue;
  vector<ll> a,b;
  rep(j,n){
    if((i>>j &1LL) && j%2)a.push_back(v[j][1]);
    else if((i>>j &1LL) && j%2==0)a.push_back(v[j][0]);
    else if(j%2)b.push_back(v[j][0]);
    else b.push_back(v[j][1]);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  bool ok=1;
  rep(i,n-1){
    if(i%2 && b[i/2]>a[i/2 +1]){ok=0;break;}
    else if(a[i/2]>b[i/2]){ok=0;break;}
  }
  if(!ok)continue;
  ll an=0;
  vector<ll> nw;
  rep(j,n)nw.push_back(((i>>j &1LL)^(j%2))?v[j][0]:v[j][1]);
  vector<ll> see(n);
  rep(j,n){
    ll tar=(j%2?b[j/2]:a[j/2]);
    ll cnt=0;
    rep(k,n){
      if(j%2==0 && (i>>k &1LL)==1 && tar==nw[k] && see[k]==0){
        an+=k-cnt;
        see[k]=1;
        break;
      }
      else if(j%2 && (i>>k &1LL)==0 && tar==nw[k] && see[k]==0){
        an+=k-cnt;
        see[k]=1;
        break;
      }
      if(see[k]==1)cnt++;
    }
  }
  ans=min(ans,an);
}
if(ans==INF)ans=-1;
cout << ans << endl;
return 0;
}

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

#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pqb             priority_queue<ll>
#define pqs             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mx 3000
ll n,m;
bool dp[100005];
vector<ll>v;

string solve(ll k){
   for(int i=1;i<=k;i++){
    for(ll move: v){
        if(move>i)
            continue;
        if(dp[i-move]==0){//cout<<"i "<<i<<" move "<<move<<"  "<<i-move<<"  dp i "<<i<<"  "<<1<<endl;
                dp[i]=1;}
    }
   }
   return dp[k]?"First":"Second";
}
int main()
{
    FIO;
    ll c,d,e,f=0,sum=0,ck,k,p,q,r,t,add=0,w,x,y,z;
    string ans;
    cin>>n>>k;
    memset(dp,0,sizeof dp);
//vector<ll>v(n);
for(int i=0;i<n;i++){
        cin>>p;
        v.pb(p);
    }

/*
     for(int i=0;i<n;i++){
        cout<<i<<" "<<v[i];
   }*/
    ans=solve(k);
    cout<<ans<<endl;
v.clear();
    return 0;
}


Measured memory_bytes: 3744
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f;
int n;
double ans=0;
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i;
	double l;
	cin>>l;
	printf("%f",(l*1.0/3)*(l*1.0/3)*(l*1.0/3));
}

Measured memory_bytes: 256
//  C - Replacing Integer
// https://atcoder.jp/contests/abc161/tasks/abc161_c
#include <iostream>
#include <bits/stdc++.h>
#include <map>
#include <queue>
#include <set>
#include <string> 
#include <vector>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x , val) memset(x , val , sizeof(x));

const ll mxsize = 2e5 + 5;
const ll linf = 1e9;
const long double inf = 10000000000.0;

#define fastIO                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

const ll mod = 998244353;
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 

int main()
{
    fastIO;
    ll n , m;
    cin >> n >> m;
    ll val = n % m;
    cout << min(val , m - val) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define all(x) x.begin(), x.end()
 
typedef long long ll;
typedef long double ld;
 
const int N = 123456;
const int M = 1234567;
 
int a[2222], b[2222];
ll bst[1111], c[2222];
bool has_a_cycle[1111];
 
int main(int argc, char const *argv[])
{
	
	#ifdef Cyborg101
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
 
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
	int n, m;
	cin >> n >> m;
 
	for(int i = 0; i < m; ++i){
		cin >> a[i] >> b[i] >> c[i];
		c[i] = -c[i];
	}
 
	//const ll inf = 1e18;
	#define inf (1ll << 62)
 
 
	for(int i = 0; i <= n; ++i)
		bst[i] = inf;
 
	bst[1] = 0;
 
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
 
			if(bst[a[j]] == inf) continue;
 
			if(bst[a[j]] + c[j] < bst[b[j]])
				bst[b[j]] = bst[a[j]] + c[j];
		}
	}
 
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
 
			if(bst[a[j]] == inf) continue;
 
			if(bst[a[j]] + c[j] < bst[b[j]]){
				bst[b[j]] = bst[a[j]] + c[j];		
				has_a_cycle[b[j]] = true;
			}
 
			if(has_a_cycle[a[j]])
				has_a_cycle[b[j]] = true;
		}
	}
 
	if(has_a_cycle[n])
		cout << "inf" << endl;
	else
		cout << -bst[n] << endl;
 
	return 0;				
}

Measured memory_bytes: 256
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
    if n > 1:return {n} 
    return set(ret)
def main():
    n=int(input())
    a=list(map(int,input().split()))
    g=a[0]
    for i in a[1:]:g=gcd(g,i)
    if g!=1:
        print("not coprime")
        exit()
    ans=0
    s=set()
    for i in a:
        p=primeFactor(i)
        ans+=len(p)
        s|=p
    if ans!=len(s):print("setwise coprime")
    else:print("pairwise coprime")
if __name__ == "__main__":
    main()

Measured memory_bytes: 204660
#include <cstdio>
int main(){
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	r=a%b;
	f=((double)a)/b;
	d=(int)a/b;
	printf("%d %d %.5lf\n",d,r,(double)f);
return 0;
}

Measured memory_bytes: 1068
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            String[] a_op_b = sc.nextLine().split(" ");
            String op = a_op_b[1];
            int a = Integer.parseInt(a_op_b[0]);
            int b = Integer.parseInt(a_op_b[2]);
            switch(op) {
                case "+":
                    System.out.println(a + b);
                    break;
                case "-":
                    System.out.println(a - b);
                    break;
                case "*":
                    System.out.println(a * b);
                    break;
                case "/":
                    System.out.println(a / b);
                    break;
                default:
                    return;
            }
        }
    }
}



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

using ll=long long;



void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)cout<<c<<endl;
    if(a==c)cout<<b<<endl;
    if(b==c)cout<<a<<endl;
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
   for (int i = 0; i < N; i++) {
      vec.at(i) = i + 1;
   }
  for (int i = 0;i < K;i++){
    int j, d;
    j = 0;
    d = 0;
    cin >> d;
    for (j = 0;j < d;j++){
      int A;
      cin >> A;
      vec.at(A - 1) = 0;
    }
  }
  int count = 0;
  for (int n = 0;n < N;n++){
    if(vec.at(n) != 0)
      count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 3632
#include<stdio.h>

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

int main(void){
  int k;
  scanf("%d",&k);

  int ans = 0;

  for(int i = 1;i <= k;i ++){
    for(int j = 1;j <= k;j ++){
      for(int t = 1;t <= k;t ++){
        ans += gcd(gcd(i,j),t);
      }
    }
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 1716
#include<iostream>
#include<string>
#include<vector>
#include<cmath>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
	ll x;
	cin >> x;

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

	bool ok = true;

	//prime test
	ll i=x,ans;
	while(ok){
		REP(j,2,sqrt(i)+1){
			if(i % j == 0){
				ok = false;
				break;
			}
		}
		
		if(ok){
			ans = i;
			break;
		}
		else ok = true;
		
		i++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
int main(){
    int t,a,b,c,d;
    scanf("%d",&t);
    a=t/3600;
    b=t%3600;
    c=b/60;
    d=b%60;
    printf("%d:%d:%d\n",a,c,d);
    return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    VL a(n);
    REP(i,n){
        cin>>a[i];
    }
    SORT_ASC(a);
    auto itr = upper_bound(ALL(a),a[n-1]/2);
    LL k1 = *itr;
    if(itr==a.begin()){
        cout<<a[n-1]<<" "<<k1<<endl;
        return;
    }
    LL k2 = *(itr-1);
    int k;
    if(abs(k1*2-a[n-1])<abs(k2*2-a[n-1])){
        k = k1;
    }
    else{
        k = k2;
    }
    cout<<a[n-1]<<" "<<k<<endl;
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	cout << (a + b) / 2 << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::vector<int> v(10);
while (std::cin >> x,x) {
  rep(i,10)v[i]=0;
  rep(i,x){
    std::cin >> y;
    v[y]++;
  }
  rep(i,10){
    if(v[i]>0){
      Rep(j,v[i]){
        std::cout << "*";
     }
      std::cout<< '\n';
  }else std::cout << "-" << '\n';
}
}
}



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

int main(int argc, char **argv)
{
	ll S, W;
	cin >> S >> W;
	std::cout << (S <= W ? "unsafe" : "safe")<< std::endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(b, n * a) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int H,W,i,j;
  while(1)
       {
  scanf("%d%d",&H,&W);
  if(H==0&&W==0){break;}
 
  for(i=1;i<=H;i++)
    {
      for(j=1;j<=W;j++)
    {
      if(j%2==1)
        {
          if(i%2==1)printf("#");
          else printf(".");
        }
      else
        {
              if(i%2==1)printf(".");
          else printf("#");
        }
    }
      printf("\n");
    }
  printf("\n");
     
       }
  return 0;
}


Measured memory_bytes: 2048
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		int[] count = new int[N+1];
		count[0] = 0;
		for(int i=0;i<N;i++) {
			if(S.charAt(i)=='I') {
				count[i+1] = count[i]+1;
			}else {
				count[i+1] = count[i]-1;
			}
		}
		Arrays.parallelSort(count);
		System.out.println(count[N]);


	}
	public static int sample(int n) {
		return n;
	}

}


Measured memory_bytes: 23124
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u64,
        b: String,
    }

    let b = b.replace(".", "").parse::<u64>().unwrap();
    let ans = a * b / 100;
    println!("{}", ans);
}


Measured memory_bytes: 2152