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

ll n, a, b, c, d;
string str;

bool check (ll l, ll r)
{
    ll i = l;
    while (i < r)
    {
        if (str[i] == '#' && str[i + 1] == '#')    return false;
        i++;
    }
    return true;
}

int main()
{
    cin >> n >> a >> b >> c >> d;
    cin >> str;
    a--;    b--;    c--;    d--;
    vector<bool>flg (n + 1, false);
    if (check (a, c) && check (b, d))
    {
        if (c > d)
        {
            for (ll i = b; i <= d; i++)
            {
                if (str[i - 1] == '.' && str[i] == '.' && str[i + 1] == '.')
                {
                    cout << "Yes";
                    return 0;
                }
            }
            cout<<"No";
            return 0;
        }
        cout << "Yes";
    }
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 640
from queue import Queue

K=int(input())
q=Queue()
for h in range(1,10):
    q.put(h)
for i in range(K):
    x=q.get()
    d=x%10
    if x%10!=0:
        q.put(x*10+d-1)
    q.put(x*10+d)
    if x%10!=9:
        q.put(x*10+d+1)
print(x)

Measured memory_bytes: 12476
#include<cstdio>
using namespace std;

int main(){
  int n;
  long long int a;
  long cnt=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&a);
    while(a%2==0){
      cnt++;
      a/=2;
    }
  }
  printf("%ld\n",cnt);
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
  int P, Q, R;
  int PQ=0, QR=0, PR=0;
  cin >> P >> Q >> R;
  PQ = P+Q;
  QR = Q+R;
  PR = P+R;
  int min1 = min(PQ, QR);
  int min2 = min(min1, PR);
  cout << min2 << endl;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int imos[40][200010];

