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

using namespace std;

int n, m, dp[100005], cnt[100005];

bool used[100005];

int main () {
  cin >> n >> m;
  dp[0] = 1;
  used[1] = true;
  for (int i = 1;i <= n;i ++) {
    cnt[i] = 1;
  }
  for (int i = 1;i <= m;i ++) {
    dp[i] = dp[i - 1];
    int l, r;
    cin >> l >> r;
    if (used[l]) {
      if (cnt[l] == 1) {
        dp[i]--;
        used[l] = false;
      }
      if (!used[r]){
        used[r] = true;
        dp[i] ++;
      }
      cnt[r] ++;
      cnt[l] --;
    }else {
      cnt[l] --;
      cnt[r] ++;
    }
  }cout << dp[m];
}

Measured memory_bytes: 1152
#include <sstream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <string>
#include <queue>
#include <bitset>
using namespace std;

#define int long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; --i)
#define REP(i, a) for (int i = 0, _a = (a); i < _a; ++i)
#define REPD(i,n) for(int i = (n)-1; i >= 0; --i)

#define DEBUG(X) { cerr << #X << " = " << (X) << endl; }
#define PR(A, n) { cerr << #A << " = "; FOR(_, 1, n) cerr << A[_] << ' '; cerr << endl; }
#define PR0(A, n) { cerr << #A << " = "; REP(_, n) cerr << A[_] << ' '; cerr << endl; }

#define sqr(x) ((x) * (x))
#define ll long long
#define double long double
typedef pair<int, int> II;
#define PI (2 * acos((double)0))
#define __builtin_popcount __builtin_popcountll
#define SZ(x) ((int)(x).size())
#define ALL(a) (a).begin(), (a).end()
#define MS(a,x) memset(a, x, sizeof(a))
#define epsilon 0.0000001
using namespace std;


int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[9];
  MS(a, 0);
  REP(i, n) {
    int t;
    cin >> t;
    if (t <= 399) {
      a[0]++;
    } else if (t <= 799) {
      a[1]++;
    } else if (t <= 1199) {
      a[2]++;
    } else if (t <= 1599) {
      a[3]++;
    } else if (t <= 1999) {
      a[4]++;
    } else if (t <= 2399) {
      a[5]++;
    } else if (t <= 2799) {
      a[6]++;
    } else if (t <= 3199) {
      a[7]++;
    } else {
      a[8]++;
    }
  }
  int mi = 0, ma;
  REP(i, 8) {
    if (a[i] != 0) {
      mi++;
    }
  }
  ma = mi + a[8];
  if (mi == 0) mi = 1;
  cout << mi << " " << ma << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <vector>

#include <string>
#include <limits.h>
#include <set>
#define ll long
#define MAX 1e9
using namespace std;
typedef long long lli;
int main(){
    ios_base::sync_with_stdio(false);

    string str;
    cin>>str;
    string s1 = "ABC";
    string s2 = "ARC";
    if(str.compare(s1)==0)
    	cout<<s2<<"\n";
    else if(str.compare(s2)==0)
    	cout<<s1<<"\n";
    return 0;
}


Measured memory_bytes: 3640
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = LI()

for i in range(len(N)):
    if N[i] == 0:
        print(i+1)
        exit()

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

//将字符串转化为数值
int getChar(char ch) {
	if (ch == 'A')return 1;
	else if (ch == 'C')return 2;
	else if (ch == 'G')return 3;
	else if (ch == 'T')return 4;
	else return 0;
}

//将字符串转化为数值并生成key
long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) {
	return key % M;
}

int h2(int key) {
	return 1 + (key % (M - 1));
}

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0)return 1;
		else if (strlen(H[h]) == 0)return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0)return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; i++)H[i][0] = '\0';
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", com, str);
		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}
	return 0;
}


Measured memory_bytes: 16044
def get_min_point(points, ratio)

  ap, bp = points
  ar, br = ratio

  an = get_min_count(ap, ar)
  bn = get_min_count(bp, br)

  mn = [an, bn].max
  result = [ar*mn, br*mn]
  result
end

def get_min_count(ap, ar)
  if ap % ar == 0
    (ap / ar)
  else
    (ap / ar) + 1
  end
end

inputs = readlines.map(&:chomp)
points = inputs[1].split(" ").map(&:to_i)
ratios = inputs[2..-1].map {|x| x.split(" ").map(&:to_i) }

