akhauriyash/Code-Regression huggingface dataset:
n = int(input())
ans = [0,0]
for i in range(n):
    a,b = map(str,input().split())
    if a > b:
        ans[0] += 3
    elif a == b:
        ans[0] += 1
        ans[1] += 1
    elif b > a:
        ans[1] += 3
print(" ".join(map(str,ans)))


Measured memory_bytes: 5600
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
X=many_int()

count4=0
count2=0

for i in X:
    if i%4==0:
        count4+=1
    if i%2==0:
        count2+=1
        

count_sa = count2 - count4
count = count4 + count_sa//2

if count >= len(X)//2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62960
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int M;
int col[114514];
vector<int> es[114514];
LL alo, tri, bip;

bool Dfs(int v, int c) {
  if (col[v]) {
    return col[v] == c;
  }

  bool ret = true;
  col[v] = c;
  for (int u : es[v]) {
    if (!Dfs(u, 3-c)) ret = false;;
  }
  return ret;
}

int main() {
  scanf("%d%d", &N, &M);
  rep(i, M) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    es[u].eb(v);
    es[v].eb(u);
  }

  rep(v, N) {
    if (col[v]) continue;
    if (es[v].empty()) alo++;
    else {
      bool res = Dfs(v, 1);
      if (res) bip++;
      else tri++;
    }
  }

  LL ans = 0;
  ////printf("alo=%lld bip=%lld tri=%lld\n", alo, bip, tri);
  ans += alo*alo;
  //printf("alo*alo=%lld\n", alo*alo);
  ans += 2*alo*(N-alo);
  //printf("2*alo*(N-alo)=%lld\n", 2*alo*(N-alo));
  ans += bip*bip*2;
  //printf("2*bip*bip=%lld\n", 2*bip*bip);
  ans += tri*tri;
  ans += bip*tri*2;
  printf("%lld\n", ans);
}