int main(){
    int N, C;
    cin >> N >> C;
    rep(i, N){
        int s, t, c;
        cin >> s >> t >> c;
        s *= 2;
        --s;
        t *= 2;
        --c;
        ++imos[c][s];
        --imos[c][t];
    }
    rep(i, C){
        REP(j, 1, 200010){
            imos[i][j] += imos[i][j-1];
        }
    }
    int ans = 0;
    rep(j, 200010){
        int cnt = 0;
        rep(i, C){
            if(imos[i][j] > 0){
                ++cnt;
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

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

 using namespace std;

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

   int fN = 0;

   for(int i = 0; i < N.length(); i++) {
     fN += (int)(N.at(i) - '0');
   }

   if (stoi(N) % fN == 0) cout << "Yes" << endl;
   else cout << "No" << endl;
 }


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


void solve(long long N, long long A){
    cout << N * N - A << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    solve(N, A);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/
#define fast            ios_base::sync_with_stdio(false)
#define mems(x, y)      memset(x, y, sizeof x)
#define pii             pair < int, int >
#define prec(x)         << fixed << setprecision(x)
#define itf             it->first
#define its             it->second
#define it(x)           it = x.begin(); it != x.end(); it++
#define pq_max(x)       priority_queue < x >
#define pq_min(x)       priority_queue < x, vector < x >, greater < x > >
#define ll              long long
#define nl              << "\n"
#define spc             << " "
#define pb              push_back
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define EPS             1e-9
#define toint(st, x)    stringstream ss(st); ss >> x
// =======Debug========//
#define watch(x)        cout << (#x) spc << x nl

int main()
{
    int n;
    cin >> n;
    if(n >= 30)     cout << "Yes\n";
    else    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3592
from sys import stdin


def main() -> int:
    dic = dict()
    s = next_str()
    ans = "yes"

    for v in s:
        if v in dic:
            ans = "no"
        dic[v] = True
    
    print(ans)
    return 0


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
using ll = long long;
vector<int> graph[100005];
const ll MOD = 1000000007;
ll cnt[100005];

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

    rep(i, n-1)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    queue<int> que;
    que.push(0);
    cnt[0] = 2;
    while(que.size() > 0)
    {
        int now = que.front();
        que.pop();

        int c = 0;
        for (auto next: graph[now])
        {
            if(cnt[next] > 0) continue;
            cnt[next] = 2 + c;
            c++;
            que.push(next);
        }
    }

    cnt[0] = 0;
    for (auto next: graph[0])
        cnt[next]--;
    
    ll ans = 1;
    rep(i, n)
        ans = (ans * (k - cnt[i])) % MOD;
    
    cout << ans << endl;
    return 0;
}

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

int main(){
	while (true) {
		int m,nmin,nmax;
		cin>>m>>nmin>>nmax;

		if (m==0&&nmin==0&&nmax==0) break;

		int P[200];
		for (int i = 0; i < m; i++) {
			cin>>P[i];
		}

		int gap=-1;
		int n=-1;

		for (int i = nmin; i <= nmax; i++) {
			int g=P[i-1]-P[i];

			if(gap<=g){
				gap=g;
				n=i;
			}
		}
		cout<<n<<endl;
	}
	return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    string s,t;
    cin >> s >> t;
    ll res = 0;
    res = pow(10,18);
    for(int i = 0;i < (int)s.size();i++){
        if(i + t.size() - 1 >= s.size())break;
        ll now = 0;
        for(int j = i;j < (int)t.size() + i;j++){
            if(t[j - i] != s[j])now++;
        }
        res = min(res,now);
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 2つの文字の固まりをそれぞれ整数値と想定して読み込む
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b/* ここを変えて面積を求めよう */;
        int length = 2*(a+b)/* ここを変えて周囲の長さを求めよう */;
        System.out.println(area + " " + length);
    }
}


Measured memory_bytes: 25932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = 100000 * 300 * 10; // (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);


class Edge{
public:
	int from, to, cost;
	Edge(int from = 0, int to = 0, int cost = 0) :
			from(from), to(to), cost(cost){}

	bool operator < (const Edge &e) const{
		return cost < e.cost;
	}
	bool operator >(const Edge &e) const{
		return cost > e.cost;
	}

};

class Node{
public:
	vector<Edge> edges;
	int dist;

	Node(){
		dist = INFTY;
	}
};

class Graph{
public:
	vector<Node> nodes;
	Graph(int n) {
		rep(i, n) { Node n;  nodes.push_back(n); }
	}
	Node& operator[](int i){
		return nodes[i];
	}
};

class Data{

public:
	int dist;
	Edge *edge;
	Data(int dist, Edge *edge) {
		this->dist = dist;
		this->edge = edge;
	}

	bool operator < (const Data &d) const{
		return dist < d.dist;
	}
	bool operator >(const Data &d) const{
		return dist > d.dist;
	}
};

Graph G(0);
int N, M, R;
int RR[8];
int D[8][8];

int dijkstra(int st, int ed){

	// initialize
	rep(i, N) G[i].dist = INFTY;

	priority_queue<Data, vector<Data>, greater<Data>> pq;
	Edge e0 = Edge(-1, st, 0);
	Data d0 = Data(0, &e0);
	pq.push(d0);

	while(!pq.empty()){
		Data d = pq.top(); pq.pop();
		Edge &e = *d.edge;
		Node &n = G[e.to];
		if(n.dist <= d.dist) continue;
		n.dist = d.dist;
		// cerr << n.dist << endl;

		for(auto &ee: n.edges){
			pq.push(Data(n.dist + ee.cost, &ee));
		}
	}

	return G[ed].dist;
}

int minimum_permuatation(){

	int ret = INFTY;
	vector<int> vec; rep(i, R) vec.push_back(i);

	do {
		int r = 0;
		rep(i, R-1) { r += D[vec[i]][vec[i+1]];}
		ret = min(ret, r);
	} while( next_permutation(vec.begin(), vec.end()) );

	return ret;
}

int main() {

	// input
	cin >> N >> M >> R;
	rep(i, R) {
		cin >> RR[i]; RR[i]--;
	}
	G = Graph(N);

	rep(i, M){
		int from, to, cost;
		cin >> from >> to >> cost; from--; to--;
		G[from].edges.push_back(Edge(from, to, cost));
		G[to].edges.push_back(Edge(to, from, cost));
	}

	// dijkstra
	rep(i1, R) rep(i2, R) {D[i1][i2] = 0;}
	rep(i1, R) rep(i2, R) if(i1 < i2){
		D[i1][i2] = dijkstra(RR[i1], RR[i2]);
		D[i2][i1] = D[i1][i2];
	}

	/*
	rep(i1, R) {
		rep(i2, R) fprintf(stderr, "%d ", D[i1][i2]);
		fprintf(stderr, "\n");
	}
	*/

	// minimum permutation
	cout << minimum_permuatation() << endl;

}

Measured memory_bytes: 2600
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf = sizeof(Def) == sizeof(ll) ? 2e18:1e9+10;

#include<complex>
typedef complex<double> P;
typedef vector<P> G;
const double PI=acos(-1);
const double EPS=1e-7;

struct L: public vector<P> {
	L(const P &a,const P &b){
		push_back(a);push_back(b);
	}
};
struct C{
	P c;double r;
	C(const P &c,double r):c(c),r(r){}
};
namespace std{
	bool operator < (const P &a, const P &b){
		return real(a) != real(b) ? real(a)<real(b) :imag(a)<imag(b);
	}
	bool operator == (const P &a, const P &b){
		return a.real() == b.real() && a.imag() == b.imag();
	}
}


double dot(P a,P b){
	return real(conj(a)*b);
}

P projection(L a, P p){
	double t=dot(p-a[0],a[0]-a[1])/norm(a[0]-a[1]);
	return a[0]+t*(a[0]-a[1]);
}

double distanceLP(const L &l, const P &p){
	return abs(p-projection(l,p));
}


P turn(P p,double t){
	return p*exp(P(.0,t*PI/180.0));
}

vector<L> tangentCC(C a, C b){
	if(a.r<b.r)swap(a,b);
	double d=abs(a.c-b.c);
	vector<L> l;
	if(d<EPS)return l;
	if(a.r+b.r<d-EPS){
		double t=acos((a.r+b.r)/d);
		t=t*180/PI;
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),t),b.c+turn(b.r/d*(a.c-b.c),t)));
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),-t),b.c+turn(b.r/d*(a.c-b.c),-t)));
	}else if(a.r+b.r<d+EPS){
		P p=a.c+a.r/d*(b.c-a.c);
		l.pb(L(p,p+turn(b.c-a.c,90)));
	}
	
	if(abs(a.r-b.r)<d-EPS){
		double t1=acos((a.r-b.r)/d);
		t1=t1*180/PI;
		double t2=180-t1;
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),t1),b.c+turn(b.r/d*(a.c-b.c),-t2)));
		l.pb(L(a.c+turn(a.r/d*(b.c-a.c),-t1),b.c+turn(b.r/d*(a.c-b.c),t2)));	
	}else if(abs(a.r-b.r)<d+EPS){
		P p=a.c+a.r/d*(b.c-a.c);
		l.pb(L(p,p+turn(b.c-a.c,90)));
	}
	return l;
}

