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

using namespace std;

#define si(a) scanf("%d",&a)
#define MOD 1000000007
#define MAX 200005

long long mul_inv(long long a, long long b)
{
	long long b0 = b, t, q;
	long long x0 = 0, x1 = 1;
	if (b == 1) return 1;
	while (a > 1) {
		q = a / b;
		t = b, b = a % b, a = t;
		t = x0, x0 = x1 - q * x0, x1 = t;
	}
	if (x1 < 0) x1 += b0;
	return x1;
}

int mod_mul(long long a,long long b)
{
    return (a*b)%MOD;;
}

int mod_div(long long a,long long b)
{
    return mod_mul(a,mul_inv(b,MOD));
}

int mod_plus(int a,int b)
{
    return (a+b)%MOD;
}

int mod_min(int a,int b)
{
    return (a-b+MOD)%MOD;
}


int fact[MAX];
int cnt[MAX],ans[MAX];

int ncr(int n,int r)
{
    return mod_div(fact[n],mod_mul(fact[r],fact[n-r]));
}

int main()
{
    //freopen("input.txt","r",stdin);
    int i,n,ex;
    si(n);
    memset(cnt,-1,sizeof(cnt));
    fact[0]=1;
    for(i=1;i<MAX;i++)fact[i]=mod_mul(fact[i-1],i);
    for(i=0;i<=n;i++){
        int x;
        si(x);
        if(cnt[x]!=-1)
            ex=cnt[x]+(n-i);
        cnt[x]=i;
    }
    for(i=1;i<=n+1;i++)
        ans[i]=ncr(n+1,i);
    for(i=0;i<=ex;i++)
        ans[i+1]=mod_min(ans[i+1],ncr(ex,i));
    for(i=1;i<=n+1;i++)printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<stack>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
int dp[101000];
int w[110];
int val[110];
int main()
{
	int n,wi;
	cin>>n>>wi;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>val[i];
		sum+=val[i];
	}
	for(int i=0;i<=sum+5;i++)
	{
		dp[i]=0x3f3f3f3f;
	}
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=sum;j>=val[i];j--)
			dp[j]=min(dp[j],dp[j-val[i]]+w[i]);
	}
	for(int i=sum;i>=0;i--)
	{
		if(dp[i]<=wi)
		{
			cout<<i;
			return 0;
		}
	}
	return 0;
}


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

const int mod = 1000000007, inv2 = 500000004;

long long dp[110][10010];

void add(long long &a, long long b){
	a = (a + b) % mod; 
}

long long power(int a, int b){
	if (!b) return 1;
	long long tmp = power(a, b >> 1);
	return b & 1 ? tmp * tmp % mod * a % mod : tmp * tmp % mod;
}

