akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n)                    \
  for (int i = 0; i < (int)(n); i++) \
    ;

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (ll &x : a) {
    cin >> x;
  }

  sort(a.begin(), a.end());

  vector<bool> ok(n, true);
  for (long i = 0; i < n; i++) {
    if (i != 0 && a.at(i) == a.at(i - 1)) {
      ok.at(i) = false;
      ok.at(i - 1) = false;
    }
    if (!ok.at(i)) {
      continue;
    }

    ll maxVal = a.at(n - 1);
    for (ll x = a.at(i) * 2; x <= maxVal; x += a.at(i)) {
      auto iter = lower_bound(a.begin(), a.end(), x);
      if (iter != a.end()) {
        if (*iter == x) {
          ok.at(distance(a.begin(), iter)) = false;
        }
      }
    }
  }
  ll ans = 0;
  for (auto x : ok) {
    if (x) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int N=1e5+10;
int a[N];
int op[N];
int n;
ll dp[N][3];
string s;
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	scanf("%d",&n);getchar();
	getline(cin,s);
	int len=s.length(),t=0,p1=0,p2=0;  
	for(int i=0;i<len;i++){
		if(s[i]==' '){
			if(t)a[++p1]=t;
			t=0;continue;
		}else if(s[i]>='0'&&s[i]<='9')t=t*10+s[i]-'0';
		else{
			if(s[i]=='-')op[++p2]=-1;else op[++p2]=1;
		}
	}
	a[++p1]=t;
	dp[1][0]=a[1],dp[1][2]=dp[1][1]=-1e18;
	for(int i=2;i<=n;i++){
		dp[i][0]=dp[i][1]=dp[i][2]=-1e18;
		int f=(op[i-1]==-1);
		for(int j=0;j<3;j++){
			int t=j%2;
			t=t^f;
			int temp=a[i];
			if(t)temp=-temp;
			if(f&&j<2)dp[i][j+1]=max(dp[i][j+1],dp[i-1][j]+temp);
			for(int k=0;k<=j;k++)dp[i][k]=max(dp[i][k],dp[i-1][j]+temp);
		}
	}
	//for(int i=1;i<=p1;i++)cout<<a[i]<<" ";puts("");
	//for(int i=1;i<=p2;i++)cout<<op[i]<<" ";puts("");
	printf("%lld\n",dp[n][0]);

	return 0;
}

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

using namespace std;
using ll = long long;

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

ll dp[410][410];
ll a[410], b[410];

const ll INF = 1e18;

ll rec(int l, int r) {
  if (r - l <= 1)
    return 0;
  if (r - l == 2)
    return a[l] + a[r - 1];

  if (dp[l][r] != INF)
    return dp[l][r];

  for (int i = l + 1; i <= r - 1; ++i) {
    dp[l][r] = min(dp[l][r], rec(l, i) + rec(i, r) + b[r] - b[l]);
  }
  return dp[l][r];
}

int main() {
  int n;
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) b[i + 1] = b[i] + a[i];

  rep(i, n + 1) rep(j, n + 1) dp[i][j] = INF;
  cout << rec(0, n) << endl;
  return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s,t;
    int a,b;
    string u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s == u && t == u) cout << a-1 << " " << b-1 << endl;
    else if(s == u) cout << a-1 << " " << b << endl;
    else if(t == u) cout << a << " " << b-1 << endl;
    else cout << a << " " << b << endl;
    
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        for(int i = 0; i <= x; i++){
            if(i*4+(x-i)*2 == y){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 25344
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,cnt = 0;
  cin >> a >> b >> c;
  for(int i = a;i <= b;i++){
    if(c % i == 0) cnt++;
  }
  cout << cnt << '\n';
  return 0;
}


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

int main() {
  
  string N;
  int X,A=0,B=0;
  cin >> N;
  X= N.size();
  for(int i=0;i<X;i++){
    if(N.at(i)=='0'){
      A+=1;
    }
    else{
      B+=1;
    }
  }
  if(A<B){
    cout << X-(B-A) <<endl;
  }
  else{
    cout << X-(A-B) <<endl;
  }
}
  

Measured memory_bytes: 512
n,*a=map(int,open(0).read().split())
m=max(a)+9
l=[0]*m
for x in a:l[x]+=1
r=0
for i in range(m):
	if l[i]:
		r+=l[i]==1
		for j in range(i,m,i):l[j]=0
print(r)

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}



int main(void)
{
  ll m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  cout << (m1 != m2 ? 1 : 0) << endl;
}


Measured memory_bytes: 256
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
A = LI()
B = [0]*(10**5+1)
for a in A:
    B[a] += 1

print(sum(B[i] != 0 for i in range(10**5+1))-(sum(max(0,B[i]-1) for i in range(10**5+1)) % 2))


Measured memory_bytes: 84580
def main():
    import collections

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

    balls_dict = collections.Counter(balls)
    num_patterns = 0
    for value in balls_dict.values():
        num_patterns += value * (value-1) // 2

    for ball in balls:
        print(num_patterns - balls_dict[ball] + 1)