int main(){
	int n;
	while(cin>>n,n){
		vector<C>in;
		vector<C>je;
		vi r(n),m(n);
		rep(i,n){
			int x,y;
			cin>>x>>y>>r[i]>>m[i];
			
			je.pb(C(P(x,y),r[i]));
			in.pb(C(P(x,y),r[i]));
			in.pb(C(P(x,y),m[i]+r[i]));
		}
		if(n==1){
			cout<<1<<endl;
			continue;
		}
		int out=0;
		rep(i,in.size())loop(j,i+1,in.size()){
			vector<L>l=tangentCC(in[i],in[j]);
			rep(k,l.size()){
				int co=0;
				rep(q,n){
					double dis=distanceLP(l[k],je[q].c);
					if(dis<EPS+m[q]+r[q]&&r[q]<EPS+dis)co++;
				}
				out=max(out,co);
			}
			
		}
		cout<<out<<endl;
	}
}







Measured memory_bytes: 3432
#115_C
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()

ans = 1000000000
for i in range(n-k+1):
    diff = h[i+k-1] - h[i]
    ans = min(ans, diff)
    
print(ans)

Measured memory_bytes: 13240
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


void solve(string s,int dice[6]){
    int ans[6]={};
    rep(i,6)ans[i]=dice[i];
    if(s=="North"){
        ans[0]=dice[1];
        ans[1]=dice[5];
        ans[4]=dice[0];
        ans[5]=dice[4];
    }
    if(s=="East"){
        ans[0]=dice[3];
        ans[2]=dice[0];
        ans[3]=dice[5];
        ans[5]=dice[2];
    }
    if(s=="West"){
        ans[0]=dice[2];
        ans[2]=dice[5];
        ans[3]=dice[0];
        ans[5]=dice[3];
    }
    if(s=="South"){
        ans[0]=dice[4];
        ans[1]=dice[0];
        ans[4]=dice[5];
        ans[5]=dice[1];
    }
    if(s=="Right"){
        ans[1]=dice[2];
        ans[2]=dice[4];
        ans[3]=dice[1];
        ans[4]=dice[3];
    }
    if(s=="Left"){
        ans[1]=dice[3];
        ans[2]=dice[1];
        ans[3]=dice[4];
        ans[4]=dice[2];
    }
    
    rep(i,6){
        dice[i]=ans[i];
    }
}

int main() {
    int n;
    
    while(cin>>n){
        if(n==0)break;
        
        int data[20000]={};
        
        int c=0;
        bool flag=true;
        rep(i,n){
            cin>>data[i];
            if(data[i]!=0)c++;
            if(data[i]>=2)flag=false;
        }
        
        if(flag){
            cout<<"NA"<<endl;
        }
        else{
            cout<<c+1<<endl;
        }

    }
    return 0;
}

Measured memory_bytes: 1244
import java.util.ArrayList;
import java.util.*;
  public class Main
{
	public static void main (String[] args)
	 {
		Scanner sc=new Scanner(System.in); 
		long n=sc.nextLong();
		long k=sc.nextLong();
		int a[]=new int[(int)n+1];
		long c[][]=new long[(int)n+1][2];
		long r=0;
		
		for(int i=1;i<=n;i++)
		{
			a[i]=sc.nextInt();
			
		}
		int i=1;
		
		
		while(k>0)
		{
			if(c[i][0]==1)
			{
				r=r-c[i][1];
				break;
			}
			c[i][0]=1;
			c[i][1]=r;
			i=a[i];
			r++;
			k--;
		}
		k%=r;
		
		while(k>0)
		{
			i=a[i];
			k--;
		}
		System.out.println(i);
	}
}

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

const int N = 2e5 + 100, LOG = 40;

typedef long long LL;

int a[N], b[N];
int dp[N][LOG];
int tmin[LOG];

