akhauriyash/Code-Regression huggingface dataset:
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	
	int ac=0,wa=0,tle=0,re=0;
	
	
	string s;
	rep(x,0,n){
		cin>>s;
		
		if (s=="AC") ac++;
		else if (s=="WA") wa++;
		else if (s=="TLE") tle++;
		else re++;
	}
	
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
#define ll long long
const int N = 1e5+5;
int n,a[N];
ll cal(int m,int op1,int op2){
	ll sum=0;
	for (int i=1;i<=m;++i) sum-=a[i]<<1;
	sum+=a[m+1]*op1;sum+=a[m+2]*op2;
	for (int i=m+3;i<=n;++i) sum+=a[i]<<1;
	return sum;
}
int main(){
	n=gi();
	for (int i=1;i<=n;++i) a[i]=gi();
	sort(a+1,a+n+1);
	if (n&1) printf("%lld\n",max(cal(n-3>>1,-1,-1),cal(n-1>>1,1,1)));
	else printf("%lld\n",cal(n-2>>1,-1,1));
	return 0;
}


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


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>

pii h[100010];

int n;
char s[100010];

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	if (s[n]=='1'||s[1]=='0'||s[n-1]=='0') { puts("-1");return 0; }
	for (int i=1;i<n;i++) if (s[i]!=s[n-i]) { puts("-1");return 0; }
	int tot=1,now=1,tt=0,sum=1;
	while (233)
	{
		int fa=++tot;sum++;
		h[++tt]=pii(fa,now);
		while (s[sum]=='0'&&sum<n) h[++tt]=pii(fa,++tot),sum++;
		now=fa;if (sum==n) break;
	}
	for (int i=1;i<n;i++) printf("%d %d\n",h[i].first,h[i].second);
	return 0;
}

Measured memory_bytes: 2304
nt = input().split(" ")
n = int(nt[0])
t = int(nt[1])

min_cost = 0

for i in range(n):
    cost_time = input().split(" ")
    cost = int(cost_time[0])
    time = int(cost_time[1])
    if time <= t:
        if min_cost == 0:
            min_cost = cost
        else:
            if min_cost > cost:
                min_cost = cost

if min_cost == 0:
    print("TLE")
else:
    print(min_cost)  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define INFI ((ll)1e9)
#define MINI ((ll)-1e9)
using namespace std;
typedef long long ll;       
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }          
ll height[200001];
ll beauty[200001];
ll n;

#define oper max
#define NEUT 0
struct STree { // segment tree for min over llegers
	vector<ll> st;ll n;
	STree(ll n): st(4*n+5,NEUT), n(n) {}
	void init(ll k, ll s, ll e, ll *a){
		if(s+1==e){st[k]=a[s];return;}
		ll m=(s+e)/2;
		init(2*k,s,m,a);init(2*k+1,m,e,a);
		st[k]=oper(st[2*k],st[2*k+1]);
	}
	void upd(ll k, ll s, ll e, ll p, ll v){
		if(s+1==e){st[k]=v;return;}
		ll m=(s+e)/2;
		if(p<m)upd(2*k,s,m,p,v);
		else upd(2*k+1,m,e,p,v);
		st[k]=oper(st[2*k],st[2*k+1]);
	}
	ll query(ll k, ll s, ll e, ll a, ll b){
		if(s>=b||e<=a)return NEUT;
		if(s>=a&&e<=b)return st[k];
		ll m=(s+e)/2;
		return oper(query(2*k,s,m,a,b),query(2*k+1,m,e,a,b));
	}
	void dump(ll n){
		fore(i,0,n){
			cout << st[i] << " ";
		}
		cout << endl;
	}
	void init(ll *a){init(1,0,n,a);}
	void upd(ll p, ll v){upd(1,0,n,p,v);}
	ll query(ll a, ll b){return query(1,0,n,a,b);}
}; // usage: STree rmq(n);rmq.init(x);rmq.upd(i,v);rmq.query(s,e);

