akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int a, b, c, x, i=0;
    scanf("%d %d %d", &a, &b, &c);
    for(x=a;x<=b;x++){
        if(c%x==0)i++;
        else ;
    }
    printf("%d\n",i);
    return 0;
}



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

ll A[100000];

int main()
{
	ll N;
  	ll MIN = 1000000000;
  	cin >> N;
  	for ( ll i = 0; i < N; i++ )
    {
	  cin >> A[i];
      if ( A[i] < MIN ) MIN = A[i];
    }
  
  	int ans = -1;
  	while ( ans != MIN )
    {
      ans = MIN;
      for ( ll i = 0; i < N; i++ )
      {
        ll h = A[i] % MIN;
        if ( h > 0 && h < MIN ) MIN = h;
      }
    }
  	  
  	cout << MIN << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int N, K; cin >> N >> K;
   if(K == 1) {
       cout << 0 << endl;
       return 0;
   }
   cout << N - K << endl;
   return 0;
}

Measured memory_bytes: 256
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n;i>0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    char c;
    cin>>c;
    cout<<((c=='a'||c=='i'||c=='u'||c=='e'||c=='o')?"vowel":"consonant")<<endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque
s = list(input())
q = int(input())

d = deque()
for i in s:
    d.append(i)

c = 1
for _ in range(q):
    t = list(input().split())
    if t[0] == '1':
        c *= -1
    else:
        if t[1] == '1':
            if c == 1:
                d.appendleft(t[2])
            else:
                d.append(t[2])
        else:
            if c == 1:
                d.append(t[2])
            else:
                d.appendleft(t[2])

print(''.join(list(d)[::c]))

Measured memory_bytes: 17000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <math.h>

using namespace std;

int main()
{
	int n, r = 0, b = 0;
	string s;
	cin >> n >> s;
	for (int a = 0; a < n; a++) {
		if (s[a] == 'R') {
			r++;
		} else {
			b++;
		}
	}
	if (r > b) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

string k;
int d;
LL dp[10101][2][101];
const LL mod = 1e9 + 7;

int main(){
    cin >> k;
    cin >> d;
    dp[0][0][0] = 1;
    REP(x, (int)k.size()){
        REP(y, 2){
            REP(z, d){
                for(int i = 0;i <= (y ? 9 : k[x] - '0');i++){
                    (dp[x + 1][y | ((k[x] - '0') != i)][(z + i) % d] += dp[x][y][z]) %= mod;
                }
            }
        }
    }
    LL ans = 0;
    REP(i, 2)(ans += dp[(int)k.size()][i][0]) %= mod;
    cout << (ans - 1 + mod) % mod << endl;
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	std::string str; std::cin >> str;
	auto count = 1;
	auto prev_is_one = true;
	for (auto i = 1; i < str.size(); ++i) {
		++count;
		if (prev_is_one) {
			if (str[i] == str[i - 1]) {
				prev_is_one = false;
				++i;
				if (i == str.size()) --count;
			}
			else {
				prev_is_one = true;
			}
		}
		else prev_is_one = true;
	}
	auto max = count;
	count = 1;
	prev_is_one = false;
	for (auto i = 2; i < str.size(); ++i) {
		++count;
		if (prev_is_one) {
			if (str[i] == str[i - 1]) {
				prev_is_one = false;
				++i;
				if (i == str.size()) --count;
			}
			else {
				prev_is_one = true;
			}
		}
		else prev_is_one = true;
	}
	std::cout << std::max(max, count) << std::endl;
}

Measured memory_bytes: 640
(*
#load "str.cma"
*)
let str_insert str pos s =
  let pre = Str.string_before str pos in
  let suf = Str.string_after str pos in
  pre ^ s ^ suf

let str_eval str =
  List.fold_left (fun x y -> x + int_of_string y) 0
  (Str.split (Str.regexp "+") str)
              
let make_all_list str =
  let rec loop str pos =
    if pos >= (String.length str) then [str]
    else
      loop (str_insert str pos "+") (pos+2) @ loop str (pos+1)
  in loop str 1

let main () =
  let num = read_line () in
  let l = make_all_list num in
  let ans = List.fold_left (fun x y -> x + str_eval y) 0 l in
  print_int ans;print_newline()
;;

  main ()

                          


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <unordered_map>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int number = 1;
  for (int i = 0; i < N; i++) {
    if (number * 2 < number + K) {
      number = number * 2;
    } else {
      number = number + K;
    }
  }
  cout << number << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007
typedef struct node * nodept;

struct node{
    int key = -1;
    node *par;
    node *right;
    node *left;
};

nodept nil, root;

void init(){
    nil = (nodept)malloc(sizeof(node));
    nil->par = nil;
    nil->left = nil;
    nil->right = nil;
    
    root = nil;
}

void insert(int key){
    nodept z;
    z = (nodept)malloc(sizeof(node));
    z->key = key;
    z->par = nil;
    z->right = nil;
    z->left = nil;
    
    nodept y = nil;
    nodept x = root;

    while(x != nil){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else {
            x = x->right;
        }
    }

    z->par = y;

    if(y == nil){
        root = z;
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else {
        y->right = z;
    }
}

bool find(int key){
    bool ret = false;
    nodept x = root;
    while(x != nil){
        ret |= (x->key == key);
        if(key < x->key){
            x = x->left;
        }
        else {
            x = x->right;
        }
    }
    return ret;
}

void indfs(nodept v){
    if(v == nil)return;
    if(v->left != nil){
        indfs(v->left);
    }
    printf(" %d", v->key);
    if(v->right != nil){
        indfs(v->right);
    }
}

void predfs(nodept v){
    if(v == nil)return;
    printf(" %d", v->key);
    if(v->left != nil){
        predfs(v->left);
    }
    if(v->right != nil){
        predfs(v->right);
    }
}

signed main(){
    int M;
    cin >> M;
    init();
    for(int i = 0; i < M; i++){
        char query[10];
        cin >> query;
        if(query[0] == 'i'){
            int key;
            cin >> key;
            insert(key);
        }
        else if(query[0] == 'f'){
            int key;
            cin >> key;
            if(find(key)){
                printf("yes\n");
            }
            else printf("no\n");
        }
        else {
            indfs(root);
            printf("\n");
            predfs(root);
            printf("\n");
        }
    }


    return 0;
}

/*



*/


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    deque<char> dq;
    string s;
    cin >> s;
    for (char c : s) {
        dq.push_back(c);
    }

    int q;
    cin >> q;
    bool rev = 0;
    while (q-- > 0) {
        int op;
        cin >> op;
        if (op == 1) {
            rev ^= 1;
        } else {
            int f;
            char c;
            cin >> f >> c;
            --f;
            if (f ^ rev) {
                dq.push_back(c);
            } else {
                dq.push_front(c);
            }
        }
    }

    string ans(all(dq));
    if (rev)
        reverse(all(ans));
    cout << ans << '\n';
    
    return 0;
}


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

bool have_8_divisors(int n) {
    vector<int> divisors;
    for (int i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            divisors.push_back(i);
            if(i!=1 && i*i!=n)
				divisors.push_back(n/i);
        }
    }
    divisors.push_back(n);
    if (divisors.size() == 8)
        return true;
    else return false;
}