if __name__ == '__main__':
    main()


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

int main() {
    int n, k, s, temp;
    cin >> n >> k >> s;
    vector<int> number(n);
    if(s > n) temp = 0;
    else temp = s;
    rep(i, k) number.at(i) = s;
    rep(i, n - k) number.at(i + k) = temp + 1;
    rep(i, n - 1) cout << number.at(i) << " ";
    cout << number.at(n - 1) << endl;
}

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

using namespace std;


int main() {

    int n;
    cin >> n;
    long long a[n];
    long long dp[n][n];

    for(int i = 0; i < n; ++i) {
                 for(int b = 0; b < n; ++b) {
                     dp[i][b]=0;
                 }
    }
    for(int i = 0; i < n; ++i)
        cin >> a[i];

    for(int i = n - 1; i >= 0; --i) {
        for(int j = i; j < n; ++j) {

            if(i==j)
                dp[i][j] = a[j];
            else
                dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);
             
        }
    }

    cout << dp[0][n-1];

    return 0;
}


Measured memory_bytes: 70528
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int s = sc.nextInt();
        int[] a = new int[1000010];
        a[0] = s;
        boolean isLoop = false;
        for (int i = 1; i < a.length; i++) {
            if (a[i-1] % 2 == 0) {
                a[i] = a[i-1] / 2;
            } else {
                a[i] = 3 * a[i-1] + 1;
            }
            
            for (int j = 0; j < i; j++) {
                if (a[j] == a[i]) {
                    isLoop = true;
                    System.out.println(i+1);
                }
            }
            
            if (isLoop)
                break;
        }
    }
}


Measured memory_bytes: 26708
local n = io.read("*n")
local edge = {}
local len = {}
for i = 1, n do
  edge[i] = {}
  len[i] = -1
end
for i = 1, n - 1 do
  local u, v, w = io.read("*n", "*n", "*n")
  edge[u][v], edge[v][u] = w, w
end
len[1] = 0
local tasks = {1}
for i = 1, n do
  local src = tasks[i]
  if not src then break end
  for dst, cost in pairs(edge[src]) do
    if len[dst] < 0 then
      len[dst] = len[src] + cost
      table.insert(tasks, dst)
    end
  end
end
for i = 1, n do
  print(len[i] % 2)
end