int main(){
	int n, K; scanf("%d%d", &n, &K);
	dp[n - 1][0] = K == n ? K : K + 1;
	dp[n - 1][1] = K == n ? 1 : 0;
	for (int i = n - 1; i >= 1; i--){
		for (int j = 0; j <= 10000; j++){
			if (!dp[i][j]) continue;
			for (int k = 0; k <= min(i, K); k++){
				int cnt = (k + j) / i, last = (k + j) % i;
				add(dp[i - 1][j + cnt], dp[i][j]);
			}
			for (int k = i + 1; k <= K; k++){
				add(dp[i - 1][j], dp[i][j]);
			}
		}
	}
	long long ans = 1ll * n * power(K + 1, n - 1) % mod * K % mod * (K + 1) % mod * inv2 % mod;
	for (int i = 0; i <= 10000; i++){
		ans = ((ans - i * dp[0][i]) % mod + mod) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N[4];
  for(int i=0;i<4;i++) cin>>N[i];
  sort(N,N+4);
  if((N[0]==1&&N[1]==4)&&(N[2]==7&&N[3]==9)) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



Measured memory_bytes: 256
let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let x = Array.make (n-1) 0 in
  x.(0) <- a.(0);
  for i = 1 to n - 2 do
    x.(i) <- x.(i-1) + a.(i);
  done;
  let y = Array.make (n - 1) 0 in
  y.(0) <- a.(n-1);
  for i = 1 to n - 2 do
    y.(i) <- y.(i-1) + a.(n-1-i);
  done;
  let ans = ref max_int in
  for i = 0 to n - 2 do
    let t = abs (x.(i) - y.(n-2-i)) in
    if t < !ans then ans := t;
  done;
  Printf.printf "%d\n" !ans

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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  rep(i, S.size()) {
    rep(j, i+1) {
      bool flag = true;
      for(int k=j; k<=i; k++) {
        if(!(S[k] == 'A' || S[k] == 'C' || S[k] == 'G' || S[k] == 'T')) flag=false;
      }
      if(flag) ans = max(ans, i-j+1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3564
#include <iostream>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	n%=10;
	if(n==3)cout<<"bon\n";
	else if(n==0||n==1||n==6||n==8)cout<<"pon\n";
	else cout<<"hon\n";
	
	return 0;
}

Measured memory_bytes: 3132
//#define DEB1 //input from input.txt
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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




/*
constant values
*/

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

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    if(N%2==1){
        cout << "No" << endl;
        return;
    }
    int a;
    a = N/2;
    string s1 = S.substr(0,a);
    string s2 = S.substr(a,a);
    cerr << s2 << endl;
    REP(i,a){
        if(s1[i]!=s2[i]){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
    return;
}



// ----------------------------------------------
int main(){

#ifdef DEB1
    cout << "DEBUG MODE"  << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf()); //for debug
#endif

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int count5 = 0, count7 = 0;
	if (a == 5) {
		count5++;
	}
	if (a == 7) {
		count7++;
	}
	if (b == 5) {
		count5++;
	}
	if (b == 7) {
		count7++;
	}	
	if (c == 5) {
		count5++;
	}
	if (c == 7) {
		count7++;
	}
	if (count5 == 2 && count7 == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
from collections import deque
from itertools import product

INF = 1001001001
dr = [(1, 0), (-1, 0), (0, 1), (0, -1)]

H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

ans = 0
for i, j in product(range(H), range(W)):
    if S[i][j] == '#':
        continue
    d = [[INF] * W for i in range(H)]
    d[i][j] = 0
    q = deque([(i, j)])
    while len(q) > 0:
        x, y = q.popleft()
        for dx, dy in dr:
            nx, ny = x + dx, y + dy
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] != '#' and d[nx][ny] == INF:
                d[nx][ny] = d[x][y] + 1
                ans = max(d[nx][ny], ans)
                q.append((nx, ny))
print(ans)


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

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main() {
  int a1, a2, a3;

  scanf("%d%d%d", &a1, &a2, &a3);

  if (a1 + a2 + a3 > 21) {
    printf("bust\n");
  } else {
    printf("win\n");
  }

  return 0;
}

Measured memory_bytes: 128
fun main(args:Array<String>) {
    val (a,b) = readLine()!!.split(" ").map { it.toInt() }
    when {
        a>b -> println(if(b==1)"Bob" else "Alice")
        a<b -> println(if(a==1)"Alice" else "Bob")
        else-> println("Draw")
    }

}

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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int a=fsc.nextInt();
        int b=fsc.nextInt();
        fsc.close();
        String ans="";
        if(a<b){
            for(int i=0;i<b;i++){
                ans+=Integer.toString(a);
            }
        } else{
            for(int i=0;i<a;i++){
                ans+=Integer.toString(b);
            }
        }
        System.out.println(ans);
    }
    

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


Measured memory_bytes: 21332
#include<iostream>
#include <algorithm>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()

using namespace std;

int main(){
  int N;
  int nx = 0;
  int ny = 0;
  int nt = 0;
  int t[100000],x[100000],y[100000],margin;
  bool judge = true;
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> t[i] >> x[i] >> y[i];
  }
  for(int i=0;i<N;++i){
    margin = abs(nt-t[i])-(abs(nx-x[i])+abs(ny-y[i]));
    if(margin >=0 && margin%2==0){
      nx = x[i];
      ny = y[i];
      nt = t[i];
    }else{
      judge = false;
      break;
    }
  }

  if(judge){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
import Data.Maybe (isJust, fromJust)

update [] _ = Nothing
update (h:hs) (x:xs)
  | h == x = (x:) <$> update hs xs
  | h > x  = Just $ grow (h:hs) (x:xs)
  where
    grow [] _ = []
    grow (h:hs) (x:xs)
      | h == x = x:xs
      | h > x = (x + 1) : grow hs xs

solv hs = length . takeWhile isJust . iterate (update hs.fromJust) $ update hs [0,0..]

main = do
  getLine
  hs <- map read . words <$> getLine :: IO [Int]
  print $ solv hs 



Measured memory_bytes: 1020
n = int(input())
data = dict()
name = set()
for i in range(n):
    s, p = input().split()
    p = int(p)
    if s in data:
        data[s].append([p, i + 1])
    else:
        data[s] = []
        data[s].append([p, i + 1])
    name.add(s)
name = list(name)
name.sort()
for n in name:
    data[n].sort(reverse = True)
    for i in data[n]:
        print(i[1])




Measured memory_bytes: 38512
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

int N;
inline void solve(){
  IN(N);
  OUT((N*2/__gcd(N,2)));
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
int main(){
  string s;
  cin >> s;
  int l = s.length();
  int res = 754;
  for (int i = 0; i < l-2; i++) {
    int X = abs(100* (s[i] - '0') + 10* (s[i+1] - '0')+ s[i+2] - '0' - 753);
  
    res = min(res, X);
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum=0;
    
    for(int i=0; cin>>ch; i++){
        if(ch=='\\') S1.push(i);
        else if (ch=='/' && S1.size()>0){
            int j =S1.top(); S1.pop();
            sum+=i-j;
            int a=i-j;
            while(S2.size()>0&&S2.top().first>j){
                a += S2.top().second; S2.pop();
                
            }
            S2.push(make_pair(j, a));
        }
    }
    
    vector<int> ans;
    while (S2.size()>0) { ans.push_back(S2.top().second); S2.pop(); }
    reverse(ans.begin(), ans.end());
    cout<<sum<<endl;
    cout<<ans.size();
    for(int i=0; i<ans.size(); i++){
        cout<<" ";
        cout<<ans[i];
    }
    
    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 3236
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int gcd(int a, int b)
{
	if (b == 0)	return a;
	return gcd(b, a % b);
}
int main()
{
	int n;
	cin >> n;
	ll ans = 0;
	rep(i, n + 1) {
		if (i % 3 != 0 && i % 5 != 0)	ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin>>s;
  vector<int> X(1000000);
  X.at(0) = s;
  for(int i=0;i<10000;i++){
    if(X.at(i)%2==0){
      X.at(i+1)=X.at(i)/2;
    }
    else{
      X.at(i+1)=3*X.at(i)+1;
    }
  }
  bool ok = false;
  for(int i=0;i<10000;i++){
    for(int j=i+1;j<10000;j++){
      if(X.at(i)==X.at(j)){
        cout<<j+1<<endl;
        ok = true;
        break;
      }
    }
    if(ok){
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {

			String cards = scan.next();

			if (cards.equals("-")) {
				break;
			}
			//System.out.println("cards = " + cards);

			int m = scan.nextInt();
			//System.out.println("m = " + m);

			for (int i = 0; i < m; i++) {
				int h = scan.nextInt();
				//System.out.println("h = " + h);

				cards = (cards.substring(h) + cards.substring(0, h));
				//System.out.println(cards);
			}

			sb.append(cards + "\n");
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 26208
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    int N;
    double last;


    //入力
    cin >> N;

    vector<int> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end() );

    last=v[0];
    for(int i=1; i<N; i++) {
        last = (last+v[i]) / 2;
    }

    cout << fixed << setprecision(20) << last << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007

struct info
{
	string str;
	int x;
	int idx;
};

bool Comp(info a, info b)
{
	if(a.str!=b.str)
		return a.str<b.str;
	else
		return a.x>b.x;
}

int main()
{
	fast;
	ll n,val;
	cin>>n;
	info arr[n+5];
	string char_arr;
	for(int i=0;i<n;i++)
	{
		cin>>char_arr;
		cin>>val;
		arr[i].str=char_arr;
		arr[i].x=val;
		arr[i].idx=i+1;
	}
	sort(arr,arr+n,Comp);
	for(int i=0;i<n;i++)
		cout<<arr[i].idx<<"\n";
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        d: i64,
        a: [i64; n],
    }
    let mut g = 0;
    for a in a {
        let b = (a - 1) % (d + 1);
        g ^= b;
    }
    puts!("{}\n", if g == 0 { "Second" } else { "First" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}



Measured memory_bytes: 11124
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

struct UnionFindTree {
    size_t n;
    vector<int> tree;
    UnionFindTree(size_t n): n(n) {
        tree = vector<int>(n, -1);
    }
    int find_root(size_t v) {
        if (tree[v] < 0) return v;
        return tree[v] = find_root(tree[v]);
    }
    bool unite(size_t x, size_t y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return false;
        if (rank(x) < rank(y)) swap(x, y);
        tree[x] += tree[y];
        tree[y] = x;
        return true;
    }
    bool has_same_root(size_t x, size_t y) {
        return find_root(x) == find_root(y);
    }
    size_t rank(size_t v) {
        return -tree[find_root(v)];
    }
};

pair<Weight, Edges> minimum_spanning_forest(const Graph &g) {
    /* Kruskal */
    size_t V=g.size();
    UnionFindTree tree(V);
    gp_queue<Edge> q;
    for (size_t u=0; u<V; ++u)
        for (const Edge &e: g[u])
            q.push(e);

    Weight total=0;
    Edges F;
    while ((F.size() < V-1) && (!q.empty())) {
        Edge e=q.top(); q.pop();
        if (tree.unite(e.src, e.dst)) {
            F.push_back(e);
            total += e.weight;
        }
    }

    return make_pair(total, F);
}

int main() {
    size_t V, E;
    scanf("%zu %zu", &V, &E);

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight w;
        scanf("%zu %zu %lld", &s, &t, &w);

        join(g, s, t, w);
    }

    printf("%lld\n", minimum_spanning_forest(g).first);
    return 0;
}

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

vector<int> FordFulkerson_dfs_sub(
    const vector<map<int, int>>& graph, // source, (target, capacity)
    int source, int target, set<int>& prev)
{
    if(source==target) return vector<int>{source};
    for(auto v : graph.at(source)){
        if(v.second == 0) continue; 
        if(prev.count(v.first) > 0) continue;
        prev.insert(source);
        auto ret = FordFulkerson_dfs_sub(graph, v.first, target, prev);
        if(ret.size() != 0){
            ret.push_back(source);
            return ret;
        }
    }
    return vector<int>();
}

vector<int> FordFulkerson_dfs(
    const vector<map<int, int>>& graph, // source, (target, capacity)
    int source, int target)
{
    auto s = set<int>();
    auto ret = FordFulkerson_dfs_sub(graph, source, target, s);
    reverse(ret.begin(), ret.end());
    return ret;
}

// Graph: Directed, no loop
// Complexity: E * (max flow)
vector<map<int, int>> FordFulkerson(
    vector<map<int, int>> graph, // source, (target, capacity)
    int s, int t)
{
    const int N = graph.size();
    auto res = graph;

    // Add inverted edges
    for(int i=0; i<N; i++){
        for(auto e : res[i]){
            auto v = e.first;
            graph[v][i] = -0;
        }
    }

    while(true){
        auto path = FordFulkerson_dfs(graph, s, t);
        if(path.size()==0) break;
        int c_min = numeric_limits<int>::max();
        for(int i=0; i<path.size()-1; i++){
            auto u = path[i];
            auto v = path[i+1];
            c_min = min(c_min, graph[u][v]);
        }
        if(c_min == 0) break;
        for(int i=0; i<path.size()-1; i++){
            auto u = path[i];
            auto v = path[i+1];
            graph[u][v] -= c_min;
            graph[v][u] += c_min;
        }
    }
    for(int i=0; i<res.size(); i++){
        for(auto v : res[i]){
            res[i][v.first] = graph[v.first][i];
        }
    }
    return res;
}

vector<array<int, 2>> MaximumMatching(
    vector<vector<int>> graph // source, target
){
    const int N = graph.size();
    vector<map<int, int>> graph2(2 + 2 * N);
    for(int i=0;i<N;i++){
        graph2[2*N][i] = 1;
        graph2[N+i][2*N+1] = 1;
        for(auto v : graph[i]){
            graph2[i][v + N] = 1;
        }
    }
    auto ret = FordFulkerson(graph2, 2*N, 2*N+1);
    vector<array<int, 2>> res;
    for(int i=0;i<N;i++){
        for(auto m : ret[i]){
            if(m.second == 0) continue;
            res.push_back(array<int, 2>{i, m.first});
        }
    }

    return res;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    vector<int> D(N);
    for(int i=0;i<N;i++) cin >> A[i] >> B[i];
    for(int i=0;i<N;i++) cin >> C[i] >> D[i];
    vector<vector<int>> graph(N);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(A[i] < C[j] && B[i] < D[j]){
                graph[i].push_back(j);
            }
        }
    }
    auto ret = MaximumMatching(graph);
    cout << ret.size() << endl;

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    ll x; cin>>x;
    int y = 0; ll a = 100;
    while (a < x) {
        y++; a += a / 100;
    }
    cout << y << endl;

    return 0;
}


Measured memory_bytes: 3600
import sys
sys.setrecursionlimit(10**8)
def solve(n,pos):
    global data,helper
    if(n==-1):
        return 0
    if(helper[n][pos]!=-1):
        return helper[n][pos]
    if(pos==0):
        helper[n][pos]=max(data[n][1]+solve(n-1,1),data[n][2]+solve(n-1,2))
        return helper[n][pos]
    elif(pos==1):
        helper[n][pos] = max(data[n][0]+solve(n-1,0),data[n][2]+solve(n-1,2))
        return helper[n][pos]
    else:
        helper[n][pos] = max(data[n][1]+solve(n-1,1),data[n][0]+solve(n-1,0))
        return helper[n][pos]
n=int(input())
data=[]
helper=[[-1 for y in range(3)] for x in range(n)]
for _ in range(n):
    temp=[int(x) for x in input().split()]
    data.append(temp)
t1=data[-1][0]+solve(n-2,0)
t2=data[-1][1]+solve(n-2,1)
t3=data[-1][2]+solve(n-2,2)
print(max(t1,t2,t3))

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

int main()
{  
    int n;
    map<string,int>cnt;
    ll ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){ 
        string s=to_string(i);
        string t;
        t+=s[0];
        t+=s[s.size()-1];
        cnt[t]++;
    } 
    for(auto i:cnt){ 
        string s=i.first;
        swap(s[0],s[1]);
        ans+=(long long)i.second*cnt[s];
    } 
    cout<<ans<<'\n';
        

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  bool ans = false;
  int cnt = 0;
  REP(i, N-1){
    if(A[i]+A[i+1] >= L){
      ans = true;
      cnt = i+1;
    }
  }

  if(!ans){
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;
  FOR(i, 1, cnt) cout << i << endl;
  RFOR(i, cnt, N) cout << i << endl;

  return 0;
}

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

int main() {
	long long x, y;
	cin >> x >> y;
	long long  a = 2 * x;
	long long ans = 1;
	while (a <= y) {
		a = 2 * a;
		ans += 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int N_MAX = 100001;
typedef pair<int,int> P;
int main()
{
  int n,i,j=1,xn,xb=0,k,kk,k1=0,k2=0;
  int a[N_MAX],x[N_MAX];
  bool u[N_MAX];
  priority_queue<P> q;
  cin >> n;
  if(n==2){
    cout << "-1" << endl;
    return 0;
  }
  fill(x+1,x+n+1,0);
  fill(u+1,u+n+1,0);
  for(i=1;i<=n;i++){
    cin >> a[i];
    x[a[i]]++;
  }
  for(i=1;i<=n;i++)
    q.push(P(x[i],i));
  for(i=1;i<=n;i++){
    xn=q.top().first;
    k=q.top().second;
    while(u[k]==1||xn>=n-i&&x[k]<xn){
      q.pop();
      if(u[k]==0)
        q.push(P(x[k],k));
      xn=q.top().first;
      k=q.top().second;
    }
    if(xn<n-i){
      while(u[j]==1) j++;
      k=j;
      if(xb==k){
        k++;
        while(u[k]==1) k++;
      }
    }
    if(i==n-2){
      for(kk=1;kk<=n;kk++)
        if(k1==0&&u[kk]==0&&kk!=k) k1=kk;
        else if(u[kk]==0&&kk!=k) k2=kk;
      if(a[k1]==k2&&a[k2]==k1){
        k=k1;
        if(xb==k) k=k2;
      }
    }
    cout << k << " ";
    u[k]=1;
    x[a[k]]--;
    xb=a[k];
  }
  cout << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define chmax(a,b) a=max(a,b)

const int V = 1000;
const int C = 310;
const int INF = 830252521;
int dp[2][V][V];

int main(){
  int n;
  int x,y;
  cin>>n>>x>>y;
  REP(i,V)REP(j,V)dp[0][i][j]=dp[1][i][j]=-INF;
  dp[0][C+x][C+y] = 0;
  REP(i,n){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    REP(uma,V)REP(fuga,V)dp[1][uma][fuga]=dp[0][uma][fuga];
    REP(uma,V)REP(fuga,V){
      chmax(dp[1][uma-a][fuga+b],dp[0][uma][fuga]);
      chmax(dp[1][uma][fuga-c],dp[0][uma][fuga]+d);
    }
    swap(dp[0],dp[1]);
  }
  int res = 0;
  FOR(uma,C,V)FOR(fuga,C,V)chmax(res,dp[0][uma][fuga]);
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 8976
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright  : @Huki_Hara
# Created    : 2015-03-05

n=int(input())

for _ in range(n):
    a=int(input())
    b=int(input())
    sum=a+b
    if len(str(sum)) > 80:
        print("overflow")
    else:
        print(sum)

Measured memory_bytes: 6724
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int H, W;
	char a[1010][1010];
	int dp[1010][1010] = { 0 };

	for (int i = 0; i < 1010; i++)
	{
		for (int j = 0; j < 1010; j++)
		{
			a[i][j] = '#';
		}
	}

	cin >> H >> W;
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			cin >> a[i][j];
		}
	}

	dp[1][1] = 1;
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			if (a[i - 1][j] == '.') {
				dp[i][j] += dp[i - 1][j];
			}
			if (a[i][j - 1] == '.') {
				dp[i][j] += dp[i][j - 1];
				dp[i][j] %= 1000000007;
			}

		}
	}

	cout << dp[H][W] << endl;

	return 0;
}



Measured memory_bytes: 9216
#include<iostream>
#include<vector>
using namespace std;
bool hv[123];
string s;
int main(){
	ios::sync_with_stdio(false);
	cin >> s;
	if(s.size()<26){
		for(int i=0; i<s.size() ;i++) hv[s[i]]=true;
		cout << s;
		for(char i='a'; i<='z' ;i++){
			if(!hv[i]){
				cout << i;
				return 0;
			}
		}
	}
	else{
		vector<char>v;
		v.push_back(s[25]);
		for(int i=24; i>=0 ;i--){
			if(s[i]>v.back()) v.push_back(s[i]);
			else break;
		}
		int cur=25-(int)v.size();
		if(cur==-1){
			cout << -1 << endl;
			return 0;
		}
		for(int i=0; i<cur ;i++) cout << s[i];
		for(int i=0; i<v.size() ;i++){
			if(v[i]>s[cur]){
				cout << v[i];
				return 0;
			}
		}
		
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
string n;
int s=0;
int t[1000005];
int main()
{
	cin >>n;
	int len = n.size() ;
	for(int i=0;i<len;i++){
		t[i]=n[len-1-i]-'0';	
	}
	for(int i=0;i<len+1;i++) {
		if(t[i]<5) s+=t[i];
		else if(t[i]>5) {
			s+=10-t[i]; 
			t[i+1]++;
		}else{
			if(t[i+1]>=5)  t[i+1]++,s+=5;
			else s+=5;
		}
	}
	cout << s <<endl;
	return 0;
}




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

int main(){
  long long n,i,j,ans=0,cn=0,ret;
  cin >> n;
  long long a[n];
  for(i=0;i<n;i++)cin >> a[i];
  //偶数を正とする
  for(i=0;i<n;i++){
    if(i%2==0){
      if(a[i]+ans<=0){
        cn+=-1*(a[i]+ans)+1;
        ans=1;
      }else ans = a[i]+ans;
    }else{
      if(a[i]+ans>=0){
        cn+=a[i]+ans+1;
        ans=-1;
      }else ans = a[i]+ans;
    }
  }
  ret = cn;
  cn = ans = 0;
  //奇数が正
  for(i=0;i<n;i++){
    if(i%2==0){
      if(a[i]+ans>=0){
        cn+=a[i]+ans+1;
        ans=-1;
      }else ans = a[i]+ans;
    }else{
      if(a[i]+ans<=0){
        cn+=-1*(a[i]+ans)+1;
        ans=1;
      }else ans = a[i]+ans;
    }
  }
  cout << min(ret,cn) << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll n;
    cin >> n;
    vector<ll> t(n);
    ll sum = 0;
    rep(i, n){
        cin >> t[i];
        sum += t[i];
    }
    ll m;
    cin >> m;
    vector<ll> p(m), x(m);
    rep(i, m){
        cin >> p[i] >> x[i];
    }
    rep(i, m){
        ll tmp = sum - t[p[i]-1] + x[i];
        cout << tmp << endl;
    }
}

Measured memory_bytes: 256
class dice:
    men = [0] * 7
    def __init__(self, li):
        self.men = [0] + li
    def move0(self, a, b, c, d):
        self.men[a], self.men[b], self.men[c], self.men[d] = self.men[b], self.men[c], self.men[d], self.men[a]
    def move(self, h):
        if h == "N":
            self.move0(1, 2, 6, 5)
        elif h == "S":
            self.move0(1, 5, 6, 2)
        elif h == "W":
            self.move0(1, 3, 6, 4)
        elif h == "E":
            self.move0(1, 4, 6, 3)
    def move2(self, a, b):
        if self.men[1] != a:
            for i, ss in [(2, "N"), (3, "W"), (4, "E"), (5, "S"), (6, "NN")]:
                if self.men[i] == a:
                    for s in ss:
                        self.move(s)
                    break
        if self.men[2] != b:
            if b == self.men[3]:
                self.move0(2, 3, 5, 4)
            elif b == self.men[4]:
                self.move0(2, 4, 5, 3)
            else:
                self.men[2], self.men[5], self.men[3], self.men[4] = self.men[5], self.men[2], self.men[4], self.men[3]
saikoro = dice(list(map(int, input().split())))
for _ in range(int(input())):
    saikoro.move2(*map(int, input().split()))
    print(saikoro.men[3])



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

int main(){
    int n;
    cin >> n;
    ll ans = 0;

    for (int i =1; i <= n; ++i){
        if (i%3 == 0) continue;
        if (i%5 == 0) continue;

        ans += i;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include<iostream>
#include<vector>
#include<cmath>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#define INF 0x3f3f3f3f
#define MAXN 1e16
#define DEBUG 0

using namespace std;
typedef long long ll;

string a,b;
int main()
{
    #if DEBUG
    freopen("in.txt","r",stdin);
    #endif // DEBUG
    cin>>a>>b;

    int ok=0;
    for(int i=0;i<a.length();i++)
    {
        if(a!=b)
        {
            string tem=b.substr(0,1);

            b.erase(b.begin());
            b=b+tem;
        }
        else {ok=1;printf("Yes");break;}
    }

    if(ok==0) printf("No");
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    long A,B,C,D;
    cin >>A>>B>>C>>D;
    while(A>0 && C>0){
        C -= B;
        if(C > 0){
            A -= D;
        }else{
            break;
        }
    }
    if(A>0){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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


int main() {
	LL n;
	cin>>n;
	LL a[n];
	for(LL i=0;i<n;i++){
	    cin>>a[i];
	}
	bool f=true;
	for(LL i=n-1;i>=1;i--){
	    if(a[i]>=a[i-1]){
	        continue;
	    }
	    else{
	        if(abs(a[i-1]-a[i])==1){
	            a[i-1]--;
	        }
	        else{
	            f=false;
	            break;
	        }
	    }
	}
	if(f){
	    cout<<"Yes"<<endl;
	}
	else{
	    cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
// AtCoder Grand Contest 017
// A - Biscuits

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;


int N, P;

int main() {

    bool is_all_even = true;
    int a;
    ll ans;

    cin >> N >> P;
    for (int i = 0; i < N; i++) {
        cin >> a;
        is_all_even = is_all_even && (a % 2 == 0);
    }

    if (is_all_even) {
        ans = (P % 2 == 0 ? (1LL << N) : 0LL);
    } else {
        ans = 1LL << (N - 1);
    }

    cout << ans << endl;

    return 0;

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
constexpr int MAX = 1e6;
constexpr int NIL = -1;
int n;
vector<vi> G(MAX);
vi color(MAX, NIL), S;
inline void dfs(int r, int c) {
	S.eb(r);
	color[r] = c;
	int u, v;
	while(!S.empty()) {
		u = S.back(); S.pop_back();
		rep(i, 0, len(G[u])) {
			v = G[u][i];
			if(color[v] == NIL) {
				color[v] = c;
				S.eb(v);
			}
		}
	}
}
inline void assignColor() {
	int id = 0;
	rep(u, 0, n) {
		if(color[u] == NIL) dfs(u, ++id);
	}
}
int main() {
	int m;
	cin >> n >> m;
	int s, t;
	rep(i, 0, m) {
		cin >> s >> t;
		G[s].eb(t);
		G[t].eb(s);
	}
	assignColor();
	int q; cin >> q;
	rep(i, 0, q) {
		cin >> s >> t;
		P(color[s] == color[t] ? "yes" : "no");
	}
	return 0;
}

Measured memory_bytes: 33232
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>

typedef long long LL;
const LL Infll = 0x3f3f3f3f3f3f3f3f;

int N, Ans;
std::map<std::pair<LL, LL>, std::pair<int, int>> mp;

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) {
		LL x, y = 1, z = 1;
		scanf("%lld", &x);
		for (int j = 2; j <= 2154; ++j) if (x % j == 0) {
			int c = 0, d = 0;
			while (x % j == 0) x /= j, ++c, d += 2;
			c %= 3, d %= 3;
			while (c) y *= j, --c;
			while (d) z = j <= Infll / z ? z * j : Infll + 1, --d;
		}
		y *= x;
		LL v = sqrt(x);
		while (v * v <= x) ++v;
		while (v * v > x) --v;
		if (v * v == x) z = v <= Infll / z ? z * v : Infll + 1;
		else if (x <= 100000) z = x * x <= Infll / z ? z * x * x : Infll + 1;
		else z = Infll;
		if (y == 1) Ans = 1;
		else if (y <= z) ++mp[{y, z}].first;
		else ++mp[{z, y}].second;
	}
	for (auto p : mp) Ans += std::max(p.second.first, p.second.second);
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 6528
def insertionSort(arr,step):
    count = 0
    for i in range(step, len(arr)):
        j = i
        while j >= step and arr[j] < arr[j-step]:
            count += 1
            t = arr[j]
            arr[j] = arr[j-step]
            arr[j-step] = t
            j -= step
    return count
 
def shellSort(arr):
    gaps = [776591, 345152, 153401, 68178, 30301, 13467, 5985, 2660, 1182, 525, 233, 103, 46, 20, 9, 4, 1]
    m = 0
    count = 0
    for step in gaps:
        if step > len(arr):
            continue
        m += 1
        count += insertionSort(arr, step)
    print(m)
    print(" ".join(map(str, gaps[len(gaps)-m:])))
    print(count)
    for num in arr:
        print(num)
 
arr = list()
for _ in range(int(input())):
    arr.append(int(input()))
shellSort(arr)


Measured memory_bytes: 45508
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n, k;
  cin>>n>>k;
  vector<int> cnt(n, 0);
  REP(_, k){
    int d;
    cin>>d;
    REP(_, d){
      int a;
      cin>>a;
      a--;
      cnt[a]++;
    }
  }
  int ans = 0;
  REP(i, n) if(cnt[i] == 0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
n, q = map(int, input().split())
s = input()
t = [0] * (n + 1)

for i in range(n):
    m = 0
    if s[i:i+2] == 'AC':
        m = 1
    t[i + 1] = t[i] + m

for _ in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])


Measured memory_bytes: 12980
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<iomanip>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;


void solve(long long N){
    int odd = (N + 1) / 2;
    int even = N / 2;
    cout << fixed << setprecision(10) << (double)odd / N << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256