akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int n;
	while(cin>>n,n){
		int cnt = 0;
		while(n!=1){
			if(n%2==0){
				n /=2;
			}else{
				n =3*n+1;
			}
			cnt++;
		}
		cout <<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
//IOI 2021

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 100 * 1000 + 17;

int n, dp[MAXN];
bool ispath[MAXN];
vector<int> adj[MAXN];

bool dfs_path(int v, int par) {
	if ((int)adj[v].size() - (par > 0) == 0)
		return ispath[v] = true;
	else if ((int)adj[v].size() - (par > 0) == 1) {
		for (auto i : adj[v])
			if (i != par)
				return dfs_path(i, v);
	}
	else {
		for (auto i : adj[v])
			if (i != par)
				dfs_path(i, v);
		return ispath[v] = false;
	}
}

void dfs_dp(int v, int par) {
	if (par && adj[v].size() == 1) {
		dp[v] = 0;
		return;
	}
	int res = 0;
	bool flag = false;
	for (auto i : adj[v])
		if (i != par) {
			dfs_dp(i, v);
			res += dp[i];
			if (!dp[i])
				res++, flag = true;
		}
	if (!flag)
		dp[v] = res;
	else
		dp[v] = res - 1;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		++v, ++u;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	dfs_path(1, 0);
	for (int i = 1; i <= n; i++)
		if (adj[i].size() > 2) {
			dfs_dp(i, 0);
			return cout << dp[i] << endl, 0;
		}
	cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 10496
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

#define int long long

signed main() {
	queue<char> Sa;
	queue<char> Sb;
	queue<char> Sc;
	
	string s;
	for (int i = 0; i < 3; i++) {
		cin >> s;
		for (int j = 0; j < s.length(); j++) {
			if (i == 0) {
				Sa.push(s[j]);
			}
			else if (i == 1) {
				Sb.push(s[j]);
			}
			else {
				Sc.push(s[j]);
			}
		}
	}

	char flag = 'a';
	while (true) {
		if (flag == 'a') {
			if (Sa.empty() == 1) {
				cout << "A" << endl;
				return 0;
			}
			flag = Sa.front();
			Sa.pop();

		}
		else if (flag == 'b') {
			if (Sb.empty() == 1) {
				cout << "B" << endl;
				return 0;
			}
			flag = Sb.front();
			Sb.pop();

		}
		else {
			if (Sc.empty() == 1) {
				cout << "C" << endl;
				return 0;
			}
			flag = Sc.front();
			Sc.pop();

		}
	
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long long
#define W V<L>
#define R(n) for(L i=0;i<n;i++)
L E=70;
W S(V<W>p){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}R(2){L c=0;for(W x:T[!i]){L Q=(2*x[0]+x[1])%3;c^=Q+1;}if(!c){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p){v[0]++;}W A=S(p);A[0]--;return A;}
int main(){L M=2e17,n;cin>>n;V<W>p(n);R(n){L a,b;cin>>a>>b;p[i]={a+M,b+M};}W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

Measured memory_bytes: 62908
#include<stdio.h>
int main()
{
long long int n,ans,c,k;
  c=0;
  k=0;
  ans=0;
  scanf("%lld",&n);
  
  if(n<10) printf("%lld",n);

  else{
   while(n>=10)
   {
   if(n%10==9) k++;
   n=n/10;
   c++;
   ans=ans+9;
   }
    if(k==c) ans=ans+n;
    else ans=ans+n-1;
   printf("%lld",ans);
  }
return 0;
}

Measured memory_bytes: 1696
<?php
// https://atcoder.jp/contests/abc046/tasks/abc046_a

// count_string($array, $string)で$arrayに含まれる$stringの数をカウントする
function count_string($array, $string)
{
  return count(array_keys($array, $string));
}

$array = explode(" ", trim(fgets(STDIN)));
$next = 0;
$ans = 3;

foreach ($array as $key => $value) {
  if(count_string($array, $value) != 1){
    $ans--;
    $array[$key] = 0;
  }
}

echo $ans."\n";

Measured memory_bytes: 4728
import sys
import math


N_MAX = 200000 + 5
INF = 10**9 + 7
sys.setrecursionlimit(N_MAX)
MOD = 10**9 + 7


def eatosthenes(N):
    prime = []
    D = [1] * (N + 1)

    for i in range(2, N + 1):
        if D[i] != 1:
            continue
        for j in range(N // i + 1):
            if D[i * j] == 1:
                D[i * j] = i
        prime.append(i)

    return prime


def main():
    N = int(sys.stdin.readline().rstrip())
    A = [int(x) for x in sys.stdin.readline().rstrip().split()]

    maxA = max(A)
    primelist = eatosthenes(maxA)

    # 1 <= a <= maxA までの、要素の登場回数
    C = [0] * (maxA + 1)
    for a in A:
        C[a] += 1

    pc = True

    # p の倍数である個数をカウントする
    for p in primelist:
        cnt = 0
        for k in range(maxA // p + 1):
            cnt += C[k * p]

        # k*p となるような要素が2個以上あったら、pairwise coprime ではない
        if cnt > 1:
            pc = False

    if pc:
        print("pairwise coprime")
        return

    GCD = A[0]
    for i in range(1, N):
        GCD = math.gcd(GCD, A[i])

    if GCD == 1:
        print("setwise coprime")
        return

    print("not coprime")


main()


Measured memory_bytes: 133072
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;

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

Measured memory_bytes: 256
s = 0
mod = 0
for _ in range(5):
    i = int(input())
    m = i % 10
    if m != 0:
        if mod == 0:
            mod = m
        else:
            mod = min(mod, m)
        s += (i // 10 + 1) * 10
    else:
        s += i
if mod != 0:
    s = s - 10 + mod

print(s)


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func toLower(char byte) string {
	if char == []byte("A")[0] {
		return "a"
	} else if char == []byte("B")[0] {
		return "b"
	}
	return "c"
}

func main() {
	var n, k int
	var s string
	fmt.Scanf("%d %d", &n, &k)
	fmt.Scanf("%s", &s)

	fmt.Print(s[0 : k-1])
	fmt.Print(toLower(s[k-1]))
	fmt.Print(s[k:])

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,suma=0,sumb=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
   reverse(a,a+n);
	for(int i=0;i<n;i++){
		if(i%2==0){
			suma+=a[i];
		}
		else{
			sumb+=a[i];
		}
	}
	cout<<suma-sumb;
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
const ll inv2 = 5e8 + 4;

ll D[3030][3030], K[3030][3030];
ll A[3030], X[3030], Y[3030];
ll n, q, ans;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll i, j, t;
	
	cin >> n >> q;
	
	for(i=1; i<=n; i++){
		cin >> A[i];
	}
	
	for(i=1, t=1; i<=q; i++){
		cin >> X[i] >> Y[i];
		t = t * 2 % mod;
	}
	
	for(i=1; i<n; i++){
		for(j=i+1; j<=n; j++){
			D[i][j] = t;
		}
	}
	
	for(i=q; i>=1; i--){
		for(j=1; j<=n; j++){
			if(j != Y[i]){
				K[j][X[i]] = (D[j][X[i]] + D[j][Y[i]]) * inv2 % mod;
				K[X[i]][j] = (D[X[i]][j] + D[Y[i]][j]) * inv2 % mod;
			}
			if(j != X[i]){
				K[j][Y[i]] = (D[j][Y[i]] + D[j][X[i]]) * inv2 % mod;
				K[Y[i]][j] = (D[Y[i]][j] + D[X[i]][j]) * inv2 % mod;
			}
		}
		
		for(j=1; j<=n; j++){
			if(j != Y[i]){
				D[j][X[i]] = K[j][X[i]];
				D[X[i]][j] = K[X[i]][j];
			}
			if(j != X[i]){
				D[j][Y[i]] = K[j][Y[i]];
				D[Y[i]][j] = K[Y[i]][j];
			}
		}
		
		D[X[i]][Y[i]] = D[Y[i]][X[i]] = t * inv2 % mod;
	}
	
	for(i=1; i<=n; i++){
		for(j=1; j<=n; j++){
			if(A[i] > A[j]) ans = (ans + D[i][j]) % mod;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"
#include "profile.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 600001;
const int MOD = 1e9 + 7;
using cd = complex<double>;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll dp[101][4][4];

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    profile("all");

    auto solve = [](int _) {
        int n;
        cin >> n;
        vector<int> a(n);
        int odd = 0;
        for (int i = 1; i <= n; ++i) {
            cin >> a[i - 1];
            if (a[i - 1] & 1) {
                ++odd;
            }
        }
        if (odd & 1) {
            cout << "NO";
        } else {
            cout << "YES";
        }
    };


    fast_io();
    cout.precision(9);
    cout << fixed;

    solve(1);


}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(){
	int i,j,cflag=0,cnt=0;
	char ch1[55],ch2[55],ans[55]={'0'},save[55];
	scanf("%s%s",ch1,ch2);
	if(strlen(ch1)<strlen(ch2)){
		printf("UNRESTORABLE\n");
		return 0;
	}
	j=0;
	for(i=0;i<strlen(ch1);i++){
		if(ch1[i]==ch2[j]){
			j++;
			if(j==strlen(ch2)) break;
		}
		else
			j=0;
	}
	if(j==strlen(ch2)){
		for(i=0;i<strlen(ch1);i++)
			if(ch1[i]=='?') ch1[i]='a';
		printf("%s\n",ch1);
		return 0;
	}
	for(i=0;i<strlen(ch1);i++){
		cflag=0;cnt=0;
		strcpy(save,ch1);
		for(j=0;j<strlen(ch2);j++){
			if(ch1[i+j]==ch2[j]||ch1[i+j]=='?')
				cnt++;
		}
		if(cnt==strlen(ch2)){
			for(j=0;j<strlen(ch2);j++)
				save[i+j]=ch2[j];
			for(j=0;j<strlen(save);j++)
				if(save[j]=='?')
					save[j]='a';
			if(ans[0]=='0') strcpy(ans,save);
			if(strcmp(save,ans)<0)
				strcpy(ans,save);
		}
	}
	if(ans[0]=='0'){
		printf("UNRESTORABLE\n");
		return 0; 
	}
	else
		printf("%s\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repv(i,a,b) for(ll i=b-1;i>=a;i--)
#define MAXN 300005
#define endl "\n"

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;}

ll n;
ll arr[100005],arr1[100005];

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(ll i=1;i<=n;i++) cin>>arr[i];
    ll temp=-1,sum=0;
    for(ll i=n;i>=1;i--)
    {
        if((n-i)%2==1) sum+=(temp*arr[i]); 
        else sum+=arr[i];
    }
    arr1[1]=sum/2;
    ll x=arr1[1];
    for(ll i=2;i<=n;i++)
    {
        arr1[i]=arr[i-1]-x;
        x=arr1[i];
    }
    for(ll i=1;i<=n;i++) cout<<2*arr1[i]<<" ";
    cout<<endl;
}

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

int main() {
  int n;
  cin >> n;
  
  if (n==1) cout << 1 << endl;
  if (n==2 || n==3) cout << 2 << endl;
  if (4 <= n && n <= 7) cout << 4 << endl;
  if (8 <= n && n <= 15) cout << 8 << endl;
  if (16 <= n && n <= 31) cout << 16 << endl;
  if (32 <= n && n <= 63) cout << 32 << endl;
  if (64 <= n) cout << 64 << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    cout<<"ABC"<<n<<endl;
    
    
    return 0;   
}




 
 


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

int main(){
  int n,l[1000],v=0;
  cin >> n;
  n*=2;
  for(int i=0;i<n;i++){
    cin >> l[i];
  }
  sort(l,l+n,greater<int>());
  for(int i=0;i<n;i++){
    if(i%2==1){
      v+=l[i];
    }
  }

  cout << v << endl;
  
} 

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

int main() {
  int n;
  cin >> n;
  
  ll ans = 0;
  for (int a = 1; a <= n; a++) {
    ans += (n - 1) / a;
  }
  cout << ans << endl;
  return 0;
}

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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

int N, A[200009];
ll K;

int main() {
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
        A[i]--;
    }

    int table[60][200009];
    REP(i, N) table[0][i] = A[i];
    FOR(i, 1, 59) {
        REP(j, N) table[i][j] = table[i-1][table[i-1][j]];
    }

    int pos = 0;
    REPD(i, 60) {
        if (1LL<<i <= K) {
            pos = table[i][pos];
            K -= 1LL<<i;
        }
    }
    pos++;
    PRINT(pos);
    return 0;
}

Measured memory_bytes: 51292
# 2019/05/20
# AtCoder Beginner Contest 081 - C

# 1. 集計
# 2. ソート
# 3. 集計テーブルの長さ<=kまで加算(小さい方から)

from operator import itemgetter

def numcount(in_list):
    wkdict = dict()
    for i in range(len(in_list)):
        if wkdict.get(in_list[i]) == None:
            wkdict[in_list[i]] = 1
        else:
            wkdict[in_list[i]] += 1
    numlist = list()
    for x in wkdict.keys():
        wlst = list()
        wlst.append(x)
        wlst.append(wkdict[x])
        numlist.append(wlst)
    return numlist

# Input
n, k = map(int, input().split())
a = list(map(int, input().split()))

# 1.
acnt = numcount(a)

# 2.
acnt.sort(key=itemgetter(1))

# 3
idx = 0
acm = 0
while(len(acnt) - idx > k):
    acm += acnt[idx][1]
    idx += 1

# Output
print(acm)

Measured memory_bytes: 46772
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  int N;
  cin >> N;
  int num = 0;
  for(int i = 0; i < N; i++){
    int s,l;
    cin >> s >> l;
    num += l-s+1;
  }
  cout << num <<endl;
}

Measured memory_bytes: 256
N = int(input())
A = input()
list_A = A.split()
set_A = set(list_A)
i = 0

for a in list_A:
    if a in set_A:
        i += 1
        
i = i - len(set_A)
if i % 2 == 0:
    print(N - i)
else:
    print(N - (i +1))


Measured memory_bytes: 17204
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N;
signed main(){
  cin >> N;
  int res=N;
  for(int i=0;i<=N;i++){
    int c=0;
    int t=i;
    while(t>0) c+=t%6,t/=6;
    t=N-i;
    while(t>0) c+=t%9,t/=9;
    res=min(res,c);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



const int MAX = 10100;
bool IsPrime[MAX];
vector<int> Era(int n = MAX) {
    vector<int> res;
	IsPrime[0] = false; IsPrime[1] = false; 
	for (int i = 2; i < n; ++i) IsPrime[i] = true;
	for (int i = 2; i < n; ++i) {
		if (IsPrime[i]) {
            res.push_back(i);
			for (int j = i*2; j < n; j += i) IsPrime[j] = false;
		}
	}
    return res;
}

int n;

int main() {
    Era();
    while (cin >> n) {
        int res = 0;
        for (int i = 1; i <= n; ++i) {
            int j = n+1-i;
            if (IsPrime[i] && IsPrime[j]) ++res;
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 1240
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void) {
	int H, W, N;
	scanf("%d %d %d", &H, &W, &N);
	printf("%d\n", (N + max(H, W) - 1) / max(H, W));
	return 0;
}


Measured memory_bytes: 3828
using System;

namespace ITP1_5_D
{
    class Program
    {
        static void Main()
        {
            int x = int.Parse(Console.ReadLine());
            
            for (int i = 3; i <= x; i ++)
            {
                if (i % 3 == 0 || i % 10 == 3 || i % 100 / 10 == 3 || i % 1000 / 100 == 3 || i % 10000 / 1000 == 3)
                {
                    Console.Write(" " + i);
                }
                else continue;
            }
            Console.WriteLine();
            
        }
    }
}


Measured memory_bytes: 15940
b = input()
len = len(b)
ACGT = 0
MAX = 0
flag = 0
for i in range(len):
  if b[i]=="A" or b[i]=="C" or b[i]=="G" or b[i]=="T":
    ACGT += 1
  else:
    if ACGT > MAX:
      MAX = ACGT
    ACGT = 0
if ACGT > MAX:
  MAX = ACGT
print(MAX)

Measured memory_bytes: 3064
j = 0
a = 0
i = 0
N,K=(int(x) for x in input().split())
h = [int(x) for x in input().split()]
"""j = 0
a = 0
i = 0"""
for i in range(N):
    if h[i]>=K:
        a = a+1
print(a)

Measured memory_bytes: 11908
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 1e5+500;
ll T,n,m;
int a[maxn];
ll num[maxn];
ll pos[maxn];
int main() {
    cin>>n>>m;
    int cnt = 0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]>a[j]){
				num[i]++;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i]>a[j]){
				pos[i]++;
			}
		}
	}
	ll sum=0;
	for(int i=0;i<n;i++){
		sum+=pos[i];
	}
	
	sum%=mod;
	ll ssum = 0;
	ll temp = (m-1)*m/2;
	temp%=mod;
	temp*=sum;
	temp%=mod;
	ssum = temp;
	ll p = 0;
	for(int i=0;i<n;i++){
		p+=num[i];
	}
	p%=mod;
	p*=m;
	p%=mod;
	ssum+=p;
	ssum%=mod;
	cout<<ssum<<endl;
    return 0;
}

Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

l,r,d = gets.split.map(&:to_i)

count = 0
l.upto(r) do |i|
  count += 1 if i % d == 0
end

puts count

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

int main() {
  int n,k;
  cin>>n>>k;
  vector<int>h(n);
  for(int i=0;i<n;i++) cin>>h[i];
  int dp[n+1];
  dp[1]=0;
  for(int i=2;i<n+1;i++) dp[i]=1000000001;
  for(int i=2;i<n+1;i++){
    for(int j=1;j<=k;j++){
      if(i-j>=1) dp[i]=min(dp[i],dp[i-j]+abs(h[i-1]-h[i-j-1]));
    }
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
from fractions import gcd
inpl = lambda: list(map(int,input().split()))
def lcm(a,b):
    return a*b//gcd(a,b)

N = int(input())
rate = []
rate.append(inpl())
rate.append(inpl())
AB = []
BA = []
for i in range(3):
    rA, rB = rate[0][i], rate[1][i]
    if rB > rA:
        AB.append((rA, rB))
    elif rA > rB:
        BA.append((rB, rA))
for l in [AB, BA]:
    l.sort(key=lambda x: -x[1]/x[0])

def buy_and_sell(N, cost_ret):
    if len(cost_ret) == 0:
        return N
    else:
        minor_max = sum([ min([lcm(cost,cost_ret[i][0])-cost_ret[i][0] for cost,ret in cost_ret[:i]])
                          for i in range(1,len(cost_ret))])
        b0, s0 = cost_ret[0]
        n = max(0, N - minor_max) // b0
        Ndp = N - n*b0
        dp = [0]*(Ndp+1)
        w = [0]*(len(cost_ret)+1)
        for i in range(1,Ndp+1):
            k = 1
            for cost, ret in cost_ret:
                if i >= cost:
                    w[k] = dp[i-cost] + ret
                    k += 1
            dp[i] = max(dp[i-1]+1, max(w))
        return s0*n + dp[-1]

M = buy_and_sell(N, AB)
L = buy_and_sell(M, BA)
print(L)

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N, tmp;
	cin >> N;
	vector<int> a(4);
	forn(i, N)
	{
		cin >> tmp;
		a[tmp]++;
	}
	unordered_map<int32_t, double> m;
	m[0] = 0;

	function<double(int32_t)> memo = [&](int32_t t) {
		if (m.count(t))
			return m[t];
		int c1 = t&1023;
		int c2 = (t >> 10) & 1023;
		int c3 = t >> 20;
		int su = c1 + c2 + c3;
		int c0 = N - su;

		double res = 0;
		if(c1)
		{//1
			double r1 = memo(t-1);
			double m1 = static_cast<double>(c1) / su;
			double s1 = static_cast<double>(su + c0) / su;
			res += (r1 + s1)*m1;
		}
		if (c2)
		{
			double r2 = memo(t- (1024) + 1);
			double m2 = static_cast<double>(c2) / su;
			double s2 = static_cast<double>(su + c0) / su;
			res += (r2 + s2)*m2;
		}
		if (c3)
		{
			double r3 = memo(t-1023*1024);
			double m3 = static_cast<double>(c3) / su;
			double s3 = static_cast<double>(su + c0) / su;
			res += (r3 + s3)*m3;
		}
		m[t] = res;
		return res;
	};

	int32_t start = a[1] + 1024 * a[2] + 1024 * 1024 * a[3];

	double res = memo(start);
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 239576
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int a,b,c,x,y,z,i,k=0;
	cin>>a>>b>>c;
	if(a%2!=0 || b%2!=0 || c%2!=0)
	{
		cout<<k<<endl;
		return 0;
	}
	for(i=0;(a!=b || b!=c);i++)
	{
	x=(b+c)/2;
	y=(a+c)/2;
	z=(a+b)/2;
	a=x;
	b=y;
	c=z;
	k++;
	if(a%2!=0 || b%2!=0 || c%2!=0)
	{
		cout<<k<<endl;
		return 0;
	}
	
	}
	cout<<-1<<endl;
}

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

int main() {
	string s; cin>>s;
	vector<int> nums(4);
	for (int i=0; i<4; i++)
		nums[i]=s[i]-'0';

	int result=0;
	int mask=0;
	while (mask<8) {
		result=nums[0];
		for (int i=0; (1<<i) < 8; i++) {
			if (1<<i&mask)
				result+=nums[i+1];
			else
				result-=nums[i+1];
		}
		if (result==7) break;
		mask++;
	}

	cout << nums[0];
	for (int i=0; (1<<i) < 8; i++) {
		if (nums[i+1]==0) {
			cout << "+0";
			continue;
		}
		if (1<<i&mask)
			cout << '+' << nums[i+1];
		else
			cout << -nums[i+1];
	}
	cout<<"=7"<<endl;
	return 0;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())
a_l = []
b_l = []

for i in range(1, a+1):
    if a % i == 0:
        a_l.append(i)

for i in range(1, b+1):
    if b % i == 0:
        b_l.append(i)

c_s = set(a_l) & set(b_l)
c_l = sorted(list(c_s), reverse=True)
print(c_l[k - 1])

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

int main() {
    string s; cin >> s;
    if(s[0]!='A'){
        cout << "WA" << endl;
        return 0;
    }    
    
    int pos = -1;
    for (int i = 2; i < s.size()-1; i++)
    {
        if(s[i]=='C'){
            pos = i;
        }
    }
    if(pos==-1){
        cout << "WA" << endl;
        return 0;
    }

    for (int i = 0; i < s.size(); i++)
    {
        if(!(('a' <= s[i] && 'z' >= s[i]) || i==0 || i==pos)){
            cout << "WA" << endl;
            return 0;
        }
    }
    
    cout << "AC" << endl;
    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n, m;
  int x[1000], d[1000];
  while (true) {
    int pos = 0;
    cin >> n >> m;
    if (n == 0) {
      return 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> x[i];
    }
    for (int i = 0; i < m; ++i) {
      cin >> d[i];
    }
    for (int i = 0; i < m; ++i) {
      pos += d[i];
      if (pos < n - 1) {
        pos += x[pos];
      }
      if (pos >= n - 1) {
        cout << i + 1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H, W;
	cin >> H >> W;
    vector<vector<int>> s(H,vector<int>(W));
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            char c;
            cin >> c;
            s[i][j]=(c=='.' ? 1 : 0);
        }
    } 

    vector<vector<vector<int>>> dp(4,vector<vector<int>>(H,vector<int>(W,0)));
    for(int i=0; i<H; ++i){
        dp[0][i][0]=s[i][0];
        for(int j=1; j<=W-1; ++j){
            if(s[i][j]==0) continue;
            dp[0][i][j] = dp[0][i][j-1]+1;
        }
    }
    for(int i=0; i<H; ++i){
        dp[1][i][W-1]=s[i][W-1];
        for(int j=W-2; j>=0; --j){
            if(s[i][j]==0) continue;
            dp[1][i][j] = dp[1][i][j+1]+1;
        }
    }
    for(int i=0; i<W; ++i){
        dp[2][0][i]=s[0][i];
        for(int j=1; j<=H-1; ++j){
            if(s[j][i]==0) continue;
            dp[2][j][i] = dp[2][j-1][i]+1;
        }
    }
    for(int i=0; i<W; ++i){
        dp[3][H-1][i]=s[H-1][i];
        for(int j=H-2; j>=0; --j){
            if(s[j][i]==0) continue;
            dp[3][j][i] = dp[3][j+1][i]+1;
        }
    }

    int ans=0;
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            ans = max(ans, dp[0][i][j]+dp[1][i][j]+dp[2][i][j]+dp[3][i][j]);
        }
    } 
	cout << ans-3 << endl;
}

Measured memory_bytes: 94464
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
	int x,y,z;
  cin>>x>>y;
  z =x*y;
  cout <<z<<endl;
	return 0;
}//どうして・・・(´･_･`)

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b,ll c){if(a==b)out(c);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
int main(){
    ll n,k;cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));
    reverse(all(v));
    ll sum=0;
    rep(i,n)sum+=v[i];
    ll x=(sum-1)/(4*k)+1;
    YesNo(v[k-1]>=x);
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int n,er[40],x,a[200005]; 
map<int,int> m;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	FOR(i,1,n){
		cin>>a[i];
		m[a[i]]++;
	}
	sort(a+1,a+n+1,greater<int>());
	er[0]=1;
	rep(i,1,40)er[i]=er[i-1]*2;
	int ans=0,t;
	FOR(i,1,n){
		if(!m[a[i]])continue;
		t=(*upper_bound(er,er+40,a[i]));
		t=t-a[i];
		if(m[t]){
			m[t]--;m[a[i]]--;
			if(m[t]>=0)ans++;
		}
	}
	cout<<ans;
	RE 0;
}



Measured memory_bytes: 26880
#include<iostream>
using namespace std;
int a[1<<17],n,c;
main()
{
	cin>>n;
	for(int i=0;i++<n;)cin>>a[i];
	for(int i=0;i++<n;)
	{
		if(a[i]==i)
		{
			c++;
			if(i<n&&a[i+1]==i+1)i++;
		}
	}
	cout<<c<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    vector<ll> h(N);
    FOR(i,0,N) cin>>h[i];
    ll h0=h[N-1];
    ll h1=h[N-2];
    bool f=true;
    
    FOR(i,0,N-1){
        //cout<<h0<<' '<<h1<<endl;
        if(h1>=h0+2) f=false;
        else if(h1==h0+1) h1--;
        h0=h1;
        if(i!=N-2)h1=h[N-3-i];
    }

    if(f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

using type = int;
using P = pair<type, type>;

struct Edge{
    int to, cost;
    Edge(int a, long long b){
        to = a;
        cost = b;
    }
};

class Dijkstra{
private:
    const type _INF = 100000000;
    int V; // 頂点数
    vector<type> d;
    vector<int> prev;
    vector<vector<Edge> > G;
public:
    Dijkstra(int v){
        V = v + 1;
        d.resize(V);
        G.resize(V);
        prev.resize(V);
    }

    void shortest_path(int s){
        priority_queue<P, vector<P>, greater<P>> que;
        d.assign(V, _INF);
        prev.assign(V, -1);
        d[s] = 0;
        que.push(P(0, s));
        while(que.size()){
            P p = que.top(); que.pop();
            int v = p.second;
            if(d[v] < p.first) continue;
            for(auto e : G[v]){
                if(d[v] + e.cost < d[e.to]){
                    d[e.to] = d[v] + e.cost;
                    prev[e.to] = v;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
    }
    
    void add_path(int from, int to, type cost){
        G[from].push_back(Edge(to, cost));
    }

    type get_cost(int t){
        return d[t];
    }

    bool enable_move(int t){
        return d[t] != _INF;
    }
    
    vector<int> get_path(int t){
        vector<int> path;
        for(; t != -1; t = prev[t])
            path.push_back(t);
        reverse(path.begin(), path.end());
        return path;
    }
};

int main(){
  int K;
  cin >> K;
  Dijkstra dij = Dijkstra(K);
  for(int i = 1; i < K; i++){
    dij.add_path(i, (i + 1) % K, 1);
    dij.add_path(i, (i * 10) % K, 0);
  }
  dij.shortest_path(1);

  cout << dij.get_cost(0) + 1 << endl;
  return 0;
}


Measured memory_bytes: 7164
//MISHON69
//DATE:6/22/2020
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n%2==0)
  cout<<fixed<<setprecision(10)<<((double)n/2)/n<<endl;
  else{
     double temp=(n/2)+1;
     cout<<fixed<<setprecision(10)<<temp/n<<endl;
  }
}  


Measured memory_bytes: 3656
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

int main(){

  int n;
  int a[100];

  llong res = 1;
  scanf("%d", &n);
  REP(i,n){
    scanf("%d", &a[i]);
    res *= 3;
  }

  llong minus = 1;;
  REP(i,n){
    if(a[i] % 2 == 0)
      minus *= 2;
  }

  printf("%lld\n", res - minus);
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
 
 
public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
	
		int N = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int[] v = new int[N];
		int[] w = new int[N];
		for(int i=0;i<N;i++){
			v[i] = Integer.parseInt(sc.next());
			w[i] = Integer.parseInt(sc.next());
		}
		
		int[][] dp = new int[N+1][W+1];
		for(int i=0; i<=W; i++){
			dp[0][i] = 0;
		}
		
		for(int i=0;i<N;i++){
			for(int j=0;j<=W; j++){
				if(j-w[i]>=0){
					dp[i+1][j] = Integer.max(dp[i][j], dp[i+1][j-w[i]] + v[i]);
				}else{
					dp[i+1][j] = dp[i][j];
				}
			}
		}
		
		
		System.out.println(dp[N][W]);
		
		sc.close();
	}
	
	
	
}


Measured memory_bytes: 31056
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
t=SI()
n=len(s)
for i in range(n):
    ans=s[i:]+s[:i]
    if ans==t:
        print("Yes")
        sys.exit()
print("No")
#print(ans)

Measured memory_bytes: 3316
#include <stdio.h>

int main() {
  int a=0, e=0, k=0;
  scanf("%d\n%*d\n%*d\n%*d\n%d\n%d", &a, &e, &k);
  if (e-a > k) printf(":(\n");
  else printf("Yay!\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false
	
int main(void){
    ll X;
    cin >> X;
    ll K = gcd(360,X);
    K = 360/K;
    
    cout << K << endl;
    
    return 0;
}



Measured memory_bytes: 3592
n = int(input())
nums = [0] * 100001
A = [int(i) for i in input().split()]
for a in A:
    nums[a] += 1
q = int(input())
B = [None] * q
C = [None] * q
for i in range(q):
    B[i], C[i] = (int(i) for i in input().split())

ans = 0
for i in range(100001):
    ans += i * nums[i]
      
for i in range(q):
    if nums[B[i]] == 0:
        print(ans)
        continue
    t = nums[B[i]]
    ans += (C[i]-B[i])*t
    nums[B[i]] = 0
    nums[C[i]] += t
    print(ans)

Measured memory_bytes: 22008
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		boolean flag = false;
		for (int i = A; i <= B; i++) {
			if (i%K == 0) {
				flag = true;
				break;
			}
		}
		if (flag)
			System.out.println("OK");
		else
			System.out.println("NG");
	}
}

Measured memory_bytes: 35756
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    set<int> res;
    REP2( i, 1, N + 1 )
    {
        int sum{}, dig{}, num = i;
        while( num )
        {
            dig = num % 10;
            sum += dig;
            num = num / 10;
        }
        if( sum >= A && sum <= B )
        {
            res.emplace( i );
        }
    }
    int ans{};
    for( auto &x : res )
    {
        ans += x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
def gcd(x, y):
    x, y = max(x, y), min(x, y)
    if y == 0:
        return x
    return gcd(y, x % y)


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

l = [0]*n
r = [0] * n
for i in range(n):
    if i == 0:
        l[i] = a[i]
        continue
    l[i] = gcd(a[i], l[i-1])

for i in range(n - 1, -1, -1):
    if i == n - 1:
        r[i] = a[i]
        continue
    r[i] = gcd(a[i], r[i+1])

l = [0] + l[:-1]
r = r[1:] + [0]

ans = 0
for x, y in zip(l, r):
    ans = max(ans, gcd(x, y))
print(ans)


Measured memory_bytes: 14332
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M, Q := nextInt(), nextInt(), nextInt()
	L, R, p, q := []int{}, []int{}, []int{}, []int{}

	for i := 0; i < M; i++ {
		L = append(L, nextInt())
		R = append(R, nextInt())
	}

	for i := 0; i < Q; i++ {
		p = append(p, nextInt())
		q = append(q, nextInt())
	}

	//fmt.Printf("%d\n", ABC106D(N, L, R, p, q))
	res := ABC106D(N, L, R, p, q)
	for _, r := range res {
		fmt.Println(r)
	}
}

// ABC106D ...
func ABC106D(N int, L, R, p, q []int) []int {
	res := []int{}

	// init
	sumtable := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		sumtable[i] = make([]int, N+1)
	}
	for i := 0; i < len(L); i++ {
		sumtable[L[i]][R[i]]++
	}

	// cum sum
	for i := 1; i < N+1; i++ {
		for j := 1; j < N+1; j++ {
			sumtable[i][j] += sumtable[i-1][j]
			sumtable[i][j] += sumtable[i][j-1]
			sumtable[i][j] -= sumtable[i-1][j-1]
		}
	}

	// query
	for i := 0; i < len(p); i++ {
		tmp := sumtable[q[i]][q[i]] - sumtable[q[i]][p[i]-1] - sumtable[p[i]-1][q[i]] + sumtable[p[i]-1][p[i]-1]
		res = append(res, tmp)
	}

	return res
}


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

typedef long long ll;

const int MAXN = 4e2 + 5;

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

int N, M;
char mat[MAXN][MAXN];
bool bio[MAXN][MAXN];

void load() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++)
		scanf("%s", mat[i]);
}

void dfs(int x, int y, int &b, int &w) {
	bio[x][y] = true;
	if (mat[x][y] == '#')
		b++;
	else
		w++; 
	for (int i = 0; i < 4; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx < 0 || ny < 0 || nx >= N || ny >= M)
			continue;
		if (!bio[nx][ny] && mat[nx][ny] != mat[x][y])
			dfs(nx, ny, b, w);
	}
}

ll solve() {
	ll sol = 0;
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++)
			if (!bio[i][j]) {
				int black = 0, white = 0;
				dfs(i, j, black, white);
				sol += (ll)black * white;
			}
	return sol;
}

int main() {
	load();
	printf("%lld\n", solve());
	return 0;
}

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


int main()
{
 string S,T;
 cin>>S>>T;
 
  T.pop_back();
  if(S==T) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main()
{
	string S;
	cin >> S;
	if (S[0] == S[1] && S[1] == S[2]) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 15
using namespace std;
int n,in[M];
int main()
{
    while (~scanf("%d", &n)) {
        REP(i,1,n) scanf("%d", &in[i]);
        sort(in+1, in+n+1);
        if (accumulate(in+1, in+n, 0) > in[n]) {
            puts("Yes");
        } else {
            puts("No");
        }
    }
    return 0;
}


Measured memory_bytes: 256