akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right;
  }
 
  z->parent = y;
  if(y == NIL) {
    root = z;  
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else y->right = z;
}

Node treeSearch(Node u, int k) {
  if(u == NIL || k == u->key) {
    return u;
  }
  if(k < u->key) {
    return treeSearch(u->left, k);
  }
  else {
    return treeSearch(u->right, k);
  }
  return u;
}
 
void inorder(Node u){
  if(u->left != NIL){
    inorder(u->left);
  }
  printf(" %d",u->key);
  if(u->right != NIL){
    inorder(u->right);
  }
 
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!= NIL){
    preorder(u->left);
  }
  if(u->right!= NIL){
    preorder(u->right);
  }
   
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
   
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL) printf("yes\n");
      else printf("no\n");
    }
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
N,K=map(int,input().split());p=[int(i)-1for i in input().split()];q=[int(i)-1for i in input().split()];T=lambda s,t:[s[t[i]]for i in range(N)];m=[[0for i in[0]*N]for i in[0]*6];m[0]=p;m[1]=q
def I(s):
 r=[0]*N
 for i in range(N):r[s[i]]=i
 return r
for i in range(4):m[i+2]=T(m[i+1],I(m[i]))
E=lambda s,k:T(E(T(s,s),k//2),s)if k%2 else (E(T(s,s),k//2)if k else list(range(N)));t=E(T(T(T(q,I(p)),I(q)),p),~-K//6);print(" ".join([str(i+1)for i in T(T(t,m[~-K%6]),I(t))]))

Measured memory_bytes: 40672
n, k = map(int,input().split())
h = list(map(int,input().split()))

dp = [float('inf')] * n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    for j in range(k+1):
        if i - j < 0:
            continue
        dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]),dp[i])
print(dp[-1])

Measured memory_bytes: 55776
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {

	long long n, m;
	cin >> n >> m;
	vector<pair<long long, long long>> vp(n);
	for (int i = 0; i < n; i++) {
		long long a, b;
		cin >> a >> b;
		vp.at(i) = make_pair(a, b);
	}
	sort(vp.begin(), vp.end());
	long long cost = 0;
	for (int i = 0; i < n; i++) {
		if (vp.at(i).second >= m) {
			cost += vp.at(i).first * m;
			cout << cost << endl;
			return 0;
		}
		else {
			m -= vp.at(i).second;
			cost += vp.at(i).first * vp.at(i).second;
		}
	}
}


Measured memory_bytes: 1792
#include <stdio.h>

int main (){
	// N -> jmlh operasi, K -> nilai yang ditambahkan
	int N, K, output = 1; 
	scanf ("%d %d", &N, &K);
	
	// memanipulasi output sebanyak N kali
	for (int i = 0; i < N; i++){
		// apakah op2 > op1		
		(output + K > output * 2) ? output *= 2 : output += K;
	}
	
	printf("%d\n", output);
	return 0;
}

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

int main()
{
    LL n;
    cin>>n;
    LL a[n][3];
    for(LL i=0;i<n;i++)
        for(LL j=0;j<3;j++)
            cin>>a[i][j];

    LL b[n][3];
    b[0][0]=a[0][0];
    b[0][1]=a[0][1];
    b[0][2]=a[0][2];

    for(LL i=1;i<n;i++)
    {
            b[i][0]=max(b[i-1][1],b[i-1][2])+a[i][0];
            b[i][1]=max(b[i-1][0],b[i-1][2])+a[i][1];
            b[i][2]=max(b[i-1][1],b[i-1][0])+a[i][2];

    }
    cout<<max(b[n-1][0],max(b[n-1][1],b[n-1][2]));



}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

long long gcd(long long a, long long b){
    if(!b) return a;
    return gcd(b, a % b);
}



