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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll MAX = 20002;

bool dp[8005][MAX];
vector<ll> X, Y;

bool check(ll x, ll y) {
    {
        memset(dp, 0, sizeof(dp));
        dp[0][MAX / 2] = true;

        REP(i, X.size()) {
            REP(j, MAX + 1) {
                if (!dp[i][j])
                    continue;
                if (j - X[i] >= 0 && i > 0)
                    dp[i + 1][j - X[i]] = true;
                if (j + X[i] < MAX)
                    dp[i + 1][j + X[i]] = true;
            }
        }
        if (!dp[X.size()][(MAX / 2) + x])
            return false;
    }
    {
        memset(dp, 0, sizeof(dp));
        dp[0][(MAX / 2)] = true;

        REP(i, Y.size()) {
            REP(j, MAX + 1) {
                if (!dp[i][j])
                    continue;
                if (j - Y[i] >= 0)
                    dp[i + 1][j - Y[i]] = true;
                if (j + Y[i] < MAX)
                    dp[i + 1][j + Y[i]] = true;
            }
        }
        if (!dp[Y.size()][(MAX / 2) + y])
            return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
#if true
    string S;
    cin >> S;
    ll x, y;

    cin >> x >> y;

    X.clear();
    Y.clear();
    ll cnt = 0;
    bool rot = false;
    REP(i, S.length()) {
        if (S[i] == 'F') {
            cnt++;
            continue;
        }
        if (rot)
            Y.push_back(cnt);
        else
            X.push_back(cnt);
        cnt = 0;
        rot = !rot;
    }
    if (rot)
        Y.push_back(cnt);
    else
        X.push_back(cnt);
#endif

#if false
    REP(i, X.size()) {
        cout << X[i] << " ";
    }
    cout << endl;
    REP(i, Y.size()) {
        cout << Y[i] << " ";
    }
    cout << endl;
#endif
    if (check(x, y))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 156672
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, i, j, sum = 0;
  cin >> n >> m;
  int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  int f = 0;
  float vote = float(sum) / float(4 * m);
  if (a[n - m] >= float(vote))
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
	LL N, M;
	cin >> N >> M;
	if (N == 1) {
		if (M == 1) {
			cout << 1 << endl;
		}
		else {
			cout << M-2 << endl;
		}
	}
	else {
		if (M == 1) {
			cout << N-2 << endl;
		}
		else {
			cout << (N-2)*(M-2) << endl;
		}
	}

}

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

int main() {
  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a[i];
  }
  string ans = (accumulate(a.begin(), a.end(), 0) >= 22) ? "bust" : "win";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
O = list(input())
E = list(input())
ans = list()
LEN = len(O)+len(E)
for i in range(LEN):
    if i%2==0:
        ans.append(O[0])
        del O[0]
    else:
        ans.append(E[0])
        del E[0]
result = "".join(ans)
print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0), cin.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e5 + 5;
const int inf = ~0u >> 1;
typedef pair<int, int> P;
#define REP(i, a, n) for (int i = a; i < (n); ++i)
#define PER(i, a, n) for (int i = (n)-1; i >= a; --i)
const ll mod = 1e9 + 7;
int main() {
    IO;
    string s, t;
    cin >> s >> t;
    int ls = s.length(), lt = t.length();
    int ans = inf;
    REP(i, 0, ls - lt + 1) {
        int sum = 0;
        REP(j, 0, lt) {
            if (s[i + j] != t[j]) {
                sum++;
            }
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define dbug(x) cout<<#x<<"-->"<<x<<endl
const int maxn = 2e5 +100;
int ans = -1;
int main()
{
    int n, t,p=1;
    cin >> n;
    for(int i = 1;i<=n;i++)
    {
        cin >> t;
        if(t==p)
            p++;
    }
    cout << (p==1?-1:n-(p-1));
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int[] H = new int[N];
            for (int i = 0; i < N; i++) {
                H[i] = in.nextInt();
            }

            for (int i = N - 2; i >= 0; i--) {
                if (H[i] <= H[i + 1]) {
                    continue;
                } else if (H[i] - 1 <= H[i + 1]) {
                    H[i]--;
                    continue;
                } else {
                    System.out.println("No");
                    return;
                }
            }
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 49268
#include <stdio.h>

int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(0<=x-r && x+r<=W)
	{
		if(0<=y-r && y+r<=H)
		{
		printf("Yes\n");
		}
		else                          /*forgot*/
		{printf("No\n");
		}
	}
		else{printf("No\n");}
	return 0;
}

	

Measured memory_bytes: 584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1001

void calc(int n){
  string s;
  int ans =  0;
  bool l=false, r=false,last = false;

  for(int i=0;i<n;i++){
    cin >> s;
    
    if(s=="lu") l = true;
    if(s=="ru") r = true;
    if(s=="ld") l = false;
    if(s=="rd") r = false;
    
    if(l == r && l ^ last){
      ans++;
      last = l;
    }
  }
  
  printf("%d\n",ans);

}

int main(){
  int n,m;

  while(1){
    scanf("%d",&n);
    if(n==0) break;
    calc(n);
  }
  
  return 0;
}

Measured memory_bytes: 3288
n, a, b = map(int, input().split())
MOD = 10**9+7

def comb(n, k, MOD):
    x = 1
    for i in range(k):
        x *= (n-i)
        x *= pow(i+1, MOD-2, MOD)
        x %= MOD
    return x

ans = pow(2, n, MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD)
ans += MOD
ans %= MOD
print(ans)

Measured memory_bytes: 9204
//https://atcoder.jp/contests/agc002/tasks/agc002_c
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N,L; cin>>N>>L;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    bool possible=false;
    ll pos=0;
    REP(i,N-1){
        if(an.at(i)+an.at(i+1) >= L){
            possible = true;
            pos=i;
            break;
        }
    }
    if(possible){
        cout<<"Possible"<<endl;
        for(ll i=0;i<pos;++i){
            cout<<i+1<<endl;
        }
        for(ll i=N-2;(i>pos&&i>=0);--i){
            cout<<i+1<<endl;
        }
        cout<<pos+1<<endl;
    } else {
        //assert(0);
        cout<<"Impossible"<<endl;
    }

    return 0;
}

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

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}

typedef long long LL;
const int N=100010;
struct Seg{int l,r,extra;} seg[N<<1];
vector<Seg> R[N];
int n,m,a[N],tot=0;

int main()
{
    int cross=0,p=1;
    LL ans=INT64_MAX,cur=0;
    n=read();m=read();
    for(int i=1;i<=n;i++) a[i]=read();
    for(int i=1;i<n;i++)
        if(a[i]<a[i+1])
        {
            seg[++tot]={a[i],a[i+1],0};
            R[a[i+1]].push_back(seg[tot]);
            cur+=a[i+1]-a[i];
        }
        else
        {
            seg[++tot]={a[i],m,0};
            R[m].push_back(seg[tot]);
            seg[++tot]={0,a[i+1],m-a[i]};
            R[a[i+1]].push_back(seg[tot]);
            cur+=a[i+1]+m-a[i];
        }
    sort(seg+1,seg+1+tot,[](Seg a,Seg b){return a.l<b.l;});
    for(int i=0;i<=m;i++)
    {
        cur-=cross;
        ans=min(ans,cur);
        for(Seg s : R[i])
        {
            cur+=s.extra+i-s.l-1;
            cross--;
        }
        while(p<=tot&&seg[p].l<=i)
        {
            Seg s=seg[p];
            cur-=s.extra+i-s.l-1;
            cross++;p++;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

using namespace std;

int main() {

	int n,m;
	cin >> n >> m;
	vector < vector<int>> G(n + 1);

	//グラフ隣接リスト読み込み
	int a, b;
	for (int i = 1; i <= m; i++) {
		cin >> a >> b ;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	//幅優先探索処理
	vector<bool> seen(n + 1, false);	//発見したらtrue
	deque<int> todo;					//行く所のキュー

	int s = 1;							//今いる場所
	vector<int> dist(n + 1, 0);			//1からの距離
	vector<int> res(n + 1);

	int j = 1; //この問題では１から到達できるところを調べる

	if (seen[j] == false) {			//訪れてなかったら処理すすめる
		seen[j] = true;
		todo.push_back(j);

		while (todo.empty() != true) {				//キューが空になるまで処理	
			s = todo.front();						//処理番号を指定
			int tugiflg = false;					//次があったらtrueにするフラグ
			for (int i = 0; i < G[s].size(); i++) {
				if (seen[G[s][i]] != true) {
					seen[G[s][i]] = true;
					res[G[s][i]] = s;
					todo.push_back(G[s][i]);
					dist[G[s][i]] = dist[s] + 1;		//この問題でのみ使う（1からの距離）
					tugiflg = true;
				}
			}
			todo.pop_front(); //次を全部探したので削除する
		}
	}

	cout << "Yes" << endl;
	for (int i = 2; i <= n; i++) {
		cout << res[i] << endl;
	}

	return 0;

}

Measured memory_bytes: 10580
// Problem : C - Sum of gcd of Tuples (Easy)
// Contest : AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
int main(){
	
	ll sum = 0;
	ll k;
	
	cin >> k;
	
	for(ll i = 1; i <= k; i++)
		for(ll j = 1; j <= k; j++)
			for(ll l = 1; l <= k; l++){
				sum += __gcd(__gcd(i,j),l);
			}
	
	cout << sum << endl;
	return 0;	
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= 9; i++) {
		if (n <= 111*i) {
			ans = 111 * i;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  
  if (K < S.size()) {
    for (int i = 0; i < K; i++)
      cout << S.at(i);
    cout << "..." << endl;
  }
  
  else cout << S << endl;
}


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

char exchange(char c) {
  if('A' <= c && c <= 'Z') {
    return c + ('a' - 'A');
  }
  if('a' <= c && c <= 'z'){
      return c+('A'-'a');
  }
  else return c;
}
int main(void){
char  ch;
while(1){
    scanf("%c",&ch);
    if(ch=='\n') break;
    ch=exchange(ch);
    printf("%c",ch);
}
printf("\n");
return (0);
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    vector<int> arr;
    map<int, int> fre;
    fre[n]++;
    arr.pb(n);
    int ans = 1, cnt = 0;
    for(int i = 1; i <= 1000000; ++i){
        int cal = fun(arr[i - 1]);
        arr.pb(cal);
        fre[cal]++;
        if(fre[cal] > 1){
            cout << i + 1;
            break;
        }
    }
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <unordered_map>
#define int long long int
#define double long double
#define endl "\n"
#define PI 3.141592653589793238462643383279502884
#define sp(x)   setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define LCM(a,b)    (a*b)/__gcd(a,b)
#define all(v)  v.begin(),v.end()
#define alls(s,v)  s.begin(),s.end(),v
#define gena(arr,n,nxt)  generate(arr,arr+n, nxt)
#define genv(v,nxt)  generate(v.begin(),v.end(), nxt)
#define base ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define exit return 0;
using namespace std;
const int N=1000000;
bool prime[N];
void sieve()
{
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<100000000; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<100000; i += p)
                prime[i] = false;
        }
    }
}
int power(int x, int y)
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x*x;
    }
    return res;
}
int nxt()
{
    int x;
    cin >> x;
    return x;
}
int findTileCount(int x, int y, int l, int r)
{
    int lcm = (x * y) / __gcd(x, y);
    int countl = (l - 1) / lcm;
    int countr = r / lcm;
    return countr - countl;
}
int32_t main()
{
    base
    string s;
    cin>>s;
    string ans;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')ans+='0';
        else if(s[i]=='1')ans+='1';
        else if(s[i]=='B'&&ans.size()!=0)ans.pop_back();
    }
    cout<<ans;
    exit
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;


int main(){
  int x;
  cin >> x;
  int ans = floor(sqrt(2*x));
  if(ans*(ans+1)>=2*x){ cout << ans << endl; return 0; }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int i, j, n, a;
    cin >> n;
    string words[n], word, pre_word;
    cin >> words[0];
    a=0;
    for (i=1; i<n; i++)
    {
        cin >> words[i];
        word=words[i];
        pre_word=words[i-1];
        if (word[0]!=pre_word[pre_word.length()-1])
        {
            a=1;
        }
        for (j=0; j<i; j++)
        {
            if (word==words[j] && i!=j)
                {
                    a=1;
                }
        }
    }
    if (a!=1)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn total(a: i32, b: i32, c: i32) -> i32 {
    return 500*a + 100*b + 50*c;
}

fn main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
        x: i32,
    }

    let mut num_combination = 0;

    for ap in 0..a+1 {
        if total(ap, 0, 0) > x {
            break;
        }
        for bp in 0..b+1 {
            if total(ap, bp, 0) > x {
                break;
            }
            for cp in 0..c+1 {
                let t = total(ap, bp, cp);
                if t == x {
                    num_combination += 1;
                    break;
                } else if t > x {
                    break;
                }
            }
        }
    }
    println!("{}", num_combination);
}


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

#define MAX 10000

int V, E;
std::vector<int> G[MAX], GT[MAX];
bool visited[MAX];
int res[MAX];

void dfs(int current, std::stack<int> &st) {

    visited[current] = true;

    for (unsigned long i = 0; i < G[current].size(); i++) {
        int next = G[current][i];
        if (!visited[next]) {
            dfs(next, st);
        }
    }
    st.push(current);
}

void dfs2(int current, int cnt) {

    visited[current] = true;
    res[current] = cnt;

    for (unsigned long i = 0; i < GT[current].size(); i++) {
        int next = GT[current][i];
        if (!visited[next]) dfs2(next, cnt);
    }
}

void findSCC() {
    std::stack<int> st;

    for (int i = 0; i < V; i++) visited[i] = false;

    for (int i = 0; i < V; i++)
        if (!visited[i]) dfs(i, st);

    for (int i = 0; i < V; i++) visited[i] = false;

    int cnt = 0;
    while ( !st.empty() ) {
        int current = st.top();
        st.pop();
        if (visited[current] == false) {
            dfs2(current, cnt);
            cnt++;
        }
    }
}

int main()
{
    std::scanf("%d %d", &V, &E);
    int q, x, y, source, target;
    for (int i = 0; i < E; i++) {
        std::scanf("%d %d", &source, &target);
        G[source].push_back(target);
        GT[target].push_back(source);
    }
    findSCC();
    std::scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        std::scanf("%d %d", &x, &y);
        if (res[x] == res[y]) { std::printf("%d\n", 1); }
        else { std::printf("%d\n", 0); }
    }
    return 0;
}