Measured memory_bytes: 10240
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int A[N], B[N], C[N-1];
  for(int i=0;i<N;++i) {
    cin>>A[i];
    A[i]--;
  }
  for(int i=0;i<N;++i) cin>>B[i];
  for(int i=0;i<N-1;++i) cin>>C[i];
  int ans = 0;
  for(int i=0;i<N;++i) {
    ans += B[A[i]];
  }
  for(int i=1;i<N;++i) {
    if(A[i]==A[i-1]+1) {
      ans += C[A[i-1]];
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

struct EdgeA
{
	int to;
	ll cost;
};

void calcAllShortest(vector<vector<EdgeA>>& G, vector<vector<ll>>& d)
{
	auto numV = (int)G.size();
	for (auto i = 0; i < numV; ++i)
	{
		d.push_back(vector<ll>(numV, LLONG_MAX));

		for (auto v : G[i])
		{
			d[i][v.to] = v.cost;
		}
		d[i][i] = 0;
	}

	for (auto k = 0; k < numV; ++k)
	{
		for (auto i = 0; i < numV; ++i)
		{
			for (auto j = 0; j < numV; ++j)
			{
				if (d[i][k] >= LLONG_MAX || d[k][j] >= LLONG_MAX)
				{
					continue;
				}
				auto kd = d[i][k] + d[k][j];
				if (d[i][j] > kd)
				{
					d[i][j] = kd;
				}
			}
		}
	}
}


int main()
{
	int H, W;
	cin >> H >> W;
	int V = 10;
	vector<vector<EdgeA>> G(V);
	for (auto i = 0; i < V; ++i)
	{
		for (auto j = 0; j < V; ++j)
		{
			ll c;
			cin >> c;
			G[i].push_back({ j, c });
		}
	}

	vector<vector<ll>> d;
	calcAllShortest(G, d);

	auto ans = 0ll;
	for (auto i = 0; i < H; ++i)
	{
		for (auto j = 0; j < W; ++j)
		{
			int A;
			cin >> A;
			if (A < 0)
			{
				continue;
			}

			ans += d[A][1];
		}
	}

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

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

using namespace std;
#define FOR(i, a, b) for (int i = (a), _##i = (b); i < _##i; ++i)
#define REP(i, a) for (int i = 0, _##i = (a); i < _##i; ++i)
typedef long long LL;

int n;
int a[300004];
LL prefix[300004];
LL sufix[300004];
int main(){
	//freopen("test.in","r",stdin);
	cin >> n;
	REP(i,3*n){
		cin >> a[i];
	}
	priority_queue<int> q;
	LL s = 0;
	REP(i,n){
		q.push(-a[i]);
		s+= a[i];
	}
	prefix[n-1] = s;
	
	FOR(i,n,2*n){
		prefix[i] = prefix[i-1];
		if( a[i] > -q.top() ){
			prefix[i] += a[i] + q.top();
			q.pop();
			q.push(-a[i]);
		}
	}
	

	reverse(a,a+3*n);	
	s = 0;
	while(!q.empty()) q.pop();
	
	REP(i,n){
		q.push(a[i]);
		s += a[i];
	}
	sufix[n-1] = s;
	FOR(i,n,2*n){
		sufix[i] = sufix[i-1];
		if( a[i] < q.top() ){			
			sufix[i] += a[i] - q.top();
			q.pop();
			q.push(a[i]);
		}
	}

	LL res = LLONG_MIN;
	FOR(i,n-1,2*n){
	
		res = max(res, prefix[i] - sufix[3*n-2-i]);
	}
	cout << res << endl;
	return 0;
}

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

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, M;
  bool ng[SIZE] = {};
  ll dp[SIZE] = {};

  scanf("%d%d", &N, &M);

  for (int i=0; i<M; i++) {
    int a;
    scanf("%d", &a);
    ng[a] = true;
  }

  dp[0] = 1;

  for (int i=0; i<N; i++) {
    if (!ng[i+1]) dp[i+1] = (dp[i+1] + dp[i]) % mod;
    if (!ng[i+2]) dp[i+2] = (dp[i+2] + dp[i]) % mod;
  }

  printf("%lld\n", dp[N]);

  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#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 pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

ll n, a, s, ans;
map<ll, int> m;
map<ll, int>::iterator itr;

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

  cin >> n;
  m[0] = 1;
  FOR(i, 0, n){
    cin >> a;
    s += a;
    m[s]++;
    itr = m.find(s);
    ans += itr->se - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>
int main(void){
    int N, M;
    scanf("%d %d", &N, &M);
    int K;
    int food[30] = {0};
    for(int i = 0; i < N; i++){
        scanf("%d", &K);
        int A;
        for(int j = 0; j < K; j++){
            scanf("%d", &A);
            food[A-1] += 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < M; i++){
        if(food[i] == N){
            ans += 1;
        }
    }
    printf("%d\n", ans);
    return 0; 
}

Measured memory_bytes: 128
import collections


N = int(input())
A = list(map(int, input().split(' ')))
A_plus = [A[i]+1 for i in range(len(A))]
A_minus = [A[i]-1 for i in range(len(A))]
ans = collections.Counter(A + A_plus + A_minus).most_common()[0][1]
print(ans)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}


int quad(pint p){
	if(p.fi>0&&p.se>=0)return 0;
	if(p.se>0&&p.fi<=0)return 1;
	if(p.fi<0&&p.se<=0)return 2;
	return 3;
}
int dot(pint p,pint q){
	return p.fi*q.fi+p.se*q.se;
}
int cross(pint p,pint q){
	return p.fi*q.se-p.se*q.fi;
}
pint operator+(pint p,pint q){
	return pint(p.fi+q.fi,p.se+q.se);
}
pint operator-(pint p,pint q){
	return pint(p.fi-q.fi,p.se-q.se);
}

int norm(pint p){
	return dot(p,p);
}

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

	vpint ps;
	rep(i,N){
		int x,y;
		cin>>x>>y;
		if(x||y)ps.eb(x,y);
	}
	N=ps.size();

	sort(all(ps),[&](pint p,pint q){
		if(quad(p)!=quad(q)){
			return quad(p)<quad(q);
		}
		return cross(p,q)>0;
	});

	vpint ps_=ps;
	ps.insert(ps.end(),all(ps_));

	int ans=0;
	rep(i,N){
		pint sum;
		rep(j,N){
			sum=sum+ps[i+j];
			chmax(ans,norm(sum));
		}
	}

	printf("%.20Lf\n",sqrtl(1.0L*ans));
	return 0;
}

Measured memory_bytes: 256
n = int(input())
st = set([])

tail = ''
for i in range(n):
    w = input()
    if w in st:
        print('No')
        break
    if i != 0 and w[0] != tail:
        print('No')
        break
    st.add(w)
    tail = w[-1]
else:
    print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
using T3 = tuple<lint, lint, lint>;

template<class T> void chmin(T &a, T b) { a = min(a, b); }
char g[1123][1123];
lint dist[1123][1123];
bool visited[1123][1123];
P dir[] = { {-1,0}, {0, 1}, {1, 0}, {0, -1} };

int main() {
  lint H, W;
  cin >> H >> W;
  P S, G;
  cin >> S.first >> S.second;
  cin >> G.first >> G.second;

  fill(&g[0][0], &g[1122][1122], '#');
  for(lint i=1; i<=H; i++)
  for(lint j=1; j<=W; j++) {
    cin >> g[i][j];
  }

  auto outRange = [&](lint i, lint j) {
    return i < 0 || i > H || j < 0 || j > W;
  };

  fill(&dist[0][0], &dist[1122][1122], 1e18);
  fill(&visited[0][0], &visited[1122][1122], false);
  deque<T3> dq;
  dq.emplace_back(S.first, S.second, 0);
  while(dq.size()) {
    lint ci, cj, cost;
    tie(ci, cj, cost) = dq.front();
    dq.pop_front();

    chmin(dist[ci][cj], cost);
    visited[ci][cj] = true;
    // 移動A
    for(auto _ : dir) {
      lint di, dj;
      tie(di, dj) = _;
      if(visited[ci+di][cj+dj]) continue;
      if(g[ci+di][cj+dj] == '#') continue;
      dq.emplace_front(ci+di, cj+dj, cost);
    }

    // 移動B
    for(lint di=-2; di<=2; di++)
    for(lint dj=-2; dj<=2; dj++) {
      if(di == 0 && dj == 0) continue;
      if(outRange(ci+di, cj+dj)) continue;
      if(visited[ci+di][cj+dj]) continue;
      if(g[ci+di][cj+dj] == '#') continue;
      dq.emplace_back(ci+di, cj+dj, cost + 1);
    }
  }

  lint ans = dist[G.first][G.second];
  cout << (ans==1e18 ? -1 : ans) << endl;
}

Measured memory_bytes: 31272
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0,ans=0;

int main(){
    int n;
    cin >> n;
    if(n%1000!=0)
    cout << 1000 - n%1000 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define mod 1000000007
#define float long double
#define pb push_back
#define pi pair<int,int>
#define mp make_pair
#define do int n; cin>>n; vector<int>v1(n); rep(i,0,n) cin>>v1[i];
#define print(v1) rep(i,0,v1.size()){cout<<v1[i]<<" ";} cout<<"\n";
using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int modulo(int n,int m=1000000007){
    if(n<0){
        return (m-abs(n)%m)%m;
    }
    else return n%m;
}
bool isPrime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0)
      return false;
  }
  return true;
}
int power(int a,int n){
    if(n==0) return 1;
    if(n==1) return a;
    if(n==2) return (a*a)%mod;
    if(n&1){
        n--;
        return (a*power(power(a,2),n/2))%mod;
    }
    else return (power(power(a,2),n/2))%mod;
}
int fact(int n){
  int total=1;
  rep(i,2,n+1){
    total=(total*i)%mod;
    cout<<total+mod<<"\n";
  }
  return (total)%mod;
}
int find(int n){
  int x=n,sum=1;
  while(x>0){
    sum*=(x%10);
    x=x/10;
  }
  return sum;
}
void solve()
{   
    int n;
    cin>>n;
    cout<<!n;
}
 
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   
   int t=1;
   //cin>>t;
   while(t--)
   {
      solve();
      cout<<"\n";
   }
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
  return 0;
 }

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int time=h2*60+m2-h1*60-m1;
    cout<<time-k<<endl;
    return 0;
}