int main(){
    long long n, m, nok;
    cin >> n >> m;
    vector<long long> a(n);
    cin >> a[0];
    a[0] /= 2;
    nok = a[0];
    for(int i = 1; i < n; ++i){
        cin >> a[i];
        a[i] /= 2;
        long long g = gcd(nok, a[i]);
        nok = nok * a[i] / g;
        if(nok > m){
            cout << 0;
            return 0;
        }
    }
    for(int i = 0; i < n; ++i){
        if((nok / a[i]) % 2 == 0){
            cout << 0;
            return 0;
        }
    }
    cout << (m / nok - 1) / 2 + 1;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <string>
#include <vector>

using namespace std;
int r, c;

string ConvertDecToBinString(int dec_num) {
    if (dec_num == 0) { return string("0"); }
    string bin_num_str;
    while (dec_num) {
        if ((dec_num & 1) == 0) { bin_num_str.insert(bin_num_str.begin(), '0'); }
        else { bin_num_str.insert(bin_num_str.begin(), '1'); }
        dec_num >>= 1;
    }

    return bin_num_str;
}

int GetTurnOverMaxGoodNum(vector<vector<int> >& senbeis, int raw) {
    string bin_raw_string = ConvertDecToBinString(raw);
    for (size_t i = 0; i < r; i++) {
        if (bin_raw_string[i] == '1') {
            for (size_t j = 0; j < c; j++) {
                senbeis[i][j] = 1 - senbeis[i][j];
            }
        }
    }

    int max_good_senbei_num = 0;
    for (size_t j = 0; j < c; j++) {
        int zero_num = 0;
        for (size_t i = 0; i < r; i++) {
            if (senbeis[i][j] == 0) { zero_num++; }
        }
        max_good_senbei_num += max(zero_num, r - zero_num);
    }

    for (size_t i = 0; i < r; i++) {
        if (bin_raw_string[i] == '1') {
            for (size_t j = 0; j < c; j++) {
                senbeis[i][j] = 1 - senbeis[i][j];
            }
        }
    }

    return max_good_senbei_num;
}

int main() {
    scanf("%d %d", &r, &c);
    while (r * c != 0) {
        auto senbeis = vector<vector<int> >(r, vector<int>(c));
        int max_good_senbei_num = 0;
        for (size_t i = 0; i < r; i++) {
            for (size_t j = 0; j < c; j++) {
                scanf("%d", &senbeis[i][j]);
            }
        }
        for (size_t i = 0; i < 2 << (r - 2) + 1; i++) {
            int good_num = GetTurnOverMaxGoodNum(senbeis, i);
            if (max_good_senbei_num < good_num) { max_good_senbei_num = good_num; }
        }
        printf("%d\n", max_good_senbei_num);
        scanf("%d %d", &r, &c);
    }

    return 0;
}

Measured memory_bytes: 2900
import math

N = int(raw_input())

limit = int(math.sqrt(N)) + 1
n = float(N)
minimum = (1, 1, N)
for i in range(1, limit):
    j = n / i
    if not j.is_integer():
        continue
    j = int(j)
    distance = i + j - 2
    if minimum[2] > distance:
        minimum = i, j, distance
print(minimum[2])


Measured memory_bytes: 34436
#include <iostream>

using namespace std;

int arr[7];
int main () {
	// input
	int oddc = 0;
	for (int i = 0; i < 7; i ++) {
		cin >> arr[i];
		if (i == 0 || i == 3 || i == 4)
			if (arr[i] % 2 == 1)
				oddc ++;
	}
	
	if (oddc >= 2 && arr[0] >= 1 && arr[3] >= 1 && arr[4] >= 1) {
		cout << 1ll * 3 + ((arr[0] - 1) / 2 * 2) + ((arr[3] - 1) /2 * 2) + ((arr[4] - 1) /2 * 2) + arr[1] << endl;
		return 0;
	}
	cout << 1ll * (arr[0] / 2 * 2) + (arr[3] / 2 * 2) + (arr[4] / 2 * 2) + arr[1] << endl;
	return 0;
}



Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	long n,blue,red,amari,shou;

	scanf("%ld %ld %ld",&n,&blue,&red);

    amari=n%(blue+red);
    shou=n/(blue+red);

    if(amari<blue) {printf("%ld",shou*blue+amari);return(0);}
    printf("%ld",(shou+1)*blue);return(0);
    }

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

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-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9+7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e9;
int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

int H, W;
int dist[500][500];
char A[30][30];

void solve() {
	cin >> H >> W;
	REP(i, H) {
		REP(j, W) {
			cin >> A[i][j];
		}
	}

	REP(i, 500)REP(j, 500) {
		if (i != j)dist[i][j] = INF;
	}
	REP(i, H) {
		REP(j, W) {
			if (A[i][j] == '#')continue;
			REP(k, 4) {
				int nx = i + dx[k];
				int ny = j + dy[k];
				if (nx < 0 || nx >= H || ny < 0 || ny >= W)continue;
				if (A[nx][ny] == '#')continue;
				int n = i * W + j, nxt = nx * W + ny;
				dist[n][nxt] = 1;
				dist[nxt][n] = 1;
			}
		}
	}
	int N = H * W;

	REP(k, N) {	//kが中継点
		REP(i, N) {
			REP(j, N) {
				dist[i][j] = min(dist[i][j], (dist[i][k] + dist[k][j]));
			}
		}
	}
	ll ans = 0;
	REP(i, N) {
		REP(j, N) {
			if (A[i / W][i%W] == '#' || A[j / W][j%W] == '#')continue;
			ans = max(ans, dist[i][j]);
		}
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int m = 1000000007; 

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	int  n; cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];

	int totalxor = arr[0];
	for (int i = 1; i < n; i++)
		totalxor = totalxor ^ arr[i];

	for (int i = 0; i < n; i++)
		cout << (totalxor ^ arr[i]) << " ";


}




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

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;
const double PI = acos(-1);