int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i+=2) {
        if (have_8_divisors(i))
            ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
    #include <utility>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <set>
    #include <cmath>
             
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
       
    #define PI 3.14159265358979323846
             
    const double EPS = 1e-8;
            
    int main()
    {
		ll h,w;

		cin >> h >> w;

		char a;

		for(int i=0;i<=w+1;i++){
			cout << '#';
		}
		cout << endl;

		for(int i=1;i<h+1;i++){
			for(int j=0;j<=w+1;j++){
				if(j==0||j==w+1){
					cout << '#';
				}else{
					cin >> a;
					cout << a;
				}
			}
			cout << endl;
		}

		for(int i=0;i<=w+1;i++){
			cout << '#';
		}
		cout << endl;

		return 0;
    }

Measured memory_bytes: 256
import math
Q = int(input())
rui = [0]*50000
def sosuu(n):
    for i in range(2,1+int(math.sqrt(n))):
        if n % i == 0:
            return 0
    return 1
for i in range(1,50000):
    n = i*2 + 1
    han = 0
    rui[i] = rui[i-1] + min(sosuu(n),sosuu((n+1)/2))
for i in range(Q):
    l,r = [int(x) for x in input().split()]
    l2 = (l-1) // 2
    r2 = (r-1) // 2
    if l2 != 0:
        print(rui[r2] - rui [l2-1])
    else:
        print(rui[r2])

Measured memory_bytes: 54364
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int main(void) {
    int a,b;

    cin>>a>>b;

    if(a > 12) {
        cout<<b<<endl;
    } else if(a > 5 && a < 13) {
        cout<<b/2<<endl;
    } else {
        cout<<0<<endl;

    }

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int num[100010];

int main () {
        int n;
        cin >> n;
        for (int i = 1; i <= n; i++)    cin >> num[i];
        sort (num + 1, num + n + 1);
        int cnt = 0, dis = 1;
        for (int i = 2; i <= n; i++) {
                if (num[i] != num[i - 1]) {
                        dis++;
                } else {
                        cnt++;
                }
        }
        if (cnt % 2 == 0)       cout << dis << endl;
        else    cout << dis  - 1 << endl;
        return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, int> PL;
constexpr int mod = 1e9 + 7;
constexpr int INF = 2e9;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  cout << accumulate(a.begin(), a.begin() + k, 0) << endl;
  return 0;
} 

Measured memory_bytes: 3628
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-2):
    if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]:
        count += 1
    elif p[i] == p[i+2]:
        if p[i] > p[i+1]:
            count += 1