Measured memory_bytes: 3648
var N,i:Longint;
pre,ans,c:int64;
begin
read(N);
for i:=1 to N do begin
read(c);
if c=0 then pre:=0 else begin
inc(ans,(c+pre)div 2);
pre:=(c+pre)mod 2;
end;
end;
writeln(ans);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
#define lim 10000000
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int x;  cin >> x;
	bool is_prime[lim];
  	for(int i = 0 ; i <= lim ; i++)  is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for(int i = 2 ; i < lim ; i++){
		if(is_prime[i]){
			for(int j = 2 * i ; j < lim ; j += i)  is_prime[j] = false;
        }
	}

	for(int i = x ; i < lim ; i++){
      if(is_prime[i]){
        cout << i << endl;
		break;
      }
    }
	return 0;
}


Measured memory_bytes: 9984
a,b = map(int,input().split())
def gcd(x,y):
    if x < y:
        x,y = y,x
    while x%y != 0:
        a = x%y
        x = y
        y = a
    return y
N = gcd(a,b)
import math
n = math.floor(math.sqrt(N))
ans = 1
for i in range(2,n+1):
    if N%i == 0:
        ans += 1
        while N%i == 0:
            N /= i
if N != 1:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

int n;
int A[50];

//i番目以降の要素を使ってsumを作れる場合trueを返す
bool solve(int i, int sum){
    if(sum == 0) return true;
    if(i>=n) return false;

    int res = (solve(i+1, sum) || solve(i +1, sum-A[i]));
    return res;
}