#define rep(i, n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

int main() {
    string s;
    cin >> s;
    vector<ll> a(s.size()+1, 0), b(s.size()+1, 0);

    rep(i, s.size()) {
        if (s[i] == '<') {
            a[i+1] = a[i] + 1;
        }
    }

    for(int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == '>') {
            b[i] = b[i+1] + 1;
        }
    }

    ll ans = 0;
    rep(i, s.size() + 1) {
        ans += max(a[i], b[i]);
    }

    cout << ans << endl;
}


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

int main() {
    int c, x, y;
    while (1) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }

        if (x > y) {
            cout << y << " " << x << endl;
        } else {
            cout << x << " " << y << endl;
        }
    }

    return 0;
}


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

int main(){
	double xa1,xa2,xb1,xb2,ya1,ya2,yb1,yb2; 
	bool h, v;
	while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
		h = (xb1 <= xa2) && (xa1 <= xb2);
		v = (yb1 <= ya2) && (ya1 <= yb2);
		if(h && v){
			cout << "YES" << endl;
		}else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

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

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

ll fct[2000010];

ll nCr(ll n, ll r) {
    ll ans = fct[n];

    ans = (ans*modpow(fct[r], mod - 2))%mod;
    ans = (ans*modpow(fct[n-r], mod - 2))%mod;

    return ans;
}

int main(){

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

    ll r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;


    fct[0] = 1;
    fct[1] = 1;
    for(int i = 2; i < 2000010; i++) {
        fct[i] = (fct[i-1] * i)%mod;
    }

    ll ans = 0;

    for(int i = r1; i <= r2; i++) {
        ans = ans + nCr(i + c2 + 1, i + 1) - nCr(i + c1, i + 1);

        ans = ans%mod;
    }

    if(ans < 0) ans+=mod;

    cout<<ans<<endl;
    

}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

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


Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 200000
#define K 18
struct edge{int nx,t;}e[MN*4+5];
int A[MN+5],B[MN+5],en,fa[K][MN+5],d[MN+5],ans;
inline void ins(int*h,int x,int y)
{
	e[++en]=(edge){h[x],y};h[x]=en;
	e[++en]=(edge){h[y],x};h[y]=en;
}
void pre(int x)
{
	for(int i=B[x];i;i=e[i].nx)if(e[i].t!=fa[0][x])
		d[e[i].t]=d[fa[0][e[i].t]=x]+1,pre(e[i].t);
}
int lca(int x,int y)
{
	if(d[x]<d[y])swap(x,y); 
	int k=d[x]-d[y],i;
	for(i=0;k;k>>=1,++i)if(k&1)x=fa[i][x];
	if(x==y)return x;
	for(i=K;i--;)if(fa[i][x]!=fa[i][y])x=fa[i][x],y=fa[i][y];
	return fa[0][x];
}
void solve(int x,int y,int f,int p)
{
	if(x==y)return;
	ans=max(ans,d[x]+d[y]-d[lca(x,y)]*2+p);
	for(int i=A[x];i;i=e[i].nx)if(e[i].t!=f&&e[i].t!=y)
	{
		if(d[x]+d[e[i].t]-d[lca(x,e[i].t)]*2>2)ans=2e9;
		if(lca(e[i].t,y)==y)
		{
			int t=e[i].t,k=d[t]-d[y]-1,j;
			for(j=0;k;k>>=1,++j)if(k&1)t=fa[j][t];
			solve(e[i].t,t,x,p+1);
		}
		else solve(e[i].t,fa[0][y],x,p+1);
	}
}
int main()
{
	int n,x,y,i,j;
	n=read();x=read();y=read();
	for(i=1;i<n;++i)ins(A,read(),read());
	for(i=1;i<n;++i)ins(B,read(),read());
	pre(1);
	for(i=1;i<K;++i)for(j=1;j<=n;++j)fa[i][j]=fa[i-1][fa[i-1][j]];
	solve(x,y,0,0);
	printf("%d",ans>1e9?-1:ans<<1);
}

Measured memory_bytes: 32768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC128_B_Guidebook
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			List<CityPoint> list = new List<CityPoint>();
			for(int i = 0; i < n; i++)
			{
				string[] input = Console.ReadLine().Split(' ');
				list.Add(new CityPoint(i + 1, input[0], int.Parse(input[1])));
			}

			var sorted = list.OrderByDescending(value => value.point).OrderBy(value => value.cityName);

			foreach(var data in sorted)
			{
				Console.WriteLine(data.index);
			}
		}
	}

	class CityPoint
	{
		public int index;
		public string cityName;
		public int point;

		public CityPoint(int index, string cityName, int point)
		{
			this.index = index;
			this.cityName = cityName;
			this.point = point;
		}
	}
}