print(count)

Measured memory_bytes: 3064
def f(S):
    if S=="R":
        return 1
    else:
        return -1

S=input()
N=len(S)
K=20
L=list(map(f,S))

A=[[0]*N for _ in range(K)]

for i in range(N):
    A[0][i]=i+L[i]

for k in range(1,K):
    for x in range(N):
        A[k][x]=A[k-1][A[k-1][x]]

Z=[0]*(N)
for k in range(N):
    P=10**6
    a=k
    i=0
    while P>0:
        if P%2:
            a=A[i][a]
        i+=1
        P>>=1
    Z[a]+=1

print(" ".join(map(str,Z)))


Measured memory_bytes: 98976
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <random>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1e10 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

void DFS(vvll &g,vll &par,vll &cnt,int p,int pre){
	par[p] = pre ;
	for(int i=0;i<g[p].size();i++) cnt[g[p][i]]-- ;
	for(int i=0;i<g[p].size();i++) if(cnt[g[p][i]]==0&&par[g[p][i]]==-1) DFS(g,par,cnt,g[p][i],p+1) ;
}

int main(){
	ll n,m ;
	cin >> n >> m ;
	vvll g(n) ;
	vll cnt(n,0) ;
	for(int i=1;i<n+m;i++){
		ll a,b ;
		cin >> a >> b ;
		a-- ; b-- ;
		g[a].push_back(b) ;
		cnt[b]++ ;
	}
	vll par(n,-1) ;
	for(int i=0;i<n;i++){
		if(cnt[i]==0){
			DFS(g,par,cnt,i,0) ;
			break ;
		}
	}
	for(auto i:par) cout << i << endl ;
}


