akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(int i=int(x);i<int(y);++i)
#define For(i,x,y)  for(int i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(int i=int(x);i>=int(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)    ((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
typedef complex<double> E;
namespace cqz{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);}
	void writeln(ll x){write(x);puts("");}
}using namespace cqz;
const ll N=3000010;
ll s[N],a[N],n,ans;
int main(){
	n=read();
	For(i,1,n){		ll x=read();		s[i]=s[i-1]+x;	a[i]=a[i-1]^x;	}ll l=1;
	For(r,1,n){		for (;(s[r]-s[l-1])!=(a[r]^a[l-1]);l++);	ans+=r-l+1;	}writeln(ans);
}

Measured memory_bytes: 9984
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using vvv = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ priority_queue<ll, vector<ll>, greater<ll>>
#define VVI(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVI(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &a, const Pair &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * POW(n, m - 1)) % MOD;
  }
}

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

int main() {
  ll N;
  cin >> N;
  vector<ll> C(N + 1, 0);
  vector<ll> DP(N + 1, 1);
  vector<ll> CP(200001, 0);
  REP(i, N) cin >> C[i + 1];

  FOR(i, 1, N + 1) {
    DP[i] = DP[i - 1];
    if (CP[C[i]] > 0 && CP[C[i]] < i - 1) {
      DP[i] += DP[CP[C[i]]];
    }
    DP[i] %= MOD;
    CP[C[i]] = i;
  }
  cout << DP[N] << endl;

  return 0;
}


Measured memory_bytes: 5624
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
	int n;
	float tem, ideal;
	scanf("%d%f%f", &n, &tem, &ideal);
	float hight[n];
	for(int i=0; i<n; i++){
		scanf("%f", &hight[i]);
	}
	float min= fabsf(ideal-(tem-hight[0]*0.006));
	int min_n=0;
	for(int i=1; i<n; i++){
		if(min > fabsf(ideal-(tem-hight[i]*0.006))){
			min= fabsf(ideal-(tem-hight[i]*0.006));
			min_n=i;
		}
		//printf("i:%d, min:%f, min_n:%d\n", i,min,min_n);
	}
	printf("%d", min_n+1);
	
	return 0;
}