int main(){

    scanf("%d", &n);

    for(int i=0;i<n;i++) scanf("%d", &A[i]);

    int q;
    scanf("%d", &q);
    int sum = 0;

    for(int i=0; i<q; i++){
        scanf("%d", &sum);
        if(solve(0, sum)) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; string s; cin >> N >> s;
	int cur = 0;
	for (char c : s) cur += (c == 'E');
	int ans = cur;
	for (char c : s) {
		if (c == 'E') {
			cur--;
		} else {
			cur++;
		}
		ans = min(ans, cur);
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 720
import bisect


def is_ok(a, target, m):
    num = 0
    for val in a:
        index = bisect.bisect_left(a, target - val)
        num += len(a) - index
    if num <= m:
        return True
    else:
        return False


n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

ok, ng = 10 ** 10, -1
while ok - ng > 1:
    mid = (ok + ng) // 2
    if is_ok(a, mid, m):
        ok = mid
    else:
        ng = mid

rui = [0] * (n + 1)

for i in range(n):
    rui[i+1] = rui[i] + a[i]

cnt = 0
ret = 0

for val in a:
    index = bisect.bisect_left(a, ok - val)
    num = len(a) - index
    cnt += num
    ret += (num * val) + (rui[-1] - rui[index])

ret += (m - cnt) * ng

print(ret)


Measured memory_bytes: 14092
use proconio::input;
use std::cmp::min;

fn main() {
    input! {
        n: usize,
        k: usize,
        xx: [i64; n],
    }

    let mut positives = vec![];
    let mut negatives = vec![];
    let mut zero = None;

    for x in xx {
        match x {
            0 => zero = Some(0),
            x if x > 0 => positives.push(x),
            x if x < 0 => negatives.push(-x),
            _ => unreachable!(),
        }
    }

    negatives.reverse();

    let mut count_pos = min(k, positives.len());

    let mut count_neg = if k > positives.len() { k - positives.len() } else { 0 };

    if zero.is_some() {
        if count_pos > 0 {
            count_pos -= 1;
        }
        if count_neg > 0 {
            count_neg -= 1;
        }
    }

    let mut ans = std::i64::MAX;

    for _ in 0..k {
        let pos = if count_pos > 0 {
            positives[count_pos-1]
        } else {
            0
        };
        let neg = if count_neg > 0 {
            if count_neg > negatives.len() {
                break;
            }
            negatives[count_neg-1]
        } else {
            0
        };
        ans = min(ans, pos * 2 + neg);
        ans = min(ans, pos + neg * 2);

        if count_pos == 0 {
            break;
        }
        count_pos -= 1;
        count_neg += 1;
    }

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


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

int main() {
  string S, T;
  cin >> S >> T;

  int count = 0;

  for (int i = 0; i < 3; i++) {
    if (S[i] == T[i]) {
      count++;
    }
  }

  cout << count << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

a, b, x = map(int, input().split())
bd = x - (a*a*b/2)
if bd >= 0:
    tmp = (2*b/a) - (2*x/a/a/a)
    print(math.degrees(math.atan(tmp)))
else:
    tmp = b*b*a/2/x
    print(math.degrees(math.atan(tmp)))




Measured memory_bytes: 38256
#include <stdio.h>

int main(void){
	int n,max =0,ans =0;
	scanf("%d",&n);
	char s[n];
	int flag_a[26];
	int flag_b[26];
	scanf("%s",&s);
	
	int i,j;
	for(i=0;i<n;i++){
		//flagの初期化
		for(j=0;j<26;j++){
		flag_a[j]=0;
		flag_b[j]=0;
		}
		//0からiまでにa-zがあるかどうか判別する
		for(j=0;j<i;j++){
			if( s[j] =='a')flag_a[0] =1;
			if( s[j] =='b')flag_a[1] =1;
			if( s[j] =='c')flag_a[2] =1;
			if( s[j] =='d')flag_a[3] =1;
			if( s[j] =='e')flag_a[4] =1;
			if( s[j] =='f')flag_a[5] =1;
			if( s[j] =='g')flag_a[6] =1;
			if( s[j] =='h')flag_a[7] =1;
			if( s[j] =='i')flag_a[8] =1;
			if( s[j] =='j')flag_a[9] =1;
			if( s[j] =='k')flag_a[10] =1;
			if( s[j] =='l')flag_a[11] =1;
			if( s[j] =='m')flag_a[12] =1;
			if( s[j] =='n')flag_a[13] =1;
			if( s[j] =='o')flag_a[14] =1;
			if( s[j] =='p')flag_a[15] =1;
			if( s[j] =='q')flag_a[16] =1;
			if( s[j] =='r')flag_a[17] =1;
			if( s[j] =='s')flag_a[18] =1;
			if( s[j] =='t')flag_a[19] =1;
			if( s[j] =='u')flag_a[20] =1;
			if( s[j] =='v')flag_a[21] =1;
			if( s[j] =='w')flag_a[22] =1;
			if( s[j] =='x')flag_a[23] =1;
			if( s[j] =='y')flag_a[24] =1;
			if( s[j] =='z')flag_a[25] =1;
		}
		//i+1からnまでにa-zがあるかどうか判別する
		for(j=i;j<n;j++){
			if( s[j] =='a')flag_b[0] =1;
			if( s[j] =='b')flag_b[1] =1;
			if( s[j] =='c')flag_b[2] =1;
			if( s[j] =='d')flag_b[3] =1;
			if( s[j] =='e')flag_b[4] =1;
			if( s[j] =='f')flag_b[5] =1;
			if( s[j] =='g')flag_b[6] =1;
			if( s[j] =='h')flag_b[7] =1;
			if( s[j] =='i')flag_b[8] =1;
			if( s[j] =='j')flag_b[9] =1;
			if( s[j] =='k')flag_b[10] =1;
			if( s[j] =='l')flag_b[11] =1;
			if( s[j] =='m')flag_b[12] =1;
			if( s[j] =='n')flag_b[13] =1;
			if( s[j] =='o')flag_b[14] =1;
			if( s[j] =='p')flag_b[15] =1;
			if( s[j] =='q')flag_b[16] =1;
			if( s[j] =='r')flag_b[17] =1;
			if( s[j] =='s')flag_b[18] =1;
			if( s[j] =='t')flag_b[19] =1;
			if( s[j] =='u')flag_b[20] =1;
			if( s[j] =='v')flag_b[21] =1;
			if( s[j] =='w')flag_b[22] =1;
			if( s[j] =='x')flag_b[23] =1;
			if( s[j] =='y')flag_b[24] =1;
			if( s[j] =='z')flag_b[25] =1;
		}
		for(j=0;j<26;j++){
			if( flag_a[j] == flag_b[j] && flag_a[j]==1){
				ans++;
			}
		}
		if( max < ans) max = ans;
		ans =0;
	}
	printf("%d",max);
	return 0;
}


Measured memory_bytes: 128
#include <cctype>
#include <iostream>
#include <string>

int main() {
  int counters[26] = {};
  std::string str;

  while (std::cin >> str) {
    for (auto ch : str) {
      char lower = std::tolower(static_cast<unsigned char>(ch));
      int index = lower - 'a';
      counters[index]++;
    }
  }
  for (int i = 0; i < 26; i++) {
    char ch = i + 'a';
    std::cout << ch << " : " << counters[i] << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3132
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int[] A = in.ii(N);

        HashMap<Long, Integer> hm = new HashMap<>();
        hm.put(0L, 1);

        long sum = 0;
        long ans = 0;
        for (int i = 0; i < N; i++) {
            sum += A[i];
            Integer j = hm.put(sum, 1 + hm.getOrDefault(sum, 0));
            ans += j == null ? 0 : j;
        }

        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 62592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			StringTokenizer buffer = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(buffer.nextToken());
			int b = Integer.parseInt(buffer.nextToken());
			
			String op = "a == b";
			if(a > b) {
				op = "a > b";
			}else if (a < b) {
				op = "a < b";
			}
			
			System.out.println(op);
	}
}


Measured memory_bytes: 24316
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
int C[213456], F[213456], S[213456];
int main() {
	long long n, c, s, f; cin >> n;
	for (int h = 1; h < n; h++) {
		cin >> c >> s >> f;
		C[h] = c; S[h] = s; F[h] = f;
	}
	for (int h = 1; h < n; h++) {
		int jikan = 0, ans = 0;
		for (int i = h; i < n; i++) {
			if (ans <= S[i]) {
				ans = S[i] + C[i];
			}
			else {
				ans = (ans - S[i] + F[i] - 1) / F[i] * F[i] + S[i] + C[i];
			}
		}
		cout << ans << endl;
	}
	cout << 0 << endl;
	cin >> n;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
       PROGRAM-ID. ABC042-B.
       DATA DIVISION.
       FILE SECTION.
       WORKING-STORAGE SECTION.
       77 INSTR PIC X(100).
       77 N PIC 9(3).
       77 L PIC 9(3).
       77 I PIC 9(3).
       01 STR.
        03 STRARR OCCURS 1 TO 100 TIMES DEPENDING ON N.
         05 STRDATA PIC X(100).
       77 ANS PIC X(10000).

       PROCEDURE DIVISION.
       MAIN-PROCEDURE.
            ACCEPT INSTR FROM SYSIN.
            UNSTRING INSTR DELIMITED " "
             INTO N L.
            PERFORM VARYING I FROM 1 BY 1
             UNTIL N < I
               ACCEPT INSTR FROM SYSIN
               MOVE INSTR TO STRARR(I)
            END-PERFORM.
            SORT STRARR ASCENDING STRDATA.
            PERFORM VARYING I FROM 1 BY 1
             UNTIL N < I
               STRING ANS STRARR(I) DELIMITED BY SPACE
                INTO ANS
            END-PERFORM.
            DISPLAY ANS.
            STOP RUN.
       END PROGRAM ABC042-B.


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

using namespace std;

int N, M;
int k[15], s[15][15], p[15];

int CHECK(int j, int K) {

	int tmp = 0;

	for (int i = 1; i <= k[j]; i++) {
		if ((K >> (s[j][i] - 1)) & 1) { tmp++; }
	}

	if ((tmp % 2) == p[j]) { return 1; }
	return -1;
}

int main(void) {

	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> k[i];
		for (int j = 1; j <= k[i]; j++) {
			cin >> s[i][j];
		}
	}

	for (int i = 1; i <= M; i++) {
		cin >> p[i];
	}


	int ans = 0;

	for (int m = 0; m < (1<<N); m++) {

		int c = 0;
		for (int i = 1; i <= M; i++) {
			if (CHECK(i, m) == 1) { c++; }
		}

		if (c == M) { ans++; }
		//cout << "m= " << m << endl;

	}

	cout << ans << endl;


/*	for (int m = 0; m < 4; m++) {
		cout << m << " " << CHECK(2, m) << endl;
	}*/

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        ans += y - x + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    int N, K;
    cin >> N >> K;
    set<int> explore;
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int temp;
            cin >> temp;
            explore.insert(temp);
        }
    }
    cout << N - explore.size() << endl;
}

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

int main() {
    int n, a[1010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 0; i < n; i++) {
        cout << a[i];
        if (i != n - 1) cout << " ";
    }
    cout << endl;

    for (int i = 1; i < n; i++) {
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;

        for (int i = 0; i < n; i++) {
            cout << a[i];
            if (i != n - 1) cout << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <limits.h>

void insertionSort(int *arr, int size){
	int j = 0;
	for(int i=1; i<size; i++){
		for(int k=0; k<size; k++){
			if(k!=size-1){
				printf("%d ", arr[k]);
			}
			else if(k==size-1){
				printf("%d\n", arr[k]);
			}
		}

		int v = arr[i];
		j = i-1;
		while(j>=0 && arr[j]>v){
			arr[j+1] = arr[j];
			j--;
		}
		arr[j+1] = v;
	}
	for(int k=0; k<size; k++){
			if(k!=size-1){
				printf("%d ", arr[k]);
			}
			else if(k==size-1){
				printf("%d\n", arr[k]);
			}
		}
}

int main(){
	int size = 0;
	scanf("%d", &size);
	int num[size];
	for(int i = 0; i<size; i++){
		scanf("%d", &num[i]);
	}
	insertionSort(num, size);
	return 0;
}




Measured memory_bytes: 1964
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		List<Integer> list1 = new ArrayList<Integer>();
		List<Integer> list2 = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			if(N == 1) {
				System.out.println(K);
				System.exit(0);
			}
			for (int j = 0; j < K; j++) {
				int A = sc.nextInt();
				//初回
				if (i == 0) {
					list1.add(A);
					continue;
				} else if (list1.contains(A)) {
					list2.add(A);

				}
			}

			if (i != 0 || i == N-1) {
				list1.clear();
				list1.addAll(list2);
				list2.clear();

			}

		}
		System.out.println(list1.size());
	}
}


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

int main()
{
    int arr[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> arr[i][j];
        }
    }
    int n,b;
    cin >> n;
    int ar[3][3]={0};
    int flag2=0;
    while(n--){
        cin >> b;int flag=0;
        for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(b==arr[i][j]){
                arr[i][j]=-1;
                flag=1;
                break;
            }
        }
        if(flag==1){
            break;
        }
    }
    if((arr[0][0]==-1 && arr[0][1]==-1 && arr[0][2]==-1)||(arr[1][0]==-1 && arr[1][1]==-1 && arr[1][2]==-1)||(arr[2][0]==-1 && arr[2][1]==-1 && arr[2][2]==-1)||(arr[2][2]==-1 && arr[1][2]==-1 && arr[0][2]==-1)||(arr[2][1]==-1 && arr[1][1]==-1 && arr[0][1]==-1)||(arr[2][0]==-1 && arr[1][0]==-1 && arr[0][0]==-1)||(arr[2][2]==-1 && arr[0][0]==-1 && arr[1][1]==-1)||(arr[2][0]==-1 && arr[1][1]==-1 && arr[0][2]==-1)){
        flag2=1;
        break;
    }

    }
    if(flag2==1){
        cout << "Yes" ;
    }else{
        cout << "No";
    }



    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn = 300300;
int main(){
    long long 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;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

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

  double s = x / a;
  double theta;

  if (s * 2 <= a * b) {
    // At the maximum tilt, a triangle forms
    theta = atan((b * b) / (2 * s));
  } else {
    // At the maximum tilt, a quadrilateral forms
    theta = atan(2 * (a * b - s) / (a * a));
  }

  double ans = theta * 180 / M_PI;

  cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  string s; cin >> s;
  if (s == "AAA" || s == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

// EOF


Measured memory_bytes: 256
N = int(input())
a = [0]*N
b = [0]*N
c = [0]*N
for i in range(N):
    a[i],b[i],c[i] = map(int,input().split())
dp = [[int(0) for i in range(3)] for i in range(N)]
ans = int(0)

dp[0][0] = a[0]
dp[0][1] = b[0]
dp[0][2] = c[0]

for i in range(1,N):
    dp[i][0] = max(a[i]+dp[i-1][1], a[i]+dp[i-1][2])
    dp[i][1] = max(b[i]+dp[i-1][0], b[i]+dp[i-1][2])
    dp[i][2] = max(c[i]+dp[i-1][0], c[i]+dp[i-1][1])

ans = max(dp[N-1])

print(ans)

Measured memory_bytes: 36172
def sum_1_to_k(k):
  return k * (k + 1) // 2


def main():
  n = int(input().rstrip())
  
  sum_to_n = sum_1_to_k(n)
  sum_of_3 = 3 * sum_1_to_k(n // 3)
  sum_of_5 = 5 * sum_1_to_k(n // 5)
  sum_of_15 = 15 * sum_1_to_k(n // 15)
  
  print(sum_to_n - sum_of_3 - sum_of_5 + sum_of_15)
  

if __name__ == "__main__":
  main()


Measured memory_bytes: 9180
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String S = sc.next();
    	String T = sc.next();
    	String ans = "No";
    	for (int i = 0; i < S.length(); i++) {
    		S = S.substring(1, S.length()) + S.substring(0, 1);
    		if (S.equals(T)) {
    			ans = "Yes";
    		}
    	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 21972
import sys
import math
 
from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))
 
 
n = load()
s = 0
for i in range(1, n+1):
    if i % 3 == 0 or i % 5 == 0:
        pass
    else:
        s += i
 
print(s)

Measured memory_bytes: 9520
a_len = int(input())
a_ar = sorted([int(n) for n in input().split(" ")])
b_len = int(input())
b_ar = [int(n) for n in input().split(" ")]
dp = [0 for n in range(2001)]
for a in a_ar:
    new_dp = dp[:]
    new_dp[a] = 1
    for i,d in enumerate(dp):
        if d and i + a <= 2000:
            new_dp[i + a] = 1
    dp = new_dp
for b in b_ar:
    if dp[b]:
        print("yes")
    else:
        print("no")

Measured memory_bytes: 7792
def main():
    N = int(input())

    print((100000 - N) % 1000)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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

int main() {
    string s; cin >>s;
    string ret = "NO";

    if (s[0]=='k'
     && s[1]=='e'
     && s[2]=='y'
     && s[3]=='e'
     && s[4]=='n'
     && s[5]=='c'
     && s[6]=='e'
    ) ret = "YES";

    int size = s.size();
    if (s[size-7]=='k'
     && s[size-6]=='e'
     && s[size-5]=='y'
     && s[size-4]=='e'
     && s[size-3]=='n'
     && s[size-2]=='c'
     && s[size-1]=='e'
    ) ret = "YES";

    if (s[0]=='k' && s[size-1]=='e') {
        string key = "keyence";
        int f = 0;
        while (s[f]==key[f]){f++;}
        int b = 0;
        while (s[s.size()-b]==key[7-b]){b++;}
        if (f+b > 7) ret ="YES";
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

#define PI 3.14159265358979323846 

int main() {
    // a^2 + b^2 - 2ab cos(theta)
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double angle_m = m*6;
    double angle_h = h*30 + m*0.5;
    double angle_diff = fabs(angle_m-angle_h);
    angle_diff = min(angle_diff, 360-angle_diff);
    angle_diff = angle_diff* PI /180;
    cout << fixed << setprecision(16) << sqrt(a*a+b*b-a*b*2*cos(angle_diff)) << endl;
    return 0;
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
const int _max = 100010;
typedef long long ll;

ll a[1000];
ll x,p=26;
void solve(){
    int count=0;
    do{
        a[count++]=(x-1)%p;
        x=(x-1)/p;
    }while(x!=0);
    for(int i=count-1;i>=0;i--){
        printf("%c",a[i]+97);
    }
}

int main()
{
    cin>>x;
    solve();
    return 0;
}

Measured memory_bytes: 3756
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int K = in.i();
        System.out.println((N - 1 + K - 2) / (K - 1));
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 32448
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr front()
#define tp top()
typedef long long int ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define iofile freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
const ll LLINF = 9e18;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 200005;

map<string,int> Mp;

int main (){
	
	iofast;
	int N;
	string S, prev;
	
	cin>>N;
	N--;
	cin>>S;
	if(Mp[S]==0) Mp[S]++;
	prev=S;
	int n=prev.size()-1;
	bool valid=true;
	while(N--){
		cin>>S;
		if(Mp[S]==0){
			if(S[0]!=prev[n]) valid=false;
			Mp[S]++;
		}
		else valid=false;
		prev=S;
		n=prev.size()-1;
	}
	if(valid==true) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
//AtCoder ABC110 B - 1 Dimensional World's Tale
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
    ll N,M,X,Y; cin>>N>>M>>X>>Y;
    vector<ll> xn(N);
    vector<ll> ym(M);
    for(auto&& x:xn){
        cin>>x;
    }
    for(auto&& y:ym){
        cin>>y;
    }
    sort(xn.begin(),xn.end());
    sort(ym.begin(),ym.end());
    ll xn_max=xn.back();
    ll ym_min=ym.front();
    bool ans=false;
    for(ll z=X+1;z<=Y;++z){
        if (xn_max<z&&ym_min>=z) {
            ans=true;
            break;
        }
    }
    cout<<(ans?"No War":"War")<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

A = list(range(1, n+1))
A = list(itertools.permutations(A, n))
            
a = A.index(P)
b = A.index(Q)
print(abs(a-b))

Measured memory_bytes: 8052