Measured memory_bytes: 16372
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=405;
ll dp[N][N],sum[N];
int a[N];
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i),sum[i]=sum[i-1]+a[i];
    for(int i=1;i<n;i++) dp[i][i+1]=a[i]+a[i+1];
    for(int k=3;k<=n;k++){
        for(int i=1;i+k-1<=n;i++){
            int j=i+k-1;
            dp[i][j]=1LL<<60;
            for(int t=i;t<j;t++){
                dp[i][j]=min(dp[i][j],dp[i][t]+dp[t+1][j]);
            }
            dp[i][j]+=sum[j]-sum[i-1];
        }
    }
    cout<<dp[1][n];
}


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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){
    
    ll a,b,c,k;
    cin >> a >> b >> c >> k;

    if(k <= a){
        cout << k << endl;
    }else if(k <= a + b){
        cout << a << endl;
    }else{
        cout << a - (k - a  - b) << endl;
    }

    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int d[240],s[120];

int main(){
	int i,j,n,m,q;
	while(scanf("%d%d",&n,&q)>0&&n+q){
		for(i=1;i<=100;i++) s[i]=0;
		for(i=0;i<n;i++){
			scanf("%d",&m);
			for(j=0;j<m;j++) scanf("%d",d+j),++s[d[j]];
		}
		int ind,maxs=0;
		for(i=1;i<=100;i++){
			if(maxs<s[i]) ind=i,maxs=s[i];
		}
		if(maxs>=q) printf("%d\n",ind);
		else puts("0");
	}
	
	return 0;
}


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

using namespace std;

mt19937 rng(time(NULL));

int D;
int c[27];
int s[410][27];
const int MAX = 26;

int ans[410];

int last[27];
long long dc = 0, score = 0, sum = 0;

vector<int> candidate;

set<int> position[27];

double prob = 0;

long long f(long long x){
	if(x < 0) return 0;
	return x * (x + 1) / 2;
}

const int PMAX = 1000000000;

double dice(){
	return (double) (rng() % PMAX) / (PMAX - 1);
}

long long calc(vector<int> &a){
	long long score = 0;

	memset(last, 0, sizeof(last));
	for(int i = 1; i < (int) a.size(); i++){
		score += s[i][a[i]];

		last[a[i]] = i;
		for(int j = 1; j <= MAX; j++){
			score -= 1LL * c[j] * (i - last[j]);
		}
	}

	return score;
}

void Randomize(){
	for(int i = 1; i <= MAX; i++) position[i].insert(-1);
	for(int i = 1; i <= MAX; i++) position[i].insert(D + 1);

	int id = 1;
	for(auto &k : candidate) position[k].insert(id++);

	// for(int i = 1; i <= MAX; i++){
	// 	int pre = -1;
	// 	for(auto &k : position[i]){
	// 		score -= 1LL * f(k - pre - 1) * c[i];
	// 		pre = k;
	// 	}
	// }

	for(int asd = 0; asd <= 1000; asd++){
		int pos, contestNxt;
		pos = rng() % D + 1; contestNxt = rng() % 26 + 1;
		
		// int contestNow = candidate[pos];

		// int lfNow = *position[contestNow].lower_bound(pos - 1);
		// int rgNow = *position[contestNow].upper_bound(pos);

		// int rgNxt = *position[contestNxt].lower_bound(pos);
		// int lfNxt = *prev(position[contestNxt].lower_bound(pos));

		// long long paramNow = s[pos][contestNow] - f(rgNxt - lfNxt - 1) * c[contestNxt] - f(rgNow - pos - 1) * c[contestNow] - f(pos - lfNow - 1) * c[contestNow];
		// long long paramNxt = s[pos][contestNxt] - f(rgNxt - pos - 1) * c[contestNxt] - f(pos - lfNxt - 1) * c[contestNxt] - f(rgNow - lfNow - 1) * c[contestNow];

		vector<int> nxt = candidate;

		nxt[pos] = contestNxt;

		long long paramNow = calc(candidate);
		long long paramNxt = calc(nxt);

		double p = 0;
		if(paramNow < paramNxt) p = 0.9999;
		else p = 0.001;
		
		if(dice() <= p) swap(candidate, nxt);
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> D;

	for(int i = 1; i <= MAX; i++) cin >> c[i], sum += c[i];

	for(int i = 1; i <= D; i++){
		for(int j = 1; j <= MAX; j++){
			cin >> s[i][j];
		}
	}

	candidate.emplace_back(0);

	for(int i = 1; i <= D; i++){
		int opt = -1; long long inc = -1e18;

		for(int j = 1; j <= MAX; j++){
			if(inc < s[i][j] - (dc + sum) + c[j] * (i - last[j])){
				opt = j;
				inc = s[i][j] - (dc + sum) + c[j] * (i - last[j]);
			}
		}

		candidate.emplace_back(opt);
		// cout << opt << "\n";

		dc += sum;
		dc -= c[opt] * (i - last[opt]);
		last[opt] = i;

		// score += inc;
		score += s[i][opt];
		// cout << (i % MAX) + 1 << "\n";
	}

	Randomize();

	for(int i = 1; i < (int) candidate.size(); i++){
		cout << candidate[i] << "\n";
	}

	// cerr << score << "\n";

	return 0;
}

Measured memory_bytes: 3724
x = int(input())
if x % 11 == 0:
    print(x // 11 * 2)
else:
    cnt = x // 11 * 2
    x -= x // 11 * 11
    while x > 0:
        if cnt % 2 == 0:
            x -= 6
        else:
            x -= 5
        cnt += 1
    print(cnt)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    map<ll, ll> mp;
    rep(i, 0, n)
    {
        cin >> v[i];
        mp[v[i]]++;
    }
    ll all = 0;
    for (auto x:mp)
        all += (x.second * (x.second-1)) / 2;
    rep(i, 0, n)
    {
        ll ans = all;
        ll x = mp[v[i]];
        ans -= (x * (x-1))/2;
        x--;
        ans += (x * (x-1))/2;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main()
{
    string T;
    cin >> T;
    int t = T.size();

    rep(i, t)
    {
        if (T[i] == 'P')
        {
            if (i + 1 < t && T[i + 1] == '?')
                T[i + 1] = 'D';
        }
        else if (T[i] == '?')
        {
            if (i + 1 < t && T[i + 1] == 'D')
                T[i] = 'P';
            else
                T[i] = 'D';
        }
    }

    cout << T << endl;
}

Measured memory_bytes: 3764
//#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fast_io()                \
    ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define mod 998244353
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    fast_io();
    ll n;
    cin >> n;
    ll a[n];
    ll m = 0, ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (i == 0)
            m = a[0];
        else if (m > a[i])
            ans += m - a[i];
        else
            m = a[i];
    }
    cout << ans;
    return 0;
}


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

int N; vector<vector<int>> A; int V;

int id[1010][1010];//ナンバリング
vector<int> to[1001000]; //隣接リスト

int visited[1001000]; bool flag[1001000];
int dp[1001000];

int dfs(int a){
  
  if( visited[a]){
    if(!flag[a]){ return -1;} else{ return dp[a];}} //メモ化再帰
  
   visited[a] = true; dp[a] = 1;
  for(int u : to[a]){
    int res = dfs(u);
    if(res == -1){ return -1;}
    dp[a] = max(dp[a], res+1);}
    flag[a] = true;
  return dp[a];}
  
  
  

int toId(int a, int b){
  if( a > b){ swap(a,b);}
  return id[a][b];}

int main(){
  cin >> N;  A = vector<vector<int>> (N,vector<int> (N-1));
  V = 0; 
  
  for(int i = 0; i < N; i++){ 
    for(int j = 0; j < N-1; j++){ cin >> A[i][j]; A[i][j]--;}}
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if( i < j ){ id[i][j] = V++;}}} 
  
  for(int i = 0; i < N; i++){
    
    for(int j = 0; j < N-1; j++){
      A[i][j] = toId( i , A[i][j]);}
    
    for(int j = 0; j < N-2; j++){
      to[A[i][j+1]].push_back(A[i][j]);}
  } //トポロジカルソートして組みに順番をつけてグラフ化した
  
  int ans = 0;
  
  for(int i = 0; i < V; i++){
    
    int res = dfs(i); 
    if(res == -1){ cout << -1 << endl; return 0;}
    ans = max(ans, res);}
  
  cout << ans << endl; return 0;}
    
  
    