Measured memory_bytes: 11604
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	ll n;
	scanf("%ld", &n);

	ll ans = 0;
	for(ll i=1; i*i<=n; i++){
		if(n%i) continue;
		if(n/i-2>=i) ans += n/i-1;
	}
	printf("%ld\n", ans);
	return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list()
for i in range(120):
    a.append(0)
for i in range(n):
    b, f, r, v = map(int, input().split())
    a[(b - 1) * 30 + (f - 1) * 10 + (r - 1)] += v
for i in range(4):
    if i >= 1:
        print("#" * 20)
    for j in range(3):
        for k in range(10):
            print(' ', end = '')
            print(a[i * 30 + j * 10 + k], end = '')
        print()


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
typedef pair<mp,char> mmp;
ll inf =  1e9;


int main(){
 ll n;
 cin>>n;
 map<ll,ll> ld,lu,rd,ru;
 vector<mp> z(n);
 vector<char> c(n);
 for(ll i=0;i<n;i++){
  cin>>z[i].first>>z[i].second>>c[i];
 }

 ll time = inf;
 /*
 for(ll i=0;i<n;i++){
  if( c[i] == 'L'){
   ld[ z[i].first + z[i].second ]
   ld[ z[i].second-z[i].first]
  }else if(c[i]=='R'){

  }
 }
 for(ll i=0;i<n;i++){
  if( c[i] == 'U'){

  }else if(c[i] =='D'){

  }
 }*/



 vector<mmp> left,right;
 for(ll i=0;i<n;i++){
  if( c[i] != 'R' ){
   left.push_back( mmp( z[i], c[i] ) );
  }
  if( c[i] != 'L' ){
   right.push_back( mmp(z[i], c[i] ) );
  }
 }
 sort( left.begin(), left.end() );
 sort( right.begin() ,right.end() );
 reverse( left.begin(), left.end() );
 
 for(ll i=0;i<left.size();i++){
  mp now = left[i].first;
  if( left[i].second == 'L' ){
   ld[ now.first  + now.second ] = now.first;
   lu[ now.second - now.first ] = now.first;
  }else if(left[i].second == 'U'){
   if( lu.find( now.second - now.first ) != lu.end() ){
    time = min( time , (lu[now.second-now.first] - now.first)*10 );
   }
  }else if(left[i].second == 'D'){
   if( ld.find( now.second + now.first ) != ld.end() ){
    time = min( time , (ld[now.second+now.first] - now.first)*10 );
   }
  }

 }

 for(ll i=0;i<right.size();i++){
  mp now = right[i].first;
  if( right[i].second == 'R' ){
   rd[ now.second  - now.first ] = now.first;
   ru[ now.second + now.first ] = now.first;
  }else if(right[i].second == 'U'){
   if( ru.find( now.second + now.first ) != ru.end() ){
    time = min( time , (-ru[now.second+now.first] + now.first)*10 );
   }
  }else if(right[i].second == 'D'){
   if( rd.find( now.second - now.first ) != rd.end() ){
    time = min( time , (-rd[now.second-now.first] + now.first)*10 );
   }
  }

 }

 //lr
 map<ll,ll> mr;
 vector<mmp> lr;
 for(ll i=0;i<n;i++){
  if( c[i] == 'L' ){
   lr.push_back( mmp( z[i] , c[i] ) );
  }else if( c[i] == 'R' ){
   lr.push_back( mmp(z[i],c[i]) );
  }
 }
 sort(lr.begin() , lr.end() );
 for(ll i=0;i<lr.size();i++){
  if( lr[i].second == 'R' ){
   mr[ lr[i].first.second] = lr[i].first.first;
  }else{
   if( mr.find( lr[i].first.second ) != mr.end() ){
    time = min( time , (lr[i].first.first -  mr[ lr[i].first.second ] )*5 );
   }
  }
 }
// ud
 map<ll,ll> mu;
 vector<mmp> ud;
 for(ll i=0;i<n;i++){
  if( c[i] == 'U' ){
   ud.push_back( mmp( mp( z[i].second , z[i].first ) , c[i] ) );
  }else if( c[i] =='D'){
   ud.push_back( mmp( mp( z[i].second , z[i].first ) , c[i] ) );
  }
 }
 sort( ud.begin() , ud.end());
 for(ll i=0;i<ud.size();i++){
  if( ud[i].second == 'U' ){
   mu[ ud[i].first.second ] = ud[i].first.first;
  }else{
   if( mu.find( ud[i].first.second ) != mu.end() ){
    time = min( time , ( ud[i].first.first - mu[ ud[i].first.second ] )*5 );
   }
  }
 }





 if( time != inf ){
  cout<<time<<endl;
 }else{
  cout<<"SAFE"<<endl;
 }


    return 0;
}


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