Measured memory_bytes: 4940
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int max = Character.getNumericValue(n.charAt(0));
        int sum = 0;
        for (int i = 0; i < n.length() - 1; i++) {
            sum += max;
            sum *= 10;
        }
        sum += max;
        if (Integer.parseInt(n) <= sum) {
            System.out.println(sum);
            return;
        }
        max++;
        System.out.println(max * 100 + max * 10 + max);
    }
}


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

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

int ntime(int time, int sta, int n, int c[], int s[], int f[]){
    if(sta == n)return time;
    else{
        if(time <= s[sta]){
            return ntime(s[sta]+c[sta], sta+1, n, c, s, f);
        }else{
            int t;
            if(time%f[sta]==0)t = time;
            else t = (time/f[sta]+1)*f[sta];
            return ntime(t+c[sta], sta+1, n, c, s, f);
        }
    }
}

int main(void){
    int n;
    scanf("%d", &n);
    int c[n], s[n], f[n];
    for(int i = 1;i < n;i++){
        scanf("%d %d %d", &c[i], &s[i], &f[i]);
    }
    for(int i = 1;i <= n;i++){
        printf("%d\n", ntime(0, i, n, c, s, f));
    }
    return 0;
}

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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;
constexpr double PI=3.14159265358979323846;

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

    int x,y;
    cin >> x >> y;
    if((y-2*x)%2==0 && (4*x-y)%2==0){
        if( (y-2*x)/2>=0 && (4*x-y)/2>=0 ){
            cout << "Yes" << "\n";
        }else{
            cout << "No" << "\n";
        }
    }else{
        cout << "No" << "\n";
    }
}   

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