bool cmp(pair<int,int> &p, pair<int,int> &q) {
    int a1 = p.first, b1 = p.second;
    int a2 = q.first, b2 = q.second;
    a1++, a2++;
    b1++, b2++;
    LL lft = 1ll*b1*a2+b2, rgt = 1ll*b2*a1+b1;
    return lft < rgt;
}

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, T;
    cin >> n >> T;
    vector<int> a0s;
    vector<pair<int,int>> a1s;
    for(int i = 1; i <= n; i++) {
        int x, y;
        cin >> x >> y;
        if(x == 0) a0s.push_back(y);
        else a1s.push_back({x, y});
    }
    sort(a0s.begin(), a0s.end());
    sort(a1s.begin(), a1s.end(), cmp);
    int sz = a1s.size();
    a1s.insert(a1s.begin(), make_pair(0,0));

    for(int i = 0; i <= sz; i++) {
        for(int j = 0; j < LOG; j++) {
            dp[i][j] = T+1;
        }
    }
    dp[0][0] = 0;
    for(int i = 1; i < LOG; i++) tmin[i] = T+1;

    for(int i = 1; i <= sz; i++) {
        for(int j = 0; j < LOG; j++) {
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            if(j > 0) {
                LL tt = dp[i-1][j-1];
                tt = tt+1 + (tt+1)*a1s[i].first + a1s[i].second;
                dp[i][j] = min((LL)dp[i][j], tt);
            }
            tmin[j] = min(tmin[j], dp[i][j]);
        }
    }
    int ans = 0;
    for(int i = 0; i < LOG; i++) {
        int t = tmin[i];
        if(t > T) continue;
        int cur = i;
        for(int j = 0; j < a0s.size(); j++){
            if(t + a0s[j] + 1 > T) break;
            cur++;
            t += a0s[j]+1;
        }
        ans = max(ans, cur);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 34672
#include <bits/stdc++.h>
using namespace std;
int n, m, j, i, k, a, b;
char s[100005];
int main(){
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		scanf("%s", s);
		if(s[0]=='A'){
			m++;
		}
		else if(s[0]=='W'){
			k++;
		}
		else if(s[0]=='T'){
			a++;
		}
		else if(s[0]=='R'){
			b++;
		}
	}
	printf("AC x %d\n", m);
	printf("WA x %d\n", k);
	printf("TLE x %d\n", a);
	printf("RE x %d\n", b);
	return 0;
}

Measured memory_bytes: 3832
N=int(input())
dp =[[0]*3 for _ in range(N)]
dp[0]= list(map(int,input().split()))
for i in range(1,N):
    a,b,c=map(int,input().split())
    dp[i][0] = a+max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = b+max(dp[i-1][2], dp[i-1][0])
    dp[i][2] = c+max(dp[i-1][0], dp[i-1][1])
print(max(dp[N-1]))


Measured memory_bytes: 22772
N, M = [int(x) for x in input().split()]
A = [None] * M
B = [None] * M
for i in range(M):
    A[i], B[i] = [int(x) - 1 for x in input().split()]

def nC2(n):
    if n < 2:
        retval = 0
    else:
        retval = n * (n - 1) // 2
    return retval

# 島同士が全く繋がっていない状態からスタート
# M-1番目, M-2番目, ..., , 2番目, 1番目の橋の順に橋をかけていく
comp = list(range(N))  # comp[i] = 島iの属するコンポーネント番号
mem = {}
for i in range(N):  # comp iに属する島
    mem[i] = [i]
conv = [0] * M  # 不便さの逆 ... 便利さ（お互いに行き来できる島の組み合わせ）


for i in range(M - 1, -1, -1):
    # i番目の橋をかける
    comp1 = comp[A[i]]
    comp2 = comp[B[i]]
    if comp1 != comp2:
        size_comp1 = len(mem[comp1])
        size_comp2 = len(mem[comp2])

        if size_comp1 > size_comp2:
            comp1, comp2 = comp2, comp1
            size_comp1, size_comp2 = size_comp2, size_comp1
        # comp1に属する島の数はcomp2に属する島の数以下
        mem[comp2] += mem[comp1]
        for j in mem[comp1]:
            comp[j] = comp2
        mem[comp1] = []  #comp1は無くなる

        if i > 0:
            conv[i - 1] = conv[i] - nC2(size_comp1) - nC2(size_comp2) + nC2(size_comp1 + size_comp2)
    else:
        if i > 0:
            conv[i - 1] = conv[i]

tot = nC2(N)
for i in range(M):
    print(tot - conv[i])