Measured memory_bytes: 55936
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    int N; cin >> N;
    vector<int> dp(N+1, 1000000);
    dp[0] = 0;

    vector<int> withdraw;
    for (int pow6 = 1; pow6 <= N; pow6 *= 6){
        withdraw.push_back(pow6);
    }
    for (int pow9 = 1; pow9 <= N; pow9 *= 9){
        withdraw.push_back(pow9);
    }

    rep(i, withdraw.size()){
        rep(j, N+1){
            if (j - withdraw[i] >= 0){
                dp[j] = min(dp[j], dp[j-withdraw[i]]+1);
            }
        }        
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string N;
	int maximum = 0, num = 0;
	
	cin>>N;
	
	for(int i = 0; i < N.size(); i++){
		if(N[i] != '0') {
			maximum = max(maximum, num + (N[i] - '0') - 1 + ((int)N.size() - i - 1) * 9);
		}
		// cout<<num<<" "<<maximum<<" "<<" "<<endl;
		num += N[i] - '0';
	}
	
	maximum = max(maximum, num);
	
	
	cout<<maximum<<endl;
	
	return 0;
}

Measured memory_bytes: 256
var
 s:qword;
 n,i,a,b,x,y:longint;
begin
 read(n,a,b);
 for i:=1 to n do
 begin
 x:=i;
 y:=0;
  while x>0 do
  begin
  y:=y+x mod 10;
  x:=x div 10;
  end;
  if (y>=a) and (y<=b) then s:=s+i;
  end;
  writeln(s);
end.

Measured memory_bytes: 128
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect
 
def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

N, M = reads()
orig_edges = set()
for _ in range(M):
  A, B = reads()
  A, B = A-1, B-1
  orig_edges.add((A, B))
  orig_edges.add((B, A))

edges = [[] for _ in range(N)]
for A, B in combinations(range(N), 2):
  if (A, B) not in orig_edges:
    edges[A].append(B)
    edges[B].append(A)

remain = set(range(N))
color = [-1] * N

def walk(u, c, ctr, remain):
  if u in remain:
    remain.remove(u)
  if color[u] >= 0:
    if color[u] != c:
      print(-1); exit()
    return ctr

  color[u] = c; ctr[c] += 1
  for v in edges[u]:
    walk(v, 1-c, ctr, remain)
  return ctr

ps = []
while len(remain) > 0:
  s = remain.pop()
  p = walk(s, 0, [0, 0], remain)
  ps.append(p)

dp = set([0])
for a, b in ps:
  d = b - a
  dp = {x - d for x in dp} | {x + d for x in dp}
m = min(abs(x) for x in dp)
a, b = (N + m) // 2, (N - m) // 2
print(a*(a-1)//2 + b*(b-1)//2)


Measured memory_bytes: 103640
#include<cstdio>
long long a[100000],b[100000];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%lld%lld",&a[i],&b[i]);
    long long d,dsum=0;
    for(int i=n-1;i>=0;i--){
        d=(a[i]+dsum)%b[i];
        if(d>0)dsum+=b[i]-d;
    }
    printf("%lld",dsum);
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;

int main() {
  int N,K;
  cin>>N>>K;
  vector<int>A(N);
  int x=99999999;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(x>A[i]){x=min(x,A[i]);}
  }
  int m=0;
  for(int i=0;i<N;i++){
    if(x==A[i]){m=i;}
  }
  int ans=1+(N-K+K-2)/(K-1);
  cout<<ans<<endl;
  return 0;}

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

#define ARRAY_SIZE 1