vector<int> p;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	for(int i=1; 7*i<301010; ++i){
		int a[2] = {7*i-1, 7*i+1};
		for(int j=0; j<2; ++j){
			bool f = true;
			for(int k=0; k<p.size()&&p[k]*p[k]<=a[j]; ++k){
				if(a[j] % p[k] == 0){
					f = false;
					break;
				}
			}
			if(f) p.push_back(a[j]);
		}
	}
	while(1){
		int n;
		cin >> n;
		if(n == 1) return 0;
		cout << n << ":";
		for(int i=0; p[i]<=n; ++i)
			if(n % p[i] == 0)
				cout << " " << p[i];
		cout << "\n";
	}
}


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

typedef long long ll;
typedef pair<int,int> P;
ll const INF = INT_MAX;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct SegmentTree {
private:
    int n;
    vector<int> node;
public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1,INF);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = min(node[2*i+1],node[2*i+2]);
    }
    void update(int x,int val) {
        x += (n-1);
        node[x] = val;
        while (x > 0) {
            x = (x-1)/2;
            node[x] = min(node[2*x+1],node[2*x+2]);
        }
    }

    int getmin(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return node[k];
        int vl = getmin(a,b,2*k+1,l,(l+r)/2);
        int vr = getmin(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> p(n+2),q(n+2),ans;
    vector<SegmentTree> seg(2,vector<int>(n+10,INF));
    priority_queue<P,vector<P>,greater<P>> que;
    set<int> st;
    for (int i = 1;i < n+1;++i) {
        cin >> p[i];
        q[p[i]] = i;
        seg[i&1].update(i,p[i]);
    }
    st.insert(0);
    st.insert(n+1);
    int a = seg[1].getmin(1,n+1),b = seg[0].getmin(q[a],n+1);
    que.push(P(a,b));
    for (int x = 0;x < n/2;++x) {
        P t = que.top();
        que.pop();
        ans.push_back(t.first);
        ans.push_back(t.second);
        int y[4] = {*(--st.lower_bound(q[t.first])),q[t.first],q[t.second],*st.lower_bound(q[t.second])};
        st.insert(q[t.first]);
        st.insert(q[t.second]);
        for (int i = 0;i < 3;++i) if (y[i]+1 < y[i+1]) {
            int u = seg[y[i+1]&1].getmin(y[i]+1,y[i+1]),v = seg[y[i]&1].getmin(q[u],y[i+1]);
            que.push(P(u,v));
        }
    }
    for (int i = 0;i < n;++i) cout << ans[i] << " \n"[i == n-1];
    return 0;
}

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

int main() {
  int k;
  cin >> k;
  vector<int> a = {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};
  cout << a[k-1] << endl;
  return 0;
}

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

using namespace std;

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

	int n;
	vector<int>v;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		if (v.empty() or
		    x != v.back())
			v.push_back(x);
	}
	int sol = 0;
	n = v.size();
	for (int i = 0; i < n;) {
		if (i == n - 1) {
			sol++;
			break;
		}
		int j = i;
		bool sgn = v[i] < v[i + 1];
		while (j < n && (v[j] < v[j + 1]) == sgn) {
			++j;
		}
		sol++;
		i = j + 1;
	}
	cout << sol;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <math.h>