ratios.each do |ratio|
  points = get_min_point(points, ratio)
end

puts points.reduce(:+)


Measured memory_bytes: 2044
n = input()
op_cnt = len(n) - 1  
ans = 0
for i in range(2 ** op_cnt):
    op = [""] * op_cnt  
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  

    formula = ""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    ans += eval(formula)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N;
	cin >> N;
	int A[200];
	rep(i, N + N) cin >> A[i];
	sort(A, A + N + N);

	int kotae = 0;
	rep(i, N) kotae += A[i * 2];
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
PROGRAM guessTheNumber
      IMPLICIT NONE
      integer :: n,num(3),m
      integer,allocatable :: s(:),c(:)
      integer :: i,ii,k
      
      read*,n,m
      allocate( s(m),c(m) )
      do i = 1,m
        read*,s(i),c(i)
      end do
 !     print*,n,m
 !     do i = 1,m
 !       print*,s(i),c(i)
 !     end do
      
      if( n==2 ) s(:) = s(:) + 1
      if( n==1 ) s(:) = s(:) + 2
      
      outer:do i = 0,999
        if( n==1 .and. .not.(0  <=i .and. i<=9  ) ) cycle
        if( n==2 .and. .not.(10 <=i .and. i<=99 ) ) cycle
        if( n==3 .and. .not.(100<=i .and. i<=999) ) cycle
        ii = i
        do k = 1,3
          num(k) = ii - ii/10*10
          ii = ii / 10
        end do
 ! print*,num
      
      do k = 1,m
        if( num(3-s(k)+1)/=c(k) ) cycle outer
      end do
      print*,i;stop
      
      end do outer
      
      print*,'-1'
      
      
      END PROGRAM

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

long calc(int n, int s) {

    long rec(int p, int sum, int to, long[][][] memo) {
        if (to > 0 && memo[p][to][sum] >= 0)
            return memo[p][to][sum];

        if (p == n) {
            return sum == s ? 1 : 0;
        }

        long ans = 0;
        for (int i = to + 1; i <= 100; i++) {
            if (sum + i > s)
                break;
            ans += rec(p + 1, sum + i, i, memo);
        }

        if (to > 0)
            memo[p][to][sum] = ans;
        return ans;
    }

    auto memo = new long[][][](n + 1, 101, 1001);
    for (int i = 0; i < n + 1; i++) {
        for (int j = 0; j < 101; j++) {
            for (int k = 0; k < 1001; k++)
                memo[i][j][k] = -1L;
        }
    }
    return rec(0, 0, -1, memo);
}

void main() {
    string t;
    while ((t = readln.chomp).length > 0) {
        auto ns = t.split.map!(to!int).array;
        int n = ns[0], s = ns[1];
        if (n == 0 && s == 0)
            break;

        writeln(calc(n, s));
    }
}

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

int main(int argc, char **argv)
{
	string str; cin >> str;

	stack<char> st;
	for (ll i = 0; i < str.size(); ++i)
	{
		char c{str[i]};

		if (st.empty())
		{
			st.push(c);
		}
		else if (st.top() == 'S' && c == 'T') {st.pop();}
		else st.push(c);
	}
	std::cout << st.size() << std::endl;
}


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;
    
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x3, y3, x4, y4;

  x3 = x2 - (y2 - y1);
  y3 = y2 + (x2 - x1);

  x4 = x1 - (y2 - y1);
  y4 = y1 + (x2 - x1);

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <string>

using namespace std;

int main(){
    char S[4];
    char c='\0';
    bool flag = true;
    scanf("%s", S);
    for (int i = 0 ; i < 4 ; i++){
        if (S[i] == c){
            flag = false;
            break;
        }
        c = S[i];
    }
    printf("%s\r\n", (flag)? "Good" : "Bad");
    fflush(stdout);
    return 0;
}

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

  int main() {
    int N;
    long long sum=0;
    cin >> N;

    for(int i=1;i<N+1;i++){
      if((i%3!=0)&&(i%5!=0)){
        sum += i;
      }
    }

    cout << sum << endl;
  }


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

struct Edge {
  ll from, to;
  ll cost;
  Edge(ll from, ll to, ll cost):
  from(from),to(to),cost(cost){}
};

ll minv = -1ll * (1ll << 35ll);
ll n, m, p;
ll s, t, c;
ll dist[3000];
vector<Edge> G;