Measured memory_bytes: 128
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
#include<iostream>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int n,k;
    cin >> n >> k;
    
    ll * arr = new ll[n];
    
    for(int i=0;i<n;i++)
    {
        cin >> arr[i];
    }
    sort(arr,arr+n);
    ll val = INT_MAX;
    for(int i=0;i<n-k+1;i++)
        val = min(val,arr[i+k-1]-arr[i]);
    cout<<val;
    delete[] arr;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;
    cin>>s;
    if(n % 2){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i = 0; i < n / 2; i++){
        if(s[i] != s[i + n / 2]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if ((((x+r)<=W)&&((y+r)<=H))&&(((x-r)>=0)&&((y-r)>=0))) {
		cout <<"Yes"<<endl;
	} else {
		cout <<"No"<<endl;
	} 
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

int n;
LL m;
LL a[200000];

bool ok(int x){
  FOR(i,x,n){
    if(a[x+i]+a[2*n-1-(i-x)]<m)return false;
  }
  return true;
}

int main(){
  cin>>n>>m;
  REP(i,2*n)cin>>a[i];

  sort(a,a+2*n);

  int lb=0,ub=n;
  while(lb<ub){
    int mid = lb+(ub-lb)/2;
    if(ok(mid)){
      ub=mid;
    }else{
      lb=mid+1;
    }
  }
  LL ret=0;
  REP(i,lb)ret=max(ret,(a[i]+a[2*lb-1-i])%m);
  FOR(i,lb,n)ret=max(ret,(a[lb+i]+a[2*n-1-(i-lb)])%m);
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
const int mod=998244353;
LL a[1000222],n,m,dp[1000222];
LL asd=0;
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=n;++i)
	{
		dp[0]++;
		for(int j=m;j>=a[i];--j)dp[j]=(dp[j]+dp[j-a[i]])%mod;
		asd=(dp[m]+asd)%mod;
	}
	printf("%lld\n",asd);
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

int main(void){
  int i,j,n;
  cin>>n;

  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      if(i*j==n){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }

  cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#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 x,y;
    cin >> x >> y;
    cout << (x-1)*(y-1) << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    // Input numbers
    int n;
    cin >> n;
    long long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

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

    long long ans = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] <= 1000000000000000000 / ans) {
            ans *= a[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;
typedef long long ll;

int D, T, S;

int main(){
  cin >> D >> T >> S;
  if (T*S >= D) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut v: Vec<i32> = vec![sc.read(), sc.read(), sc.read()];
    v.sort();
    println!("{} {} {}", v[0], v[1], v[2]);
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define inf 1e18
#define inp(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define fr(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int T=1;
    while (T--) {
        string s;
        cin>>s;
        cout<<s[0]<<s[1]<<s[2]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3584
N, K = map(int, input().split())

def count_k():
    return (N // K) ** 3

def count_khalf():
    if K % 2 == 1:
        return 0
    b = N // K
    if N % K >= K // 2:
        b += 1
    return b ** 3


print(count_k() + count_khalf())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int i,j,a,b,n,m,k,l;
int main(){
  cin>>n>>m>>k>>l;
  for(i=1;i<m;i++){
    cin>>a>>b;
    k=max(k,a);l=min(b,l);
  }
  cout<<max(0,l-k+1);
}

Measured memory_bytes: 256
from collections import Counter

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

n = int(input())

t = []
for tmp in range(2, n+1):
    t.extend(prime_decomposition(tmp))

ans = 1

for v in Counter(t).values():
    ans *= v + 1


print(ans % (10**9+7))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll ans=0;
    ll now=0;
    ll cnt=0;
    rep(i,len(s)){
      if(s[i]=='A'){
        cnt++;
      }
      if(s[i]!='A') cnt=0;
      if(i+1<=len(s)-1 && i+2<=len(s)-1 && s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
        ans+=cnt;
        if(cnt==1){
          s[i]='B';
          s[i+1]='C';
          s[i+2]='A';
          cnt=0;
        }else if(cnt==2){
          s[i]='B';
          s[i+1]='A';
          s[i+2]='A';
          cnt=0;
        }else{
          s[i]='A';
          s[i+1]='A';
          s[i+2]='A';
          cnt=cnt-2;
        }
      }
    }
    //cout<<s<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 720
# -*- coding: utf-8 -*-

N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]

record = [[0] * 10 ** 5 for _ in range(C)]
for s, t, c in stc:
    for i in range(s, t + 1):
        record[c-1][i-1] = 1

ans = 0
for i in range(10 ** 5):
    cnt = 0
    for j in range(C):
        cnt += record[j][i]
    ans = max(ans, cnt)

print(ans)


Measured memory_bytes: 50924
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def main():
    a = int(stdin.readline().rstrip())
    b, c = [int(x) for x in stdin.readline().rstrip().split()]
    check = 0
    while b <= c:
        if b % a == 0:
            check += 1
        b += 1
    if check > 0:
        print("OK")
    else:
        print("NG")
main()

Measured memory_bytes: 9912
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main() {
  string s;
  char tmp = 0;
  cin >> s;
  for(int i =0;i<s.size();i++){
    if(tmp == s[i]) {
      cout << "Bad" << endl;
      return 0;
    }
    tmp = s[i];
  }
  cout << "Good" << endl;

  return 0;
}

Measured memory_bytes: 256
N=int(input())
A=sorted(list(map(int,input().split())))

def hoge(num):
    value=sum(A[:num+1])
    for a in A[num+1:]:
        if value*2>=a:
            value+=a
        else:
            return (0)
    return(1)

if hoge(0):
    print(N)
    exit()

st=0
end=N-1
while end-st>1:

    num=(end+st)//2
    #print(num)
    if not hoge(num):
        st=num
    else:
        end=num

print(N-st -1)


Measured memory_bytes: 71912
#define _GLIBCXX_DEBUG
#include <iostream>
using namespace std;

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool tkhs;
    while(true){
        c -= b;
        if(c <= 0){tkhs = true; break;}
        a -= d;
        if(a <= 0){tkhs = false; break;}
    }
    if(tkhs) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

void solve62(string s) {
    vector<int> v;
    REP(i,10) {
        v.push_back(s[i] - '0');
    }
    REP(i,9) {
        vector<int> w;
        REP(j,9-i) {
            w.push_back(v[j] + v[j+1]);
        }
        swap(v,w);
    }
    cout << to_string(v[0]).back() << endl;
}

int main() {
    string s;
    while(cin >> s) {
        solve62(s);
    }
    return 0;
}

Measured memory_bytes: 3124
n = int(input())
l = []
mx = 0
mn = 0
for i in range(n):
    a = int(input())
    l.append(a)
    if a > mx:
        mx = a
        mn = i+1
l.sort()
if l.count(mx) > 1:
    for i in range(n):
        print(mx)
else:
    for i in range(mn-1):
        print(mx)
    print(l[n-2])
    for i in range(n-mn):
        print(mx)

Measured memory_bytes: 12532
#include <iostream>

using namespace std;

int X;
int main()
{

	cin >> X;

	int a = X / 100;
	bool ans = false;
		
	for (int i = a; !ans ; i--) {
		int l = X - a * 100;

		if (l >= 0
			&& l <= 5 * i) {
			ans = true;
		}

		if (l > 5 * i) {
			break;
		}

	}
	
	cout << (ans ? 1 : 0) << endl;

	return 0;


}



Measured memory_bytes: 256
N = int(input())
lis = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(N):
        if i != j:
           ans += ((lis[i][0]-lis[j][0])**2+(lis[i][1]-lis[j][1])**2)**0.5
print(ans/N)

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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int n, m;
vector<int> win[5001];
int res[5001];
bool flag[5001], latte[5001][5001];
int cnt = 0;

void dfs(int now) {
    flag[now] = true;
    rep(i, win[now].size()) if(!flag[win[now][i]]) {
        dfs(win[now][i]);
    }
    res[cnt++] = now;
    cout << now << endl;
}

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

    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        win[b].push_back(a);
        latte[a][b] = true;;
    }
    FOR(i, 1, n + 1) if(!flag[i]) {
        dfs(i);
    }
    rep(i, n - 1) {
        if(!latte[res[i]][res[i + 1]] && !latte[res[i + 1]][res[i]]) {
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 28080
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }

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

    ll N, K, Q; cin >> N >> K >> Q;
    ll A[Q]; REP(i, Q) cin >> A[i];
    ll P[N]; REP(i, N) {
        P[i] = K-Q;
    }

    REP (i, Q) {
        ++P[A[i]-1];
    }

    REP (i, N) {
        cout << ((P[i]>0)?"Yes":"No") << '\n';
    }
    return 0;
}



Measured memory_bytes: 2176
import java.util.*;
import static java.lang.System.*;

import java.io.IOException;
import java.io.InputStream;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int N = sc.nextInt();
	  long[]score = new long[N+1];
	  int[] k = new int[N+1];
	  long sum = 0;
	  
	  for(int i=0; i<N; i++) {
		  k[i]= sc.nextInt();
		  score[k[i]]++;
	  }
	  for(int i=1; i<=N; i++) {
		  sum += (score[i] * (score[i]-1)) / 2;
	  }

	  for(int i=0; i<N; i++) {
		  long ans = sum - score[k[i]] + 1;
		  out.println(ans);
	  }

  }
}

Measured memory_bytes: 95596
# B 
z = list(map(int, input().split(" ")))
maxnum = z[0]*z[2]
for i in range(2):
    for j in range(2):
        x = z[i]
        y = z[j+2]
        prod = x*y
        # print(x, y, prod, maxnum, prod > maxnum)
        if prod > maxnum:
            maxnum = prod
print(maxnum)

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

int n, cnt[3] = {};
double dp[301][301][301];

double solve(int i, int j, int k) {
    if (i == 0 && j == 0 && k == 0)
        return 0;
    if (dp[i][j][k] != -1)
        return dp[i][j][k];

    dp[i][j][k] = (double) n / (i + j + k);
    if (i > 0)
        dp[i][j][k] += solve(i-1, j, k) * i / (i + j + k);
    if (j > 0)
        dp[i][j][k] += solve(i+1, j-1, k) * j / (i + j + k);
    if (k > 0)
        dp[i][j][k] += solve(i, j+1, k-1) * k / (i + j + k);

    return dp[i][j][k];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

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

    for (int i=0; i<=n; i++)
        for (int j=0; j<=n; j++)
            for (int k=0; k<=n; k++)
                dp[i][j][k] = -1;
    cout << fixed << setprecision(10) << solve(cnt[0], cnt[1], cnt[2]) << "\n";

    return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<ll,int> pi;

int main()
{
    int w,h;
    scanf(" %d %d", &w, &h);

    vector<pi> e;

    rep(i,w)
    {
        int c;
        scanf(" %d", &c);
        e.pb(pi(c,0));
    }
    rep(i,h)
    {
        int c;
        scanf(" %d", &c);
        e.pb(pi(c,1));
    }

    sort(all(e));

    ll ans=0;
    rep(i,e.size())
    {
        if(e[i].se==0)
        {
            ans+=e[i].fi*(h+1);
            --w;
        }
        else
        {
            ans+=e[i].fi*(w+1);
            --h;
        }
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4464
import bisect

S=input()
dig=len(S)

ans=0

b=0#繰り上がり
for i in range(dig):
    a=int(S[dig-i-1])+b
    if a<=4:
        ans+=a
        b=0
    elif a>=6:
        ans+=(10-a)
        b=1
    else:#a==5
        if i==dig-1:
            ans+=5
            b=0
        else:
            if int(S[dig-i-2])>=5:
                b=1
            else:
                b=0
            ans+=5


        

if b==1:
    ans+=1

    
print(ans)
    
    

Measured memory_bytes: 52716
/// In the name of God
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define y1 def1
#define X first
#define Y second
#define endl '\n'
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
main(){
    IOS;
    int a[4];
    for(int i=0; i<4; i++)
        cin >> a[i];
    vector<pii> v;
    for(int i=0; i<4; i++){
        bool can = 1;
        for(int j=0; j<i; j++){
            int t = (1<<(i - j));
            if(a[i] >= t * a[j])
                can = 0;
        }
        if(can) v.push_back({(1<<i), a[i]});
    }
    int n;
    cin >> n;
    n *= 4;
    reverse(all(v));
    ll ans = 0;
    for(auto p : v){
        int mod = p.X, c = p.Y;
        ans += 1LL * c * (n / mod);
        n %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split(' '))
count1 = 0
if K % 2 == 0:
    half = K//2
    a = half
    while a <= N:
        count1 += 1
        a += K
b = 0
count2 = -1
while b <= N:
    b += K
    count2 += 1
ans = count1 ** 3 + count2 ** 3
print(ans)


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

int main(){
  int n;
  while(cin >> n, n){
    string op;
    int ans = 0;
    bool state = false;
    bool l = false, r = false;
    
    for(int i = 0 ; i < n ; i++){
      cin >> op;
      if(op == "lu") l = true;
      if(op == "ru") r = true;
      if(op == "ld") l = false;
      if(op == "rd") r = false;
      
      if(!state && l && r){ ans++; state = true; }
      if(state && !l && !r){ ans++; state = false; }      
    }
    cout << ans << endl;
  }
  
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	vector<ll> A(N);
	ll ans = 0;
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		if(i != 0) {
			if(A[i] < A[i - 1]) {
				ans += A[i - 1] - A[i];
				A[i] = A[i - 1];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
int ar[105];
int main(){
	int n;cin>>n;for(int i=1;i<=n;i++){cin>>ar[i];}
  	cout<<(*max_element(ar+1,ar+n+1)-(*min_element(ar+1,ar+n+1)));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e5+10;
int a[N],b[N];
int32_t main()
{
    int n,m;
    cin>>n>>m;
    int mx=0;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
        mx=max(mx,a[i]);
    }
    int cnt=0;
    vector<int>vp;
    for(int i=1;i<=n;i++)
    {
        if(mx<=b[i])
        {
            sum+=b[i];
            vp.pb(b[i]);
        }
    }
    sort(all(vp));
    if(sum>=m)
    {
        int ans=0;
        int k=0;

        for(int i=vp.size()-1;i>=0;i--)
        {
            k+=vp[i];
            ans++;
            if(k>=m)
            {
                cout<<ans<<endl;
                break;
            }
        }
        return 0;
    }
    else
    {
        cout<<vp.size()+((m-sum)/mx)+(((m-sum)%mx)!=0)<<endl;;
    }

}

Measured memory_bytes: 2936
#include<iostream>
using namespace std;
int main()
{
    int n,k,ans;
    cin>>n>>k;
    ans=1;
    for(int i=0;i<n;i++)
    {
        if(ans>k) 
          ans=ans+k;
        else 
          ans=ans*2;
    }

    cout<<ans<<endl; 
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> c(h);
  
  rep(i,h) cin >> c[i];
  
  rep(i,h){
    rep(j,2){
      cout << c[i] << endl;
    }
  }
  return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int A, B, C, D, E, F;
  while (cin >> A >> B >> C >> D >> E >> F) {
    const int N = 7000;
    bool sugar[N];
    bool water[N];

    fill(sugar, sugar + N, false);
    fill(water, water + N, false);
    sugar[0] = water[0] = true;

    for (int i = 0; i <= F; ++i) {
      if (sugar[i]) {
        sugar[i + C] = true;
        sugar[i + D] = true;
      }
      if (water[i]) {
        water[i + A * 100] = true;
        water[i + B * 100] = true;
      }
    }

    double mx = 0;
    int p = 100 * A;
    int q = 0;
    for (int w = 1; w <= F; ++w) {
      unless (water[w]) continue;
      for (int s = 0; s <= F && s <= (w / 100.0) * E; ++s) {
        unless (sugar[s]) continue;
        if (w + s <= F) {
          double d = 100.0 * s / (w + s);
          if (mx < d) {
            mx = d;
            p = w + s;
            q = s;
          }
        }
      }
    }
    cout << p << ' ' << q << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int  
// Function to find the number of divisors 
// of all numbers in the range [1, n] 
ll findDivisors(ll n) 
{ 
  ll ans=0;
    // Array to store the count 
    // of divisors 
    ll div[n + 1]; 
    memset(div, 0, sizeof div); 
  
    // For every number from 1 to n 
    for (ll i = 1; i <= n; i++) { 
  
        // Increase divisors count for 
        // every number divisible by i 
        for (ll j = 1; j * i <= n; j++) 
            div[i * j]++; 
    } 
  
    // Print the divisors 
    for (ll i = 1; i <= n; i++)
	ans+=i*div[i];
	return ans; 
      //  cout << div[i] << " "; 
} 
int main()
{
	ll n;
	cin>>n;
	cout<<findDivisors(n);
}


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

int main()
{
	int n, x;
	string com;
	list<int> lis;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			cin >> x;
			lis.push_front(x);
		}
		else if (com == "delete") {
			cin >> x;
			for (auto ite = lis.begin(); ite != lis.end(); ite++) {
				if (*ite == x) {
					lis.erase(ite);
					break;
				}
			}
		}
		else if (com == "deleteFirst") {
			lis.pop_front();
		}
		else if (com == "deleteLast") {
			lis.pop_back();
		}
	}
	for (auto ite = lis.begin(); ite != lis.end(); ite++) {
		if (ite == lis.begin())
			cout << *ite;
		else
			cout << ' ' << *ite;
	}
		cout << endl;
	return 0;
}



Measured memory_bytes: 34480
#include<stdio.h>

int main()
{
	char buf[1002];
	int field[2][1000];
	int i,j,n,max,tmp;

	while(1)
	{
		scanf("%d",&n);
		if(n==0){break;}
		max=0;

		for(i=0;i<=n;i++)
		{
			fgets(buf,n+2,stdin);
			for(j=0;j<n;j++)
			{
				if(i==0)
				{
					if(buf[j]=='*')
					{
						field[0][j]=0;
					}
					else
					{
						field[0][j]=1;
					}
				}				
				else
				{
					if(buf[j]=='*')
					{
						field[1][j]=0;
					}
					else
					{
						if(j>0)
						{
							tmp=field[0][j-1];
							if(tmp>field[0][j])tmp=field[0][j];
							if(tmp>field[1][j-1])tmp=field[1][j-1];
						}
						else{tmp=0;}
						field[1][j]=tmp+1;
						if(field[1][j]>max)max=field[1][j];
					}
				}
			}
			if(i>0)
			{
				for(j=0;j<n;j++)
				{
					field[0][j]=field[1][j];
				}
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

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

  int h, w;
  cin >> h >> w;
  vector<string> g(h);
  for (int i = 0; i < h; i++) {
    cin >> g[i];
  }

  queue<P> q;
  q.push(P(0, 0));

  int d[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      d[i][j] = INF;
    }
  }

  d[0][0] = g[0][0] == '.' ? 0 : 1;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      for (int i = 0; i < 2; i++) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (ny < h && nx < w) {
          int next = d[y][x] + (g[ny][nx] == '#' && g[y][x] == '.' ? 1 : 0);
          d[ny][nx] = min(next, d[ny][nx]);
        }
      }
    }
  }

  cout << d[h - 1][w - 1] << ln;

  return 0;
}

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

int main() {
    int L,R,d;
    cin >> L >> R >> d;
    L -= 1;
    cout << (R/d) - (L/d) << "\n";
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define out(a) cout<<fixed<<setprecision((a))

class UnionFind{
public:
	vector<int> par,siz;
	//0-indexed
	UnionFind(int n){
		init(n);
	}
	void init(int n = 1) {
		par.resize(n);
		siz.resize(n,1);
		for (int i = 0; i < n; ++i) par[i] = i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		else{
			return par[x] = root(par[x]);
		}
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		par[x] = y;
		siz[y] += siz[x];
	}
	int num(int x){
		return siz[root(x)];
	}
};

int reform(int h,int w,int ){

}


int main(){
	int H,W;
	cin >> H >> W;
	auto r = [H,W](int h,int w) -> int{return w+h*W;};
	string S[H];
	FOR(i,0,H)cin >> S[i];
	UnionFind uf1(H*W),uf2(H*W);
	FOR(i,0,H){
		FOR(j,0,W-1){
			if(S[i][j]=='.'&&S[i][j+1]=='.'){
				uf1.unite(r(i,j),r(i,j+1));
			}
		}
	}
	FOR(j,0,W){
		FOR(i,0,H-1){
			if(S[i][j]=='.'&&S[i+1][j]=='.'){
				uf2.unite(r(i,j),r(i+1,j));
			}
		}
	}
	int ans = 0;
	FOR(i,0,H){
		FOR(j,0,W){
			if(S[i][j]=='.'){
				ans = max(ans,uf1.num(r(i,j))+uf2.num(r(i,j))-1);
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 66944
x1, y1, x2, y2 = gets.split.map(&:to_i)

dy = y2 - y1
dx = x2 - x1

x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy

puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

typedef long long ll;
typedef map<int, int> M;
typedef pair<int, int> P;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((ll)(x).size())

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d <= s * t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};


template<typename T>
struct Combination {
private:
  int sz;
  vector<T> F, F_;
public:
  Combination(int sz) : sz(sz), F(sz+1), F_(sz+1) {
    F[0] = 1;
    for(int i = 0; i < sz; ++i) F[i+1] = F[i]*(i+1);
    F_.back() = (T)1/F.back();
    for(int i = sz-1; i >= 0; --i) F_[i] = F_[i+1]*(i+1);
  }
  T C(int n, int k){
    assert(n <= sz);
    if(n < 0 or k > n) return (T)0;
    return F[n]*F_[k]*F_[n-k];
  }
};

int main(){
  using mint = modint<(int)1e9+7>;
  Combination<mint> comb((int)1e6);
  int X, Y;
  cin >> X >> Y;
  int s = (2*Y-X)/3, t = (2*X-Y)/3;
  if(s+2*t != X or 2*s+t != Y or s < 0 or t < 0){
    cout << 0 << endl;
    return 0;
  }
  cout << comb.C(s+t,s) << endl;
}


Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int s[10000];

int main() {
	int N;
	cin >> N;
	FOR (i, N)
		cin >> s[i];
	int sum = 0;
	FOR (i, N)
		sum += s[i];
	int mm = -1;
	FOR (i, N)
		if (s[i] % 10 != 0)
			if (mm == -1 || s[i] < mm)
				mm = s[i];
	if (sum % 10 != 0)
		cout << sum << endl;
	else {
		if (mm == -1)
			cout << 0 << endl;
		else
			cout << (sum - mm) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath> 
using namespace std;
long long n[50050],f[100050],zs,a,lefts,rights;
//n[]为辅助空间，里面处理完全是质数；f[]用来前缀和，zs代表质数个数（欧拉线筛需要）
bool b[100050];
//标准的质数表
int main()
{
	b[0]=1,b[1]=1;//初始值
	for(int s=2;s<=100005;s++)//欧拉线筛
	{
		if(!b[s])//一个质数
		{
			n[zs++]=s;
		}
		for(int v=0;v<zs;v++)//处理
		{
			if(s*n[v]>100005)break;//超过了所求的质数范围
			b[n[v]*s]=true;//筛质数
			if(s%n[v]==0)break;//压成到O(n)的关键
		}
	}
	cin>>a;
	for(int s=2;s<=100005;s++)//前缀和
	{
		if(s%2==1&&b[s]==0&&b[(s+1)/2]==0)
		f[s]=1;
		f[s]+=f[s-1];
	}
	while(a--)//输入
	{
		cin>>lefts>>rights;
		cout<<f[rights]-f[lefts-1]<<endl;//前缀和的大法
	}
    return 0;
}

Measured memory_bytes: 1536
N=int(input())
inf=100000
dp=[inf for _ in range(N+1)]
dp[0]=0
for n in range(1,N+1):
    num=100000
    i=0
    j=0
    while 9**(i+1)<=n:
        i+=1
    while 6**(j+1)<=n:
        j+=1
    for k in range(i+1):
        num=min(num,dp[n-9**k]+1)
    for k in range(j+1):
        num=min(num,dp[n-6**k]+1)
    dp[n]=min(dp[n],num)
print(dp[N])

Measured memory_bytes: 9868
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
//#include<stdlib.h>
using namespace std;
int main() {
	int a,b,d;
	cin >> a >> b;
	if (a > 12) { d = b; }
	else if (a > 5) { d = b / 2; }
	else d = 0;
	cout << d;
	return 0;
}

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

typedef long long ll;
const ll InF = 1e15;

int main() {
  map<char,char> alp1,alp2;
  for (char c = 'a'; c <= 'z'; c++) alp1[c] = alp2[c] = c;
  string s,t;
  cin>>s>>t;
  bool ok = true;
  for (int i = 0; i < s.size(); i++) {
    if (alp1[s[i]] == s[i] && alp2[t[i]] == t[i] && s[i] != t[i]) {
      alp1[s[i]] = t[i];
      alp2[t[i]] = s[i];
    } else if (alp1[s[i]] != s[i] && alp1[s[i]] != t[i]) {
      ok = false;
      break;
    } else if (alp2[t[i]] != t[i] && alp2[t[i]] != s[i]) {
      ok = false;
      break;
    }
  }
  if (ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;

    bool ans = false;
    for( int i = s.size() - 1; i >= t.size() - 1; --i ) {
        bool flg = true;
        int spos = i;
        int tpos = t.size() - 1;
        while( flg && tpos >= 0 ) {
            if( s[spos] != t[tpos] && s[spos] != '?' ) flg = false;
            --spos;
            --tpos;
        }

        if( flg ) {
            spos = i; tpos = t.size() - 1;
            while( tpos >= 0 ) {
                s[spos] = t[tpos];
                --spos; --tpos;
            }
            ans = true;
            break;
        }
    }

    if( ans ) {
        for( int i = 0; i < s.size(); ++i ) {
            if( s[i] == '?' ) cout << 'a';
            else cout << s[i];
        }
    } else cout << "UNRESTORABLE";

    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, M, K; cin >> N >> M >> K;
  vector<ll> A(N+1, 0), B(M+1, 0);
  rep(i, N) cin >> A[i+1];
  rep(i, M) cin >> B[i+1];
  rep(i, N) A[i+1] += A[i];
  rep(i, M) B[i+1] += B[i];
  ll ans = 0;
  rep(i, N+1){
    ll k = K-A[i];
    if (k < 0)
      break;
    ll tmp = i;
    auto itr = lower_bound(all(B), k+1);
    ll add = itr - B.begin() - 1;
    tmp += add;
    chmax(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6352
from itertools import permutations

N = int(input())
points = []
for _ in range(N):
    x, y = map(int, input().split())
    points.append((x, y))

lengths = []
for ps in permutations(points):
    lengths.append(sum(
        ((ps[i][0] - ps[i - 1][0]) ** 2 + (ps[i][1] - ps[i - 1][1]) ** 2) ** 0.5
        for i in range(1, N)
    ))
print(sum(lengths) / len(lengths))

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

int main() {
    int n;
    cin >> n;
    deque<int> deq;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (i & 1)
            deq.push_back(a);
        else
            deq.push_front(a);
    }

    bool first = true;
    if ((n & 1) == 0) {
        reverse(deq.begin(), deq.end());
    }
    for (int x : deq) {
        if (first) {
            first = false;
        } else {
            cout << ' ';
        }
        cout << x;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
struct edge{ll to, cost;};
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define INF 1000000000000
#define ALL(a)  (a).begin(),(a).end()
#define large 1000000000000000000
#define mod 1000000007

int modPow(long long a, long long n, long long p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    if(n == 2 && a == 1 && b == 2){
        cout << 0 << endl;
        return 0;
    }
    ll zentai = 2;
    ll ans = 0;
    zentai = modPow(2,n,mod);
    ll x = 1,y=1;
    for(int i = 0; i < a;i++){
        x *= (n-i) % mod;
        x = x % mod;
    }
    for(int i = 1; i <= a;i++){
        y *= i % mod ;
        y = y % mod;
    }
    ll huga = modPow(y,mod-2,mod);
    ll ans1 = x * huga % mod;
    x = 1,y=1;
    for(int i = 0; i < b;i++){
        x *= (n-i) % mod;
        x = x % mod;
    }
    for(int i = 1; i <= b;i++){
        y *= i % mod ;
        y = y % mod;
    }
    ll hoge = modPow(y,mod-2,mod);
    ll ans2 = x * hoge % mod;


    ans = zentai - 1;
    ans += mod - ans1;
    ans %= mod;
    ans += mod - ans2;
    ans %= mod;
    cout << ans << endl;

}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 26.01.2020 20:47:14       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> t(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    t[x].push_back(y);
    t[y].push_back(x);
  }
  vector<vector<int>> pr(n, vector<int>(n, -2));
  vector<vector<int>> ques(n);
  for (int start = 0; start < n; start++) {
    vector<int>& que = ques[start];
    que.assign(1, start);
    pr[start][start] = -1;
    for (int b = 0; b < (int) que.size(); b++) {
      for (int j : t[que[b]]) {
        if (pr[start][j] == -2) {
          que.push_back(j);
          pr[start][j] = que[b];
        }
      }
    }
  }
  vector<vector<int>> id(n, vector<int>(n, -1));
  function<void(int, int)> Add = [&](int x, int y) {
    if (x == y) {
      return;
    }
    if (id[x][y] != -1) {
      Add(id[x][y], y);
      return;
    }
    if (id[y][x] != -1) {
      Add(x, id[y][x]);
      return;
    }
    vector<pair<int, int>> go;
    for (int start : {x, y}) {
      int other = x ^ y ^ start;
      vector<int> que(1, start);
      id[other][start] = start;
      for (int b = 0; b < (int) que.size(); b++) {
        for (int j : t[que[b]]) {
          if (j != pr[other][que[b]]) {
            if (id[other][j] != -1) {
              go.emplace_back(start, j);
            } else {
              que.emplace_back(j);
              id[other][j] = start;
            }
          }
        }
      }
    }
    for (auto& p : go) {
      Add(p.first, p.second);
    }
  };
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    Add(x, y);
  }
  vector<vector<int>> g(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (id[i][j] == j) {
        g[i].push_back(j);
      }
    }
  }
  int ans = 0;
  for (int start = 0; start < n; start++) {
    function<void(int, int)> Dfs = [&](int v, int r) {
      if (id[r][v] == v) {
        ++ans;
        r = v;
      }
      for (int j : t[v]) {
        if (j != pr[start][v]) {
          Dfs(j, r);
        }
      }
    };
    Dfs(start, start);
  }
  cout << ans / 2 << '\n';
  return 0;
}


Measured memory_bytes: 48384