int main(){FIN;
	cin >> n;
	fore(i,0,n){
		cin >> height[i];
	}
	fore(i,0,n){
		cin >> beauty[i];
	}
	STree rmq(n+1);
	fore(i,0,n){
		rmq.upd(height[i],rmq.query(0,height[i])+beauty[i]);
	}
	cout << rmq.query(0,n+1);
	
	
}

Measured memory_bytes: 9600
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	if (S[2] == S[3] && S[4] == S[5])
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }

void solve() {
    int n = read();
    int[] a = reads();

    int r, m;
    long ans;
    foreach (l; 0..n) {
        while (r < n && !(m & a[r])) {
            m ^= a[r++];
        }
        ans += r - l;
        m ^= a[l];
    }
    writeln(ans);
}


void main() {
    solve();
    readln;
}

Measured memory_bytes: 10800
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

signed main()
{
	int N;
	string S, T;
	cin >> N;
	cin >> S >> T;
	string ans;
	for (int i = 0; i < N; i++)
	{
		ans += S[i];
		ans += T[i];
	}
	cout << ans << endl;
}




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 inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    int n;
    ll ans = 0;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    priority_queue<ll>dq;
    rep(i,n){
        if(i==0) continue;
        if(i==1) {
            ans += a[0];
            dq.push(a[1]);
            dq.push(a[1]);
        }
        else{
            ans += dq.top();
            dq.pop();
            dq.push(a[i]);
            dq.push(a[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6924
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, a, k = 0;
	cin >> num;
	for (i = 1; i <= num; i++) {
		cin >> a;
		if (a != i)
			k++;
	}
	if (k <= 2)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int[] a = new int[3];
                for(int i = 0 ; i < 3 ; i++){
                        a[i] = sc.nextInt();
                }
                sc.close();
                System.out.println(a[0] * a[1] / 2);
        }
}

Measured memory_bytes: 35704
#include <stdio.h>

// 再帰関数
/*
int keta(int n) {
	if (n < 10)
		return 1;

	return keta(n / 10) + 1;
}
*/

int keta(int n) {
	int ret = 1;

	while (n > 9) {
		n /= 10;
		++ret;
	}

	return ret;
}

/*
int keta(int n) {
	int ret;
	char str[100];

	sprintf(&str[0], "%d", n);

	for (ret = 0; str[ret]; ++ret);

	return ret;
}
*/

int main() {
	int a, b, c;

	while (scanf("%d%d", &a, &b) != EOF) {
		c = a + b;
		printf("%d", keta(c));
		puts("");
	}
	return 0;
}

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

int main(){

  int n;

  while(cin>>n, n){
    int w, h, s, t;
    cin>>w>>h;
    bool p[101][101]={};
    for(int i=0;i<n;i++){
      int x, y;
      cin>>x>>y;
      p[y][x]=true;
    }
    cin>>s>>t;
    int cnt=0, ma=0;
    for(int i=1;i<=h-t+1;i++){
      for(int j=1;j<=w-s+1;j++){
	for(int y=i;y<=i+t-1;y++){
	  for(int x=j;x<=j+s-1;x++){
	    if(p[y][x]==true) cnt++;
	  }
	}
	ma=max(ma, cnt);
	cnt=0;
      }
    }
    cout<<ma<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define int long long
int a[114514];
int b[114514];
using namespace std;
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n%2==0){
        for(int i=0;i<n;i++){
            if(a[i]%2!=1){
                cout<<0<<endl;
                return 0;
            }
            else{
                b[(a[i]-1)/2]++;
            }
        }
        for(int i=0;i<n/2;i++){
            if(b[i]!=2){
                cout<<0<<endl;
                return 0;
            }
        }
        int ans=1;
        for(int i=0;i<n/2;i++){
            ans=ans*2;
            ans=ans%1000000007;
        }
        cout<<ans<<endl;
    }
    else{
        for(int i=0;i<n;i++){
            if(a[i]%2!=0){
                cout<<0<<endl;
                return 0;
            }
            else{
                b[a[i]/2]++;
            }
        }
        if(b[0]!=1){
            cout<<0<<endl;
            return 0;
        }
        for(int i=0;i<n/2;i++){
            if(i!=0&&b[i]!=2){
                cout<<0<<endl;
                return 0;
            }
        }
        int ans=1;
        for(int i=0;i<n/2;i++){
            ans=ans*2;
            ans=ans%1000000007;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll x;
  cin >> x;
  for (ll i = -2500; i <= 2500; i++) {
    for (ll j = -2500; j <= 2500; j++) {
      if (i * i * i * i * i - j * j * j * j * j == x) {
        cout << i << ' ' << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3652
H, W = map(int, input().split())

G = []
for _ in range(H):
    G.append(list(input()))

L, R, U, B = [], [], [], []
for y in range(H):
    targets = [L, R]
    ranges = [range(W), range(W-1, -1, -1)]
    for target, rng in zip(targets, ranges):
        row = [0] * W
        c = -1
        for x in rng:
            if G[y][x] == "#":
                c = -1
            else:
                c += 1
            row[x] = c
        target.append(row)
for x in range(W):
    targets = [U, B]
    ranges = [range(H), range(H-1, -1, -1)]
    for target, rng in zip(targets, ranges):
        col = [0] * H
        c = -1
        for y in rng:
            if G[y][x] == "#":
                c = -1
            else:
                c += 1
            col[y] = c
        target.append(col)

max_light = 0
for y in range(H):
    for x in range(W):
        light = L[y][x] + R[y][x] + U[x][y] + B[x][y] + 1
        max_light = max(light, max_light)
print(max_light)


Measured memory_bytes: 346728
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int n;cin>>n;
    string s,t;cin>>s>>t;
    string ans="";
    for(int i=0;i<n;i++){
        ans+=s[i];
        ans+=t[i];
    }
    cout<<ans;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val input = readLine()!!.trim().split(" ").filterNot(String::isBlank).map(String::toInt)
    println(
        if (input[0] >= 13) {
            input[1]
        } else if (input[0] <= 5) {
            0
        } else {
            input[1] / 2
        }
    )
}

Measured memory_bytes: 37868
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.trim().split("\n");
  const [N, K] = input[0].split(" ").map((n) => parseInt(n));
  var ans = N.toString(K).length
  console.log(ans);
}
// *この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require("fs").readFileSync("./input.txt", "utf-8"));


Measured memory_bytes: 29564
#include <iostream>
using namespace std;
int N,fields[2][200];
int max(int x,int y){
        return x>y?x:y;
}
int main(){
        cin >> N;
        for(int i=0 ; i<2 ; i++ )
                for(int j=0 ; j<N ; j++ )
                        cin >> fields[i][j];
        fields[1][N]=fields[0][N]=0;
        int m=0;
        for(int i=0 ; i<N ; i++ ){
                int res=0;
                for(int l=0;l<=i;l++){
                        res+=fields[0][l];
                }
                for(int l=i;l<N;l++){
                        res+=fields[1][l];
                }
                m=max(m,res);
        }
        cout << m<<endl;
        return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 9223372036854775807
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n;
  string s;
  cin >> n >> s;
  
  int cnt = 1;
  bool f[n];
  REP(i,n) f[i] =false;
  while(cnt != 0){
    cnt = 0;
    REP(i,n-1){
      if(s[i]!='(' || f[i]) continue;
      int j = i+1;
      while(f[j]) j++;
      if(j < n && s[j] == ')'){
        f[i] = f[j] = true;
        cnt++;
      }
    }
  }
  
  int l = 0, r = 0;
  REP(i,n){
    if(!f[i]){
      if(s[i] == '(') r++;
      else			  l++;
    }
  }
  
  REP(i,l) cout << "(";
  REP(i,n) cout << s[i];
  REP(i,r) cout << ")";
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long ll;

int main(void)
{
	ll a, b, n;

	scanf("%lld %lld %lld", &a, &b, &n);

	ll rlast = n % b;
	if (n - rlast - 1 > 0)
		rlast = b - 1;

	printf("%lld", a * rlast / b);
	return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;
public class Main { 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//データ入力数nとmをここで得る。
		int n =sc.nextInt();
		int m = sc.nextInt();
		//bとAの配列を作る
		int[]b = new int[100];
		int[][]A = new int[100][100];
		//答えを入れておくように箱作っておく
		int[]ans= new int[100];

		//配列Aの読み込み
		for(int i=0;i<n;i++) {
			for(int j=0;j<m;j++) {
				A[i][j] = sc.nextInt();
			}
		}

		//配列bの読み込み
		for(int j=0;j<m;j++) {
			b[j]=sc.nextInt();
		}
		//中身の計算
		for(int i = 0; i < n; i++) {
			ans[i]=0;
			for(int j = 0; j < m; j++){
				ans[i] += A[i][j]*b[j];
			}
		}
		//出力
		for (int i = 0; i < n; i++) {
			System.out.println(ans[i]);
		}
	}
}





Measured memory_bytes: 40896
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    bool rev = false;
    Int count = 0;
    string fr = "", ba = "";
    for (Int i = 0; i < q; i++) {
        int t;
        cin >> t;

        if (t == 1) {
            count++;
            rev = !rev;
        } else {
            int f = 0;
            char c = '\0';
            cin >> f >> c;

            if (!rev) {
                if (f == 1) {
                    fr.push_back(c);
                } else {
                    ba.push_back(c);
                }
            } else {
                if (f == 1) {
                    ba.push_back(c);
                } else {
                    fr.push_back(c);
                }
            }
        }
    }

    if (count % 2 == 1) {
        reverse(ba.begin(), ba.end());
        reverse(s.begin(), s.end());
        s = ba + s + fr;
    } else {
        reverse(fr.begin(), fr.end());
        s = fr + s + ba;
    }

    cout << s << endl;
}


Measured memory_bytes: 1348
a=[input() for i in range(2)]
a1=int(a[0])
a2=[int(i) for i in a[1].split()]

money=1000
kabu=0

for i in range(a1-1):
	if a2[i]<a2[i+1]:
		kabu=int(money/a2[i])
		money+=kabu*(a2[i+1]-a2[i])

print(money)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main()
{
	daman;
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
		
	map<int,int>m;
	
	for(int i=0;i<n;i++)
		m[arr[i]]++;
		
	bool sieve[1000001];
	
	for(int i=0;i<=1000001;i++)
		sieve[i] = true;
	
	int max = *max_element(arr,arr+n);
	
	for(int i=0;i<n;i++)
	{
		int temp = arr[i],ans = 2*arr[i];
		int count = 3;
		
		while(ans <= max){
			sieve[ans] = false;
			ans = temp*count;
			count++;
		}
	}
	
	int count = 0;
	
	for(int i=0;i<n;i++)
	{
		if(sieve[arr[i]] == true && m[arr[i]] == 1){
			count++;
		}
	}
	
	cout<<count<<"\n";
	
}

Measured memory_bytes: 14772
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  string s;
  cin >>s;
  bool a[26];
  for(int i=0; i<26;i++)
  a[i]=false;

  int n=s.length();
  for(int i=0;i<n;i++)
  a[s[i]-'a']=true;

  for(int i=0;i<26;i++){
    if(!(a[i])) {cout<<(char)(i+'a')<<endl; return 0;}
  }

cout<<"None"<<endl;


}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

/*
//C
int main(void) {
	int n;
	cin >> n;
	vector<ll> a = vector<ll>(n);

	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll index = n;
	rep(i, 0, n) {
		if (a[i] >= 0) {
			index = i;
			break;
		}
	}
	if (index <= 1 && index != n) {
		ll sum = -a[0];
		rep(i, 1, n) {
			sum += a[i];
		}
		cout << sum << endl;
		rep(i, 0, n - 2) {
			cout << a[i] << " " << a[i + 1] << endl;
			a[i + 1] = a[i] - a[i + 1];
		}
		cout << a[n - 1] << " " << a[n - 2] << endl;
	}
	else {
		vector<string> ans = vector<string>();
		if (index == n)index = n - 1;
		for (int i = index - 1; i > 0; i--) {
			ans.push_back(to_string(a[n - 1]) + " " + to_string(a[i]));
			a[n - 1] -= a[i];
		}
		rep(i, index, n - 1) {
			ans.push_back(to_string(a[0]) + " " + to_string(a[i]));
			a[0] -= a[i];
		}
		ans.push_back(to_string(a[n - 1]) + " " + to_string(a[0]));
		a[n - 1] -= a[0];
		cout << a[n - 1] << endl;
		rep(i, 0, ans.size()) {
			cout << ans[i] << endl;
		}
	}
	
}
*/


//B
int main(void) {
	vector<pair<ll, ll>> p = vector<pair<ll, ll>>();
	int n;
	cin >> n;
	rep(i, 0, n) {
		ll x, y;
		cin >> x >> y;
		p.push_back(make_pair(x, y));
	}
	map<pair<ll, ll>, ll> mp = map<pair<ll, ll>,ll>();
	rep(i, 0, n) {
		rep(j, 0, n) {
			if(i != j)
			mp[make_pair(p[i].first - p[j].first, p[i].second - p[j].second)]++;
		}
	}

	auto iter = mp.begin();
	ll count = 0;
	while (iter != mp.end()) {
		count = max(count, iter->second);
		iter = next(iter, 1);
	}

	cout << n - count << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define PB push_back
#define P push
#define inf 100000000000000000
vector<LL>vc;
LL dp[100000+9];
LL rec(LL pos,LL n)
{

    if(pos==n-1)
    {
        return abs(vc[pos]-vc[n-1]);;
    }

    if(dp[pos]!=-1) return dp[pos];

    LL res1,res2;

    if(pos+1<n) res1=rec(pos+1,n)+abs(vc[pos]-vc[pos+1]);
    else res1=inf;
    if(pos+2<n) res2=rec(pos+2,n)+abs(vc[pos]-vc[pos+2]);
    else res2=inf;

    return dp[pos]= min(res1,res2);


}

int main()
{
    memset(dp,-1,sizeof(dp));
    LL n,i,j,m;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>m;
        vc.PB(m);
    }

    cout<<rec(0,n)<<endl;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define BR "\n"

int toInt(string s) {
  int ans = 0;
  rep0(i, s.size()) {
    ans = ans * 10 + (s[i] - '0');
  }
  return ans;
}

int main() {

  stack<int> sta;
  string line, s;
  getline(cin, line);
  istringstream iss(line);

  while (iss >> s) {
    
    if (s[0] == '+' || s[0] == '-' || s[0] == '*') {
      int a, b;
      a = sta.top(); sta.pop();
      b = sta.top(); sta.pop();

      if (s[0] == '+') sta.push(b + a);
      if (s[0] == '-') sta.push(b - a);
      if (s[0] == '*') sta.push(b * a);

    } else {
      int a = toInt(s);
      sta.push(a);
    }
  }

  cout << sta.top() << BR;
  return 0;
}


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

int main(){
	int N,K;
	cin >> N >> K;
	vector<int> a(N);
	for(int i=0; i<N; i++) cin >> a[i];

	vector<bool> dp(K+1,false);
	for(int i=1; i<=K; i++){
		for(int j=0; j<N; j++){
			if( i-a[j]>=0 && !dp[i-a[j]]) dp[i] = true;
		}
	}

	if(dp[K]) cout << "First" << endl;
	else cout << "Second" << endl;

	return 0;
}



Measured memory_bytes: 3608
#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 d, t, s;
  cin >> d >> t >> s;
  string ans;
  if((double)d/s <= t){
    ans = "Yes";
  }else{
    ans = "No";
  }
  cout << ans << endl;

}

Measured memory_bytes: 3560
n = int(input())
s = int(input())

flag = False
if s > n or (n//2)+1<s<n:
  print(-1)
  exit()
  
if s == n:
  print(n+1)
  exit()

def chk(b, n):
  if n//b == 0:
    return n
  else:
    return chk(b,n//b) + n%b

for b in range(2, int(n**0.5)+1):
  if chk(b, n) == s:
    print(b)
    flag = True
    exit()

for i in range(int(n**0.5), 0, -1):
  b = (n-s)//i + 1
  if chk(b, n) == s:
    if b > 1:
      print(b)
      flag = True
      exit()

if flag == False:
  print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <regex>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    string s; 
    cin >> s;
    cout << (regex_match(s, regex("(erase|eraser|dream|dreamer)*")) ? "YES\n" : "NO\n");
    return 0;
}

Measured memory_bytes: 39760
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
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(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int X=tx-sx;
    int Y=ty-sy;
    string S;
    rep(i,X){
        S=S+"R";
    }
    rep(i,Y){
        S=S+"U";
    }
    rep(i,X){
        S=S+"L";
    }
    rep(i,Y){
        S=S+"D";
    }
    S=S+"D";
    rep(i,X+1){
        S=S+"R";
    }
    rep(i,Y+1){
        S=S+"U";
    }
    S=S+"LU";
    rep(i,X+1){
        S=S+"L";
    }
    rep(i,Y+1){
        S=S+"D";
    }
    S=S+"R";
    cout<<S<<endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
using namespace std;

int n,a[105];

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	int ans=0x3f3f3f3f;
	for(int i=1;i<=100;i++){
		int s=0;
		for(int j=1;j<=n;j++)
		s+=(a[j]-i)*(a[j]-i);
		ans=min(ans,s);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int N,K;
    ll ans=0;
    cin >> N >> K;
    
    REP2(b,K+1,N+1){
        ans+=(b-K)*(N/b);
        if(K==0) ans+=max(0,N%(int)b-K);
        else ans+=max(0,N%(int)b-K+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    X = int(input())
    if X == 1:
        print(1)
    else:
        for x in range(X, 0, -1):
            for b in range(2, X):
                p = 2
                while True:
                    if b ** p > x:
                        break
                    if x == b ** p:
                        print(x)
                        exit()
                    p += 1


main()


Measured memory_bytes: 2940
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	cnt := 0
	for i := 0; i < N; i++ {
		A, B := sc.NextInt(), sc.NextInt()
		if A != B {
			cnt = 0
		} else {
			cnt++
		}

		if cnt >= 3 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){
    int N;
    cin>>N;
    int A[N], B[N][N], i, j;
    for (i=0; i<N; i++){
        cin>>A[i];
    }
    for (i=0; i<N; i++){
        for (j=0; j<N; j++){
            B[i][j]=std::abs(A[i]-A[j]);
        }
    }

    int max_abs=0;

    for (i=0; i<N; i++){
        for (j=0; j<N; j++){
            if (B[i][j] > max_abs){
                max_abs = B[i][j];
            }
        }
    }

    cout<<max_abs<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int a, b, c;
  std::string res = "NO";
  std::cin >> a >> b >> c;
  if((a == 7 && b == 5 && c == 5) ||
    (a == 5 && b == 7 && c == 5 ) ||
    (a == 5 && b == 5 && c == 7))
  {
    res = "YES";
  }
  std::cout << res;
  return 0;
}

Measured memory_bytes: 3532
import math,sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda:int(input())
li = lambda:list(map(int,input().split()))

def solve():
    n=I()
    a=[2,4,5,7,9]
    b=[0,1,6,8]
    if(n%10 in a):
        print("hon")
    elif(n%10 in b):
        print("pon")
    else:
        print("bon")

for _ in range(1):
    solve()

Measured memory_bytes: 65096
(*,n) = gets.split.map(&:to_i)
s = gets.chomp
si = Array.new(s.size, 0)
b = n.times.map{gets.split.map(&:to_i)}

s.each_char.with_index do |c, i|
  si[i] = s[i-1..i] == 'AC' ? si[i-1]+1 : si[i-1]
end
puts b.map { |e| si[e[1]-1] - si[e[0]-1]  }


Measured memory_bytes: 11772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

const ll N=1e3+10;
ll n,m;
vector<set<ll>> G(N),GG(N);

int main() {
  cin >> n >> m;
  for(ll i=0;i<m;i++) {
    ll a,b;
    cin >> a >> b;
    a--,b--;
    G[a].insert(b);
    GG[b].insert(a);
  }
  ll ans=inf;
  vec ansv(n);
  for(ll i=0;i<n;i++) {
    priority_queue<pll> q;
    ll id=-1;
    vec d(n,-1);
    q.push({0,i});
    while(q.size()) {
      ll f=q.top().second;
      ll td=q.top().first;
      q.pop();
      if(d[f]>-1) continue;
      d[f]=td;
      for(ll t:G[f]) {
        ll nd=td+1;
        if(t==i) {
          id=f;
          break;
        }
        q.push({nd,t});
      }
      if(id>-1) break;
    }
    if(id>-1) {
      if(ans>d[id]+1&&d[id]) {
        ans=d[id]+1;
        ll j=0;
        while(1) {
          ansv[j]=id+1;
          j++;
          if(id==i) break;
          for(ll t:GG[id]) {
            if(d[t]+1==d[id]) {
              id=t;
              break;
            }
          }
        }
      }
    }
  }
  if(ans==inf) ans=-1;
  cout << ans << endl;
  for(ll i=0;i<ans;i++) {
    cout << ansv[ans-i-1] << endl;
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;

using namespace std;
int main() {
	int n;
	vector<int> hats(3,0);
	
	ll ans = 1;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		ll count = 0;
		int last = 0;
		for(int j = 0; j < 3; j++) {
			if (hats[j] == a) {
				count++;
				last = j;
			}
		}
		ans = (ans * count) % 1000000007LL;
		hats[last]++;
	}




	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
vector <vector<int> > inp;
 
int dp[(int)pow(10,5)][3];
 
int find(int n,int A){
  if(n==1){
    dp[n-1][A]= inp[n-1][A];
    return inp[n-1][A];
  }
  if(dp[n-1][A]!=0){
    return dp[n-1][A] ;
  }
  else{
  	dp[n-1][A] = max(inp[n-1][A]+find(n-1,(A+1)%3), inp[n-1][A]+find(n-1,(A+2)%3));
    return dp[n-1][A] ;
  }
	  
}
 
int main(){
    int N,temp;
    cin >> N;
    for(int i=0;i<N;i++){
      vector<int>  temp1;
      for(int j=0;j<3;j++){
        cin >> temp;
        temp1.push_back(temp);
 
      }  
      inp.push_back(temp1);
    }	
    for(int i=0;i<N;i++){
      for(int j=0;j<3;j++){
        dp[i][j]=0;
      }
    }    
 
    
    int happ = max(find(N,0),find(N,1));
    int final_happ = max(happ,find(N,2));
    cout << final_happ;
    return 0;
  
}

Measured memory_bytes: 17760
#include"bits/stdc++.h"
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int ans=0;
	if(a!=b || b!=c){
		while(!(a&1 || b&1 || c&1)){
			int x=(b+c)/2,y=(a+c)/2,z=(a+b)/2;
			a=x,b=y,c=z;
			++ans;
		}
		cout<<ans;
	}
	else
		cout<<(a&1 ? 0:-1);
}

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

int main(){
  int N,A;
  cin >> N >> A;
  
  if(N%500 == 0){
    cout << "Yes" << endl;}
  
  else{
    if(N%500 <= A){
      cout << "Yes" << endl;}
    
    if(N%500 >= A){
      cout << "No" << endl;}
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
const ll inf = 1e18;

ll n;
pair<ll,ll> a[200005];

int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) {
		scanf("%lld%lld",&a[i].X,&a[i].Y);
		if(a[i].X > a[i].Y) swap(a[i].X, a[i].Y);
	}
	sort(a+1, a+1+n);
	ll N1 =	inf, X1 = -inf, N2 = inf, X2 = -inf;
	for(ll i=1;i<=n;i++) {
		N1 = min(a[i].X, N1); X1 = max(a[i].X, X1);
		N2 = min(a[i].Y, N2); X2 = max(a[i].Y, X2);
	}
	ll ans = (X2 - N2) * (X1 - N1), C = inf;
	for(ll i=1;i<=n;i++) {
		ans = min(ans, (X2 - N1)*(X1 - min(C, a[i].X)));
		C = min(C, a[i].Y);
		X1 = max(X1, a[i].Y);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

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; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = (1e9+7);
#define rep(i,n) for(ll i=0;i<(n);++i)

main(){

  string s;
  cin>>s;

  ll n=s.size();
  vector<ll> C(n);
  vector<vector<ll>> dp (n+1,vector<ll>(13,0));
  C[0]=1LL;
  for(ll i=1;i<n;++i)C[i]=C[i-1]*10%13;
  reverse(s.begin(),s.end());
  if(s[0]=='?'){
    rep(i,10){
      dp[1][i]++;
    }
  }
  else{
    dp[1][ (s[0]-'0') ]++;
  }
  for(ll i=1;i<n;++i){
    if(s[i]=='?'){
      rep(j,10){
        rep(k,13){
          ll num=j*C[i]%13;
          num+=k;
          num%=13;
          dp[i+1][num]+=dp[i][k];
          dp[i+1][num]%=MOD;
        }
      }
    }
    else{
      rep(k,13){
        ll num=s[i]-'0';
        num*=C[i];
        num+=k;
        num%=13;
        dp[i+1][num]+=dp[i][k];
        dp[i+1][num]%=MOD;
      }
    }
  }
  cout<<(dp[n][5])<<endl;

}

Measured memory_bytes: 14464
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;

struct Problem {

	void Solve() {
		UL n; cin >> n;
		bool ins[100] = {};
		stack<UL> spot; spot.push(101);
		int mem[1000]; rep(i, n) cin >> mem[i];
		rep(i, n) {
			if (mem[i] > 0) {
				UL c = mem[i] - 1;
				if (ins[c]) { cout << i + 1 << endl; return; }
				ins[c] = true;
				spot.push(c);
			}
			else {
				UL c = (-mem[i]) - 1;
				if (!ins[c]) { cout << i + 1 << endl; return; }
				if (spot.top() != c) { cout << i + 1 << endl; return; }
				ins[c] = false;
				spot.pop();
			}
		}
		cout << "OK" << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9;
int main(){
	int n;
	cin>>n;
	int x[n];
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	int ans=inf;
	for(int i=0;i<100;i++){
		int sum=0;
		for(int j=0;j<n;j++){
			sum+=pow((x[j]-i),2);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  map<int,int> m;
  rep(i,n){
    int a; cin>>a;
    m[a+1]++,m[a-1]++,m[a]++;
  }
  int ans=0;
  for(auto e: m){
    chmax(ans,e.second);
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repb(i, n) for (int i = (int)n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define repsb(i, m, n) for (int i = (int)m; i >= (int)n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
#define ll long long int
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
using namespace std;
int main(int argc, char const *argv[])
{

    int n, ave, cnt;

    while (1)
    {
        ave = cnt = 0;
        cin >> n;
        if (n == 0)
            break;
        vector<int> v(n);
        rep(i, n)
        {
            cin >> v[i];
            ave += v[i];
        }
        ave /= n;
        rep(i, n)
        {
            if (v[i] <= ave)
            {
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
int main(void)
{
    int n,m,k;
    cin>>n>>m>>k;
    for (int i = 0;i <= n;++i)
        for (int j = 0;j <= m;++j)
            if (i * m + (n - i) * j - i * j == k)
                return puts("Yes") * 0;
    puts("No");
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastIO fio = new FastIO();

        long n = fio.readInt();
        System.out.println(((n - 1) * n) / 2);
    }

    private static class FastIO {
        private StringTokenizer stringTokenizer;
        private BufferedReader bufferedReader;

        public FastIO() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            stringTokenizer = null;
        }

        public String read() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return stringTokenizer.nextToken();
        }

        public int readInt() {
            return Integer.parseInt(read());
        }

        public long readLong() {
            return Long.parseLong(read());
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
typedef pair<int, int> P;

const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
double dist(int x, int y) {
	return sqrt(x * x + y * y);
}
double dist(int xx1, int xx2, int yy1, int yy2) {
	return sqrt(abs(xx1 - xx2) * abs(xx1 - xx2) + abs(yy1 - yy2) * abs(yy1 - yy2));
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	string s;
	int k;
	set<string>se;
	cin >> s >> k;
	for (int i = 0; i < s.size(); i++) {
		string s2 = "";
		for (int j = i; j < min((int)s.size(),i+5); j++) {
			s2 += s[j];
			se.insert(s2);
		}
	}
	cout << *next(se.begin(), k-1) << endl;
}

Measured memory_bytes: 4748