#include <stdio.h>
#define llint long long

using namespace std;
typedef pair<double, double> P;
typedef pair<double, P> V;

llint n;
vector<V> vec, vec2;

int main(void)
{
	cin >> n;
	double x, y;
	for(int i = 0; i < n; i++){
		cin >> x >> y;
		if(fabs(x) < 0.5 && fabs(y) < 0.5) continue;
		vec.push_back(make_pair(atan2(y, x), make_pair(x, y)));
	}
	sort(vec.begin(), vec.end());
	
	n = vec.size();
	for(int i = 0; i < n; i++) vec2.push_back(vec[i]);
	for(int i = 0; i < n; i++) vec2.push_back(vec[i]);
	
	double ans = 0;
	for(int i = 0; i < n; i++){
		double x = 0, y = 0;
		for(int j = 0; j < n; j++){
			x += vec2[i+j].second.first, y += vec2[i+j].second.second;
			ans = max(ans, x*x+y*y);
		}
	}
	printf("%.15f\n", sqrt(ans));
	
	return 0;
}

Measured memory_bytes: 256
s = input()
length = len(s)
sum = 0
right = [0]
left = [0]
r = 0
for i in range(length):
  if s[i] == "<":
    r += 1
    right.append(r)
  else:
    r = 0
    right.append(r)