int buildSumTable (vector<int> L, vector<int> R);
int getSumRange (int L, int R);

int N, M, Q;

int main () {

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

    vector<int> L(M), R(M);

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

    vector<int> p(Q), q(Q);
    for (int i = 0; i < Q; i++) {
        scanf("%d %d", &p[i], &q[i]);
    }

    buildSumTable(L, R);

    for (int i = 0; i < Q; i++) {
        printf("%d\n", getSumRange(p[i], q[i]));
    }

    return 0;
}

vector<vector<int>> sum;

int buildSumTable (vector<int> L, vector<int> R) {

    sum = vector<vector<int>> (N + 1, vector<int>(N + 1, 0));

    for (int i = 0; i < M; i++) {
        sum[L[i]][R[i]]++;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            sum[i][j] += sum[i-1][j];
            sum[i][j] += sum[i][j-1];
            sum[i][j] -= sum[i-1][j-1];
        }
    }
}

int getSumRange (int L, int R) {

    return sum[R][R] - sum[R][L-1] - sum[L-1][R] + sum[L-1][L-1];
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int p, q, r = 1;
int main() {
	scanf("%d%d", &p, &q);
	q = q / __gcd(p, q);
	for (int i = 2; i * i <= q; i++) {
		if (q % i == 0) {
			r *= i;
			while (q % i == 0) q /= i;
		}
	}
	printf("%d\n", r * q);
	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=110;
void upd(int &a,int b) { a+=b; if (a>=mod) a-=mod; }
int n,m;
int dp[N][N*N];
ll ret;
int main() {
	scanf("%d%d",&n,&m);
	dp[n][0]=1;
	per(i,0,n) rep(j,0,n*m+1) if (dp[i+1][j]>0) {
		rep(k,0,m+1) {
			if (k<=i+1&&k+j>=i+1) upd(dp[i][j+(k+j)/(i+1)],dp[i+1][j]);
			else upd(dp[i][j],dp[i+1][j]);
		}
	}
	ret=m*(m+1)/2*n*powmod(m+1,n-1)%mod;
	rep(i,0,n*m+1) {
		ret=(ret-(ll)dp[0][i]*i)%mod;
	}
	if (ret<0) ret+=mod;
	printf("%lld\n",ret);
}


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

int main()
{
	bool f;
	double x1,x2,x3,x4,y1,y2,y3,y4;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4)
	{
		f=false;
		if(x4<x1) f=true;
		if(x2<x3) f=true;
		if(y4<y1) f=true;
		if(y2<y3) f=true;

		cout << (f?"NO":"YES") << endl;
	}
}

Measured memory_bytes: 0
import collections
N = int(input())
A = list(map(int,input().split()))
Am = [a-1 for a in A]
Ap = [a+1 for a in A]
A.extend(Am)
A.extend(Ap)
# print(A)
c = collections.Counter(A)
print(c.most_common()[0][1])



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

int main(){
  int N;
  cin>>N;
  int i;
  int a=100;
  for(i=1;i<=N;i++){
    int d=0;
    int A;
    cin>>A;
    while(A%2==0){
      A=A/2;
      d=d+1;
    }
    a=min(a,d);
  }
  cout<<a<<endl;
}

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

// Remove GCC optimizer for codechef

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define aint(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 1000005;


int32_t main()
{

	    #ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	    #endif
    IOS




    int n;
    cin >> n;

    map<int,int> mp;

    for(int i = 2; i*i <= n; i++)
    {
    	while(n%i == 0)
    	{
    		n/=i;
    		mp[i]++;
    	}
    }

    if(n != 1)mp[n]++;

    int ans = 0;
    for(auto i : mp)
    {
    	int j = 1 ,k = i.second;
    	while(k-j >=0)
    	{
    		k-=j;
    		j++;
    		ans++;
    	}
    }


    cout << ans;



    return 0;
}


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

int main(){
	int n,m,k;cin>>n>>m>>k;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i*(m-j)+j*(n-i)==k){
				cout<<"Yes"<<"\n";
				return 0;
			}
		}
	}
	cout<<"No"<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long fun(long long x, long long y)
{
	long long tmp = 0;
	while (y != 0)
	{
		tmp = y;
		y = x%y;
		x = tmp;
	}
	return x;
}
int main()
{
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d-b/(c*d/(fun(c,d)))+(a-1)/(c*d/(fun(c,d))));
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = list(input() for i in range(n))
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    if s[i] == 'AC':
        ac += 1
    elif s[i] == 'WA':
        wa += 1
    elif s[i] == 'TLE':
        tle += 1
    else:
        re += 1
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

