akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

bool f(){
    int n,m; 
    cin >> n >> m;
    vector<int> x(n);
    float s=0;
    
    for(int i=0;i < n; i++){
        cin >> x[i];
        s+=x[i];
    }
    
    s = s/(4*m);
    
    int j=0;
    for(int c: x){
        if(c >= s) j++;
        if(j >= m) return true;
    }
    
    return false;
}


int main()
{
    if(f()){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
	#define REP(i, n) for (int i = 0; i < (n); ++i)
	#define RREP(i, n) for (int i = (n - 1); 0 <= i; --i)
	using namespace std;
	using ll = long long;
	using P = pair<int, int>;

	int main()
	{
		int N, K, C;
		cin >> N >> K >> C;
		string S;
		cin >> S;

		// 左から K個 貪欲に詰め込んでいく
		vector<int> ls(K, -1);
		int pos = 0;
		REP (i, K) {
			while (S[pos] == 'x') {
				++pos;
			}
			// S[pos] は o
			ls[i] = pos;
			pos += C + 1;
		}
		for (auto &&p : ls) {
			cerr << p << " ";
		}
		cerr << endl;

		// 右から K個 貪欲に詰め込んでいく
		vector<int> rs(K, -1);
		pos = S.size() - 1;
		RREP (i, K) {
			while (S[pos] == 'x') {
				--pos;
			}
			// S[pos] は o
			rs[i] = pos;
			pos -= C + 1;
		}
		for (auto &&p : rs) {
			cerr << p << " ";
		}
		cerr << endl;

		// 同じボール番号が同じところに入るなら
		// それはそこにしかおけないということ
		REP (i, K) {
			if (ls[i] == rs[i]) {
				cout << ls[i] + 1 << endl;
			}
		}
	}

Measured memory_bytes: 3332
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const LL N=100005,mo=1e9+7;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main()
{
	int a=read(),b=read();
	printf("%d\n",a*b-a-b+1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 3e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;
const int M = 1e6 + 5;
 
clock_t start = clock();

bool possible(int a, int b, int c, int k) {
	if (a < b && b < c) return true;
	if (k == 0) return false;
	if (possible(a<<1, b, c, k-1)) return true;
	if (possible(a, b<<1, c, k-1)) return true;
	if (possible(a, b, c<<1, k-1)) return true;
	return false;
}

void solve() {
	int a, b, c;
	int k; 
	cin >> a >> b >> c >> k;
	cout << (possible(a, b, c, k) ? "Yes\n" : "No\n");
}
 
int main() {
	FASTIO;
	int T = 1;
	// pre();
	// cin >> T;
	while(T--) {
		solve();
	}
	// cout << fixed << setprecision(10);
	// cout << (clock() - start) / ((double)(CLOCKS_PER_SEC)) << " s\n";
	return 0;
} 

Measured memory_bytes: 3656
#include <stdio.h>

int main(void) {
  int N;
  scanf("%d", &N);
  int A[N], x[N] = {};
  for (int n = 0; n < N; ++n) scanf("%d", &A[n]);
  for (int n = 0; n < N; ++n) x[0] += ((n%2==0) ? +1 : -1) * A[n];
  for (int n = 0; n < N-1; ++n) x[n+1] = 2*A[n]-x[n];
  for (int n = 0; n < N; ++n) printf("%s%d", (n==0) ? "" : " ", x[n]);
  puts("");
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n; lint a;
  cin >> n;
  v1i v(n);
  rep(i, n) cin >> v[i];
  v2li dp(n+1, v1li(4, -1*1e15)); dp[0][0] = 0; dp[1][0] = v[0]; dp[2][1] = v[1]; if(n > 2) dp[3][2] = v[2];
  rep(i, n-2){
    if(i % 2 == 0){
      dp[i+3][0] = dp[i+1][0] + v[i+2];
      dp[i+3][2] = max(dp[i+3][2], max(dp[i+1][2] + v[i+2], dp[i][1] + v[i+2]));
      if(i > 0) dp[i+3][2] = max(dp[i+3][2], dp[i-1][0] + v[i+2]);
    }
    else dp[i+3][1] = max(dp[i+1][1] + v[i+2], dp[i][0] + v[i+2]);
  }
  if(n % 2 == 0) a = max(dp[n][1], dp[n-1][0]);
  else a = max(dp[n][2], max(dp[n-1][1], dp[n-2][0]));
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 17984
const MAXN = 100;
          oo = MAXLONGINT;
var n,m: longint;
    a: array[1..MAXN] of longint;

procedure Nhap;
var i: longint;
begin
        readln(n);
        for i:= 1 to n do read(a[i]);
end;

procedure QT;
var s,i,min,x: longint;
begin
        min:= +oo;
        //s:= 0;
        for x:= -100 to 100 do
        begin
                s:= 0;
                for i:= 1 to n do
                begin
                        s:= s + ((a[i] - x)*(a[i] - x));
                end;
                if s < min then min:= s;
        end;
        writeln(min);
end;

BEGIN
        Nhap;
        QT;
END.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
	long long a,b,k;
	cin >> a>>b>>k;
	if (k <= a)cout << a-k<<" "<<b << endl;
	else if (k <= a + b)cout << 0<<" "<<b-(k - a) << endl;
	else cout << 0 <<" "<<0<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int convert(char *s)
{
    int n=10000000;
    int i,num=0;
    for(i=0;i<8;i++)
    {
        num+=(int)(*(s+i)-'0')*n;
        n/=10;
    }
    return num;
}
 
void sort(char *data,int muki)
{
    int i,j;
    char tmp;
 
    for(i=0;i<7;i++)
    {
        for(j=i+1;j>0;j--)
        {
            if(muki==1)
            {
                if(*(data+j)<*(data+j-1))
                {
                    tmp=*(data+j);
                    *(data+j)=*(data+j-1);
                    *(data+j-1)=tmp;
                }
            }
            else if(muki==-1)
            {
                if(*(data+j)>*(data+j-1))
                {
                    tmp=*(data+j);
                    *(data+j)=*(data+j-1);
                    *(data+j-1)=tmp;
                }
            }
        }
    }
}
 
int main()
{
    char str[9];
    int max,min,diff,n,i;
 
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",str);
        sort(str,-1);
        max=convert(str);
        sort(str,1);
        min=convert(str);
        diff=max-min;
        printf("%d\n",diff);
    }
    return 0;
}

Measured memory_bytes: 596
from collections import Counter
S=input()[::-1]
mod=2019

X = [0]
for i, s in enumerate(S):
  X.append((X[-1] + int(s)*pow(10, i, mod)) % mod)

C = Counter(X)
ans = 0
for v in C.values():
    ans += v * (v - 1) // 2
print(ans)

Measured memory_bytes: 16604
N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
# 降順ソート
A.sort(reverse=True)
# 対象ピックアップ
pickup = A[:M]
# 足きり算出
if min(pickup) < sum(A) * (1/(4*M)):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 3060
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n;

int main()
{
	scanf("%d",&n);
	if(n<1200)
	{
		puts("ABC");
	}
	else
	{
		if(n<2800)
		{
			puts("ARC");
		}
		else
		{
			puts("AGC");
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	int x,y;
	cin >> x >> y;
	if(x == 0){
		cout << abs(x-y) + (y < 0 ? 1 : 0) << endl;
	}
	else if(max(x,y) <= 0){
		if(x < y){
			cout << y-x << endl;
		}
		else{
			cout << 1 + x-y + 1 << endl;
		}
	}
	else if(min(x,y) >= 0){
		if(x < y){
			cout << y-x << endl;
		}
		else{
			cout << 1 + min(y+x, x-y+1) << endl;
		}
	}
	else{
		if(x < y){
			if(-x <= y){
				cout << 1 + y+x << endl;
			}
			else{
				cout << -y-x + 1 << endl;
			}
		}
		else{
			if(-x <= y){
				cout << 1 + x+y << endl;
			}
			else{
				cout << -y-x + 1 << endl;
			}
		}
	}

	return 0;
}

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

int main()
{
  ll N,A,B;
  cin >> N >> A >> B;

  ll ans;

  ll d = B-A;
  if(d % 2 ==0){
    ans = d/2;
  }else{
    if(A-1 < N-B){
      ans = A -1 + 1 + (B-A-1)/2;
    }else{
      ans = N-B + 1 + (B-A-1)/2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int k,n;
cin>>k>>n;
vector<int> v(n);
rep(i,n)cin>>v[i];
vector<int> d(n);
rep(i,n){
  if((i-1)<0)continue;
  d[i]=v[i]-v[i-1];
}
d[0]=v[0]+k-v[n-1];
sort(d.begin(),d.end());
d[n-1]=0;
int sum=0;
rep(i,n)sum+=d[i];
cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 1792
n,m=map(int,input().split())
s=[]
for i in range(n):
  t=input()
  if '#' in t:
    s.append(t)
s2=[list(x) for x in zip(*s)]
s3=[]
for i in range(m):
  if '#' in s2[i]:
    s3.append(s2[i])
s4=[list(x) for x in zip(*s3)]
for i in s4:
  print("".join(map(str,i)))

Measured memory_bytes: 3188
n,m=map(int,input().split())
h=list(map(int,input().split()))
suba,subb=0,0
ls=[0]*n

for _ in range(m):
  a,b=map(int,input().split())
  suba=h[a-1]
  subb=h[b-1]
  
  if suba>subb:
    ls[b-1]+=1
    
  elif suba==subb:
    ls[a-1]+=1
    ls[b-1]+=1
    
  else:
    ls[a-1]+=1
    
print(ls.count(0))

Measured memory_bytes: 20116
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int main(){
	int t;
	cin >> t;
	rep(i, 0, t){
		int n;
		cin >> n;
		int now,MIN=0,MAX=0;
		cin >> now;
		int pre = now;
		rep(i, 0, n-1){
			cin >> now;
			if(now>pre) MAX = max(MAX, now - pre);
			else MIN = max(MIN, pre - now);
			pre = now;
		}
		o(MAX << " " << MIN);
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(void){
  char s[2*10*10*10*10*10];
  int ans=0;
  cin >> s;
  int num = strlen(s);
  for(int i=0;i<num;i++){
    char t;
    cin >> t;
    if(t != s[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3792
import sys

n = int(input())
l = sys.stdin.readlines()
s = ""
for i in l:
  x, y, z = sorted(map(lambda x:x*x,map(int, i.split())))
  if x + y == z:
      s += "YES\n"
  else:
      s += "NO\n"

print(s,end="")

Measured memory_bytes: 7708
#ABC063C
N = int(input())
s = [int(input()) for _ in range(N)]
ans = -1
s.sort()    
if sum(s) % 10 != 0:
    ans = sum(s)
else:
    for i in range(len(s)):
        if s[i]%10 != 0:
            s.pop(i)
            ans = sum(s)
            break
    if ans == -1:
        ans = 0
print(ans)

Measured memory_bytes: 3060
s = list(input())
pre_index = 0
split_s = []
for i in range(len(s) - 1):
    if s[i] == '>' and s[i + 1] == '<':
        split_s.append(s[pre_index:i+1])
        pre_index = i + 1
split_s.append(s[pre_index:])
ans = 0
for i in range(len(split_s)):
    l = split_s[i].count('<')
    r = split_s[i].count('>')
    if l > r:
        ans += sum(range(1,l+1))
        ans += sum(range(1,r))
    else:
        ans += sum(range(1,r+1))
        ans += sum(range(1,l))
print(ans)

Measured memory_bytes: 21168
n, m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]
start = 0
end = 9999999999
for i in range(m):
    if l[i][0] > start:
        start = l[i][0]
    if l[i][1] < end:
        end = l[i][1]
print(max(end-start + 1, 0))

Measured memory_bytes: 27336
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);

		String line1 = sc.nextLine();
		String line2 = sc.nextLine();
		int result = 0;

		int R =Integer.parseInt(line1);
		int G = Integer.parseInt(line2);

		result = G*2 -R;

		System.out.println(result);
	}

}

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

void solve(long long H, long long W, long long K, std::vector<std::string> A) {
    map<int, map<int, int>> dist;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            dist[i][j] = -1;
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == 'S') {
                dist[i][j] = 0;
                queue<pair<int, int>> que;
                que.push(make_pair(i, j));

                while (que.size()) {
                    auto f = que.front();
                    que.pop();

                    for (int dx = -1; dx <= 1; dx++) {
                        for (int dy = -1; dy <= 1; dy++) {
                            if (dx == 0 && dy == 0) {
                                continue;
                            }
                            if (dx * dy != 0) {
                                continue;
                            }
                            if (dist[f.first + dx][f.second + dy] == -1 && A[f.first + dx][f.second + dy] != '#') {
                                dist[f.first + dx][f.second + dy] = dist[f.first][f.second] + 1;
                                que.push(make_pair(f.first + dx, f.second + dy));
                            }
                        }
                    }
                }
            }
        }
    }

    int ans = numeric_limits<int>::max();

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (dist[i][j] != -1 && dist[i][j] <= K) {
                ans = min(ans, (min({i, j, (int)H - 1 - i, (int)W - 1 - j}) + (int)K - 1) / (int)K);
            }
        }
    }

    cout << ans + 1 << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    long long K;
    scanf("%lld", &K);
    std::vector<std::string> A(H);
    for (int i = 0; i < H; i++) {
        std::cin >> A[i];
    }
    solve(H, W, K, std::move(A));
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a;
	cin >> a;
	cout << (a / 500) * 1000 + ((a % 500) / 5) * 5; 	
	return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  n <- (read :: String -> Integer) <$> getLine
  print $ ans n

ans :: Integer -> Integer
ans n
  | odd n = 0
  | even n = let m = n `div` 10 in m + blind m where
  blind k
   | k < 5 = 0
   | k > 4 = let l = k `div` 5 in l + blind l

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define endl "\n"
#define debug(x)  cout<<#x<<" " <<x<<endl;
#define dbg(x,y)  cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define all(v) v.begin(),v.end()
#define si(x) x.size()

const int e = 100005;
const ll INF = 1e18+5;
template<typename T>void show2(T& dp)
{
    for( auto row:dp)
    {
        for(auto col:row)
            cout<<col<<" ";
        cout<<endl;
    }
}
template<typename T>void show1(T &a)
{
    for(auto x:a)
        cout<<x<<" ";
    cout<<endl;
}
int n,cnt;
void solve(){
	cin>>n;
	queue<ll> q;
	rep(i,1,10)q.push(i);
	while(1){
		int m = q.size();
		for(int i=0;i<m;i++){
			ll s = q.front();
			q.pop();
			if(++cnt==n){
				cout<<s;
				return ; 
			}
			if(s%10==0)q.push(s*10),q.push(s*10+1);
			else if(s%10==9)q.push(s*10+8),q.push(s*10+9);
			else q.push(s*10+(s%10)-1),q.push(s*10+s%10),q.push(s*10+(s%10)+1);
		}
	}
}
int main() {
	// your code goes here
	io;
	
    solve();
	return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
import itertools
INF = float("inf")


def solve(N: int, A: "List[int]"):

    wa = list(itertools.accumulate(A))
    # print(wa)
    m = INF
    # しゃくとり法
    atama1, atama2 = 0, 2
    # 真ん中iを固定する
    for i in range(1, N-2):
        # 0からi-1までの分割位置を決める
        # 最も前後の数列の和が近くなるように

        # 前の虫
        s0, s1 = wa[atama1], wa[i]-wa[atama1]
        for j in range(atama1+1, i):
            t0, t1 = wa[j], wa[i]-wa[j]
            # print(s0, s1, t0, t1, atama1)
            if t0 >= t1:
                if abs(s1-s0) >= abs(t1-t0):
                    s0, s1 = t0, t1
                    atama1 += 1
                break
            s0, s1 = t0, t1
            atama1 += 1
        # print(s0, s1, t0, t1)

        # 後ろの虫
        s2, s3 = wa[atama2]-wa[i], wa[N-1]-wa[atama2]
        for j in range(atama2+1, N):
            t2, t3 = wa[j]-wa[i], wa[N-1]-wa[j]
            if t2 >= t3:
                if abs(s3-s2) >= abs(t3-t2):
                    s2, s3 = t2, t3
                    atama2 += 1
                break
            s2, s3 = t2, t3
            atama2 += 1

        s = [s0, s1, s2, s3]
        # print(s)
        s.sort()
        m = min(s[3]-s[0], m)

    print(m)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	int n;
	cin >> n;
	vector<double> v(n);
	FOR(i, 0, n - 1) {
		cin >> v[i];
	}
	sort(ALL(v));
	FOR(i, 0, n - 2) {
		v[i + 1] = (v[i] + v[i + 1]) / 2;
	}
	cout << setprecision(16) << v[n - 1] << endl;
	return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int calc(const vector<int> &exp) {
    stack<int> st;
    for (int i = 0; i < 7; i++) {
        if (exp[i] == '+') {
            if (st.empty()) return 0;
            int a = st.top(); st.pop();
            if (st.empty()) return 0;
            int b = st.top(); st.pop();
            st.push(a + b);
        } else if (exp[i] == '-') {
            if (st.empty()) return 0;
            int a = st.top(); st.pop();
            if (st.empty()) return 0;
            int b = st.top(); st.pop();
            st.push(b - a);
        } else if (exp[i] == '*') {
            if (st.empty()) return 0;
            int a = st.top(); st.pop();
            if (st.empty()) return 0;
            int b = st.top(); st.pop();
            st.push(a * b);
        } else {
            st.push(exp[i]);
        }
    }
    return st.top();
}

inline bool is_op(char c) {
    return (c == '+' || c == '-' || c == '*');
}

void format(const vector<int> &exp) {
//    for (int i = 0; i < exp.size(); i++) cout << exp[i] << ' ';
//    cout << endl;
    if (is_op(exp[2]) && is_op(exp[5]) && is_op(exp[6])) {
//        cout << "A\n";
        printf("(((%d %c %d) %c (%d %c %d)))\n", 
                exp[0], exp[2], exp[1], exp[6], exp[3], exp[5], exp[4]);
    } else if (is_op(exp[2]) && is_op(exp[4]) && is_op(exp[6])) {
//        cout << "B\n";
        printf("(((%d %c %d) %c %d) %c %d)\n",
                exp[0], exp[2], exp[1], exp[4], exp[3], exp[6], exp[5]);
    } else if (is_op(exp[3]) && is_op(exp[4]) && is_op(exp[6])) {
//        cout << "C\n";
        printf("((%d %c (%d %c %d)) %c %d)\n",
                exp[0], exp[4], exp[1], exp[3], exp[2], exp[6], exp[5]);
    } else if (is_op(exp[3]) && is_op(exp[5]) && is_op(exp[6])) {
//        cout << "D\n";
        printf("(%d %c (%d %c %d) %c %d)\n",
                exp[0], exp[6], exp[1], exp[3], exp[2], exp[5], exp[4]);
    } else if (is_op(exp[4]) && is_op(exp[5]) && is_op(exp[6])) {
//        cout << "E\n";
        printf("(%d %c (%d %c (%d %c %d)))\n",
                exp[0], exp[6], exp[1], exp[5], exp[2], exp[4], exp[3]);
    } else {
        printf("ERROR");
        exit(1);
    }
}

int main() {
    vector<int> n(7);
    while (cin >> n[0] >> n[1] >> n[2] >> n[3]) {
        if (!(n[0] || n[1] || n[2] || n[3])) break;

        string op = "+-*";

        bool found = false;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    n[4] = op[i], n[5] = op[j], n[6] = op[k];
                    sort(n.begin(), n.end());

                    do {
                        if (calc(n) == 10) {
                            found = true;
                            format(n);
                            goto loop_end;
                        }
                    } while (next_permutation(n.begin(), n.end()));
                }
            }
        }
loop_end:
        if (!found) cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 1264
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 1000000000000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n;
long long a[100006];
long long b[100006];
long long l,r;
long long ans;
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	b[n]=INF;
	rep(i,n)
	{
		l=0;
		r=n;
		while(1)
		{
			if(l+1==r)break;
			long long k=(l+r)/2;
			if(b[k]<=a[i])l=k;
			else r=k;
		}
		ans+=(l+i)%2;
	}
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 300011

ll n, A, B, i, j;

bool check(ll n, ll A, ll B) {
    ll l, r;

    l = A + B - 1;
    r = A * B;

    if (n < l || n > r) return false;
    return true;
}

bool check2(ll n, ll A, ll B) {
    ll l, r;

    l = B;
    r = A * B;

    if (n < l || n > r) return false;
    return true;
}

int main()
{
    //freopen("test.in","r",stdin);

    cin >> n >> A >> B;
    if (!check(n, A, B)) {
        cout << -1;
        return 0;
    }

    while (B > 0) {
        for (i = 1; !check2(n - i, A, B - 1); i++);
        for (; check2(n - i, A, B - 1) && i <= A; i++);
        i--;

        for (j = i; j > 0; j--)
            cout << n - j + 1 << ' ';

        n -= i;
        B--;
    }


    return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)

const int INF = 1001001001;

using namespace std;

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

    int n; cin >> n;
    vector<int> h(n); rep(i,n) cin >> h[i];

    vector<int> dp(n,INF);

    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);

    for(int i=2; i<n; i++) {

        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));

    }

    cout << dp[n-1] << endl;

    return 0;
}

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

int main(int argc, char *argv[]){

	char line[7];

	fgets(line, sizeof(line), stdin);

	int i;
	for(i=0;i<6;i++){
		if(line[i] == 'A' && line[i+1] == 'C'){
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int jud_YN(void){
  char str[101];
  scanf("%s",str);
  int len=strlen(str);
  for(int i=0;i<len;i++){
    if(str[i]!=str[len-i-1]){
      return 0;
    }
  }
  for(int i=0;i<len/2;i++){
    if(str[i]!=str[len/2-i-1]){
      return 0;
    }
  }
  return 1;
}
int main(void){
  if(jud_YN()){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
ans = 0
count = 0
masu = h[0]
for he in h[1:]:
    # print(count,ans)
    if masu < he:
        ans = max(ans,count)
        count = 0
    else:
        count += 1
    masu = he
ans = max(ans,count)

print(ans)


Measured memory_bytes: 14224
all_cards = []
[all_cards.append((s, nu)) for s in ['S', 'H', 'C', 'D'] for nu in range(1, 14)]

n = int(input())
hold_cards = []
for i in range(n):
    suit, num = input().split()
    num = int(num)
    hold_cards.append((suit, num))
for card in all_cards:
    if card not in set(hold_cards):
        print(*card)



Measured memory_bytes: 5600
#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;
typedef long long  ll;
typedef long double ld;
typedef pair<ll,ll> pp;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> super_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> multi_set;
#define x1 dfds
#define y1 dsfdsfe
#define pb push_back
#define forn(i,n) for(ll i = 1;i<=n;++i)
#define fi first
#define sc second
#define endl '\n'
#define po(x) (1ll<<x)
const ll DIM = 1e5+7;
const ll INF = 1e9;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

string s;
ll pal(ll l,ll r){
    while(l<r){
        if (s[l]!=s[r])return 0;
        l++;
        r--;
    }
    return 1;
}
int main(){


    cin>>s;
    ll n = s.length()-1;
    if (pal(0,n) && pal(0,n/2-1) && pal((n+4)/2-1,n))cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<functional>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

int main(){
    int N,M;
    bool b[31][31]={};
    cin >>N>>M;
    for(int i=0;i<N;i++){
        int K;
        cin>>K;
        for(int j=0;j<K;j++){
            int a;
            cin>>a;
            b[i][a]=true;
        }
    }
    bool f[31]={};
    int ans=0;
    for(int i=1;i<=M;i++){
        for(int j=0;j<N;j++){
            if(!b[j][i]){
                f[i]=true;
                break;
            }
        }
        if(!f[i]){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
s = [input() for _ in range(H)]

dist = [[H*W for i in range(W)] for j in range(H)]

if s[0][0] == "#":
    dist[0][0] = 1
else :
    dist[0][0] = 0

for h in range(H):
    for w in range(W):
        if w + 1 < W:
            if s[h][w] == "." and s[h][w+1] == "#":
                dist[h][w+1] = min(dist[h][w+1], dist[h][w] + 1)
            else:
                dist[h][w+1] = min(dist[h][w+1], dist[h][w])
        if h + 1 < H:
            if s[h][w] == "." and s[h+1][w] == "#":
                dist[h+1][w] = min(dist[h+1][w], dist[h][w] + 1)
            else:
                dist[h+1][w] = min(dist[h+1][w], dist[h][w])

print(dist[-1][-1])

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

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

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


const ll mod = 1e9+7;
const double eps = 1e-9;



void solve(){
    ll n;
    cin>>n;
    int cnt=0;
    ll t=n;
    int ans=0;
    for(ll i=2;i*i<=n;i++) {
        cnt=0;
        while(t%i==0) {
            t/=i;
            cnt++;
        }
        ans+=((int)(sqrt(1+8*cnt)-1))/2;
    }
    if(t>1)ans++;
    cout<<ans;
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3692
L, R = map(int, input().split())
NUM = 2019

if (L <= 673 <= R and R - L >= 3) or (R - L >= 673):
    print(0)
else:
    mods = []
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % NUM
            mods.append(m)
            if m == 1:
                print(1)
                exit()
    print(min(mods))

Measured memory_bytes: 3060
money_val = int(input())

if money_val < 5:
    print(0)
elif money_val < 500:
    print((money_val // 5)*5)
else:
    fivehun_num = (money_val // 500)
    five_num = money_val - (500*fivehun_num)
    five_num = five_num // 5
    print((fivehun_num*1000) + (five_num*5))

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

int main(){
    int n,W;
    cin>>n>>W;
    vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));
    vector<ll> v(n),w(n);
    for(int i=0;i<n;i++){
        cin>>v[i]>>w[i];
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
            if(j-w[i]>=0){
                dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
                dp[i+1][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[n][W]<<endl;

    return 0;
}

Measured memory_bytes: 10752
def main():
    N = int(input())
    ab = [tuple(int(j) for j in input().split()) for i in range(N)]
    cd = [tuple(int(j) for j in input().split()) for i in range(N)]
    # x 降順
    ab.sort(key=lambda x: x[0], reverse=True)
    # y 昇順
    cd.sort(key=lambda x: x[1])
    ans = 0
    for bx, by in cd:
        for rx, ry in ab:
            if rx < bx and ry < by:
                ab.remove((rx, ry))
                ans += 1
                break
    print(ans)
    return


main()


Measured memory_bytes: 3064
#define taskname "test"
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define sz(x) (int)x.size()
#define fi first
#define se second
 
typedef long long lli;
typedef pair<int, int> pii;
 
const int maxn = 5e5 + 5;
const int K = 710;
 
int n, Q;
int a[maxn];
pair<pii, int> query[maxn];
 
int cnt[maxn], ans[maxn];
 
void read_input()
{
    cin >> n >> Q;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(int i = 1; i <= Q; ++i)
    {
        int l, r;
        cin >> l >> r;
        query[i] = make_pair(pii(l, r), i);
    }
}
 
bool cmp(const pair<pii, int>&x, const pair<pii, int>&y)
{
    if(x.fi.fi / K == y.fi.fi / K)
        return x.fi.se < y.fi.se;
    return x.fi.fi < y.fi.fi;
}
 
inline void update(int l, int r, int&cur)
{
    static int curl = 1, curr = 0;
    while(curr < r)
    {
        ++curr;
        ++cnt[a[curr]];
        if(cnt[a[curr]] == 1) ++cur;
    }
    while(curr > r)
    {
        --cnt[a[curr]];
        if(cnt[a[curr]] == 0) --cur;
        --curr;
    }
    while(curl < l)
    {
        --cnt[a[curl]];
        if(cnt[a[curl]] == 0) --cur;
        ++curl;
    }
    while(curl > l)
    {
        --curl;
        ++cnt[a[curl]];
        if(cnt[a[curl]] == 1) ++cur;
    }
}
 
void solve()
{
    sort(query + 1, query + Q + 1, cmp);
    fill(begin(cnt), end(cnt), 0);
    int cur = 0;
    for(int i = 1; i <= Q; ++i)
    {
        int l = query[i].fi.fi, r = query[i].fi.se;
        int id = query[i].se;
        update(l, r, cur);
        ans[id] = cur;
    }
    for(int i = 1; i <= Q; ++i)
        cout << ans[i] << '\n';
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}
 

Measured memory_bytes: 15512
#include <cstring>
#include <vector>
#include <stack>
#include <bitset>
#include <algorithm>
#include <utility>
#include <cstring>
#include <map>
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);++i)
#define mp(a,b) make_pair((a),(b))

typedef long long int lli;
typedef pair<int,int> P;

const int INF=100000000;
const long long int INF_=1000000000000000000;

int N,Q;

int Solve(int q,vector<int> &t,vector<int> &l,int m){
	int result=0;
	for(int i=m+1; i>=0;){
		int tmp=l[i]%q;
		result=max(result,tmp);
		i-=tmp+1;
	}
	return result;
}

int main(){
	cin >> N >> Q;
	vector<int> t(300001);
	vector<int> l(300001);
	int m=-1;
	rep(i,N) {
		int tmp;
		cin >> tmp;
		t[tmp]=1;
		m=max(m,tmp);
	}
	rep(i,m+2){
		if(i==0) continue;
		if(t[i]==1) l[i]=i;
		else l[i]=l[i-1];
	}
	rep(i,Q){
		int q;
		cin >> q;
		int ans=Solve(q,t,l,m);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3380
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,c=map(int,input().split())
xv= [map(int, input().split()) for _ in range(n)]
x, v = [list(i) for i in zip(*xv)]
calolic=[0]*(n+1)
l=[0]*(n+1)
l[1]=v[0]
calolic[1]=max(0,l[1]-x[0])
for i in range(2,n+1):
    l[i]=l[i-1]+v[i-1]
    res=l[i]-x[i-1]
    if res>calolic[i-1]:
        calolic[i]=res
    else:
        calolic[i]=calolic[i-1]
ans=0
for i in range(n+1):
    if i==0:
        ans=max(ans,calolic[n])
    else:
        ans=max(ans,calolic[i-1]+l[-1]-l[i-1]-2*(c-x[i-1]))
calolic=[0]*(n+1)
l=[0]*(n+1)
l[1]=v[-1]
calolic[1]=max(0,l[1]-c+x[-1])
for i in range(2,n+1):
    l[i]=l[i-1]+v[n-i]
    res=l[i]-c+x[n-i]
    if res>calolic[i-1]:
        calolic[i]=res
    else:
        calolic[i]=calolic[i-1]

for i in range(n+1):
    if i==0:
        ans=max(ans,calolic[n])
    else:
        ans=max(ans,calolic[n-i]+l[-1]-l[n-i]-2*x[i-1])
print(ans)

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

int a, b;

void solve()
{
    int num_socket = 1;
    int ans = 0;
    while (num_socket < b)
    {
        num_socket += a - 1;
        ans++;
    }

    cout << ans << endl;
}

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

    solve();
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
struct ToUpper {
	char operator()(char c) { return toupper(c); }
};
vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}
int main() {
	while (1) {
		string st; cin >> st;
		char c; cin >> c;
		if (c == 'X')break;
		else {
			vector<string>names(1);
			if (st.find('_') == string::npos) {
				int now = 0;
				for (int i = 0; i < st.size(); ++i) {
					if (i&&st[i] >= 'A'&&'Z' >= st[i]) {
						names.push_back(string());
						now++;
					}
					names[now].push_back(char(tolower(st[i])));
				}
				
			}
			else {
				names = split(st, '_');
			}
			if (c == 'U') {
				for (int i = 0; i < names.size(); ++i) {
					for (int j = 0; j < names[i].size(); ++j) {
						if (j)cout << names[i][j];
						else cout << char(toupper(names[i][j]));
					}
				}
				cout << endl;
			}
			else if (c == 'L') {
				for (int i = 0; i < names.size(); ++i) {
					for (int j = 0; j < names[i].size(); ++j) {
						if (!i||j)cout << names[i][j];
						else cout << char(toupper(names[i][j]));
					}
				}
				cout << endl;
			}
			else {
				for (int i = 0; i < names.size(); ++i) {
					for (int j = 0; j < names[i].size(); ++j) {
						cout << names[i][j];

					}
					if (i == names.size() - 1)cout << endl;
					else cout << '_';
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end()
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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


void solve() {
	vi in(3), c(3, 0);
	rep(i, 3) cin >> in[i];
	rep(i, 3) rep(j, 3) if(in[i] == in[j]) c[i]++;
	sort(all(c));
	if(c == vi{1,2,2}) cout << "Yes"; else cout << "No";
}
int main() {
	fastio;
	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace  std;
typedef long long int ll;
ll mod=1e9+7;
const int N=1e5+5;
ll dp[505][505];
ll a[N];
int main()
{
  ll n;
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>a[i],a[i]+=a[i-1];
  for(int i=n;i>=1;i--)
  {
    for(int j=i+1;j<=n;j++)
    {
      dp[i][j]=LLONG_MAX/(ll)100;
      ll ans=LLONG_MAX/(ll)100;
      for(int k=i;k<=j;k++) 
      ans=min(dp[i][k]+a[j]-a[i-1]+dp[k+1][j],ans);
      dp[i][j]=ans;
    }
 }
  
  cout<<dp[1][n]<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
  int X;
  cin>>X;
  bool flag=true;
  while(flag){
    if(IsPrime(X)){
      cout<<X<<endl;
      break;
    }
    else{
      X=X+1;
    }
  }
}
    
  

Measured memory_bytes: 256
import itertools
N = int(input())

# shougen[i]: i番目の人の証言リスト
shougen=[]

for i in range(N):
  Ai = int(input())
  s = []
  for j in range(Ai):
    x, y = map(int, input().split())
    s.append((x-1, bool(y)))
  shougen.append(s)

#print(shougen)

ans=0

# 正直者、嘘つき者のすべての組み合わせを作成
combinations = itertools.product((True, False), repeat=N)
for is_honest in combinations:
  isOK = True # 矛盾があるかないかを表すフラグ
  # この組み合わせ(is_honest) において、
  # すべての人の発言に矛盾がないか調べる
  for i in range(N):
    if is_honest[i]:
      # i番目の人間が正直者の時,
      # i番目の人間の証言と組み合わせに矛盾があったら
      # 矛盾ありフラグを立てる
      for x, y in shougen[i]:
        if is_honest[x] != y:
          isOK = False
          break
  if isOK:
    # この組み合わせ(is_honest) において、
    # 矛盾が存在しない場合は、この組み合わせにおける正直者の人数を数えて
    # 最大値をとっていく
    ans = max(ans, sum(is_honest))

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll N;
	ll res=0;
	string sres;
	string s;
	cin>>s;
	if(s=="ABC") sres="ARC";
	else sres="ABC";

	cout << sres << "\n";
	return;
}

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


Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<algorithm>
#define ll long long
#define rep(i,a,b) for(int i = a;i < b;i++)
#define INF 1e17
#define N 200004

using namespace std;

ll n;
unsigned ll X,x[N],pre[N];
unsigned ll ans;

unsigned ll get_sum(int i,int j)
{
    if(i < 1)
        return pre[j];

    return pre[j] - pre[i-1];
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> X;

    rep(i,1,n+1)
    {
        cin >> x[i];

        if(i == 1)
            pre[i] = x[i];
        else
            pre[i] = pre[i-1] + x[i];
    }

    ans = INF;

    for(ll reps = 1;reps <= n;reps++)
    {
        unsigned ll cur = 5*get_sum(max((ll)1,n-2*reps+1),n) + reps*X;
        unsigned ll mult = 7;

        for(int j = n-2*reps;j >= 1;j -= reps)
        {
            cur = cur + mult*get_sum(max((ll)1,j-reps+1),j);
            mult += 2;
        }

        ans = min(ans,cur);
    }

    ans += X*n;

    cout << ans;

    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[4][13] = {};
	int x,y;
	char c[] = "SHCD";
	char b;
	for(int i=0;i<n;i++){
		cin >> b >> y;
		for(int j=0;j<4;j++) if(b==c[j]) x = j;
		a[x][y-1] = 1;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++) if(a[i][j]==0) cout << c[i] << " " << j+1 << endl;
	}
}

Measured memory_bytes: 1160
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long




//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  vector<int> arr = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << arr[K-1] << endl;


  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
    if(a<10&&b<10){
      System.out.println(a*b);
    }
      else{
        System.out.println(-1);
      }
	}
}

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

int main() {
	int n; cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	int num;
	int count=0;
	int ans, anscount = 0;
	for (int i = 1; i <= n; i++) {
		count = 0;
		num = i;
		while (num % 2 == 0) {
			num /= 2;
			count++;
		}
		if (anscount < count) {
			anscount = count;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;

    for (int i = 1; i <= 1250;i++){
        if(int(i*0.08)==A&&int(i*0.1)==B){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256