int checkTrue(int* firstValue, int* secondValue)
{
	if (*firstValue == *secondValue)
	{
		printf("Yes \n");
	}
	else
	{
		printf("No \n");
	}
	return 0;
}

int main()
{
	int inputA[ARRAY_SIZE];
	int inputB[ARRAY_SIZE];
	int valueN, valueM;

	scanf("%d""%d", &inputA, &inputB);

	valueM = inputA[0];
	valueN = inputB[0];
	
	checkTrue(&valueM, &valueN);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl

using namespace std;

typedef pair<int,int>P;

int dp[(1 << 15)][15];
int d[15][15];

int main()
{
    int n,m;
    cin >> n >> m;
    rep(i,n){
        rep(j,n){
            d[i][j] = INF;
        }
    }
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        d[a][b] = c;
    }
    int ans = INF;
    rep(id,n){
        rep(i,(1 << n)){
            rep(j,n){
                dp[i][j] = INF;
            }
        }
        dp[0][id] = 0;
        rep(i,1<<n){
            rep(j,n){
                rep(k,n){
                    if(!(i & (1 << k))){
                        dp[i|(1<<k)][j] = min(dp[i|(1<<k)][j],dp[i][k] + d[k][j]);
                    }
                }
            }
        }
        rep(i,n){
            ans = min(ans,dp[(1<<n)-1][id]);
        }
    }
    if(ans == INF){
        cout << "-1\n";
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 5008
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N =sc.nextInt();
		int t[][] =new int[N][2];
		for (int i = 0; i < N; i++) {
			t[i][0]=sc.nextInt();
			t[i][1]=sc.nextInt();
		}
		
		int M =sc.nextInt();
		int y[][] =new int[M+N][2];
		for (int i = 0; i < M; i++) {
			y[i][0]=sc.nextInt();
			y[i][1]=sc.nextInt();
		}
		
		for (int i = 0; i < N; i++) {
			y[M+i][0]=t[i][0];
			y[M+i][1]=t[i][1];
		}
		
		Arrays.sort(y,new Comparator<int[]>() {
			public int compare(int a[], int b[]) {
				return a[1] - b[1];
			}
		});
		Arrays.sort(y,new Comparator<int[]>() {
			public int compare(int a[], int b[]) {
				return a[0] - b[0];
			}
		});
		int oq=100,ow=100;
		boolean e=false;
		String s="";
		for (int i = 0; i < N+M; i++) {
			if(oq==y[i][0]&&ow==y[i][1]){
				continue;
			}else{
				s+=Integer.toString(y[i][0])+":"+String.format("%1$02d", y[i][1])+" ";
			}
			oq=y[i][0];
			ow=y[i][1];
			if(N+M-1==i)break;
		}
		System.out.println(s.trim());
	}
}

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

typedef long long ll;

ll N;
vector<ll> A;
const ll L = 1000000;
ll F[L + 1];
ll R;

int main() {
  cin >> N;
  A.resize(N);
  for (ll i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  for (ll i = 0; i < N; ++i) {
    if (i > 0 && A[i] == A[i - 1]) {
      ++F[A[i]];
      continue;
    }
    for (ll b = 2 * A[i]; b <= L; b += A[i]) ++F[b];
  }
  for (ll a : A) {
    if (F[a] == 0) ++R;
  }
  cout << R << endl;
  return 0;
}


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

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

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

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

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

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

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

vector<ll> factmemo, factmemoInv;
ll factmemoMod = -1;

ll factorial(int n, int M) {
  if (factmemoMod == M) return factmemo[n];
  if (n <= 1) return 1;

  ll res = 1;
  for (int i = 1; i <= n; i++) res = res * i % M;
  return res;
}

ll power(ll k, ll n, int M) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
    n /= 2;
  }
  return res;
}

void initFactorial(int n, int M) {
  factmemo.assign(n + 1, 0);
  factmemoInv.assign(n + 1, 0);
  factmemoMod = M;
  factmemo[0] = 1;
  for (int i = 1; i <= n; i++) factmemo[i] = factmemo[i - 1] * i % M;
  factmemoInv[n] = power(factmemo[n], M - 2, M);
  for (int i = n; i > 0; i--) factmemoInv[i - 1] = factmemoInv[i] * i % M;
}

//nCm nPm nHm (mod M)