Measured memory_bytes: 16296
def INT():
    return int(input())

def MI():
    return map(int, input().split())

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

from collections import deque

N = INT()
Tree = [[] for _ in range(N)]

for _ in range(N - 1):
    u, v, w = MI()
    Tree[u - 1].append((v - 1, w))
    Tree[v - 1].append((u - 1, w))
    
color = [0] * N
queue = deque([0])
visited = [False] * N

while queue:
    q = queue.popleft()
    visited[q] = True
    
    for t in Tree[q]:
        if not visited[t[0]]:
            if t[1] % 2 == 0:
                color[t[0]] = color[q]
                
            else:
                if color[q] == 0:
                    color[t[0]] = 1
                else:
                    color[t[0]] = 0
            
            queue.append(t[0])
        
for c in color:
    print(c)

Measured memory_bytes: 97580
n = int(input())
s = input()

ss = '#' * n
ret = 0
for j in range(n):
  if s[j] != ss[j]:
    ret += 1

cnt = ret
for j in range(n):
  if s[j] == '.':
    cnt -= 1
  else:
    cnt += 1
  if cnt < ret:
    ret = cnt

print(ret)


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N, Q;
VI g[200010];
int c[200010];


void dfs(int v, int p){
    c[v] += c[p];
    rep(i, 0, SIZE(g[v]))
        if(g[v][i] != p) dfs(g[v][i], v);
}


signed main(){
    cin >> N >> Q;
    rep(i, 0, N-1){
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }

    rep(i, 0, Q){
        int p, x;
        cin >> p >> x;
        c[p] += x;
    }

    dfs(1, 0);

    rep(i, 1, N) cout << c[i] << ' ';
    cout << c[N] << endl;

    return 0;
}

Measured memory_bytes: 24320
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define inf 0x7f7f7f7f7f7f7f7f 
#define maxn 1000010
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define mod 998244353
#define db(x) cout << x << endl; 
#define eps 0.0001
using namespace std;
int a[maxn],b[maxn],c[maxn];
int s[maxn]; 
signed main()
{
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		if(a[i]+i<=200000)
			b[a[i]+i]++;
	//	cout << i << " " << a[i]+i<<endl; 
		if(i-a[i] > 0)
			c[i-a[i]]++;
	}
	int ans = 0;
	for(int i=1;i<=200000;i++)
		if(b[i])
		{
			ans+=b[i]*c[i];
		}
		cout << ans;
	return 0;
}

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

template<typename T> void chmax(T &a, T b){a = max(a,b);}
template<typename T> void chmin(T &a, T b){a = min(a,b);}
template<typename T> void chadd(T &a, T b){a = a + b;}

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

const int DAY = 365;
const int CONT = 26;

struct Solver{
    int D,C[CONT],S[DAY][CONT],ans[DAY];
    ll score;
    set<int> schedules[CONT];
    
    Solver(){
        fill(ans,ans+DAY,-1);
    }
    