Measured memory_bytes: 84948
#include <stdio.h>

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

	char init_state[num_of_human + 1];
	scanf("%s", init_state);

	int compact_expression[num_of_human];
	int i, j, k, sum;
	j = 0;
	for(i = 0; i < num_of_human; i++) {
		sum = 0;

		if(j >= num_of_human) {
			while(i < num_of_human) {
				compact_expression[i] = 0;
				i++;
			}
			break;
		}

		if(i % 2 == 0) {
			while(init_state[j] == '1') {
				j++;
				sum++;
			}
			compact_expression[i] = sum;
		} else {
			while(init_state[j] == '0') {
				j++;
				sum++;
			}
			compact_expression[i] = sum;
		}
	}

	int ans;

	if(limit_of_instruction * 2 >= i) {
		printf("%d\n", num_of_human);
		return 0;
	}

	ans = 0;
	for(j = 0; j + limit_of_instruction * 2 < i; j += 2) {
		sum = 0;
		for(k = 0; k < limit_of_instruction * 2 + 1; k++) {
			sum += compact_expression[j + k];
		}
		if(ans < sum)
			ans = sum;
	}

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

	return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int X, A; cin >> X >> A;
  if (X < A) cout << 0 << endl;
  else       cout << 10 << endl;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> p(N);
	int ans = 0;
	for (int i = 0;i < N;++i) {
		cin >> p[i];
		ans += p[i];
	}
	sort(p.begin(), p.end());
	cout << ans - p[p.size() - 1] / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	vl A(N);
	ll ans = 1;
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) {
		if (A[i] == 0)
			ans = 0;
	}
	if (ans == 1) {
		rep(i, N) {
			ans *= A[i];
		}
		if (ans > InfLL) {
			ans = -1;
		}
		else {
			ll ans1 = ans;
			rep(i, N) {
				ans1 /= A[i];
			}
			if (ans1 != 1)
				ans = -1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4052
while True:
    m, f, r = list(map(int, input().split()))
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif 80 > m+f and m+f >= 65:
        print("B")
    elif 65 > m+f and m+f >= 50:
        print("C")
    elif 50 > m+f and m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

int main() {
  int n;
  while(cin >> n) {
    int a[n];
    int mini = -1;
    for(int i = 0; i < n; ++i) {
      cin >> a[i];
      if(mini == -1 || a[i] < mini) {
        mini = a[i];
      }
    }
    for(int j = 1; j <= mini; ++j) {
      bool flag = true;
      for(int i = 0; i < n; ++i) {
        if(a[i] % j != 0) {
          flag = false;
          break;
        }
      }
      if(flag) cout << j << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int a,b;
  cin >> a >> b;
  vector<string> field(100, string(50, '#') + string(50, '.'));
  --a; --b;
  REP(i, 80) REP(j, 20) {
    if (!a) break;
    field[i*2][j*2] = '.';
    --a;
  }
  REP(i, 80) REP(j, 20) {
    if (!b) break;
    field[i*2][j*2+55] = '#';
    --b;
  }
  cout << 100 << ' ' << 100 << endl;
  REP(i, field.size()) cout << field[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "mydebug.h"
#else
#define debug(...)
#endif
typedef long long ll;typedef unsigned long long ul; typedef vector<ll> vl;

int main() {
  ios_base::sync_with_stdio(false);
  ll N, null, G;
  cin >> N >> null >> G;

  vl A;
  for(int i=0;i<N;i++) {
    ll x;
    cin >> x;
    A.push_back(x);
  }

  if(N==1) {
    cout << abs(G-A.back()) << endl;
    return 0;
     }

  if(abs(G-A.back()) > abs(A[A.size()-2]-A.back()))
    cout << abs(G-A.back()) ;
  else
    cout << abs(A[A.size()-2]-A.back());
  cout << endl;
}


Measured memory_bytes: 256
from collections import deque

LIST = deque()

n = int(input())

for _ in range(n):
    input_command = input()

    if input_command == 'deleteFirst':
        LIST.popleft()
    elif input_command == 'deleteLast':
        LIST.pop()
    else:
        com, num = input_command.split()  #input_commandでないと動作しない

        if com == 'insert':
            LIST.appendleft(num)
        elif com == 'delete':
            try:
                LIST.remove(num)
            except:
                pass  #なんもなかったらpass

print(' '.join(LIST))



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

int search(int start, int goal, int mincost){

}

int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(10, vector<int>(10));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++) cin >> c[i][j];
    }

    vector<vector<int>> a(h, vector<int>(w));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) cin >> a[i][j];
    }

    vector<int> cost(10, 0);
    for(int i = 0; i < 10; i++){
        cost[i] = c[i][1];
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                if(j == k) continue;
                if(cost[j] > c[j][k] + cost[k]) cost[j] = c[j][k] + cost[k];
            }
        }
    }

    long long int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(!(a[i][j] == 1 || a[i][j] == -1)) ans += cost[a[i][j]];
        }
    }

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

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

int ans;
int n, q;
string s;


int main(){
  cin >> n >> q >> s;
  s = s+'0';
  vector<int> dp(n+1, 0);
  for(int i = 1; i < n+1; i++){
    if(dp[i] == 0){
      dp[i] = dp[i-1];
      if(s.at(i-1) == 'A'){
        if(s.at(i) == 'C') dp[i+1] = dp[i-1] + 1; 
      }
    }
    else continue;
  }   
  rep(i, q){
    int l, r;
    cin >> l >> r;
    cout << dp[r] - dp[l] << endl;
  }
  
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll n;
cin>>n;
ll count = 0;
ll a[n];
ll mi = INT_MAX;
for(int i = 0;i<n;i++)
{
	cin>>a[i];
	mi = min(mi,a[i]);
	if(mi==a[i]) count++;
}
cout<<count<<"\n";
}


Measured memory_bytes: 5164
import java.io.IOException;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws IOException {
    Scanner scan = new Scanner(System.in);
    while (scan.hasNextLine()) {
      String line = scan.nextLine();
      String[] vals = line.split(" ");
      BigInteger int1 = new BigInteger(vals[0]);
      BigInteger int2 = new BigInteger(vals[1]);

      BigInteger gcd = int1.gcd(int2);

      BigInteger lcm = (int1.multiply(int2)).divide(gcd);
      System.out.println(gcd.toString() + " " + lcm.toString());

    }
  }
}