int bellman_ford(vector<Edge> &edges) {
  int state = 1;
  dist[1] = 0;
  for(int i = 0; i < n - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.from] == minv) continue;
      dist[e.to] = max(dist[e.to], dist[e.from] + e.cost);
    }
  }
  
  ll d[3000];
  for (int i=0;i<3000;i++)d[i]=dist[i];
  for(int i = 0; i < n - 1; i++) {
    for(auto &e : edges) {
      if(d[e.from] == minv) continue;
      d[e.to] = max(d[e.to], d[e.from] + e.cost);
    }
  }
  
  return d[n]==dist[n];
}

int main() {
  for (int i=0;i<3000;i++) dist[i] = minv;
  cin >> n >> m >> p;
  
  for (int i=0;i<m;i++) {
    cin >> s >> t >> c;
    G.push_back(Edge(s,t,c-p));
  }
  
  if (bellman_ford(G)) cout << max(0ll,dist[n]) << endl;
  else cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <map>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

inline int bsf(int n)
{
  int z;
  __asm__("bsf %1, %0;" :"=r"(z) :"r"(n));
  return z;
}


int n, m;
int mapto[256];
int len[100];
char str[100][20];
bool used[300];
bool cant0[10];
int lsum[10];
int rsum[10];

int calc(int use, int depth, int sum, int ans) {
  if (depth == m) {
    if (ans == sum) { return 1; }
    return 0;
  }
  int ret = 0;
  int v = ((1 << 10) - 1) ^ use;
  while (v) {
    int index = bsf(v);
    v -= v & -v;
    if (cant0[depth] && index == 0) { continue; }
    ans += rsum[depth] * index;
    sum += lsum[depth] * index;
    ret += calc(use | (1 << index), depth + 1, sum, ans);
    sum -= lsum[depth] * index;
    ans -= rsum[depth] * index;
  }
  return ret;
}

int main() {
  while (scanf("%d", &n), n) {
    REP(i, n) { scanf("%s", str[i]); len[i] = strlen(str[i]); }
    MEMSET(lsum, 0);
    MEMSET(rsum, 0);
    MEMSET(cant0, false);
    MEMSET(used, false);
    m = 0;
    REP(i, n) {
      int mul = pow(10, len[i] - 1);
      REP(j, len[i]) {
        if (!used[(int)str[i][j]]) {
          used[(int)str[i][j]] = true;
          mapto[(int)str[i][j]] = m;
          m++;
        }
        //str[i][j] = mapto[(int)str[i][j]];
        if (i != n -1) {
          lsum[mapto[(int)str[i][j]]] += mul;
        } else {
          rsum[mapto[(int)str[i][j]]] += mul;
        }
        mul /= 10;
      }
      if (len[i] != 1) {
        cant0[mapto[(int)str[i][0]]] = true;
      }
    }
    printf("%d\n", calc(0, 0, 0, 0));
  }
}

Measured memory_bytes: 916
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
using ll = long long;



int ipow(int a, int b){
    int r = 1;
    while (b >= 1)
    {
        if(b % 2 == 1)r *= a;
        b /= 2;
        a *= a;
    }
    return r;

    
}

int main(){
    int N;cin>>N;
    vector<int> V,W;
    for(int i = 1;i < N+1;i++){
        int v,w;cin>>v>>w;
        V.push_back(v);
        W.push_back(w);
    }
    vector<int> qV, qL;
    int Q;cin>>Q;
    int maxL = 0;
    for(int i = 0;i < Q;i++){
        int v,L;cin>>v>>L;
        maxL = max(maxL, L);
        v--;
        qV.push_back(v);
        qL.push_back(L);
    }
    vector<vector<int>> dp(min(N,700),vector<int>(maxL+1,-1));
    for(int i = 0;i < dp.size();i++){
        for(int j = 0;j <= maxL;j++){
            if(i == 0){
                dp[i][j] = W[0] <= j ? V[0] : 0;
                // cout<<dp[i][j]<<" ";
                continue;
            }
            dp[i][j] = max(dp[i][j], dp[(i+1)/2-1][j]);
            dp[i][j] = max(dp[i][j], j-W[i] >= 0 ?  dp[(i+1)/2-1][j-W[i]] + V[i] : -1);
            // cout<<dp[i][j]<<" ";
        }//cout<<endl;
    }
    for(int q = 0;q < Q;q++){
        int v = qV[q];
        int l = qL[q];
        if(v < dp.size()){
            // cout<<"!!"<<endl;
            cout<<dp[v][l]<<endl;
            continue;
        }
        int P = v;
        vector<int> road;
        while(P >= dp.size()){
            road.push_back(P);
            P = (P+1)/2 -1;
        }
        int res = 0;
        // cout<<road.size()<<" "<<ipow(2,road.size())<<endl;
        for(int i = 0;i < ipow(2,road.size());i++){
            int val = 0;
            int wei = 0;
            for(int j = 0;j < road.size();j++){
                if((i>>j)&1){
                    val += V[road[j]];
                    wei += W[road[j]];
                }
            }
            if(wei > l)continue;
            val += dp[P][l-wei];
            res = max(res,val);
        }
        cout<<res<<endl;

    }


}

Measured memory_bytes: 280308
from sys import stdin

n = int(stdin.readline().rstrip())
al = stdin.readline().rstrip().split()
ans = 1
flag = 0
for a in al:
	ans = ans * int(a)
	if ans < 0 or ans > 1000000000000000000:
		flag = 1
		ans = -1

print(ans)

Measured memory_bytes: 19484
n, m, x, y = map(int, input().split())
l_x = [int(_) for _ in input().split()]
l_y = [int(_) for _ in input().split()]
max_x = max(l_x)
min_y = min(l_y)
if max_x < min_y:
    l_ans = set([i for i in range(max_x+1, min_y+1)])
    l_ans2 = set([i for i in range(x+1, y+1)])
    if l_ans & l_ans2:
        print("No War")
    else:
        print("War")
else:
    print("War")


Measured memory_bytes: 3064
n,k=map(int,input().split())
top=[0]*n
sub=[]
for _ in range(n):
    t,d=map(int,input().split())
    t-=1
    if top[t]==0:
        top[t]=d
    else:
        if d>top[t]:
            sub.append(top[t])
            top[t]=d
        else:
            sub.append(d)
top.sort(reverse=True)
top_sum=[0]
sub.sort(reverse=True)
sub_sum=[0]

for i in top:
    if i==0:
        top_sum.append(-1)
    else:
        top_sum.append(top_sum[-1]+i)
for i in sub:
    sub_sum.append(sub_sum[-1]+i)
ans=0
for i in range(1,k+1):
    if i+len(sub_sum)-1>=k and top_sum[i]!=-1:
        ans=max(ans,top_sum[i]+sub_sum[k-i]+i**2)
print(ans)



Measured memory_bytes: 12588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define for1(i, m, n) for (int i = m; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double r;
    cin >> r;
    printf("%lf %lf\n", r * r * M_PI, 2 * r * M_PI);
    return 0;
}


Measured memory_bytes: 3312
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void 
debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
char s[5005];
int n;
int K;
int main(){
  scanf("%s",s);
  cin>>K;

  n=strlen(s);

  vector<string> S;
  REP(i,n){
    string cur;
    for(int j=0;j<K && i+j<n;++j){
      cur+=s[i+j];
      S.pb(cur);
    }
  }
  sort(ALL(S));
  S.erase(unique(ALL(S)),S.end());
  cout<<S[K-1]<<endl;
  return 0;
}





Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

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

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if (v<=w){
        cout<<"NO"<<endl;
        return;
    }
    ll meow=(v-w)*t;
    if (meow>=abs(b-a)){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 3660
import java.io.*;

class Main{
    

    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {       
                    String line1 = reader.readLine();
                    int x = Integer.parseInt(line1);
                    String line = reader.readLine();
                    String[] strAry = line.split(" ");

                    int[] a = new int[x];
			
			for (int i = 0;i < strAry.length; i++){
				a[i] = Integer.parseInt(strAry[i]);
            }
            
            for(int i = 0; i < x; i++){
                for(int k = 0; k < i; k++){
                    if(a[i] < a[k]){
                        int kara = a[i];
                        for(int j = 0; j < (i - k); j++){
                            a[i - j] = a[i - j - 1];
                        }
                        a[k] = kara;
                    } 
                }
                System.out.print(a[0]);
                for(int l = 1; l < x; l++){
                    System.out.print(" " + a[l]);
                }
                System.out.println();
            }

            
                            
        } catch (IOException e) {
            //TODO: handle exception
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 30732
#include<iostream>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<cmath>
#include<list>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
const int maxn = 100000 + 8;

struct node{
    string s;
    int n;
}x[maxn],y[maxn];

int n;
int Partition(node a[],int p,int r)
{
    node last_element = a[r];
    int i = p-1;
    for(int j = p; j < r; ++j)
    {
        if(a[j].n <= last_element.n)
        {
            i++;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return i+1;
}
void QuickSort(node a[],int p,int r)
{
    if(p < r)
    {
        int pos = Partition(a, p, r);
        QuickSort(a, p, pos - 1);
        QuickSort(a, pos + 1, r);
    }
}
void Merge(node a[],int left,int mid,int right,node temp[])
{
    int i = left,j = mid + 1 , k = 0;
    while(i <= mid && j <= right)
    {
        if(a[i].n <= a[j].n) {
            temp[k++] = a[i++];
        } else{
            temp[k++] = a[j++];
        }
    }

    while(i <= mid) temp[k++] = a[i++];
    while(j <= right) temp[k++] = a[j++];

    for(int z = 0; z < k; ++z)
    {
        a[left + z] = temp[z];
    }
}
void MergeSort(node a[],int left,int right,node temp[])
{
    if(left < right)
    {
        int mid = (right + left) / 2;
        MergeSort(a, left, mid, temp);
        MergeSort(a, mid+1, right, temp);
        Merge(a,left,mid,right, temp);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i = 0; i < n; ++i)
    {
        cin >> x[i].s;
        scanf("%d",&x[i].n);
        y[i].s = x[i].s;
        y[i].n = x[i].n;
    }
    node temp[maxn];
    MergeSort(x, 0, n-1,temp);
    QuickSort(y, 0, n-1);
    bool mark = false;
    for(int i = 0; i < n; ++i)
    {
        if(x[i].s != y[i].s ||(x[i].s == y[i].s &&  x[i].n != y[i].n))
        {
            mark = true;
            break;
        }
    }
    if(mark) printf("Not stable\n");
    else printf("Stable\n");

    for(int i = 0; i < n; ++i)
    {
        cout << y[i].s << " ";
        printf("%d\n",y[i].n);
    }
    return 0;
}

Measured memory_bytes: 12564
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int n, cl;
  cin >> n;
  int a[n];
  map<int, int> m;
  REP(i, n){
    cin >> a[i];
    cl = a[i] / 400;
    if(cl >= 8) cl = 8;
    m[cl]++;
  }

  int mn = 0;

  REP(i, m.size()){
    if(m[i] != 0 && i != 8){
      mn++;
    }
  }

  if(mn == 0){
    cout << 1 << " " << m[8] << endl;
    return 0;
  }

  cout << mn << " " << mn + m[8] << endl;
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vint a(n); rep(i,n) cin>>a[i];

    vint diff(n);
    rep(i,n) diff[i] = a[(i+1)%n] - a[i];
    ll s = 0;
    for(auto e:a) s+=e;
    ll deno = n*(n+1)/2;
    if(s%deno != 0){
        puts("NO");
        return 0;
    }

    ll cnt = s/deno;
    vint b(n);
    rep(i,n) b[i] = diff[i] - cnt;
    for(auto e:b){
        if(e%n != 0 || e > 0){
            puts("NO");
            return 0;
        }
        cnt += e/n;
    }

    if(cnt == 0) puts("YES");
    else puts("NO");





    return 0;

}

Measured memory_bytes: 2560
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

int main() {
    ll MOD = 1000000007;
    ll N, A, B;
    cin >> N >> A >> B;
    ll a = A, b = B, n = N;
    ll abunshi = 1, abunbo = 1, bbunshi = 1, bbunbo = 1;
    rep(i, A) {
        abunshi *= n;
        abunshi %= MOD;
        n--;
        abunbo *= a;
        abunbo %= MOD;
        a--;
    }

    abunbo = modpow(abunbo, pow(10, 9) + 5, MOD);
    ll acomb = (abunshi * abunbo) % MOD;
    n = N;

    rep(i, B) {
        bbunshi *= n;
        bbunshi %= MOD;
        n--;
        bbunbo *= b;
        bbunbo %= MOD;
        b--;
    }

    bbunbo = modpow(bbunbo, pow(10, 9) + 5, MOD);
    ll bcomb = (bbunshi * bbunbo) % MOD;

    ll sum = modpow(2, N, MOD);

    ll res = sum - acomb - bcomb - 1;
    while (res < 0) {
        res += MOD;
    }
    res %= MOD;
    cout << res << endl;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int n,a,b,c,d;
    cin >> n>> a >> b>> c>> d;
    a--;b--;c--;d--;
    string s;cin >> s;
    int x = max(c,d);
    for(int i=a;i<x;i++){
        if(s[i]=='#'&&s[i+1]=='#'){
            cout << "No" << endl;
            return 0;
        }
    }
    if(c<d){
        cout << "Yes" << endl;
    }else{
        //抜かせるときはBが真ん中じゃないとあかん
        for(int i=b-1;i<d;i++){
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.'){
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 644
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char s[15];
    scanf("%s",s);
    int tmp = 1;
    int ans =  1000;
    tmp = s[0] - '0';
    tmp = tmp *10 + s[1] -'0';
    for(int i=2;i<strlen(s);i++)
    {
        tmp = tmp%100 *10 + s[i] - '0';
        ans = min(ans,abs(tmp-753));
    }
    printf("%d\n",ans);
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;


signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // Failed to predict input format

    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i,0,n) {
        cin >> c[i];
        rep(j,0,m) cin >> a[i][j];
    }
    int answer = INT_MAX;
    rep(i,0,1LL << n) {
        vector<int> points(m);
        int cost = 0;
        rep(j,0,n) {
            if (i & (1LL << j)) {
                cost += c[j];
                rep(k,0,m) {
                    points[k] += a[j][k];
                }
            }
        }
        bool isValid = true;
        rep(j,0,m) {
            if (points[j] < x) {
                isValid = false;
                break;
            }
        }
        if (isValid) {
            answer = min(answer, cost);
        }
    }
    cout << (answer == INT_MAX ? -1 : answer) << endl;
    return 0;
}


Measured memory_bytes: 3632
from collections import namedtuple
Node = namedtuple('Node', ['parent', 'children'])
   
class my_binary_tree:
    def __init__(self, preorderList, inorderList):
        self.T = {}
        self.reconstruction(preorderList,inorderList)
   
    def reconstruction(self, preorderList, inorderList, parent=-1):
        i = preorderList[0]
        p = parent
        j = inorderList.index(i) 
        llen = len(inorderList[:j])
        rlen = len(inorderList[j+1:])
        if llen > 0: c0 = self.reconstruction(preorderList[1:llen+1],inorderList[:llen],i)
        else       : c0 = -1
        if rlen > 0: c1 = self.reconstruction(preorderList[llen+1:],inorderList[llen+1:],i)
        else       : c1 = -1
        self.T[i] = Node(p,[c0,c1])
        return i
   
    def getPostorderList(self, i):
        c0 = self.T[i].children[0]
        c1 = self.T[i].children[1]
        if c0 != -1: yield from self.getPostorderList(c0)
        if c1 != -1: yield from self.getPostorderList(c1)
        yield i
   
    
if __name__=='__main__':
    n = int(input())
    preorderList = list(map(int,input().split()))
    inorderList  = list(map(int,input().split()))
    tree = my_binary_tree(preorderList,inorderList)
        
    print(*tree.getPostorderList(preorderList[0]))

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

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

  vector<long long> l = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  int idx_begin = 0;
  int idx_end = l.size();
  while(true) {
    for (int i = idx_begin; i < idx_end; i++) {
      if ((l[i] % 10) - 1 >= 0) {
        l.push_back(l[i] * 10 + ((l[i] % 10) - 1));
      }

      l.push_back(l[i] * 10 + ((l[i] % 10)));

      if ((l[i] % 10) + 1 < 10) {
        l.push_back(l[i] * 10 + ((l[i] % 10) + 1));
      }
    }

    if (l.size() > k) {
      break;
    }

    idx_begin = idx_end;
    idx_end = idx_begin + (l.size() - idx_end);
  }

  sort(l.begin(), l.end());

  cout << l[k-1] << "\n";
}


Measured memory_bytes: 3828
#include <stdio.h>
int main(void){
	char n[2000001] = { '\0' };
	scanf("%s", n);
	int i = 0;
	long x = 0;
	while(n[i] != '\0'){
		x += n[i] - '0';
		i++;
	}
	if(x%9 == 0){
		printf("Yes\n");
	} else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

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

    vector<tuple<string, int>> r(n);
    vector<int> idx(n);
    for (size_t i = 0; i < n; i++)
    {
        string s;
        int p;
        cin >> s >> p;
        r[i] = make_tuple(s, p);
        idx[i] = i;
    }

    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = i; j < n; j++)
        {
            if (get<0>(r[i]) > get<0>(r[j]))
            {
                tuple<string, int> tmp = r[j];
                r[j] = r[i];
                r[i] = tmp;
                int itmp = idx[j];
                idx[j] = idx[i];
                idx[i] = itmp;
            }
            else if (get<0>(r[i]) == get<0>(r[j]) &&
                     get<1>(r[i]) < get<1>(r[j]))
            {

                tuple<string, int> tmp = r[j];
                r[j] = r[i];
                r[i] = tmp;
                int itmp = idx[j];
                idx[j] = idx[i];
                idx[i] = itmp;
            }
        }
    }

    for (size_t i = 0; i < n; i++)
    {
        cout << idx[i] + 1 << endl;
    }

    return 0;
}


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

int H, W;

int main() {
    cin >> H >> W;
    int alpha[26];
    memset(alpha, 0, sizeof(alpha));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            alpha[c - 'a']++;
        }
    }

    bool f = true;
    for (int i = 0; i < (H+1)/2; i++) {
        for (int j = 0; j < (W+1)/2; j++) {
            if (i == H/2 && j == W/2) {
                bool check = true;
                for (int k = 0; k < 26; k++) {
                    if (alpha[k] % 2 == 1) {
                        alpha[k]--;
                        check = false;
                        break;
                    }
                }
                if (check) {
                    f = false;
                    break;
                }
            }
            else if (i == H/2 || j == W/2) {
                bool check = true;
                for (int k = 0; k < 26; k++) {
                    if (alpha[k] % 4 == 2) {
                        alpha[k] -= 2;
                        check = false;
                        break;
                    }
                }
                if (check) {
                    for (int k = 0; k < 26; k++) {
                        if (alpha[k] >= 2) {
                            alpha[k] -= 2;
                            check = false;
                            break;
                        }
                    }
                }
                if (check) {
                    f = false;
                    break;
                }
            }
            else {
                bool check = true;
                for (int k = 0; k < 26; k++) {
                    if (alpha[k] >= 4) {
                        alpha[k] -= 4;
                        check = false;
                        break;
                    }
                }
                if (check) {
                    f = false;
                    break;
                }
            }

        }
        if (!f) break;
    }

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int h, w;
	int i, j;

	while (1)
	{
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) {
			break;
		}

		for (i = 1; i <= h; i++) {
			for (j = 1; j <= w; j++) {

				if (i % 2 == 1 ) {
					if (j % 2 == 1) {
						printf("#");
					}
					else {
						printf(".");
					}
				}
				else {
					if (j % 2 == 0) {
						printf("#");
					}
					else {
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

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

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define fi first
#define se second

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( reinterpret_cast<T*>(array),
             reinterpret_cast<T*>(array+N),
             val );
}

// binary search
ll BSearch(ll ok, ll ng, bool (*f)(ll)){
  ll mid;
  while(abs(ok - ng) > 1LL) {
    mid =  (ok + ng) / 2LL;
    if(f(mid)) {
      debug("BSearch: f(%d) == true\n", mid);
      ok = mid;
    }
    else
    {
      debug("BSearch: f(%d) == false\n", mid);
      ng = mid;
    }
  }
  return ok;
}

ll NUM_TEST_CASE = 1;

ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm
  ans = K * ((N + M - 1) / M);
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
void init(){
  // initialize for each test case
  // Fill(dp, -1);
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // cin >> NUM_TEST_CASE;

  for (int test_case = 0; test_case < NUM_TEST_CASE; ++test_case)
  {
    init();

    cin >> N >> M >> K;
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();
  }

  return 0;
}

Measured memory_bytes: 3596
from sys import stdin
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


A, B = [int(x) for x in stdin.readline().rstrip().split()]
# A,B = [int(x) for x in stdin.readline().rstrip().split()]
# U = stdin.readline().rstrip().split()
# print(S)
if A < 2:
    c = 0
else:
    c = combinations_count(A, 2)
if B<2:
    d=0
else:
    d = combinations_count(B, 2)
print(c+d)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

bool is_prime(int x) {
	int limit = sqrt(x);
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;
	int i = 3;
	while (i * i <= x) {
		if (x % i == 0) {
			return false;
		}
		i = i + 2;
	};
	return true;
}

int main() {
	int N; 	cin >> N;
	vector<int> a(N);

	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (is_prime(a[i])) cnt++;
	}
	cout << cnt << endl;;
}


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

using namespace std;

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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    pll ans(0, 100 * A);
    for (ll a = 0;; a++) {
        if (100 * a * A > F)
            break;
        for (ll b = 0;; b++) {
            ll s = 100LL * a * A + 100LL * b * B;
            if (s > F)
                break;
            for (ll c = 0;; c++) {
                if (s + C * c > F)
                    break;
                if (E * (a * A + b * B) < C * c)
                    break;
                for (ll d = 0;; d++) {
                    ll t = C * c + D * d;
                    if (s + t > F)
                        break;
                    if (E * (a * A + b * B) < t)
                        break;

                    if (ans.first * (s + t) < ans.second * t) {
                        ans = pll(t, s + t);
                    }
                }
            }
        }
    }

    cout << ans.second << " " << ans.first << endl;
    return 0;
}

Measured memory_bytes: 256
a = int(input())
f1 = int(2)
f2 = int(1)
f = int(1)
if a == 1:
  print("1")
elif a == 2:
  print("2")
else:
  for b in range(2,a):
    f= f1+f2
    f2 = f1
    f1 = f
  print(f)



Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define rep(i,s,e) for(int i = s; i < e; i++)
#define test(t) int t; cin >> t; while(t--) 
#define iterate(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define MOD 1000000007

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pi;
typedef set<int> si;
typedef long long ll;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int h[n];
  rep(i,0,n) {
    cin >> h[i];
  }
  int m[n];
  m[0] = 0;
  m[1] = abs(h[1] - h[0]);
  rep(i,2,n) {
    m[i] = min(
        (m[i-1] + abs(h[i] - h[i-1])),
        (m[i-2] + abs(h[i] - h[i-2]))
    );
  }
  cout << m[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
string N;
  cin >>N;
  if ( (N.at(0)==N.at(1) && N.at(1)==N.at(2)) || (N.at(1)== N.at(2) && N.at(2)== N.at(3)) ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip().split()
x = [None]*n
x = [int(s[i]) for i in range(0, n)]

ave = 0
for i in range(0, n):
   ave += x[i]
p1 = ave//n + 1
p2 = ave//n

sum1 = 0
sum2 = 0
for i in range(0, n):
   sum1 += pow(x[i]-p1, 2)
   sum2 += pow(x[i]-p2, 2)

if sum1 < sum2:
    print(sum1)
else:
    print(sum2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define debug(x_) cerr << #x_ << ":" << x_ << endl;
#define debug2(x__) for(auto a__ : x__) cerr << a__ << " "; cerr << endl;
#define debug3(x___ , sx___) rep(i, sx___) cerr << x___[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << 111 * CEIL(n, 111) << endl;
    return 0;
}


Measured memory_bytes: 256
def check(i):
	tot=k
	while(tot%i==0):
		tot//=i
	if(tot%i==1):
		setl.add(i)
import math
k=int(input())
if(k==2):
	print(1)
	exit()
setl = set()
setl.add(k); setl.add(k-1)
for x in range(2,int(math.sqrt(k))+1):
	check(x)
	check(k//x)
print(len(setl))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
typedef pair<double, int> P;
ll X[100], Y[100];
int main() {
	int N;
	cin >> N;
	vector<P> vec;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
		vec.emplace_back(atan2(Y[i], X[i]), i);
	}
	sort(vec.begin(), vec.end());
	vector<P> vec2 = vec;
	vec2.insert(vec2.end(), vec.begin(), vec.end());
	double ans = 0;
	for (int i = 0; i < vec2.size(); i++) {
		for (int j = i; j < vec2.size(); j++) {
			if (j - i + 1 > N) break;
			ll sumX = 0, sumY = 0;
			for (int k = i; k <= j; k++) {
				sumX += X[vec2[k].second];
				sumY += Y[vec2[k].second];
			}
			ans = max(ans, sqrt(sumX*sumX + sumY * sumY));
		}
	}
	printf("%.15lf\n", ans);
}


Measured memory_bytes: 384