    void read_input(){
        cin >> D;
        for(int i = 0; i < CONT; i++){
            cin >> C[i];
        }
        
        for(int i = 0; i < D; i++){
            for(int j = 0; j < CONT; j++){
                cin >> S[i][j];
            }
        }
        
        for(int i = 0; i < CONT; i++){
            schedules[i].emplace(-1);
            schedules[i].emplace(D);
        }
    }
    
    ll calc_score(bool store = true){
        ll res = 0;
        int last[CONT] = {};
        for(int i = 0; i < D; i++){
            res += S[i][ ans[i] ];
            last[ ans[i] ] = i + 1;
            for(int j = 0; j < CONT; j++){
                res -= C[j]*(i+1-last[j]);
            }
        }
        if(store)score = res;
        return max(0LL,res);
    }
    
    void update(int day, int contest){
        int pre_contest = ans[day];
        ans[day] = contest;
        
        //削除
        {
            score -= S[day][pre_contest];
            auto ptr = schedules[pre_contest].lower_bound(day);
            ll d0 = day - *prev(ptr);
            ll d1 = *next(ptr) - *prev(ptr);
            ll d2 = *next(ptr) - day;
            score += d0 * (d0 - 1) / 2 * C[pre_contest];
            score -= d1 * (d1 - 1) / 2 * C[pre_contest];
            score += d2 * (d2 - 1) / 2 * C[pre_contest];
            schedules[pre_contest].erase(day);
        }
        
        //追加
        {
            score += S[day][contest];
            schedules[contest].emplace(day);
            auto ptr = schedules[contest].lower_bound(day);
            ll d0 = day - *prev(ptr);
            ll d1 = *next(ptr) - *prev(ptr);
            ll d2 = *next(ptr) - day;
            score -= d0 * (d0 - 1) / 2 * C[contest];
            score += d1 * (d1 - 1) / 2 * C[contest];
            score -= d2 * (d2 - 1) / 2 * C[contest];
        }
    }
};



