akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

string K;
vector<int>s;
ll DP[100][2], res;
int D;

int main() {
	cin >> K >> D;
	s.push_back(0);
	for (int i = 0; i != K.size(); ++i)
		s.push_back(s[i] + K[i] - '0');
	DP[0][0] = DP[0][1] = 1;
	res = mod;
	--res;
	++s.back();
	for (int i = K.size(); i; --i) {
		for (int j = s[i - 1]; j != s[i]; ++j) {
			res += DP[(D - j%D) % D][i & 1];
			res %= mod;
		}
		for (int j = 0; j != D; ++j) {
			DP[j][(i - 1) & 1] = 0;
			for (int k = 0; k != 10; ++k) {
				DP[j][(i - 1) & 1] += DP[(D + j - (k%D)) % D][i & 1];
				DP[j][(i - 1) & 1] %= mod;
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

signed main(void)
{
	int a, b;
	cin >> a >> b;
	if (a == b)
		cout << 2 * a << endl;
	else if (a > b)
		cout << 2 * a - 1 << endl;
	else
		cout << 2 * b - 1 << endl;
	return 0;
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct Point{
  double x,y;
  Point(){}
  Point(double x,double y):x(x),y(y){}
  Point operator-(Point p){
    return Point(x-p.x,y-p.y);
  }
};

double norm(Point a){
  return a.x*a.x+a.y*a.y;
}

double abs(Point a){
  return sqrt(norm(a));
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  int n,t=1;
  while(cin>>n,n){
    Point p[2][n];
    for(int i=0;i<n;i++) cin>>p[0][i].x>>p[0][i].y>>p[1][i].x>>p[1][i].y;
    double dp[2][n][1<<n],inf=1<<30;
    //cout<<inf<<endl;

    for(int x=0;x<2;x++)
      for(int i=0;i<n;i++) 
	for(int j=0;j<(1<<n);j++)
	  dp[x][i][j]=inf;
    
    for(int i=0;i<n;i++) dp[0][i][1<<i]=dp[1][i][1<<i]=0;
    
    for(int i=0;i<(1<<n);i++){
      for(int j=0;j<n;j++){
	if(!((i>>j)&1)) continue;
	for(int k=0;k<n;k++){
	  if((i>>k)&1) continue;
	  for(int x=0;x<2;x++)
	    for(int y=0;y<2;y++)
	      dp[x][k][i+(1<<k)]=
		min(dp[x][k][i+(1<<k)],dp[y][j][i]+abs(p[!x][k]-p[y][j]));
	}
      }
    }
    
    double ans=inf;
    for(int i=0;i<n;i++) ans=min(ans,dp[0][i][(1<<n)-1]);
    for(int i=0;i<n;i++) ans=min(ans,dp[1][i][(1<<n)-1]);
    
    for(int i=0;i<n;i++) ans+=abs(p[0][i]-p[1][i]);
    
    printf("Case %lld: %.5f\n",t,ans);
    t++;
  }
  return 0;
}

Measured memory_bytes: 6804
import pprint
N,S=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
dp=[[0 for _ in range(S+1)] for _ in range(N+1)]
dp[0][0]=1
#print(A)
p=998244353
for i in range(N):
    for j in range(S+1):
        dp[i+1][j]=(dp[i+1][j]+2*dp[i][j])%p
        if (j>=A[i]):
            dp[i+1][j]=(dp[i+1][j]+dp[i][j-A[i]])%p
print(dp[N][S])


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

int main() {
	string s, t;
	cin >> s >> t;
	int x = stoi(s + t);
	if ((int)sqrt((double)x) == sqrt((double)x)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

N = int(input())
N0 = N
primes = []
exp = []
num = 2
while N>1 and num<int(N0**0.5)+1:
    if N%num==0:
        primes.append(num)
        temp = 0
        while N%num==0:
            N //= num
            temp += 1
        exp.append(temp)
    num += 1

if N>1:
    primes.append(N)
    exp.append(1)

        
ans = 0
import math
def solve(e):
    ret = (-1 + math.sqrt(1+8*e))
    ret //= 2
    return int(ret)
for e in exp:
    ans += solve(e)
print(ans)

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

typedef long long ll;

const int N = 4e6+5;

bitset<N> b;
int a[N];
int n , sum;

int main(){
	scanf("%d" , &n);
	b.reset();
	b[0] = 1;
	for(int i = 1;i <= n;i++){
		scanf("%d" , a + i);
		b |= (b << a[i]);
		sum += a[i];
	}
	sum = (sum + 1) >> 1;
	while(b[sum] == 0)sum++;
	printf("%d\n" , sum);
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define ANS(x) cout << ((x)?"YES":"NO") << endl;

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

string S;
const string T = "keyence";
const int L = 7;

int main() {

    cin >> S;
    int N = S.size();
    if (N < 7) {
        ANS(false);
        return 0;
    }
    if (S == T || S.substr(0, 7) == T || S.substr(N-7, N) == T) {
        ANS(true);
        return 0;
    }

    int n = 0;
    REP (i, N) {
        if (S[i] == T[n]) n++;
        else break;
    }
    ANS(S.substr(N-(7-n), N) == T.substr(n, 7));

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) ((x).begin(), (x).end())
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

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

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

    int m, k;
    cin >> m >> k;
    if((1 << m) <= k || m == 1 && k == 1) {
        cout << -1 << endl;
        return 0;
    }
    if(m == 1) {
        cout << "0 0 1 1" << endl;
        return 0;
    }
    V<int> x;
    rep(i, 1 << m) if(i != k) {
        x.push_back(i);
        cout << i << " ";
    }
    cout << k << " ";
    FORR(i, x.size()) cout << x[i] << " ";
    cout << k << endl;

    return 0;
}

Measured memory_bytes: 2424
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CLinearApproximation solver = new CLinearApproximation();
        solver.solve(1, in, out);
        out.close();
    }

    static class CLinearApproximation {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] d = new int[n];
            long sum = 0;
            for (int i = 0; i < n; i++) {
                d[i] = in.nextInt() - i;
                sum += d[i];
            }
            Arrays.sort(d);
            long 悲しみ = 0;
            long つらみ = d[n / 2];
            for (int i = 0; i < n; i++) {
                悲しみ += Math.abs(d[i] - つらみ);
            }
            out.println(悲しみ);
        }

    }
}



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

typedef vector<int> vi;
typedef pair<int,int> pii;
#define For(i,n) for(int i = 0; i < (int) n; ++i)
#define Rep(i,n) for(int i = 1; i <= (int) n; ++i)
#define ll long long
#define lld long double
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define ar array
#define INF 1e18;
#define all(v) (v).begin(),(v).end()
const int N=2e5+5,mod=1e9+7;

void solve(){
    int x;
    cin>>x;
    cout<<(x^1)<<endl;

}


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        //cout<<"Case #"<<a<<": ";
        solve();
        //a+=1;
    }
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
char x, y;

int main() {
  cin >> x >> y;
  if (x < y)
    cout << "<";
  else if (x > y)
    cout << ">";
  else
    cout << "=";
}


Measured memory_bytes: 3572
<?php
 fscanf(STDIN, "%s", $c1);
 fscanf(STDIN, "%s", $c2);
 if($c1[0] == $c2[2] &&
     $c1[1] == $c2[1] && $c1[2] == $c2[0]) {
     echo "YES\n";
 } else {
     echo "NO\n";
 }

Measured memory_bytes: 4728
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
int a[10004][3]; // 全て同じ, 二つ同じ, 全て違う

int main() {
  INCANT;
  cin >> N;
  // x<= y <= zと仮定
  for (int x=1; 6*x*x<=N; x++) {
    for (int y=x; 3*y*y<=N; y++) {
      for (int z=y; z*z<=N; z++) {
        int sum=x*x+y*y+z*z+x*y+x*z+z*y;
        if (sum<=N) {
          if (x==y && y==z) a[sum][0]++;
          else if (x!=y && y!=z && z !=x) a[sum][2]++;
          else a[sum][1]++;
        }
      }
    }
  }
  rep(i, N) {
    cout << a[i+1][0] + 3*a[i+1][1] + 6*a[i+1][2] << endl;
  }

  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <numeric>
#include <vector>

int main()
{
  int N,M,X,Y;
  std::cin >> N >> M >> X >> Y;
  int xmax = X;
  for (int i=0; i<N; ++i) {
	int x;
    std::cin >> x;
    xmax = xmax < x ? x : xmax;
  }
  int ymin = Y;
  for (int i=0; i<M; ++i) {
	int y;
    std::cin >> y;
    ymin = y < ymin ? y : ymin;
  }

  if (xmax < ymin) {
    std::cout << "No War" << std::endl;
  } else {
    std::cout << "War" << std::endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func chmin(a *int, b int) bool {
	if *a > b {
		(*a) = b
		return true
	}
	return false
}

func main() {
	var n int
	fmt.Scan(&n)

	const INF = 1 << 30
	var dp = make([]int, n)
	for i := range dp {
		dp[i] = INF
	}
	dp[0] = 0
  
	var h = make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	for i := 1; i < n; i++ {
		chmin(&dp[i], dp[i-1]+int(math.Abs(float64(h[i]-h[i-1]))))
		if i > 1 {
			chmin(&dp[i], dp[i-2]+int(math.Abs(float64(h[i]-h[i-2]))))
		}
	}

	fmt.Println(dp[n-1])
}

Measured memory_bytes: 5504
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[20][20];

int main(){
  ll n,m;
  cin>>n>>m;
  clr(d,0);
  rep(i,0,m){
    ll a,b;
    cin>>a>>b;
    a--;b--;
    d[a][b]=1;
    d[b][a]=1;
  }
  vector<ll> v;
  rep(i,1,n){
    v.pb(i);
  }
  ll c = 0;
  do{
    vector<ll> v1;
    v1.pb(0);
    rep(i,0,v.sz){
      v1.pb(v[i]);
    }
    int flag = 1;
    rep(i,0,v1.sz-1){
      if(d[v1[i]][v1[i+1]]==0){
        flag = 0;
      }
    }
    if(flag==1)c++;
  }while(next_permutation(all(v)));
  cout << c << endl;
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

const int mod = 1e9+7;
struct mint {
    ll x;
    mint (ll x = 0) : x((x%mod+mod)%mod) {}
    mint operator -() const {return mint(-x);}
    mint& operator +=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator -=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator *=(const mint a) {(x *= a.x) %= mod; return *this;}
    mint operator +(const mint a) const {return mint(*this) += a;}
    mint operator -(const mint a) const {return mint(*this) -= a;}
    mint operator *(const mint a) const {return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const {return pow(mod-2);}
    mint operator /=(const mint a) {return *this *= a.inv();}
    mint operator /(const mint a) {return mint(*this) /= a;}
};
istream& operator >>(istream &is, const mint &a) {return is >> a.x;}
ostream& operator <<(ostream &os, const mint &a) {return os << a.x;}

mint dp[2005][2005];
mint sum[2005][2005];

int main() {
    int n, m; cin >> n >> m;
    vint s(n), t(m);
    rep(i,n) cin >> s[i];
    rep(i,m) cin >> t[i];
    dp[0][0] = 1;
    rep(i,n+1) sum[i][0] = 1;
    rep(i,m+1) sum[0][i] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
            if (s[i-1] != t[j-1]) continue;
            dp[i][j] += sum[i-1][j-1];
            sum[i][j] += dp[i][j];
        }
    }
    mint ans = 0;
    rep(i,n+1)rep(j,m+1) ans += dp[i][j];
    cout << ans << endl;
}

Measured memory_bytes: 66428
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#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--)
#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 D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    set<ll> s;
    REP(i, n) {
        ll tmp;
        cin >> tmp;
        if (s.find(tmp) == s.end()) {
            s.insert(tmp);
        } else {
            s.erase(tmp);
        }
    }
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 4864
[w,h,n]=list(map(int,input().split()))
risuto=[]
xmin=0
xmax=w
ymin=0
ymax=h
for i in range(n):
	risuto.append(list(map(int,input().split())))
for i in range(n):
	if risuto[i][2]==1 and risuto[i][0]>xmin:
		xmin=risuto[i][0]
	elif risuto[i][2]==2 and risuto[i][0]<xmax:
		xmax=risuto[i][0]
	elif risuto[i][2]==3 and risuto[i][1]>ymin:
		ymin=risuto[i][1]
	elif risuto[i][2]==4 and risuto[i][1]<ymax:
		ymax=risuto[i][1]
menseki=int((xmax-xmin)*(ymax-ymin))
if xmax<=xmin or ymax<=ymin:
	menseki=0
print(menseki)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    
    int a,b,x=0,ans=0 ;
    scanf("%d%d",&a,&b) ;
    
    if ( b==100 ){
        
        x=a*1000+b ;
        
    } else if ( b>=10 ){
        
        x=a*100+b ;
        
    } else {
        
        x=a*10+b ;
    }
    
    for (int i=0; i<1000; i++ ){
        
        if ( x==i*i ){
            ans = 1 ;
        }   
    }
    
    if ( ans==1 ){
        printf ("Yes\n") ;
        
    } else {
        printf ("No\n") ;
        
    }

    return 0 ;
}

Measured memory_bytes: 128
#![allow(dead_code,unused_variables)]
use proconio::{fastout, input};

fn pow(x : usize, k:usize, m: usize) -> i64{
    let mut res = 1;
    let mut n = k;
    let mut a = x;
    while n > 0{
        if n&1 == 1{
            res = (res * a)%m;
        }
        a = (a * a)% m;
        n >>= 1;
    }
    res as i64
}

fn main() {
    input!{
        p: usize,
        a:[i64;p],
    }

    let mut b : Vec<i64> = vec![0;p as usize];
    let pp = p as i64;
    let c = Combination::new(p+10,p);
    for i in 0..p{
        b[0] = (b[0] + a[i])%pp;
        if i==0{
            if a[i] == 1{
                b[p-1] -= 1;
            }
            if b[p-1] < 0{
                b[p-1] += pp;
            }
        }else{
            if a[i] == 0{
                continue;
            }
            for j in 0..p{
                let d = c.comb(p-1,j) * pow(i,p-1-j,p);
                // println!("{} comb : {} pow ; {}",d,c.comb(p-1,j),pow(i,p-1-j,p));
                if (p-1-j)%2 == 1{
                    b[j] += d;
                }else{
                    b[j] -= d;
                }
                b[j] %= pp;
                if b[j] < 0{
                    b[j] += pp;
                }
            }
        }     
    }


    for i in 0..p{
        print!("{}",b[i]);
        if i != p-1{
            print!(" ");
        }else{
            println!("");
        }
    }
}

pub struct Combination{
    fac : Vec<usize>,
    finv : Vec<usize>,
    m : usize,
}

impl Combination{
    pub fn new(n : usize, m : usize) -> Self{
        let mut inv = vec![1;n+1];
        let mut fac = vec![1;n+1];
        let mut finv = vec![1;n+1];

        for i in 2..(n+1){
            fac[i] = (fac[i-1] * i) % m;
            inv[i] = m - (inv[m%i] * (m/i) % m);
            finv[i] = (finv[i-1]*inv[i])%m;
        }

        Combination{
            fac,
            finv,
            m,
        }
    }

    pub fn comb(&self, n : usize, k: usize) -> i64{
        if n < k{
            return 0;
        }

        ((self.fac[n] * (self.finv[k] * self.finv[n-k] % self.m)) % self.m)as i64
    }
}

Measured memory_bytes: 2292
#include <stdio.h>
int main(){
	int k,a,b,i;
	scanf("%d%d%d",&k,&a,&b);
	for(i=a;i<=b;i++)
		if(i%k==0)return 0*printf("OK\n");
	printf("NG\n");
	return 0;
}

Measured memory_bytes: 1624
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long ans;
	string str="";
	cin>>ans;
	while(ans>0) {
		int m=ans%26;
		if(m==0) m=26;
		str+=(char)(m+96);
		ans=(ans-m)/26;
	}
	reverse(str.begin(),str.end());
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 3624
package main

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

var n, m int
var e [][]int
var stats []stat
var inf int = int(1e9)

type stat struct {
	prev, count int
}

func bfs() {
	for i := 0; i < n; i++ {
		stats[i] = stat{-1, inf}
	}
	stats[0] = stat{-1, 0}

	var q [][]int
	i := 0
	q = append(q, []int{0, 0})
	for i != len(q) {
		v, cnt := q[i][0], q[i][1]
		i++
		if stats[v].count != cnt {
			continue
		}
		for _, u := range e[v] {
			if cnt+1 < stats[u].count {
				stats[u] = stat{v, cnt + 1}
				q = append(q, []int{u, cnt + 1})
			}
		}
	}
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	fmt.Fscan(r, &n, &m)
	e = make([][]int, n)
	for i := 0; i < m; i++ {
		var u, v int
		fmt.Fscan(r, &u, &v)
		u--
		v--
		e[u] = append(e[u], v)
		e[v] = append(e[v], u)
	}

	stats = make([]stat, n)
	bfs()
	for i := 0; i < n; i++ {
		if stats[i].count == inf {
			fmt.Fprintln(w, "No")
			return
		}
	}
	fmt.Fprintln(w, "Yes")
	for i := 1; i < n; i++ {
		fmt.Fprintln(w, stats[i].prev+1)
	}
}


Measured memory_bytes: 27140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
 
public class Main {
     
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
     
    private void solv() {
        Scanner input = new Scanner(System.in);
         
        int n = input.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
        	S[i] = input.nextInt();
        }
        int partition = 0;
        for (int i = 0; i < S.length; i++) {
			if (S[i] <= S[S.length - 1]) {
				int temp = S[i];
				S[i] = S[partition];
				if (i == S.length - 1) {
					S[partition]  = (-1)*temp;	
				}else{
					S[partition]  = temp;
				}
				
				partition++;
			}
		}
        print(S);
    }
  
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
     
    private void print(int[] xs) {
        StringBuilder sb = new StringBuilder();
        for (int x : xs) {
        	if (x < 0) {
        		sb.append("[" + (-1)*x + "]").append(' ');
			}else{
				sb.append(x).append(' ');	
			}
        	
        }
        System.out.println(sb.toString().trim());
    }
     
    private static class Scanner {
        BufferedReader r;
        StreamTokenizer st;
         
        public Scanner(InputStream in) {
            r = new BufferedReader(new InputStreamReader(in));
            st = new StreamTokenizer(r);
        }
         
        public String next() {
            nextToken();
            return st.sval;
        }
         
        public Integer nextInt() {
            nextToken();
            return (int)st.nval;
        }
         
        private int nextToken() {
            int token = st.TT_EOF;
            try {
                token = st.nextToken();
            } catch (IOException e) {
            }
            return token;
        }
    }
}

Measured memory_bytes: 34604
#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;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    vll A(N), B(N), C(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for (size_t i = 0; i < N; i++)
    {
        cin >> B[i];
    }
    for (size_t i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    sort(all(A));
    sort(all(B));
    sort(all(C));
    ll ans = 0;
    for (size_t i = 0; i < N; i++)
    {
        ll idx1 = lower_bound(all(A), B[i]) - A.begin();
        ll idx2 = C.end() - upper_bound(all(C), B[i]);
        ans += idx1 * idx2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int r, x, d;
    cin >> r >> d >> x;

    REP(i, 10)
    {
        x = r * x - d;
        cout << x << endl;
    }
    
}

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

int main() {
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    ll x=min({a,b,c,d,e});
    cout << 5+(n-1)/x << endl;
    return 0;
}

Measured memory_bytes: 3636
from heapq import heappush, heappop
from collections import deque
import sys
sys.setrecursionlimit(10**6)
n, m = map(int, input().split())
E = []
G = [[] for i in range(n)]
RG = [[] for i in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    E.append((a-1, b-1, c))
    G[a-1].append((b-1, c, i))
    RG[b-1].append((a-1, c, i))
def dijkstra(G, s):
    dist = [10**18]*n
    dist[s] = 0
    que = [(0, s)]
    while que:
        co, v = heappop(que)
        if dist[v] < co:
            continue
        for w, c, i in G[v]:
            if co + c < dist[w]:
                dist[w] = co + c
                heappush(que, (co + c, w))
    return dist
D = dijkstra(G, 0)
RD = dijkstra(RG, 1)

G0 = [[] for i in range(n)]
used = set([1])
deq = deque([1])
P = set()
while deq:
    v = deq.popleft()
    for w, c, i in RG[v]:
        if D[w] + c == D[v]:
            P.add(i)
            if w not in used:
                used.add(w)
                deq.append(w)
            G0[v].append((w, i))
            G0[w].append((v, i))

PB = set()
label = [None]*n
gen = 1
cost = [0]*n
def dfs(u, p, i):
    global gen
    res = 0
    p_cnt = 0
    for v, j in G0[u]:
        if v == p:
            p_cnt += 1
            continue
        if label[v] is not None:
            if label[v] < label[u]:
                cost[v] += 1
                res += 1
        else:
            label[v] = gen; gen += 1
            res += dfs(v, u, j)
    res -= cost[u]
    if res == 0 and p != -1 and p_cnt == 1:
        PB.add(i)
    return res
label[0] = 0
dfs(0, -1, None)

ans = []
for i in range(m):
    if i in P:
        if i in PB:
            ans.append("SAD")
        else:
            ans.append("SOSO")
    else:
        a, b, c = E[i]
        if D[b] + c + RD[a] < D[1]:
            ans.append("HAPPY")
        else:
            ans.append("SOSO")
print(*ans, sep='\n')

Measured memory_bytes: 230884
N, K = map(int, input().split())
xs = list(map(int, input().split()))
ans = 1e20
for i in range(N-K+1):
    xl = xs[i]
    xr = xs[i+K-1]
    ltor = abs(xl) + abs(xl-xr)
    rtol = abs(xr) + abs(xl-xr)
    t = min(ltor, rtol)
    if t < ans:
        ans = t
print(ans)


Measured memory_bytes: 14252
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
signed main() {
	int n,ans=0,inf=-10000;
	string s;
	cin >> n>>s;
	int cnt[26];
	int nt[26];
	for (int i = 0; i < n; i++) {
		for (int l = 0; l < 26; l++)cnt[l] = 0;
		ans = 0;
		for (int j = 0; j <= i; j++) {
			cnt[s[j] - 'a']++;
		}
		for (int l = 0; l < 26; l++)nt[l] = 0;
		ans = 0;
		for (int k = i + 1; k < n; k++) {
			nt[s[k] - 'a']++;
		}
		for (int l = 0; l < 26; l++) {
			if (cnt[l] && nt[l])ans++;
		}
		if (ans > inf) {
			inf = ans;
		}
	}
	cout << inf << endl;
	ll
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(i, 1, (n))
#define pb push_back
#define f first
#define s second
#define INF 100000000000000000
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<piii> viii;

const int MAXN = 100100;
const ll MOD = 1e9+7;
int n, m;
bool broken[MAXN];
ll dp[MAXN];

int main()
{
    FAST_IO;

    cin >> n >> m;
    FOR(i, 1, m) {
        int a;
        cin >> a;
        broken[a] = true;
    }

    dp[0] = 1;
    FOR(i, 1, n) {
        if (broken[i]) continue;
        dp[i] += dp[i-1];
        if (i > 1) dp[i] += dp[i-2];
        dp[i] %= MOD;
    }

    cout << (dp[n]%MOD) << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int i, j, k, l;
int H, W, N, Q;
int a, b, c;

int main()
{
	string s;
	cin >> s;

	int length = s.length();
	int half;
	bool ok;

	while (true)
	{
		ok = true;
		length -= 2;
		half = length / 2;
		for (i = 0; i < half; i++)
		{
			if (s[i] != s[half + i])
			{
				ok = false;
				break;
			}
		}
		if (ok)
		{
			cout << length << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int INF = 2e6;
ll MOD = 1e9 + 7;

int main(){
    int n; ll T; cin >> n >> T;
    vector<ll> t(n);
    rep(i,n) cin >> t[i];

    ll ans = 0, k = 0;
    for(int i = 0; i < n - 1; i++){
        if(t[i+1] - t[i] <= T) {
            k++;
            continue;
        }
        
        ans += t[i] + T - t[i-k];
        k = 0;
    }
    ans += t[n-1] + T - t[n-1-k];
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> H(N);
  int i;
  for(i=0;i<N;i++)cin >> H[i];
  sort(H.begin(),H.end());
  long ans=0;
  for(i=0;i<N-K;i++)ans += H[i];
  cout << ans << endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	ll h, w;
	cin >> h >> w;

	vector<vector<string>> a(h, vector<string>(w));
	for (ll i = 0; i < h; i++)
	{
		string s;
		cin >> s;
		for (ll j = 0; j < w; j++)
		{
			a[i][j] = s[j];
		}
	}

	bool b = true;
	for (ll i = 1; i < h; i++)
	{
		for (ll j = 1; j < w; j++)
		{
			ll x = j - 1;
			ll y = i - 1;
			if (a[i][x] == "#" && a[y][j] == "#")
			{
				b = false;
			}
		}
	}

	println((b ? "Possible" : "Impossible"));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double EPS = 1e-9; // 許容誤差^2
const double INF = 1e9;
#define X real()
#define Y imag()
// #define LE(n,m) ((n) < (m) + EPS)
#define LE(n,m) ((n) - (m) < EPS)
// #define GE(n,m) ((n) + EPS > (m))
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

// 外積　cross(a,b) = |a||b|sinθ
double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

// 点の進行方向
int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

// 点pの直線aへの射影点を返す
Point proj(Point a1, Point a2, Point p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

double distLP(Point a1, Point a2, Point p) {
  return abs(proj(a1, a2, p) - p);
}

// 2円の共通接線。返される各直線に含まれる頂点は円との接点となる
vector<Line> tangentLines(Point a, double ar, Point b, double br) {
  vector<Line> ls;
  double d = abs(b-a);
  rep (i,2) {
    double sin = (ar - (1-i*2)*br) / d;
    if (!LE(sin*sin, 1)) break;
    double cos = sqrt(max(1 - sin*sin, 0.0));
    rep (j,2) {
      Point n = (b-a) * Point(sin, (1-j*2)*cos) / d;
      ls.push_back(Line(a + ar*n, b + (1-i*2)*br*n));
      if (cos < EPS) break;  // 重複する接線を無視（重複していいならこの行不要）
    }
  }
  return ls;
}

int main(){
    int n;
    while(cin >>n,n){
        vector<Point> c(n);
        vector<int> r(n),m(n);
        rep(i,n){
            int x,y;
            cin >>x >>y >>r[i] >>m[i];
            c[i] = Point(x,y);
        }

        int ans = 1;
        rep(i,n)rep(j,i){
            rep(ii,2)rep(jj,2){
                vector<Line> ls = tangentLines(c[i],r[i]+ii*m[i],c[j],r[j]+jj*m[j]);
                for(const auto &l:ls){
                    int tt = 0;
                    rep(k,n){
                        double d = distLP(l.fi,l.se,c[k]);
                        if(LE(0,d-r[k]) && LE(d-r[k],m[k])) ++tt;
                    }
                    ans = max(ans,tt);
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  int n;
  int k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
//  int total_c=0;
  int arr2[n];
  arr2[0]=0;
  arr2[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++)
  {
    int min_c=INT_MAX;
    for(int j=i-1;j>=max(0, i-k);j--)
    {
      int c=arr2[j]+abs(arr[i]-arr[j]);
      if(c<min_c)
        min_c=c;
    }
    arr2[i]=min_c;
  }
  cout<<arr2[n-1]<<endl;
}

Measured memory_bytes: 1024
a, b, c, x, y = map(int,input().split())
if a+b < 2*c:
    print(a*x+b*y)
else:
  if x < y:
    if b > 2*c:
      print(y*2*c)
    else:
      print(x*2*c + (y-x)*b)
  else:
    if a > 2*c:
      print(x*2*c)
    else:
      print(y*2*c + (x-y)*a)

Measured memory_bytes: 61800
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

using namespace std;

vector<int>a;
vector<int>b;
vector<int>c;

int main(){

	int w,n,r,s; char p;

	cin >> w >> n;

	rep(i,n){
	cin >> r;
	a.push_back(r);

    cin >> p;

    cin >> s;
	b.push_back(s);


	}
	rep(i,w)
	c.push_back(i+1);

	rep(i,n)
	iter_swap(c.begin()+a[i]-1,c.begin()+b[i]-1);

	rep(i,w)
	cout << c[i] << endl;



	return 0;
}

Measured memory_bytes: 1216
NN = 18
MA = [-1] * ((1<<NN+1)-1)
def update(a, x):
    i = (1<<NN) - 1 + a
    MA[i] = x
    while True:
        i = (i-1) // 2
        MA[i] = max(MA[2*i+1], MA[2*i+2])
        if i == 0:
            break

def rangemax(x):
    l = 0 + (1<<NN)
    r = x + (1<<NN)
    ma = 0
    while l < r:
        if l%2:
            ma = max(ma, MA[l-1])
            l += 1
        if r%2:
            r -= 1
            ma = max(ma, MA[r-1])
        l >>= 1
        r >>= 1
    return ma

N = int(input())
H = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]

for i in range(N):
    update(H[i], rangemax(H[i]) + A[i])

print(rangemax(N+1))

Measured memory_bytes: 123600
n = int(input())

INF = 100010
dp = [INF] * (n + 1)
dp[0] = 0
for i in range(n + 1):
    if i + 1 <= n: dp[i + 1] = min(dp[i + 1], dp[i] + 1)
    
    j = 6
    while i + j <= n:
        dp[i + j] = min(dp[i + j], dp[i] + 1)
        j *= 6
    
    j = 9
    while i + j <= n:
        dp[i + j] = min(dp[i + j], dp[i] + 1)
        j *= 9

print(dp[n])

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

const int MOD = 1000000007;
const int MAXN = 1000005;

long long modpow(long long a, long long p){
	if(p == 0)return 1;
	if(p % 2 == 1)return a * modpow(a, p - 1) % MOD;
	
	long long r = modpow(a, p / 2);
	return r * r % MOD;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}

long long fact[MAXN], invfact[MAXN];
long long C(int n, int r){
	return fact[n] * invfact[r] % MOD * invfact[n - r] % MOD;
}

int n;

int main(){
	scanf("%d", &n);
	
	for(int i = 0; i <= n; i++){
		if(i == 0)fact[i] = 1;
		else fact[i] = i * fact[i - 1] % MOD;
	}
	for(int i = n; i >= 0; i--){
		if(i == n)invfact[i] = modinv(fact[i]);
		else invfact[i] = (i + 1) * invfact[i + 1] % MOD;
	}
	
	long long res = fact[n - 1];
	for(int i = 1; i < n - 1; i++){
		if(2 * i <= n - 1){
			res = (res + fact[n - 1]) % MOD;
		}else{
			res = (res + fact[i] * fact[n - 1 - i] % MOD * (C(n - 1, i) - C(i - 1, n - 1 - i) + MOD)) % MOD;
		}
	}
	printf("%lld\n", res);

    return 0;
}


Measured memory_bytes: 15872
//
//  management.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;


int main(int argc, const char* argv[]) {

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

  for (int i = 0; i < n; i++) {
    std::cout << a[i] << std::endl;
  }

  return 0;
}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
#define lim 100'001
using namespace std;
	
void sieve(vector<bool>&is_prime){
	for(int i=2;i*i<lim;++i){
		if(!is_prime.at(i))continue;
		for(int j=i*i;j<lim;j+=i){
			is_prime.at(j)=false;
		}
	}
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<bool>is_prime(lim,true);
	sieve(is_prime);
	vector<int>cnt(lim); cnt.at(1)=0;
	for(int i=3;i<lim;i+=2){
		cnt.at(i)=cnt.at(i-1)=cnt.at(i-2);
		if(is_prime.at(i)&&is_prime.at((i+1)/2)){
			++cnt.at(i);
		}
	}
	int q; cin>>q;
	for(int i=0;i<q;++i){
		int l,r; cin>>l>>r;
		cout<<cnt.at(r)-cnt.at(l-1)<<"\n"s;
	}
}


Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = str(input())

A = []
for i in range(N) :
  if T[i] == "r" :
    A.append("P")
  elif T[i] == "s" :
    A.append("R")
  else :
    A.append("S")
#print (A)

for i in range(N) :
  if i+K < N :
    if A[i] == A[i+K] :
      A[i+K] = "N"
#print (A)

sum = 0
for i in range(N) :
  if A[i] == "P" :
    sum += P
  elif A[i] == "R" :
    sum += R
  elif A[i] == "S" :
    sum += S    
print (sum)

Measured memory_bytes: 45936
#include <bits/stdc++.h>
#define N 101
#define prob "D"
#define pb push_back
#define ll long long
#define io freopen(prob".inp","r",stdin); freopen(prob".out","w",stdout);
#define fast ios_base::sync_with_stdio(1); cin.tie(nullptr); cout.tie(nullptr);
using namespace std;
int n,w[N],v[N],W;
ll f[100001][N],ans=0;
int main()
{
    fast
   // io
    cin>>n>>W;
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
    for(int i=1;i<=n;i++) f[w[i]][i]=v[i],ans=max(ans,f[w[i]][i]);
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=W;j++)
        {
           if(j-w[i]>=0&&f[j-w[i]][i-1]!=0)
            f[j][i]=max(f[j][i],(ll)f[j-w[i]][i-1]+v[i]);
            f[j][i]=max(f[j][i],f[j][i-1]);
            ans=max(ans,f[j][i]);

          // cout<<f[j][i]<<' ';
        }
       // cout<<endl;
    }
    cout<<ans;
}




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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    long long ans = 0;
    vector<int> c(n);
    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        ans -= b;
        c[i] = a+b;
    }

    sort(c.begin(), c.end(), greater<int>());

    for(int i = 0; i < n; i += 2){
        ans += c[i];
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
 
public class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	String S = sc.next();
      	String T = sc.next();
      	int count = 0;
      	
      	for(int i = 0 ; i < S.length() ; i++){
          if(S.charAt(i) != T.charAt(i)){
            count++;
      	  }
      	}
      	System.out.println(count);
	}
}

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

int main()
{
  int n;
  long long A,B,C,D;
  scanf("%d%lld%lld%lld%lld",&n,&A,&B,&C,&D);
  long long a=(B-A+(n-1)*D)/(C+D);
  //printf("%lld\n",a);
  puts((B-A+(n-1)*D)>=0&&a<=n-1&&B-A<=a*(C+D)-(n-1)*C?"YES":"NO");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)

int main()
{
  ll n, ans;
  cin >> n;
  
  ans = (n - 1) * n / 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	s=input().rstrip().decode()+"T"
	x,y=MI()
	X=[]
	Y=[]

	i=0

	if s[0]=="F":
		for ss in s:
			if ss=="F":
				x-=1
				i+=1
			else:
				break
	#print(x,y,i)

	while True:
		ii=s.find("T",i+1)
		if ii==-1:
			break
		Y.append(ii-i-1)

		i=s.find("T",ii+1)
		if i==-1:
			break
		X.append(i-ii-1)
	#print(X,Y)


	s=set([0])
	ss=set()
	for i in X:
		for j in s:
			ss.add(j+i)
			ss.add(j-i)
		s=ss.copy()
		ss=set()
		#print(i,s,ss)
	#print(s)

	if x not in s:
		print("No")
		exit()

	s=set([0])
	ss=set()
	for i in Y:
		for j in s:
			ss.add(j+i)
			ss.add(j-i)
		s=ss.copy()
		ss=set()
	#print(s)

	if y not in s:
		print("No")
		exit()

	print("Yes")






















if __name__ == "__main__":
	main()


Measured memory_bytes: 81528
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set <int> s;
    while(n--)
    {
        int x;
        cin>>x;
        if(s.find(x)!=s.end())
            s.erase(x);
        else
            s.insert(x);
    }
    cout<<s.size();
    return 0;
    
 } 

Measured memory_bytes: 4864
#include <iostream>
#include <numeric>
#include <vector>

auto main() -> int {
  using std::cin;
  using std::cout;

  int a, b;
  cin >> a >> b;

  std::vector<int> skill;
  for(int i = 0; i < b; i++) {
    int n;
    cin >> n;
    skill.push_back(n);
  }

  int sum = std::accumulate(skill.begin(), skill.end(), 0);

  if(sum < a) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }

  return 0;
}

Measured memory_bytes: 892
/*
 * @Author: Kaizyn
 * @Date: 2020-04-12 20:26:40
 * @LastEditTime: 2020-04-12 20:27:21
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int N = 1e6+7;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

int n;

inline void solve()
{
    cin >> n;
    long long res = 0;
    for (int i = 1; i <= n; ++i) {
        if (i%3 && i%5) res += i;
    }
    cout << res << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

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

typedef long long ll;

ll Lucas(
  int N
)
{
  ll lucas[87];
  lucas[0] = 2;
  lucas[1] = 1;
  for (int i = 2; i <= N; ++i)
    lucas[i] = lucas[i - 1] + lucas[i - 2];
  return lucas[N];
}

int main()
{
  int N;
  cin >> N;
  cout << Lucas(N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define pb push_back

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

const int mod = 1e9 + 7;
const int mod2 = 998244353;

ll exp(ll taban, ll us, ll md) {
    ll carpan = taban % md;
	if(carpan == 0) return 0;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % md;
        temp /= 2;
        carpan = (carpan*carpan) % md;
    }
    return res;
}
 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}

ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}

vector<ll> fact;
vector<ll> inv_fact;
void fact_init(int n){
	fact.resize(n+5);
	inv_fact.resize(n+5);
	fact[0] = inv_fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = (fact[i-1] * i) % mod;
		inv_fact[i] = exp(fact[i], mod-2, mod);
	}
}

ll komb(ll a, ll b){
	if(a < b) return 0;
	return fact[a] * (inv_fact[a-b] * inv_fact[b] % mod) % mod;
}

const int N = 1e7 + 5;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL);
	vector<ll> cnt(N, 1);
	vector<bool> pr(N, 1);
	for(int i = 2; i < N; i++){
		int u = 2;
		if(pr[i]) for(ll k = i; k < N; k *= i){
			for(int j = k; j < N; j += k){
				cnt[j] = cnt[j] * u / (u-1);
			}
			u++;
		}
		for(int k = 2*i; k < N; k += i) pr[k] = 0;
	}
	int n; cin>>n;
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		ans += cnt[i] * i;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 82580