l = 0    
for i in range(length-1,-1,-1):
  if s[i] == ">":
    l += 1
    left.append(l)
  else:
    l = 0
    left.append(l)
left.reverse()

for i in range(length+1):
  sum += max(right[i],left[i])

print(sum)



Measured memory_bytes: 27936
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#define N 1000005
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int n;
string s;
int main() {
	cin>>n>>s;
	vector<char> stk;
	for (int i = 0; i < n; ++i) {
		if (s[i] == '(') stk.push_back(s[i]);
		else {
			if (!stk.empty() && stk.back() == '(') stk.pop_back();
			else {
				stk.push_back(')');
			}
		}
	}
	int lcnt = 0;
	int rcnt=0;
	for (int i = 0; i < stk.size(); ++i) {
		if (stk[i] == ')') rcnt++;
		else break;
	}
	for (int i = stk.size()-1; i >= 0; --i) {
		if (stk[i] == '(') lcnt++;
		else break;
	}
	if (rcnt) {
		s = string(rcnt, '(') + s;
	}
	if (lcnt) {
		s = s + string(lcnt, ')');
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
//
// Created by 遠藤護 on 7/16/18.
//
#include <iostream>
using namespace std;

int totalDigit(int num) {
    int dig;
    int sum = 0;

    while (num) {
        dig = num % 10;
        sum = sum + dig;
        num = num / 10;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;

    int ans = 100000;
    for (int i = 1; i <= N / 2; ++i){
        ans = min(ans, totalDigit(i) + totalDigit(N - i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		int b,f,r,v,m,i,j,k;
		int [][][] d = new int[4][3][10];
		for(i=0;i<4;i++){
			for(j=0;j<3;j++){
				for(k=0;k<10;k++)
				d[i][j][k]=0;
			}
		}
		Scanner sc = new Scanner(System.in);
		m=sc.nextInt();
		for(i=0;i<m;i++){
			b=sc.nextInt();
			f=sc.nextInt();
			r=sc.nextInt();
			v=sc.nextInt();
			d[b-1][f-1][r-1]+=v;
		}
		for(i=0;i<4;i++){
			for(j=0;j<3;j++){
				for(k=0;k<10;k++)
					System.out.print(" "+d[i][j][k]);
				System.out.println();
			}
			if(i<3)
				System.out.println("####################");
		}
	}
}


Measured memory_bytes: 29968
#include <iostream>
using namespace std;
 
int main()
{
  int N;
  cin >> N;
  
  int a, b, c, d;
  a = N / 1000;
  b = ( N - a * 1000 ) / 100;
  c = ( N - a * 1000 - b * 100 ) / 10;
  d = N - a * 1000 - b * 100 - c * 10;
  
  if ( (( a == b ) && ( b == c )) || (( b == c ) && ( c == d )) ){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
ll call(long long n){
    if(n==0)return 0;
    if(n==1)return 1;
    return 1 + 2*call(n/2);
}
int main(){
    ll n;
    cin>>n;
    cout<<call(n);
}



Measured memory_bytes: 3624
import java.util.Scanner;

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

		int N = scan.nextInt();
		int result = 0;
		result = (N%1000 == 0) ? 0 : 1000 - (N % 1000);
		System.out.println(result);
	}
}

Measured memory_bytes: 27064
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int f[2010];
int n;

inline void work() {
    cin >> n;
    f[0] = 1;
    for (int i = 3; i <= n; ++i) {
        for (int j = 0; j <= i - 3; ++j) {
            f[i] += f[j];
            f[i] %= mod;
        }
    }
    cout << f[n] << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

ll x[120000];
int n;
ll e, t;
ll dp[120000];

int main() {
	scanf("%d%lld%lld", &n, &e, &t);
	for (int i = 0; i < n; ++i)
		scanf("%lld", x + i);
	int now = 0;
	ll mn = 1e10;
	for (int i = 0; i < n; ++i) {
		if (2 * (x[i] - x[0]) <= t) {
			dp[i] = t;
			continue;
		}
		mn = min(mn, -2 * x[0]);
		while (2 * (x[i] - x[now + 1]) > t) {
			mn = min(mn, dp[now] - 2 * x[now + 1]);
			now += 1;
		}
		dp[i] = mn + 2 * x[i];
		dp[i] = min(dp[i], dp[now] + t);
	}
	cout << e + dp[n - 1] << "\n";
	return 0;
}




Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define inf (int)(1e18)

int max(int a, int b){
	return a >= b ? a : b;
}

signed main(){
	int N, i, j, k;
	scanf("%lld", &N);
	int **a = (int **)malloc(sizeof(int *) * N);
	for(i = 0; i < N; i++){
		a[i] = (int *)malloc(sizeof(int) * N);
		for(j = 0; j < N; j++){
			scanf("%lld", &a[i][j]);
		}
	}
	int *dp = (int *)malloc(sizeof(int) * (1 << N));
	for(i = 0; i < (1 << N); i++){
		dp[i] = 0;
		for(j = 0; j < N; j++){
			for(k = j + 1; k < N; k++){
				if((i | (1 << j)) == i && (i | (1 << k)) == i){
					dp[i] += a[j][k];
				}
			}
		}
		for(j = ((i - 1) & i); j > 0; j = ((j - 1) & i)){
			dp[i] = max(dp[i], dp[j] + dp[i ^ j]);
		}
	}
	printf("%lld\n", dp[(1 << N) - 1]);
	return 0;
}

Measured memory_bytes: 640
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define vpi vector<pair<int,int> >
#define vpl vector<pair<ll,ll> >
#define mkpr make_pair
#define todec() to_ulong()
#define toldec() to_ullong()
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define whole(x) (x).begin(),(x).end()
#define revwhole(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
 
using namespace std; 
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> gharKaSet;
 
const int maxlimit=5e5+2;
const ll inf=1e12;
 
ll dp[(1<<21)+1][22];
int n;
ll allset;
 
vector<int> cpht[21];
//can person have this topic
 
ll getAns(int mask,int tillass){
  // all got topics
  if(mask==allset)return 1;
  //topics finished
  if(tillass==21)return 0;
  if(dp[mask][tillass]!=-1)return dp[mask][tillass];
  ll ans=0;
  for(auto &st :cpht[tillass]){
    if((mask & (1<<st))==0){
      ans= (ans+getAns(mask | (1<<st),tillass+1))%MOD;
    }
  }
  dp[mask][tillass] = ans;
  return ans;
}
 
int main()
{
  fatafat
  bool interested;
  cin>>n;
  allset=(1LL<<n)-1;
  for(int i=0;i<21;i++)cpht[i].clear();
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>interested;
      if(interested)cpht[j].eb(i);
    }
  }
  memset(dp,-1,sizeof(dp));
  cout<<getAns(0,0)<<endl;
  return 0;
} 


Measured memory_bytes: 364128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int x1,y1,x2,y2,x3,y3,x4,y4,xdif,ydif;
	cin >> x1 >> y1 >> x2 >> y2;
	xdif = abs(x1 - x2);
	ydif = abs(y1 - y2);
	if (x1 < x2&&y1 < y2) {
		x3 = x2 - ydif;
		y3 = y2 + xdif;
		x4 = x3 - xdif;
		y4 = y3 - ydif;
	}
	else if (x1<x2&&y1>y2) {
		x3 = x2 + ydif;
		y3 = y2 + xdif;
		x4 = x3 - xdif;
		y4 = y3 + ydif;
	}
	else if (x2<x1&&y2>y1) {
		x3 = x2 - ydif;
		y3 = y2 - xdif;
		x4 = x3 + xdif;
		y4 = y3 - ydif;
	}
	else if(x1>x2&&y1>y2) {
		x3 = x2 + ydif;
		y3 = y2 - xdif;
		x4 = x3 + xdif;
		y4 = y3 + ydif;
	}
	else if (x1 == x2 && y1 < y2) {
		x3 = x2 - ydif;
		y3 = y2;
		x4 = x3;
		y4 = y1;
	}
	else if (x1 == x2 && y1 > y2) {
		x3 = x2 + ydif;
		y3 = y2;
		x4 = x3;
		y4 = y1;
	}
	else if (y1 == y2 && x1 < x2) {
		x3 = x2;
		y3 = y2 + xdif;
		x4 = x1;
		y4 = y3;
	
	}
	else {
		x3 = x2;
		y3 = y2 - xdif;
		x4 = x1;
		y4 = y3;
	}
		
	
	cout << x3 <<" "<<y3<<" "<< x4 <<" "<< y4 << endl;
	

	

	
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn gcd(a: u32, b: u32) -> u32 {
    if b == 0 {
        return a
    }
    return gcd(b, a % b)
}

fn main() {
    let k: u32 = read();

    let mut ans: u128 = 0;
    for a in 1..k+1 {
        for b in 1..k+1 {
            for c in 1..k+1 {
                let x = gcd(a, b);
                let y = gcd(x, c);
                if y != 0 {
                    ans += y as u128
                }
            }
        }
    }

    println!("{}", ans);
}

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

vector<ll>a;
void dfs(ll v){
    if(v<=1e9){
        a.push_back(v);
        dfs(10*v+3);
        dfs(10*v+5);
        dfs(10*v+7);
    }
}

int main(){
    int n;
    cin>>n;
    dfs(0);
    sort(a.begin(),a.end());
    int ans=0;
    rep(i,a.size()){
        string s=to_string(a[i]);
        bool x=false,y=false,z=false;
        rep(j,s.size()){
            if(s[j]=='3')x=true;
            if(s[j]=='5')y=true;
            if(s[j]=='7')z=true;
        }
        if(a[i]<=n&&x&&y&&z)ans++;
    }
    cout<<ans<<endl;
}


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


int main() {
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    vector<int> dp(k+1,0);
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i>=v[j] && !dp[i-v[j]])
                dp[i]=1;
        }
    }
    if(dp[k])
        cout<<"First";
    else
        cout<<"Second";
    return 0;
}

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

int main()
{
    int A[10],h1,h2,h3,i,pos1,pos2;
    for(i=0;i<10;i++)
    cin>>A[i];
    h1=A[0];
    pos1=0;
    for(i=1;i<10;i++)
    {
        if(A[i]>h1)
        {
            h1=A[i];
            pos1=i;
        }
    }
    A[pos1]=-1;
    h2=A[1];
    pos2=1;
    for(i=2;i<10;i++)
    {
        if(A[i]>h2)
        {
            h2=A[i];
            pos2=i;
        }
    }
    A[pos2]=-1;
    h3=A[2];
    for(i=3;i<10;i++)
    {
        if(A[i]>h3)
            h3=A[i];
    }
    cout<<h1<<"\n"<<h2<<"\n"<<h3<<"\n";
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<set>
#include<queue>
#include<cstdlib>
#include<algorithm>

using namespace std;
#define pb push_back
#define mp make_pair
#define SZ(x) (int)(x).size()

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<LL, LL> pll;

const double eps = 1e-10;
const double PI = acos(-1.0);
//const double PI = 3.14159265358979323846264338327950288419716939937510
int dcmp(const double &x) { if (fabs(x) < eps) return 0; return x < 0 ? -1 : 1; }
const int MOD = 1e9 + 7;
const int INF = 2e9;
const double INF_d = 1e64;

template<class T> 
T qmod(T a, T b){ T ret = 1; while (b){ if (b & 1) ret *= a; b >>= 1; a *= a; } return ret; }
template<class T>
T gcd(T a, T b){ return !b ? a : gcd(b, a % b); }
template<class T>
T ex_gcd(T a, T b, T &x, T &y){
    if (!b){ x = 1, y = 0; return a; }
    T t, ret;
    ret = ex_gcd(b, a % b, x, y);
    t = x, x = y, y = t - a / b * y;
    return ret;
}
template<class T>
T inv(T t, T p){ return t == 1 ? 1 : (p - p / t) * inv(p % t, p) % p; }
// head

typedef double db;

struct point{
    db x, y;
    point(){}
    point(db a, db b): x(a), y(b){}
    point operator + (const point &p){ return point(x + p.x, y + p.y); }
    point operator - (const point &p){ return point(x - p.x, y - p.y); }
    point operator * (const db &k){ return point(x * k, y * k); }
    point operator / (const db &k){ return point(x / k, y / k); }
    db operator ^ (const point &p){ return x * p.y + y * p.x; }
    db operator * (const point &p){ return x * p.x + y * p.y; }
    bool operator == (const point &p){ return !dcmp(x - p.x) && !dcmp(y - p.y); }
    bool operator != (const point &p){ return dcmp(x - p.x) || dcmp(y - p.y); }
    bool operator < (const point &p){ return x == p.x ? y < p.y : x < p.x; }
    void read(){
        scanf("%lf%lf", &x, &y);
    }
    void print(){
        printf("%.10f %.10f\n", x, y);
    }
    point rotate(db &ang){ return point(x * cos(ang) - y * sin(ang), y * cos(ang) + x * sin(ang)); }
    point norm() { return point(-y, x); }
    db len() { return sqrt(x * x + y * y); }
    db len2(){ return x * x + y * y; }
};

point proj(point A, point B, point P){ // projection point of P in segment AB
    point AB = B - A, AP = P - A;
    return A + AB * (AP * AB / AB.len2());
}

point a, b;
int n;

int main(){
    a.read(), b.read();
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        point x; x.read();
        proj(a, b, x).print();
    }
    return 0;
}


Measured memory_bytes: 3224
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;

int is_prime(int x)
{
	if(x<2)
		return false;
	for(int i=2;i*i<=x;i++)
	{
		if(x%i==0)
			return false;
	}
	return true;
 } 
int main()
{
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int x;
	cin>>x;
	while(!is_prime(x))
	{
		x++;
	}
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define NMAX 100000
#define INF 1e+6
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
int a,b,c,x;
int main(){
  scan(a);scan(b);scan(c);scan(x);
  int res=0;
  rep(i,a+1){
    rep(j,b+1){
      rep(k,c+1){
	if(500*i+100*j+50*k==x) res++;
      }
    }
  }
  prin(res);
  return 0;
}


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


int main(){
    
    int N;
    cin >> N;

    vector<string> words(N);

    for(int i = 0; i < N; i++){
        cin >> words[i];
        if(i >= 1){
            if (words[i-1][words[i-1].length() - 1] != words[i][0]){
                cout << "No" << endl;
                return 0;
            }
        }
        for(int j = 0; j < i; j++){
            if(words[j] == words[i]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
N=int(input())
num = list(map(int,input().split()))
c=0
ans=0
for i in range(N):
  if num[i]<0:
    c+=1 
ans = list(map(lambda x: abs(x),num))
if c%2==0:
  print(sum(ans))
else:
  print(sum(ans) - min(ans,key=lambda x: abs(x))*2)

Measured memory_bytes: 15180
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> s;
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        s[a[i]]++;
    }

    ll ans = 0;
    for (auto tmp : s)
    {
        if (tmp.second > 1)
        {
            ans += tmp.second * (tmp.second - 1) / 2;
        }
    }

    for (ll i = 0; i < n; i++)
    {
        ll temp = ans;

        if (s[a[i]] > 1)
        {
            temp -= s[a[i]] * (s[a[i]] - 1) / 2;
            temp += (s[a[i]] - 1) * (s[a[i]] - 2) / 2;
        }

        cout << temp << endl;
    }
}

Measured memory_bytes: 11008
#include <iostream>

using namespace std;

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

long long lcm(long long a, long long b){
    long long g = gcd(a, b);
    return a/g * b;
}

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

    long long ans = lcm(A, B);
    cout << ans << endl;
}

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


int main(){
  ll n,ans=1;
  cin >> n;
  vector<ll> vc(n);
  rep(i,n){
    cin >> vc[i];
    if(vc[i]==0){
      cout << 0 << endl;
      return 0;
    }
  }

  rep(i,n){
    if(ans>1000000000000000000/vc[i]){
      cout << -1 << endl;
      return 0;
    }
    ans*=vc[i];
  }
  cout << ans << endl;
}


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

int main(){
  int N, P;
  cin >> N >> P;
  int odd=0; int even=0;
  for(int i=0; i<N; i++){
    int A; cin>>A;
    if(A%2==0) even++;
    else odd++;
  }
  long long ans;
  if(P==0){
    if(odd==0) ans=std::pow(2,odd+even);
    else ans=std::pow(2,odd+even-1);
  }
  else{
    if(odd==0) ans=0; 
    else ans=std::pow(2,odd+even-1);
  }
  cout << ans << endl;
}

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

#define ine long long

using namespace std;

int32_t main()
{
	string s;
	cin >> s;

	int x = (s[0]-'0')*10 + s[1]-'0';
	int y = (s[2]-'0')*10 + s[3]-'0';

	if(x > 0 && x <= 12 && y > 0 && y <= 12)
		cout << "AMBIGUOUS";
	else if(x > 0 && x <= 12)
		cout << "MMYY";
	else if(y <= 12 && y > 0)
		cout << "YYMM";
	else
		cout << "NA";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        
        String in;
        String number;
        char[] num=new char[1000];
        int result=0;
        int add=0;
        
        while(true){
            in=scan.nextLine();
            if(in.equals("0")){
                break;
            }
            number=in;
            
            num=number.toCharArray();
            result=0;
            for(int i=0;i<num.length;i++){
                add=Character.digit(num[i], 10);
                result+=add;
            }
            System.out.println(result);
        }
        
    }   
     
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  FOR(i, 1, s.length()) {
    if (s[i - 1] != s[i])
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define ll long long int
using namespace std;

int main(void){
    int N;
    string S;

    cin >> N >> S;

    int len = S.length();
    REP(i,len){
        int x = S[i]-'A';
        x = (x+N) % 26;
        putchar('A' + x);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
ll A[200010];
ll sum[200010];
ll K;
ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
        sum[i] = sum[i - 1] + A[i];
    }

    map<ll, int> mp;
    for(int i = 0; i <= N; i++){
        if(i - K >= 0) mp[(sum[i - K] - i + K) % K]--;
        ans += mp[(sum[i] - i) % K]++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    int A, B;cin >> A >> B;
    int maxAB = max(A, B);
    int minAB = min(A,B);
    rep(i, maxAB) {
        cout << minAB;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string S; cin >> S;
    vector<int> abc(3);
    for(auto c:S) {
        abc[c-'a']++;
    }
    if (*max_element(ALL(abc)) - *min_element(ALL(abc)) >= 2) {
        OUT("NO")
    } else {
        OUT("YES")
    }


    return 0;
}

Measured memory_bytes: 3788