int main(){
    Solver solver;
    solver.read_input();
    for(int i = 0; i < solver.D; i++){
        int t; cin >> t;
        solver.ans[i] = --t;
        solver.schedules[t].emplace(i);
    }
    solver.calc_score();
    
    int Q; cin >> Q;
    while(Q--){
        int d,q; cin >> d >> q;
        d--; q--;
        solver.update(d,q);
        cout << solver.score << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
N = int(input())

sum = 0
flag = 0


a = int(N / 7)
re = N % 7

if re == 0 and N != 0:
    print('Yes')
    flag += 1
else:
    for i in range(a+1):
        sum = 7 * i
#        print(sum)
        while sum<N:
            sum += 4
#            print(sum)
            if sum == N:
                print('Yes')
                flag += 1
        if flag == 1:
            break

if flag == 0:
    print('No')
                


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

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        String n = fs.next();
        String ans;
        if(n.equals("Sunny")) ans = "Cloudy";
        else if(n.equals("Cloudy")) ans = "Rainy";
        else ans = "Sunny";
        System.out.println(ans);
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
 
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

int main() {
	int n, x;

	cin >> n;
	for(int i=1; i<=n; i++) {
		x = i;

		if(x%3 == 0) {
			cout << " " << i;
			continue;
		}

		while(x) {
			if(x%10 == 3) {
				cout << " " << i;
				break;
			}else{
				x/=10;
			}
		}
	}

	cout << endl;

	return 0;

}



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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
const int MAX_N = 1e6;

vector<int> fprime()
{
	deque<bool> is_prime(MAX_N,true);
	vector<int> res;
	FOR(i,2,MAX_N) if(is_prime [i]){
		res.push_back(i);
		for(int j = i * 2;j < MAX_N;j += i){
			is_prime [j] = false;
		}
	}
	return res;
}

int main()
{
	vector<int> primes = fprime();
	while(~scanf("%d",&N)){
		int ans = upper_bound(ALL(primes),N) - primes.begin();
		printf("%d\n",ans);
	}

	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    ll n;cin>>n;
    vl p(n);
    rep(i,n)cin>>p[i];
    ll res = 0;
    rep(i,n){
        if(p[i] == i+1){
            res++;
            if(i != n-1)swap(p[i],p[i+1]);
            else swap(p[i],p[0]);
        }
    }
    out(res);
}

Measured memory_bytes: 1024
#include<stdio.h>
main(){
  int i=0,x,y,t=0,a=0;
  double b;
  while(scanf("%d,%d",&x,&y)!=EOF){
    t=t+x*y;
    a=a+y;
    b=a;
    i++;
  }
  a=a/i;
  b=b/i;
  if(b-a>=0.5){
    a++;
  }
  printf("%d\n%d\n",t,a);
  return 0;
}

Measured memory_bytes: 592
#include<stdio.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,b[100010]={};
  int a,max=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    b[a]++;
  }
  for(i=1;i<100005;i++)max=MAX(max,b[i-1]+b[i]+b[i+1]);
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 512
using System;

class Program
{
    static int Main()
    {
        int a, b;
        string[] in1= Console.ReadLine().Split(' ');
        a = int.Parse(in1[0]);
        b = int.Parse(in1[1]);
        if (a == b)
            Console.WriteLine((2 * a).ToString("d"));
        else
            Console.WriteLine((2 * (a > b ? a : b) - 1).ToString("d"));
        return 0;
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(void)
{
	int a,b,i;
	char s[12];
	scanf("%d %d %s", &a, &b, s);
	for(i=0; i<a+b+1; i++)
	{
		if(i==a&&s[i]!='-'||i!=a&&s[i]=='-')
		{
			printf("No\n");
			break;
		}
		if(i==a+b)
		printf("Yes\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;

// #define int long long

signed main(){
  

    ios::sync_with_stdio(false);
    cin.tie(0);
	//cin高速化

	int n;
	cin>>n;

	int c[n];
	int s[n];
	int f[n];


	REP(i,n-1){
		cin>>c[i]>>s[i]>>f[i];
	}

	REP(i,n){

		int time=0;

		for(int j=i;j<n-1;j++){
			

			if(time<s[j]){
				time=s[j];
			}else if(time%f[j]==0){}
			else{
				int tmp=f[j]-(time%f[j]);
				time+=tmp;
			}

			time+=c[j];
			// cout<<"time:"<<time<<endl;

			// cout<<i<<" "<<time<<endl;
		}

		cout<<time<<endl;
	}
  
 	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

void printvec(vector<int>&);

bool perfect(map<int,int> jan,bool head){

  int wa=0;
  FOR(miter,jan)wa+=miter->second;
  if(!wa)return true;

  bool syuntu=false,ko_tu=false,tou=false;
  rep(i,8){
    if(!i)continue;
    if(jan[i] && jan[i+1] && jan[i+2]){
      map<int,int> tt(jan);
      tt[i]--,tt[i+1]--,tt[i+2]--;
      if(perfect(tt,head))syuntu=true;
    }
  }

  rep(i,10){
    if(!i)continue;
    if(jan[i]>=3){
      map<int,int> tt(jan);
      tt[i]-=3;
      if(perfect(tt,head))ko_tu=true;
    }
  }

  if(!head){
    rep(i,10){
      if(!i)continue;
      if(jan[i]>=2){
        map<int,int> tt(jan);
        tt[i]-=2;
        if(perfect(tt,true))tou=true;
      }
    }
  }
  return tou||syuntu||ko_tu;
}

void print(set<int> in){
  FOR(setiter,in){
    if(setiter==in.begin())cout<<*setiter;
    else cout<<" "<<*setiter;
  }
  cout<<endl;
}

main(){
  string str;
  while(cin>>str){
    vector<int> in;
    rep(i,str.size())in.PB(str[i]-'0');

    set<int> out;
    rep(i,10){
      if(i==0)continue;
      bool skip=false;
      vector<int> add(in);
      add.PB(i);
      map<int,int> jan;
      FOR(viter,add){
        jan[*viter]++;
        if(jan[*viter]>4)skip=true;
      }
      if(skip)continue;

      if(perfect(jan,false))out.insert(i);
    }
    if(out.size()==0)puts("0");
    else print(out);
  }
}

Measured memory_bytes: 932
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

long long a[N], b[N];

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

	int n, m, k;
	cin >> n >> m >> k;

	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(i) a[i] += a[i-1];
	}

	for(int i = 0; i < m; i++) {
		cin >> b[i];
		if(i) b[i] += b[i-1];
	}

	long long ans = upper_bound(b, b+m, k) - b;

	for(int i = 0; i < n; i++) {
		if(a[i] > k) break;
		ans = max(ans, upper_bound(b, b+m, k - a[i]) - b + 1ll * (i + 1));
	}

	cout << ans;
	
	return 0;
}


Measured memory_bytes: 6760
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split();

            var num5 = 0;
            var num7 = 0;

            foreach (var item in abc)
            {
                if (item == "5")
                    num5++;
                else if (item == "7")
                    num7++;
            }

            if (num5 == 2 && num7 == 1)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 11092