Measured memory_bytes: 26416
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

int n, t, d[100005];
queue<int> qu;
void f(int p, int q) {
	if (d[p] == 0 || d[p] > q) {
		qu.push(p);
		d[p] = q;
	}
}
int main()
{
	cin >> n;
	f(1, 1);
	while (!qu.empty()) {
		t = qu.front(); qu.pop();
		f((t * 10) % n, d[t]);
		f((t + 1) % n, d[t] + 1);
	}
	cout << d[0];
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
const int N=1e9+7;
#define int long long
#define double long double

int32_t main()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 IOS;
int n;
cin>>n;

int c=0;
for (int i = 0; i < n; ++i)
{
	int a,b;
	cin>>a>>b;
	if(a==b)
		c++;
	if(a!=b)
		c=0;
	if(c==3)
	{
		cout<<"Yes";
		return 0;
	}
}
cout<<"No";











 	



  
 




  
return 0;
}


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

int main() {
	int n;
	string s, k;
	cin >> n;
	int t = 0;
	int h = 0;
	for (int i = 0; i < n; i++){
		cin >> s >> k;
		if (s > k)
			t = t + 3;
		else if (s < k)
			h = h + 3;
		else if (s == k){
			t++;
			h++;
		}
	}
	cout << t << " " <<h;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3180
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    string s;
    while (cin >> s && s != "-"){
        int m, x = 0;
        cin >> m;
        while (m--){
            int a;
            cin >> a;
            x += a;
        }
        REP(i,s.length()){
            cout << s[(i+x)%s.length()];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3160
S = list(input())
for i in range (len(S)):
  if i % 2 == 0:
    if (S[i]== "L"):
      print("No")
      exit()
      
    else:
      continue
      
  if i % 2 ==1:
    if (S[i]=="R"):
      print("No")
      exit()
      
    else:
      continue
 

print("Yes")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define DEBUG(x) cout << #x << " is " << (x) << endl;
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main() {
	int n;
	cin >> n;
	string s[n];
	for(int i = 0;i < n;i++)cin >> s[i];
	sort(s, s + n);
	int cnt = 0;
	int b[n];
	string c[n];
	for(int i = 0;i < n;i++) {
		b[i] = 1;
		c[i] = "";
	}
	c[0] = s[0];
	for(int i = 0;i < n - 1;i++) {
		if(s[i] == s[i + 1]){
			b[cnt]++;
		}
		else{
			cnt++;
			c[cnt] = s[i + 1];
		}
	}
	int m = cnt + 1;
	int maxb = 0;
	for(int i = 0;i < m;i++) {
		maxb = max(maxb, b[i]);
	}
	vector<string> v;
	for(int i = 0;i < m;i++) {
		if(b[i] == maxb)v.push_back(c[i]);
	}
	sort(v.begin(), v.end());
	for(int i = 0;i < v.size();i++){
		cout << v[i] << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin >> n >> m;
    cout << n * (n-1) / 2 + m * (m-1) / 2<< endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>  
#include <cstdio>  
#include <assert.h>  
#include <cstring>  
#include <algorithm>  
#include <vector>  
#include <map>  
#include <cmath>  
#include <set>  
#include <queue>  
const int INF=1e9+10;  
const double EPS = 1e-10;    
typedef long long ll;  
const ll mod=998244353;
using namespace std;
struct node{
    int l,r;
    bool operator<(const node &a)const{
        return l<a.l;
    }
};
int main(){
    node a[2];
    while(cin>>a[0].l>>a[0].r>>a[1].l>>a[1].r){
        sort(a,a+2);
        if(a[0].r<=a[1].l){
            printf("0\n");
        }else if(a[0].r>a[1].r){
            printf("%d\n",a[1].r-a[1].l );
        }else{
            printf("%d\n",a[0].r-a[1].l );
        }
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()

  var bool = false
  for(x in 0..25) {
    for(y in 0..25) {
      val sum = x*4 + y*7
      if(sum == N) {
        bool = true
      }
    } 
  } 
  if(bool) println("Yes") else println("No")
}

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

int main() {
    ll S; cin >> S; bool can=true;
        for(int j=1;j<10;j++){
            ll t=1;
            rep(m,j)
         t*=10;
            if(t<=S)
            continue;
            else if(t-S!=t)
            {  
                
                cout << 0 <<" "<<0<<" "<<1<<" "<<1<<" "<<flush;
                cout<<t-S<<" "<<t<<endl;
                can=false; break;
                
                
            }
            
            
        }
        if(can){
           for(ll i=1;i<=1000000000;i++){
               if(1000000000*i>=S){
                   cout << 0 <<" "<<0<<" "<<1000000000<<flush;
                   cout <<" "<<1<<" "<<1000000000*i-S<<" "<<(ll)i<<endl;
                   break;
               }
           }
        }
    
 

    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N;
    cin >> N;

    vector<ll> P(N), Q(N);
    rep (i, N) {
        cin >> P[i];
    }
    rep (i, N) {
        cin >> Q[i];
    }

    vector<ll> v(N);
    rep (i, N) {
        v[i] = i+1;
    }

    ll pcnt = 0;
    bool pflag = false;
    do {
        pcnt++;
        rep (i, N) {
            if (P[i] != v[i]) {
                break;
            }
            if (i == N-1) {
                pflag = true;
            }
        }

        if (pflag) {
            break;
        }
    } while (next_permutation(v.begin(), v.end()));

    rep (i, N) {
        v[i] = i+1;
    }

    ll qcnt = 0;
    bool qflag = false;
    do {
        qcnt++;
        rep (i, N) {
            if (Q[i] != v[i]) {
                break;
            }
            if (i == N-1) {
                qflag = true;
            }
        }

        if (qflag) {
            break;
        }
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(pcnt-qcnt) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    int H = int.Parse(Console.ReadLine());
    int W = int.Parse(Console.ReadLine());
    if (H == N && W == N) Console.WriteLine(1);
    else if (H == N) Console.WriteLine(N - W + 1);
    else if (W == N) Console.WriteLine(N - H + 1);
    else Console.WriteLine((N - H + 1) * (N - W + 1));
  }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
#include <random>
#include <cassert>
#include <sstream>
using namespace std;
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define ALL(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ln(i, n) " \n"[i == n]
typedef long long LL;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
//////////////////////
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9;
const LL  INFF = (LL)1e15;
const int mod = 998244353;
const int MXN = (int)1e6 + 7;
int a[MXN];
LL dp[MXN][5];
int main(){
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", a + i);
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 4; j++) {
			dp[i][j] = INFF;
			for (int k = 0; k <= j; k++) {
				dp[i][j] = min(dp[i][j], dp[i-1][k]);
			}
		}
		dp[i][0] += a[i];
		if (a[i] == 0) dp[i][1] += 2;
		else if (a[i] % 2) dp[i][1]++;
		dp[i][2] += (a[i] % 2 ? 0 : 1);
		if (a[i] == 0) dp[i][3] += 2;
		else if (a[i] % 2) dp[i][3]++;
		dp[i][4] += a[i];
	}
	LL ans = INFF;
	for (int i = 0; i <= 4; i++)
		ans = min(ans, dp[n][i]);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a;
  int n,c=0;
  cin>>n;
  for(int i=11;i<=55555;i+=10){
    bool f=true;
    for(int j=2;j<i;j++){
      if(i%j==0){
        f=false;
        break;
      }
    }
    if(f){
      a.push_back(i);
      c++;
    }
    if(c==n)
      break;
  }
  for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
  }
}
  

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

  // macro
  #define rep(i,n) for(i=0;i<n;i++)
  #define ll long long
  #define all(v) v.begin(), v.end()

  // code starts
  #define MAX 1000000000000001

  int main()
  {
    ll n;
    cin >> n;
    ll ks = 1;
    vector<ll> ls(0);
    while(ks < MAX)
    {
      ks *= 26;
      ls.emplace_back(ks);
    }
    int k = ls.size();
    vector<ll> sum(k+1,0);
    int i;
    rep(i,k) sum[i+1] = sum[i] + ls[i];
    ll dec;
    ll ind;
    rep(i,k)
    {
      if(n > sum[i] && n <= sum[i+1])
      {
        dec = sum[i];
        ind = i;
        break;
      }
    }
    ll num = n-dec;
    num--;
    vector<int> ans(0);
    ll now = ls[ind];
    while(now > 1)
    {
      ans.emplace_back(num%26);
      num /= 26;
      now /= 26;
    }
    int jj = ans.size();
    for(i=jj-1;i>=0;i--)
    {
      cout << (char)(ans[i]+'a');
    }
    cout << endl;
  }


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (INT_MAX/2-1)
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

struct E{
  int to,cost;
};

int main(){
  int N;
  cin>>N;
  vector<vector<E>>e(N+1);
  vector<vector<E>>f(N+1);
  int fu;
  for(int i=0;i<N;i++){
    int u,v,w;
    cin>>u>>v>>w;
    if(i==0)fu=u;
    e[u].push_back({v,w});
    f[v].push_back({u,w});
  }
  vector<bool>used(N+1,false);
  queue<pii>q;
  q.push({fu,0});
  vector<int>ans;
  ans.push_back(fu);
  while(q.size()){
    pii now=q.front();
    q.pop();
    if(used[now.first])continue;
    else used[now.first]=true;
    for(auto it:e[now.first]){
      if((now.second+it.cost)%2==0)ans.push_back(it.to);
      q.push({it.to,it.cost+now.second});
    }
    for(auto it:f[now.first]){
      if((now.second+it.cost)%2==0)ans.push_back(it.to);
      q.push({it.to,it.cost+now.second});
    }
  }
  vector<bool>res(N+1,false);
  for(auto it:ans)res[it]=true;
  for(int i=1;i<=N;i++){
    if(res[i])cout<<1<<endl;
    else cout<<0<<endl;
  }
  return 0;
}


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

int isPrime(int x){
    if(x == 2){
        return 1;
    }

    if(x < 2 || x % 2 == 0){
        return 0;
    }

    int i = 3;
    while(i <= sqrt(x)){
        if(x % i == 0){
            return 0;
        }
        i = i + 2;
    }

    return 1;
}

int main(){
    int i, x, count = 0;
    int num[10000];

    scanf("%d", &x);
    for(i = 0; i < x; i++){
        scanf("%d", &num[i]);
    }

    for(i = 0; i < x; i++){
        if(isPrime(num[i]) == 1){
            count++;
        }
    }

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

    return 0;
}
    



Measured memory_bytes: 2028
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
using ll=long long;
int a[maxn];

int main(){
    int n,x;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    if(a[0]>x){
        ans+=a[0]-x;
        a[0]=x;
    }
    for(int i=1;i<n;i++){
        if(a[i-1]+a[i]<=x)
            continue;
        else{
            ans+=(ll)(a[i-1]+a[i]-x);
            a[i]-=(a[i-1]+a[i]-x);
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
const int xdirec[] = { -1, 0, 1, 0 };
const int ydirec[] = { 0, -1, 0, 1 };
int main()
{
	// ABC088-D, 997, 
	int h, w;
	cin >> h >> w;
	string s;
	vector<vector<int>> mp(h, vector<int>(w, -2));
	rep(i, h) {
		cin >> s;
		rep(j, w) {
			if (s[j] == '.') mp[i][j] = -1;
		}
	}

	mp[0][0] = 0;
	queue<P> que;
	que.push(P(0, 0));
	while (!que.empty()) {
		P v = que.front();
		que.pop();
		rep(i, 4) {
			int x = v.first + xdirec[i];
			int y = v.second + ydirec[i];
			if (x < 0 || w <= x || y < 0 || h <= y) continue;
			if (mp[y][x] != -1) continue;
			mp[y][x] = mp[v.second][v.first] + 1;
			que.push(P(x, y));
		}
	}

	if (mp[h - 1][w - 1] == -1) {
		cout << -1 << endl;
		return 0;
	}

	int ans = 0;
	ans = h*w - mp[h - 1][w - 1] - 1;
	rep(i, h) rep(j, w) {
		if (mp[i][j] == -2) ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
void main() {
	auto K = ri;
	auto S = rs;
	if(S.length <= K) writeln(S);
	else {
		writeln(S[0..K] ~ "...");
	}	
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

struct Pair
{
  int64_t L, R;

  Pair(int64_t L = 0, int64_t R = 0) : L(L), R(R) {}

  bool operator<(const Pair &rhs) const {
    return R < rhs.R;
  }
};

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

  vector<int64_t> X(N), L(N);
  N_TIMES(n, N) {
    cin >> X[n] >> L[n];
  }

  vector<Pair> Y(N);
  N_TIMES(n, N) {
    Y[n] = Pair(X[n] - L[n], X[n] + L[n]);
  }
  sort(Y.begin(), Y.end());

  int64_t R = Y[0].L - 1;
  uint64_t C = 0;
  N_TIMES(n, N) {
    if (R <= Y[n].L) {
      ++C;
      R = Y[n].R;
    }
  }
  cout << C << endl;

  return 0;
}

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

int main() {
  int N,i;
  cin >> N;
  int a[N],b[N],c[N];
  for(i=1;i<=N;i++) {
	cin >> a[i] >> b[i];
        c[i]=a[i]+b[i];
  }
  int ans = c[1];
  for(i=1;i<=N;i++) {
    ans = min(ans,c[i]);
  }
  cout << ans << endl;
  return 0;
}  

Measured memory_bytes: 1536
#include <iostream>
#include <string>

using namespace std;

//a -> b
int get_dis(char a,char b){
    if(a <= b){
        return b - a;
    }else{
        return b + ('z' - 'a') - a + 1;
    }
}

int main(void){
    
    std::string str;
    cin >> str;
    int n;
    cin >> n;
    
    for(int i = 0; i < str.size(); i++){
        if(get_dis(str[i],'a') <= n){
            n -= get_dis(str[i],'a');
            str[i] = 'a';
        }
    }
    
    str[str.size() - 1] += (n%26);
    
    cout << str << endl;
    
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

/*bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first < b.first;
}*/
ll dp[110][100010];
ll v[110], w[110];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

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

Measured memory_bytes: 79360
#include<stdio.h>

int main(void) {
	int n, a[100][100] = {0}, u, k, v, i, j;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &u);
		scanf("%d", &k);
		for (j = 0; j < k; j++)
		{
			scanf("%d", &v);
			a[u - 1][v - 1] = 1;
		}
	}
	
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < n; j++)
		{
			printf("%d", a[i][j]);
			if (j != n - 1) printf(" ");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 2804
#include <stdio.h>
#include <string.h>
#define N 20

int main()
{
    char s[N], t[N], test[N];
    scanf("%s %s", s, t);
    strncpy(test, t, strlen(s));
    test[strlen(s)]='\0';
    if (strlen(t) == strlen(s) + 1 && strcmp(test, s) == 0)
        printf("Yes");
    else
        printf("No");

    return 0;
}

Measured memory_bytes: 1724