/*Combination*/
ll C(int n, int m, int M) {
  if (n < m) return 0;
  if (m == 0 || n == m) return 1;

  if (factmemoMod == M)
    return factmemo[n] * factmemoInv[m] % M * factmemoInv[n - m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(m, M) * factorial(n - m, M) % M;

  denom = power((int)denom, M - 2, M);

  return numer * denom % M;
}
/*Permutation*/
ll P(int n, int m, int M) {
  if (n < m) return 0;
  if (m == 0) return 1;

  if (factmemoMod == M)
    return factmemo[n] * factmemoInv[n - m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(n - m, M);

  denom = power((int)denom, M - 2, M);

  return numer * denom % M;
}
/*Combination with Repetitions*/
ll H(int n, int m, int M) {
  if (n == 0 && m == 0) return 1;
  return C(n + m - 1, m, M);
}

int main() {
  int K;
  char S[SIZE];

  scanf("%d%s", &K, S);
  int N = strlen(S);

  initFactorial(K + N, mod);

  ll ans = 0;

  for (int i = 0; i <= K; i++) {
    ll x = power(25, i, mod) * C(i + N - 1, i, mod) % mod * power(26, K - i, mod) % mod;
    ans = (ans + x) % mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35428
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
typedef long long ll;
const int N = 1e5+10;

int main()
{
    int n, k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1] = s[k-1] - 'A' + 'a';
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n, x, sum = 0, tmp;
  cin >> n;
  int arr[100000]{};
  for(int i = 0; i < n; i++)
  {
    cin >> x;
    arr[x-1]++;
    if( arr[x-1] > 1 )
      sum++;
  }
  tmp = sum/2;
  tmp *= 2;
  if( sum - tmp == 1 )
    sum++;
  cout << n - sum;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> mods(9);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    int m = a / 400;
    if (m > 8) m = 8;
    mods[m]++;
  }
  int ans = 0;
  for (int i = 0; i <= 7; i++) {
    if (mods[i]) ans++;
  }
  int ans_min = max(ans, 1);
  int ans_max = ans + mods[8];
  cout << ans_min << " " << ans_max << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  string c;
  cin >> n >> c;

  ll rsum = count(c.begin(), c.end(), 'R');
  ll cnt = 0;
  rep(i, rsum) {
    if (c[i] == 'R') cnt++;
  }

  cout << rsum - cnt << endl;

  return 0;
}


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

 using namespace std;
 int main() {
   int A, B, C, D;
   cin >> A >> B >> C >> D;
   if (A + B == C + D) cout << "Balanced" << endl;
   else if (A + B > C + D) cout << "Left" << endl;
   else cout << "Right" << endl;
 }


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

int main() {
    int t;
    cin >> t;
    REP(i,t){
        int n, d;
        cin >> n >> d;
        int ans = 127*(n-1);
        if (n % 2 == 0) ans += (127 ^ d);
        else ans += d;
        cout << ans << endl;
    }

    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int N;
	cin>>N;
	
	int A[N][3];
	int fl=0;
	
	for(int i=0;i<N;i++)
	{
	    cin>>A[i][0]>>A[i][1];
	}
	
	for(int i=0;i<N;i++)
	{
	   if(A[i][0]==A[i][1])
	   A[i][2]=1;
	   else
	   A[i][2]=0;
	}
	
	for(int i=2;i<N;i++)
	{
	   if(A[i][2]==1&&A[i-1][2]==1&&A[i-2][2]==1)
	   {
	       fl=1;
	       break;
	   }    
	}
	
	if(fl==1)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	
	
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,a[3002],dp[3002][3002];
bool f[3002][3002];
ll Comp(int l,int r) {
	int p=(n-(r-l+1))%2;
	if (f[l][r]) return dp[l][r];
	if (l==r && p%2==0) return dp[l][r]=a[l]; 
	if (l==r && p%2) return dp[l][r]=-a[l];  
	
	f[l][r]=1;
	
	ll x=Comp(l,r-1);
	ll y=Comp(l+1,r);
	ll AnsT=max(x+a[r],y+a[l]);
	ll AnsJ=min(x-a[r],y-a[l]);
	
	if (p%2==0) return dp[l][r]=AnsT;
	if (p%2) return dp[l][r]=AnsJ;
}

main () {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	
	for (int i=1; i<=n; i++) 
		cin>>a[i];
	
	cout<<Comp(1,n)<<endl;
}

Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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; }

ll n;

int main() {
    cin >> n;
    if(n%2 != 0) cout << 0 << endl;
    else {
        ll now = 10;
        ll cnt = 0;
        while(now <= n) {
            cnt += (n/now);
            now *= 5;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n){
    int k;cin >> k;
    a[k-1] = i+1;
  }
  for(auto &i:a) cout << i << endl;
}


Measured memory_bytes: 1152
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

const int MAX_V = 20000;
int w,h;
struct Edge {
    int to,cost;
    Edge(int to,int cost) : 
        to(to),cost(cost) {}
};
map<pair<P,string>,int> ids;
vector<Edge> G[MAX_V];
template<class T>
bool chmin(T& a,const T& b) {
    if(b<a) {
        a=b;
        return true;
    }

    return false;
}
int to_id(P p,string s) {
    pair<P,string> ps=pair<P,string>(p,s);
    if(!ids.count(ps)) ids[ps]=ids.size();

    return ids[ps];
}
int d[MAX_V];
int dijk(int s,int t) {
    rep(i,MAX_V) d[i]=INF;
    d[s]=0;
    priority_queue<P,vector<P>,greater<P> > que;
    que.push(P(0,s));

    while(que.size()) {
        P p=que.top(); que.pop();
        int v=p.sc;
        int cost=p.fr;

        rep(i,G[v].size()) {
            Edge e=G[v][i];
            if(chmin(d[e.to],d[v]+e.cost)) {
                que.push(P(d[e.to],e.to));
            }
        }
    }

    return d[t];
}


int diff(P p1,P p2) {
    return abs(p1.fr-p2.fr)+abs(p1.sc-p2.sc);
}
string to_s(int n) {
    stringstream ss;
    ss<<n;
    return ss.str();
}
int to_i(string& s) {
    int ret;
    stringstream ss;
    ss<<s;
    ss>>ret;
    return ret;
}
string maze[102][102];
void solve() {
    rep(i,MAX_V) G[i].clear();
    rep(i,h) rep(j,w) cin>>maze[i][j];
    map<string,set<P> > points;
    vector<int> vec;
    rep(y,h) rep(x,w) {
        if(maze[y][x]!=".") points[maze[y][x]].insert(P(y,x));
        if(maze[y][x]!="."&&maze[y][x]!="S"&&maze[y][x]!="G") vec.pb(to_i(maze[y][x]));
    }
    sort(all(vec));
    vec.erase(unique(all(vec)),vec.end());

    /*
    to_id("S");
    rep(i,vec.size()) to_id(to_s(vec[i]));
    to_id("G");
    // */

    rep(i,vec.size()+1) {
        string s=to_s(i);
        string t=to_s(i+1);
        if(i==0) s="S";
        if(i==vec.size()) t="G";
        for(auto& e1 : points[s]) {
            for(auto& e2 : points[t]) {
                // cout<<s<<" -> "<<t<<" : "<<diff(e1,e2)<<endl;
                G[to_id(e1,s)].pb(Edge(to_id(e2,t),diff(e1,e2)));
            }
        }
    }


    cout<<dijk(to_id(*points["S"].begin(),"S"),to_id(*points["G"].begin(),"G"))<<endl;
}

int main() {
    while(cin>>w>>h) {
        if(w+h==0) break;
        solve();
    }
    return 0;
}

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

using namespace std;

int main() {
  int h, w;
  string s;
  cin >> h >> w;
  string y(w + 2, '#');
  cout << y << endl;
  for (int i = 0; i < h; i++) {
    cin >> s;
    cout << '#' << s << '#' << endl;
  }
  cout << y << endl;

  return 0;
}


Measured memory_bytes: 3124
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def resolve():
    n, k = map(int, input().split())
    A = sorted(list(map(int, input().split())))

    if k in set(A):
        print("POSSIBLE")
        exit()

    if k > A[-1]:
        print("IMPOSSIBLE")
        exit()

    if n == 1:
        print("IMPOSSIBLE")
        exit()

    g = A[0]
    for i in range(1, n):
        g = gcd(g, A[i])

    if k % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 65048
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int s;
    scanf("%d", &s);
    int ss = s%60;
    s = s/60;
    int mm = s%60;
    s = s/60;
    printf("%d:%d:%d\n", s, mm, ss);

    return 0;
}



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

using namespace std;

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

    int expiredDays = B - A;
    if (expiredDays <= 0)
        cout << "delicious" << endl;
    else if (expiredDays <= X)
        cout << "safe" << endl;
    else
        cout << "dangerous" << endl;

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int n, k;
    cin >> n >> k;
    vi a(n); 
    rep(i, n){
        cin >> a[i];
    }
   
    rep3(i, k, n-1){
        if(a[i-k] < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
	return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 4000
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    a = []

    for i in range(N):
        a.append(int(input().rstrip()) - 1)
    next_a = 0
    cnt = 0
    flag=False
    for i in range(N):
        if(next_a == 1):
            flag = True
            break
        else:
            cnt +=1
            next_a = a[next_a]
    if flag:
        print(cnt)
    else:
        print(-1)
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 7580
using System;

namespace AOJ.ITP
{
    public class ReversingNumbers
    {
        public static void Main()
        {
            int len = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            for (int i = len - 1; i >= 0; i--)
            {
                if (i == len - 1) { Console.Write(input[i]); }
                else { Console.Write(" " + input[i]); }
            }
            Console.Write("\n");
        }
    }
}

Measured memory_bytes: 5292