Measured memory_bytes: 23312
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int l, r, d, cnt = 0;
  cin >> l >> r >> d;
  for(int i = l; i <= r; i++) {
    if(i % d == 0) cnt++;
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int N;
  cin >> N;
  int A[N];
  rep(i, N)
    cin >> A[i];
  //

  sort(A, A+N);

  long long ans = A[N-1];
 
  int loop = N-2;
  int index = N-2;
  while(1){
    if(2 <= loop){
      ans = ans+2*A[index];
      index--;
      loop = loop-2;
    }
    else if(loop == 1){
      ans += A[index];
      index--;
      loop--;
    }
    else{
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MP make_pair
#define pb push_back
#define ff first
#define ss second
#define sz(x) x.size()
#define all(c) c.begin(),c.end()
#define int long long
#define fr(i,j,x) for(int i=j;i<x;i++)
#define rep(i,j,x) for(int i=j;i<=x;i++)
#define mem(x,val) memset(x,val,sizeof(x))
//#define endl '\n'
#define vi vector<int>
#define ll long long
#define pii pair<int,int>
 
const int MOD=1e9+7;
const int N=2e5+10;
const int INF=1e9;


// int chk(int x){
//     vector<int>v;
//     rep(i,1,n){
//         a[i]=0;
//     }
//     int start=1,ct;
//     for(auto it=mp.rbegin();it!=mp.rend();it++){
//         v=(*it).second;
//         for(auto e:v){
//             while(start<=n && a[start]!=0){
//                 start++;
//             }
//             ct=0;
//             for(int j=start;j<=n;j+=(x+1)){
//                 while(j<=n && a[j]!=0){
//                     j++;
//                 }
//                 a[j]=e;
//                 ct++;
//                 if(ct==(*it).first){
//                     break;
//                 }
//             }
//             if(ct<(*it).first){
//                 return 0;
//             }
//         }
//     }
//     return 1;
// }

// void solve(){
//     cin>>n;
//     cnt.clear();
//     mp.clear();
//     rep(i,1,n){
//         cin>>a[i];
//         cnt[a[i]]++;
//     }   
//     for(auto &u:cnt){
//         mp[u.second].push_back(u.first);
//     }
//     lo=0;
//     hi=n-2;
//     ans=0;
//     //cout<<chk(4)<<endl;
//     while(lo<=hi){
//         mid=(lo+hi)/2;
//         if(chk(mid)){
//             lo=mid+1;
//             ans=mid;
//         }
//         else{
//             hi=mid-1;
//         }
//     }
//     cout<<ans<<endl;
// }

int a[N],b[N];

void solve(){
    int n,m,k,as=0;
    cin>>n>>m;
    cin>>k;
    rep(i,1,n){
        cin>>a[i];
        as+=a[i];
    }
    rep(i,1,m){
        cin>>b[i];
    }
    int ans=0,j=1,bs=0;
    for(int i=n+1;i>=1;i--){
        if(i<=n){
            as-=a[i];
        }
        if(as<=k){
            while(j<=m && as+bs+b[j]<=k){
                bs+=b[j];
                j++;
            }
            ans=max(ans,i+j-2);
        }
    }
    cout<<ans<<endl;
}
int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("inputf.in", "r", stdin);
    //     //freopen("outputf.in", "w", stdout);
    // #endif
    SPEED;
    int T=1;
    //cin>>T;
    int t1=1;
    while(true)
    {  
        //cout<<"Case #"<<t1<<": ";
        solve();
        t1++;
        if(t1>T)
            break;
    }
}   

Measured memory_bytes: 6772
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
#from operator import itemgetter
#from heapq import heappush, heappop
#import numpy as np
#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix
#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import sys

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
nf = lambda: float(ns())
na = lambda: list(map(int, stdin.readline().split()))
nb = lambda: list(map(float, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

X, N = na()
p = na()
kouho = []
for i in range(-100, 200):
    if i in p:
        continue
    kouho.append((abs(X - i), i))
print(min(kouho)[1])

Measured memory_bytes: 10864
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
	ll a, b, c;
	cin >> a >> b >> c;
	ll sum = 0, day = 0;
	while(sum < c){
		sum += a;
		day ++;
		if(day % 7 == 0) sum += b;
	}
	cout << day << endl;
	return 0;
}


Measured memory_bytes: 3120
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
from bisect import bisect,bisect_right,bisect_left

def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))

n = get_int()
dic = defaultdict(int)
for _ in range(n):
    st = input()
    dic[st] += 1
for val in ['AC','WA','TLE','RE']:
    print(val+" x "+str(dic[val]))

Measured memory_bytes: 9656
class Dice
 
 attr_reader :upper_number
 def initialize(numbers)
  @numbers = numbers.unshift 0
  @upper_number = numbers[0]
 end
 def rotate(instruction)
  instruction.split('').each{|op|
   case op
   when 'W'
    tmp = @numbers[1]
    @numbers[1]=@numbers[3]; @numbers[3]=@numbers[6]; @numbers[6]=@numbers[4]; @numbers[4]=tmp

   when 'E'
    tmp = @numbers[1]
    @numbers[1]=@numbers[4]; @numbers[4]=@numbers[6]; @numbers[6]=@numbers[3]; @numbers[3]=tmp

   when 'S'
    tmp = @numbers[2]
    @numbers[2]=@numbers[1]; @numbers[1]=@numbers[5]; @numbers[5]=@numbers[6]; @numbers[6]=tmp
   when 'N'
    tmp = @numbers[2]
    @numbers[2]=@numbers[6]; @numbers[6]=@numbers[5]; @numbers[5]=@numbers[1]; @numbers[1]=tmp
   end
  }
  @upper_number = @numbers[1]
 end
end

numbers = gets.split.collect{|i|i.to_i}
instruction = gets
dice = Dice.new numbers
dice.rotate instruction
puts dice.upper_number

Measured memory_bytes: 8724
#include<iostream>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 500;
const int inf = (1<<20);
int cap[N][N];
int flow[N][N];
bool vis[N];

int fordFulkerson(const int n,const int t,int now,int fl){
  if (now == t)return fl;
  if (vis[now])return 0;
  vis[now]=true;
  int tmp=0;
  rep(i,n){
    int &next=i;
    if (cap[now][i] - flow[now][i] > 0){
      tmp=fordFulkerson(n,t,next,min(fl,cap[now][i]-flow[now][i]));
      if (tmp != 0){
	flow[now][next]+=tmp;
	flow[next][now]=-flow[now][next];
	return tmp;
      }
    }
  }
  return 0;
}

int maxFlow(int n,int s,int t){
  int tmp=0,ret=0;
  rep(i,n)vis[i]=false;
  while((tmp = fordFulkerson(n,t,s,inf)) != 0){
    ret+=tmp;
    rep(i,n)vis[i]=false;
  }
  return ret;
}

bool dfs(int n,int now,int t){
  if (now == t)return true;
  if (vis[now])return false;
  vis[now]=true;
  rep(i,n){
    int &next=i;
    if (flow[now][next] < 0){
      if (dfs(n,next,t)){
	flow[now][next]=flow[next][now]=0;
	return true;
      }
    }
  }
  return false;
}

main(){
  int n,e,q;
  while(cin>>n>>e>>q){
    const int s = 0,t=n-1;
    rep(i,n)rep(j,n)cap[i][j]=0,flow[i][j]=0;
    rep(i,e){
      int f,t;
      cin>>f>>t;
      f--;t--;
      cap[f][t]=1;
      cap[t][f]=1;
    }
    int prev=maxFlow(n,s,t);
    rep(i,q){
      int a,from,to,tmp;
      cin>>a>>from>>to;
      from--;to--;
      if (a == 1){//add
	cap[from][to]=cap[to][from]=1;
	tmp = maxFlow(n,s,t);
#ifdef DEBUG1
	cout <<"add:";
#endif
	cout << prev+tmp << endl;
	prev=prev+tmp;
      }else if (flow[from][to] == 0){
#ifdef DEBUG1
	cout <<"noflow:";
#endif
	cap[from][to]=cap[to][from]=0;
	cout << prev << endl;
      }else {//delete
#ifdef DEBUG1
	cout <<"del:";
#endif
	if (flow[from][to] < 0)swap(from,to);
	cap[from][to]=cap[to][from]=0;
	flow[from][to]=flow[to][from]=0;

	rep(j,n)vis[j]=false;
	int fordFulkerson(const int n,const int t,int now,int fl);
	tmp=fordFulkerson(n,to,from,1);
	if (tmp != 0){
	  cout << prev << endl;
	  prev=prev;//keep
	}else {
	  rep(j,n)vis[j]=false;
	  //dfs(n,from,s);
	  fordFulkerson(n,s,from,1);
	  rep(j,n)vis[j]=false;
	  //dfs(n,t,to);
	  fordFulkerson(n,to,t,1);
	  cout << prev-1 << endl;
	  prev=prev-1;
	}
      }
    }
#ifdef DEBUG
    cout << "end " << endl;
#endif
  }
}

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

const int N=100010;
#define INF 2147483647

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

int n,k;
int h[N],f[N];

int main() {
	n=read();
	k=read();
	for(int i=1; i<=n; i++) f[i]=INF,h[i]=read();
	f[0]=f[1]=0;
	for(int i=2; i<=n; i++)
		for(int j=1;j<=k;j++){
			if(i-j==0) break;
			else f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
		}
	printf("%d\n",f[n]);
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);
    int A,B; cin>>A>>B;
    // (B-1) / (A-1)
    cout << (A+B-3)/ (A-1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
bool codejam = 0;
 
typedef long long li;
typedef long double ld;
 
void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
int cnt[13] = {0};
int ncnt[13];
const int N = 1e5 + 55;
const int M = 1e9 + 7;
int pw[N];
void solve() {
	pw[0] = 1;
	for (int i = 1; i < N; ++i)
		pw[i] = (pw[i - 1] * 10) % 13;
	string s;
	cin >> s;
	cnt[0] = 1;
	reverse(s.begin(), s.end());
	for (int i = 0; i < (int) s.size(); ++i) {
		for (int j = 0; j < 13; ++j)
			ncnt[j] = 0;
		for (int old_rem = 0; old_rem < 13; ++old_rem) {
			for (int new_dig = 0; new_dig < 10; ++new_dig) {
				if (s[i] != '?' and new_dig != (s[i] - '0'))
					continue;
				int new_rem = old_rem + pw[i] * new_dig;
				new_rem %= 13;
				ncnt[new_rem] += cnt[old_rem];
				ncnt[new_rem] %= M;
			}
		}
		for (int j = 0; j < 13; ++j)
			cnt[j] = ncnt[j];
	}
	cout << cnt[5];
}	

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

const int maxn=1e6+5;
int n;
int bj[maxn];
int a[maxn];
int cnta[maxn];
int cntb[maxn];
typedef pair<int,int> pii;

int main()
{

    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i&1)
        {
            cnta[a[i]]++;
        }else{
            cntb[a[i]]++;
        }
    }
    vector<pii> ji,ou;
    for(int i=1;i<=n;i++)
    {
        if(i&1)
        {
            ji.push_back(make_pair(cnta[a[i]],a[i]));
        }else
        {
            ou.push_back(make_pair(cntb[a[i]],a[i]));
        }
    }
    sort(ji.begin(),ji.end());
    ji.erase(unique(ji.begin(),ji.end()),ji.end());
    sort(ou.begin(),ou.end());
    ou.erase(unique(ou.begin(),ou.end()),ou.end());
    int ans=1e9;
    for(int i=1;i<=n;i+=2)
    {
        if(ou[ou.size()-1].second!=a[i])
        {
            ans=min(ans,n/2-cnta[a[i]]+n/2-ou[ou.size()-1].first);
        }else
        {
            if(ou.size()>=2)
            {
//                cout<<ou[n/2-2].first<<" "<<ou[n/2-2].second<<endl;
                ans=min(ans,n/2-cnta[a[i]]+n/2-ou[ou.size()-2].first);
            }else
            {
                ans=min(ans,n/2-cnta[a[i]]+n/2);
            }
        }
    }
    for(int i=2;i<=n;i+=2)
    {
        if(ji[ji.size()-1].second!=a[i])
        {
            ans=min(ans,n/2-cntb[a[i]]+n/2-ji[ji.size()-1].first);
        }else
        {
            if(ji.size()>=2)
            {
                ans=min(ans,n/2-cntb[a[i]]+n/2-ji[ji.size()-2].first);
            }else
            {
                ans=min(ans,n/2-cntb[a[i]]+n/2);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 5608
#include<iostream>
using namespace std;
int main(){
    int n, i;
    cin >> n;
    int a[n];
    for(i=0;i<n;i++){
        cin >> a[n-i-1];
    }
    for(i=0;i<n;i++){
        cout << a[i];
        if(i != n-1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3068
/*input
100
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);		
	int t = 1;
	// cin >> t;
	while(t--) {
		run();
	}
}


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;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <cstdlib>
#include <map> // pair
#include <vector>
#include <list>
#include <algorithm>

using namespace std;
int A[10];

int main()
{
    scanf("%d%d%d\n",&A[0],&A[1],&A[2] );
    sort(A, A+3); // éĺ
    int ans=10*A[2]+A[1]+A[0];

    printf("%d\n",ans );
}


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


int main() {
    int N,M;
    cin >> N >> M;
    vector<int> a(M),b(M);
    rep(i,M)cin >> a[i] >> b[i];
    rep(i,N){
        int ans = 0;
        rep(j,M){
            if(a[j]==i+1||b[j]==i+1){
                ans++;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int a; int i = 1;
    while(cin >> a) {
      if(a == 0) return 0;
        cout << "Case " << i << ": " << a << endl;
        
      i++;
    }

    
}


Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		char b = sc.next().charAt(0);

		if( b == 'A' || b == 'T') {
			System.out.println(b == 'A' ? 'T' : 'A');
		} else {
			System.out.println(b == 'G' ? 'C' : 'G');
		}
	}
}


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

int l[110];

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

    int n;cin>>n;

    for(int i=0;i<n;i++)cin>>l[i];

    int ans=0;

    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++)
    {
        int a=l[i];
        int b=l[j];
        int c=l[k];
        if(a==b||b==c||c==a)continue;

        vector<int> v;
        v.push_back(a);
        v.push_back(b);
        v.push_back(c);

        sort(v.begin(),v.end());

        if(v[2]<v[1]+v[0])ans++;
    }

    cout<<ans<<"\n";

    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int x = 1; x * x <= n; ++x) {
        for (int y = 1; y * y <= n; ++y) {
            for (int z = 1; z * z <= n; ++z) {
                const int s = x * x + y * y + z * z + x * y + y * z + z * x;
                if (s <= n) {
                    ++a[s];
                }
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        cout << a[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3648
m,n = map(int,input().split())

def amari(m,n):
    if n == 0:
        return 1
    
    if n % 2 == 0:
        return amari(m,n/2)**2%1000000007 
    else:
        return  m*amari(m,n-1)%1000000007 
print(amari(m,n))

Measured memory_bytes: 7728
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    String s=scan.next();
    String t=scan.next();
    int a=scan.nextInt();
    int b=scan.nextInt();
    String u=scan.next();
    if(s.equals(u)){
      a--;
    }else if(t.equals(u)){
      b--;
    }
    System.out.println(a+" "+b);
  }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int   
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	     
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d=0;
    cin>>a>>b>>c;
    d=a+b+c;
    if(d<=21) cout<<"win";
    else cout<<"bust";
    cout<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <cstdlib>
using namespace std;

int map[500][500];
int mapcnt[500][500];
int t, n;
int dx[6] = {0, 1, 1, 0, -1, -1};
int dy[6] = {1, 1, 0, -1, -1, 0};

void search(int x, int y, int t){
	queue<pair<pair<int, int>, int> > q;
	q.push(make_pair(make_pair(x,y),t));
	while(!q.empty()){
		pair<pair<int, int>, int> p = q.front();
		q.pop();
		pair<int , int> id = p.first;
		if(map[id.first][id.second] != 0) continue;
		if(!p.second) continue;
		map[id.first][id.second] = 1;
		for(int i = 0; i < 6; i++){
//printf("push : %d %d %d\n", id.first+dx[i], id.second+dy[i], p.second);
			if(map[id.first+dx[i]][id.second+dy[i]] != 0) continue;
			q.push(make_pair(make_pair(id.first+dx[i],id.second+dy[i]),p.second-1));
		}
	}
	return;
}

int main(void){
	int x, y;
	while(cin >> t >> n, t || n){
		for(int i = 0; i < 500; i++) for(int j = 0; j < 500; j++){ mapcnt[i][j] = 0; map[i][j] = 0;}
		for(int i = 0; i < n; i++){
			cin >> x >> y;
			map[x + 250][y + 250] = -1;
		}
		cin >> x >> y;
		search(x+250, y+250, t+1);
		int ans = 0;
		for(int i = 0; i < 500; i++){
			for(int j = 0; j < 500; j++){
				if(map[i][j] == 1) ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3176
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    if m % n == 0 {
        return (m / n).to_string();
    }

    let mut ans = 1;
    for x in 2..=(m / n) {
        if (m - (n - 1) * x) % x == 0 {
            ans = x;
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VL vector<LL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n,m;
    cin>>n>>m;
    VI g[n+1];
    int u,v;
    loop(i,0,m)
    {
        cin>>u>>v;
        g[u].PB(v);
        g[v].PB(u);
    }

    int p[n+1];
    memset(p,-1,sizeof(p));
    p[1] = 0;
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        u = q.front();
        q.pop();
        for(int v : g[u])
        {
            if(p[v] == -1)
            {
                p[v] = u;
                q.push(v);
            }
        }
    }

    int ans = 1;
    loop(i,2,n+1)
    {
        if(p[i] == -1) {ans = 0; break;}
    }

    if(ans)
    {
        cout<<"Yes\n";
        loop(i,2,n+1) cout<<p[i]<<'\n';
    }

    else cout<<"No\n";

    return 0;
}


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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e6+100;
const ll inf = 1e15;
const ll mod = 1e9+7;


ll a[MAX],b[MAX],n,k;


bool go(ll x){
	vi num;
	ll ans = 0;
	f(i,0,n) ans+= max(0LL,a[i]- x/b[i] );
	return ans<=k;
}


int main(){
	fastio;
	cin >> n >> k;
	f(i,0,n) cin >> a[i];
	f(i,0,n) cin >> b[i];
	sort(a,a+n);
	sort(b,b+n);
	reverse(b,b+n);
	ll ini = 0,fin = 1e12;
	while(ini< fin){
		ll mid = (ini+fin)/2;
		if(go(mid)) fin = mid;
		else ini = mid+1;
	}
	cout << ini << endl;
}

Measured memory_bytes: 6768
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

class Node {
public:
	int mn, v;
	Node() {
		mn = v = 0;
	}
};
Node indt[600000];
void propagate(int n) {
	int v = indt[n].v;
	indt[2 * n].mn += v;
	indt[2 * n].v += v;
	indt[2 * n + 1].mn += v;
	indt[2 * n + 1].v += v;
	indt[n].v = 0;
}
void update(int st, int en, int S, int E, int n, pii v) {
	if (E < st || en < S) return;
	if (st <= S && E <= en) {
		if (v.first == 1) {
			indt[n].mn += v.second;
			indt[n].v += v.second;		
		}
		else indt[n].mn = min(indt[n].mn, v.second);
		return;
	}
	propagate(n);

	int M = (S + E) / 2;
	update(st, en, S, M, 2 * n, v);
	update(st, en, M + 1, E, 2 * n + 1, v);
	indt[n].mn = min(indt[2 * n].mn, indt[2 * n + 1].mn);
}
int getmn(int st, int en, int S, int E, int n) {
	if (E < st || en < S) return INF;
	if (st <= S && E <= en) return indt[n].mn;
	propagate(n);

	int M = (S + E) / 2;
	return min(getmn(st, en, S, M, 2 * n), getmn(st, en, M + 1, E, 2 * n + 1));
}

vector <int> Vl[200050];
int in[200050];
int main() {
	int N, Q, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &in[i]);
	scanf("%d", &Q);
	while (Q--) {
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		Vl[t1].push_back(t2);
	}

	update(1, N, 0, IT_MAX - 1, 1, pii(1, INF));
	for (i = 1; i <= N; i++) {
		for (auto it : Vl[i]) {
			int v = getmn(i - 1, it, 0, IT_MAX - 1, 1);
			update(it, it, 0, IT_MAX - 1, 1, pii(2, v));
		}
		if (in[i] == 1) {
			int v = getmn(i - 1, i - 1, 0, IT_MAX - 1, 1);
			update(i, i, 0, IT_MAX - 1, 1, pii(2, v + 1));
		}
		else {
			update(i, N, 0, IT_MAX - 1, 1, pii(1, 1));
			int v = getmn(i - 1, i - 1, 0, IT_MAX - 1, 1);
			update(i, i, 0, IT_MAX - 1, 1, pii(2, v));
		}
	}
	return !printf("%d\n", getmn(N, N, 0, IT_MAX - 1, 1));
}

Measured memory_bytes: 14336
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	N, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	for i := 1; i < 10; i++ {
		if N/i < 10 && N%i == 0 {
			fmt.Println("Yes")
			os.Exit(0)
		}
	}

	fmt.Println("No")
}


Measured memory_bytes: 1832
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main() {
    int n, q, t;
    string name;
    queue<pair<string, int> > Q;
        
    cin >> n >> q;
    
    for(int i = 0; i < n; i++) {
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }
    
    pair<string, int> u;
    int elaps = 0, a;
    
    while( !Q.empty()) {
        u = Q.front(); Q.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if(u.second > 0) {
            Q.push(u);
        } else{
            cout << u.first << " " << elaps << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 6280
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
long long a[100005], b[100005], c[100005];
long long sum[100005], sum1[100005];
int main() {
	int n;
	cin >> n;
	for (int j = 1; j <= n; j++) {
		cin >> a[j];
	}
	for (int j = 1; j <= n; j++) {
		cin >> b[j];
	}
	for (int j = 1; j <= n; j++) {
		cin >> c[j];
	}
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + n);
	sort(c + 1, c + 1 + n);
	int cnt = 1;
	//cout << endl;
	for (int i = 1; i <= n; i++) {
		while (b[i] >= c[cnt] && cnt <= n) {
			cnt++;
		}
		sum[i] = n - cnt + 1;
		//cout << sum[i] << " " << i << endl;
	}
	//cout << endl;
	for (int i = 1; i <= n; i++) {
		sum1[i] = sum[i] + sum1[i - 1];
		//cout << "## " << i << " " << sum1[i] <<endl;
	}
	long long ans = 0;
	cnt = 1;
	for (int i = 1; i <= n; i++) {
		while (a[i] >= b[cnt]&& cnt <= n) {
			cnt++;
		}
		//cout << cnt << " "  << i;
		ans += sum1[n] - sum1[cnt - 1]; 
		//cout << sum1[cnt - 1];
		//cout <<" " << ans << endl;
	}
	cout << ans;
	return 0;
}



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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    int A, B;
    cin >> A >> B;

    cout << max(0, A-(2*B)) << endl;
}


Measured memory_bytes: 256
N,M = list(map(int,input().split(" ")))
NUM = 1000000007
ans = 1
f = [-1] * (N+1)
f[0] = 1
f[1] = 1
for _ in range(M):
    now = int(input())
    f[now] = 0

for i in range(2,N+1):
    if f[i] == -1:
        f[i] = (f[i-1] + f[i-2])%NUM

ans = f[N]
print(ans )










Measured memory_bytes: 44120
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
int main()
{
	ll i,j,k,m,n,t,d;
	cin>>t>>d;
	ll ctr=0;
	while(t--)
	{
		ll d1;
		cin>>j>>k;
		d1=j*j+k*k;
		if(d1<=d*d)
		ctr++;
	}
	cout<<ctr;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
public class Main {
	
	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		Deque<Character> que = new ArrayDeque<>(200_000);	
		int s = 0;
		while((s = bf.read()) != -1) {
			if (s == 83) {//s
				que.push('S');
			} else if (s == 84) {//t
				if (que.size() > 0 && que.getFirst() == 'S') {
					que.pop();
				} else {
					que.push('T');
				}
			} else {
				break;
			}
		}
		
		System.out.println(que.size());
	}
}

Measured memory_bytes: 23252
package main

import(
	"fmt"
	"math"
)

func main() {
	var X, ans1, ans2 int
  fmt.Scan(&X)
	N:=1000
	findFlag:=false
	for ans1 =-N; ans1<N; ans1++ {
		for ans2 =-N; ans2<N; ans2++ {
          num := int(math.Pow(float64(ans1),5)-math.Pow(float64(ans2),5))
			if num == X {
              fmt.Print(ans1, ans2)
              findFlag = true
				break
			}
		}
		if findFlag == true {
			break
		}
	}
}

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

typedef long long ll;
#define pb push_back
#define mp make_pair
#define pii pair <int,int>
#define in insert
#define X first
#define Y second
#define frn front
#define bc back
#define rep(i,a,b)for (ll (i) = (a); (i) < b(); ++(i))
#define _ << " " <<
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()

using namespace std;

const int N = 1e5 + 2;
const double PI = 3.14;
const int MOD = 1e7 + 7;

int h[N];

int n,a,sol,maks;

int main ()	{
	cin >>n;
	memset(h,0,sizeof(h));
	for (int i = 0; i < n; ++i)
	{
		cin >>a;
		h[a-1]++;
		h[a+1]++;
		h[a]++;
		maks = max(a,maks);
	}
	for (int i = 0; i <=maks; ++i){
		sol = max(sol,h[i]);
	}
	cout <<sol<<endl;
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  if(n%2==1){
    cout << "No" << endl;
    return 0;
  }
  vector<char> a(n/2);
  vector<char> b(n/2);
  for(int i=0; i<n/2; i++){
    cin >> a.at(i);
  }for(int i=0; i<n/2; i++){
    cin >> b.at(i);
  }if(a==b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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


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

	int n,k,t;
	vector <int> v(51);

	cin >> n >> k;

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

	int res = 0;

	for(int a=0;a<=k;a++)
	{
		for(int b=0;b<=k;b++)
		{
			if(b>a)
			{
				continue;
			}
			for(int c=0;c<=k;c++)
			{
				if(a+c>n)
				{
					continue;
				}
				for(int d=0;d<=k;d++)
				{
					if(d>c)
					{
						continue;
					}
					if(a+b+c+d>k)
					{
						continue;
					}
					priority_queue <int,vector<int>,greater<int>> l,r;
					for(int i=1;i<=a;i++)
					{
						l.push(v[i]);
					}
					for(int i=1;i<=c;i++)
					{
						r.push(v[n-i+1]);
					}

					for(int i=0;i<b;i++)
					{
						l.pop();
					}
					for(int i=0;i<d;i++)
					{
						r.pop();
					}

					int sum = 0;

					while(!l.empty())
					{
						sum += l.top();
						l.pop();
					}

					while(!r.empty())
					{
						sum += r.top();
						r.pop();
					}

					//cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << sum << '\n';
					res = max(res,sum);
				}
			}
		}
	}

	cout << res << '\n';

	return 0;	
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

template<typename T>
using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
}

ll const maxn = 3e5+5;
ll pos[maxn];
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n; cin >> n;
    vector<ll>a(n); for(ll i = 0; i<n; i++) cin >> a[i], pos[a[i]] = i;
    multiset<ll>kek;
    kek.insert(-1); kek.insert(-1); kek.insert(n); kek.insert(n);
    ll ans = 0;
    for(ll i = n;i>=1;i--){
        ll ps = pos[i];
        kek.insert(ps);
        auto it = kek.upper_bound(ps);
        ll b1 = *it;
        it++;
        ll b2 = *it;
        it--; it--; it--;
        ll a2 = *it;
        it--;
        ll a1 = *it;
        ll ans1 = (a2 - a1) * (b1 - ps) + (b2 - b1) * (ps-a2);
        ans += ans1 * i;
    }
    cout << ans << endl;
    return 0;
}
/*

*/

Measured memory_bytes: 6528
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i,n) for(ul i=0;i<n;i++)

ul L, R, N, M, Q;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M >> Q;
    P LR[M];
    auto pq = vector<P> (Q, make_pair(0, 0));
    auto ans = vector<int> (Q, 0);
    auto train_table = vector<vector<int>> (N + 1, vector<int>(N + 1, 0));
    auto cum = vector<vector<int>> (N + 1, vector<int>(N + 1, 0));
    REP(itr, M) {
      cin >> LR[itr].first >> LR[itr].second;
      ++train_table[LR[itr].first][LR[itr].second];
    }
    for (int i = 1; i <= N; ++i) {
      for (int j = 1; j <= N; ++j) {
        cum[i][j] = cum[i][j-1] + train_table[i][j];
      }
    }

    for (ul itr = 0; itr < Q ; ++itr) {
      cin >> pq[itr].first >> pq[itr].second;
      for (ul j = pq[itr].first; j <= pq[itr].second; ++j) {
        ans[itr] += cum[j][pq[itr].second];
      }
      cout << ans[itr] << endl;
    }
}


Measured memory_bytes: 8064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#include<queue>
#define mod 998244353
#define pb push_back
#define ll long long
using namespace std;
int red[509][509],blue[509][509];
int main(){
	int h,w;
	cin>>h>>w;
	string field[509];
	for(int i=0;i<h;i++){
		cin>>field[i];
	}
	for(int i=0;i<h;i++){
		red[i][0]=1;
		blue[i][w-1]=1;
	}
	for(int i=1;i<w-1;i++){
		for(int j=0;j<h;j++){
			if(j%2==0)red[j][i]=1;
			else blue[j][i]=1;
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(field[i][j]=='#'){
				red[i][j]=1;
				blue[i][j]=1;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(red[i][j]==1){
				cout<<"#";
			}
			else{
				cout<<".";
			}
		}
		cout<<endl;
	}
	cout<<endl;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(blue[i][j]==1){
				cout<<"#";
			}
			else{
				cout<<".";
			}
		}
		cout<<endl;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
    using namespace std;
    int main() {
        int a, b, bb;
        cin>>a>>b;
        bb=b;
        int len=0;
        while (bb!=0){
            bb/=10;
            len++;
        }
        int nou=a*pow(10, len)+b;
        int h=0;
        for(int i=nou; i>0; i--) {
            if(i*i==nou) {
                cout<<"Yes";
                h=1;
            }
        }
        if(h==0){
            cout<<"No";
        }
        return 0;
    }

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

int main() {
	
    int mini = 100;
    vector<vector<int>> board(3,vector<int>(3));
    for(int i = 0; i < 3; i++) {
      for(int j = 0; j < 3; j++){
        cin >> board.at(i).at(j);
        mini = min(mini,board.at(0).at(j));
      }
    }
    string ans = "No";
      
    for(int a1 = 0; a1 <= mini;a1++) {
      int b1 = board.at(0).at(0) - a1;
      int b2 = board.at(0).at(1) - a1;
      int b3 = board.at(0).at(2) - a1;

      vector<int> vec = {b1,b2,b3};

      bool stop = true;
      for(int i = 0; i < 2; i++) {
        if(board.at(1).at(i) - vec.at(i) != board.at(1).at(i + 1) - vec.at(i + 1) || board.at(2).at(i) - vec.at(i) != board.at(2).at(i + 1) - vec.at(i + 1)){
          stop = false;
        }
      }
      if(stop){
        ans = "Yes";
        break;
      }
     }

     cout << ans << endl;

    }

Measured memory_bytes: 256