akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    s64 n, a, b;
    cin >> n >> a >> b;

    s64 ans = (n / (a + b)) * a + MIN(a, n - (n / (a + b)) * (a + b));

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



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll K;
int main(){
    cin>>N>>K;
    ll ans=1;
    for(;pow(K,ans)<=N;ans++);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	cout << (1000 - (n % 1000)) % 1000;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

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

    cin >> N;

    vvi A(N, vi(N, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N - 1; j++) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    vi idx(N, 0);
    int ans = 0;
    vi lastday(0), today(0);
    for (int i = 0; i < N; i++) {
        lastday.push_back(i);
    }

    while (true) {
        int cnt = 0;
        vector<bool> checked(N, false);
        for (int i : lastday) {
            if (idx[i] >= N - 1) continue;
            if (checked[i]) continue;

            int j = A[i][idx[i]];
            if (A[j][idx[j]] != i) continue;

            // cout << i << ' ' << idx[i] << endl;
            // cout << j << ' ' << idx[j] << ' ' << checked[j] << endl;

            if (checked[j]) continue;

            checked[i] = true;
            checked[j] = true;
            today.push_back(i);
            today.push_back(j);
            idx[i]++;
            idx[j]++;
            cnt++;
        }

        if (cnt == 0) {
            for (int i = 0; i < N; i++) {
                if (idx[i] != N - 1) {
                    cout << -1 << endl;
                    return 0;
                }
            }
            cout << ans << endl;
            return 0;
        }

        lastday = today;
        today = vi(0);

        ans++;
    }

    return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;

int A[100005];

int partition(int A[], int p, int r){
	int x, i, temp;
	x = A[r]; 
	i = p - 1;
	for(int j = p; j < r; j++){
		if(A[j] <= x){
			i++;
			temp = A[i]; A[i] = A[j]; A[j] = temp;
		}
	}
	temp = A[i+1]; A[i+1] = A[r]; A[r] = temp;
	return i+1;
}

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) scanf("%d", A+i);
	int loc = partition(A, 0, n-1);
	for(int i = 0; i < n; i++){
		if(i)
			printf(" ");
		if(i == loc)
			printf("[%d]", A[i]);
		else
			printf("%d", A[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3580
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main(){
  long long n,m;
  cin >> n >> m;
  long long a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  long long b[n+1];
  b[0] = 0;
  for(int i=0;i<n;i++) b[i+1] = b[i]+a[i];
  map<long long,long long> hash;
  vector<long long> key;
  long long ans = 0;
  for(int i=0;i<n+1;i++){
    long long k = b[i]%m;
    if(hash.count(k) == 0){
      hash[k] = 1;
      key.push_back(k);
    }
    else{
      ans += hash[k];
      hash[k] += 1;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int n;
  ll d;
  cin >> n >> d;
  int ans = 0;
  rep(i,n) {
    ll x, y;
    cin >> x >> y;
    if (x*x+y*y <= d*d) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    private final int A, B;

    AtCoder(FastScanner sc) {
        A = sc.nextInt();
        B = sc.nextInt();

    }

    void solve(PrintWriter out) {
        out.println(A < 10 && B < 10 ? A * B : "-1");
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

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


Measured memory_bytes: 24532
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']
require 'prime'

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

s = gets.chomp
puts s[0..2]

Measured memory_bytes: 14444
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto N = readln.chomp.to!int;
    auto A = N.iota.map!(_ => readln.split.map!(x => x.to!int-1).array).array;

    auto R = A.map!(a => a[0]).array;
    auto C = A.map!(a => a[1]).array;
    if (R.sort().uniq.array.length != N|| C.sort().uniq.array.length != N) {
        writeln(-1);
        return;
    }

    auto X = new int[](N);
    auto Y = new int[](N);
    foreach (a; A) X[a[0]] = a[1];
    foreach (a; A) Y[a[1]] = a[0];

    int ans = 0;

    foreach (i; 0..N) {
        if (X[i] == i) continue;
        ans += 1;
        int r1 = i, c1 = X[i], r2 = Y[i], c2 = X[Y[i]];
        X[r1] = c2;
        X[r2] = c1;
        Y[c1] = r2;
        Y[c2] = r1;
    }

    ans.writeln;
}



Measured memory_bytes: 14740
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn f(
    state: usize,
    dp: &mut [Option<usize>],
    av: &[usize],
    cv: &[usize],
    fin: usize,
    inf: usize,
) -> usize {
    if let Some(res) = dp[state] {
        return res;
    }
    if state == fin {
        let res = 0;
        dp[state] = Some(res);
        return res;
    }
    let mut res = inf;
    for i in 0..av.len() {
        let a = av[i];
        let c = cv[i];
        let new_state = state | c;
        if new_state != state {
            let cost = a + f(new_state, dp, av, cv, fin, inf);
            res = res.min(cost);
        }
    }
    dp[state] = Some(res);
    res
}

fn solve() {
    input! {
        n: usize, m: usize
    };

    let mut av = Vec::new();
    let mut cvv = Vec::new();
    for _ in 0..m {
        input! {
            a: usize, b: usize,
            cv: [Usize1; b]
        };
        av.push(a);
        cvv.push(cv);
    }
    let fin = (1 << n) - 1;
    let inf = 1 << 60;
    let mut dp = vec![None; fin + 1];
    let cv = cvv
        .into_iter()
        .map(|cv| cv.into_iter().fold(0, |acc, c| acc | (1 << c)))
        .collect::<Vec<_>>();
    let cost = f(0, &mut dp, &av, &cv, fin, inf);
    let res = if cost == inf { -1 } else { cost as isize };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


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

using namespace std;

int main()
{
    int n, d;
    cin >> n >> d;
    int x[n+1][d+1];
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < d; ++j)
        {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i)
    {
        for(int j = i+1; j < n; ++j)
        {
            float dis = 0.0;
            for(int k = 0; k < d; ++k)
            {
                dis += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            dis = sqrt(dis);
            if(dis==ceil(dis))
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * Created by: Son Dinh
 */ 
#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define sz(X) (int)(X).size()
#define all(x) x.begin(),x.end()

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

const int mod=1e9+7;

int n,h,res,mx;
int main(){
    cin>>n>>h;
    mx=h;
    res=1;
    for(int i=2;i<=n;++i){
        cin>>h;
        if(h>=mx) res++;
        mx=max(h,mx);
    }
    cout<<res;
    return 0;
}



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

char str[15];
bool plus[15];

long long find(int lv)
{
  if (str[lv+1]==0)
  {
    long long r=0,tmp=0;

    for(int c=0;str[c];c++)
    {
      tmp*=10;
      tmp+=str[c]-'0';
      if (plus[c])r+=tmp,tmp=0;
    }
    r+=tmp;
    return r;
  }
  else
  {
    long long r=0;

    plus[lv]=0;
    r+=find(lv+1);
    plus[lv]=1;
    r+=find(lv+1);
    return r;
  }
}

int main()
{
  scanf("%s",str);
  printf("%lld\n",find(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 = sc.nextInt();
    int b = sc.nextInt();
    int hole = 1;
    int count = 0;

    while(hole < b){
      hole = hole + (a-1);
      count += 1;
    }
    System.out.println(count);


  }
}

Measured memory_bytes: 23764
using System;
using System.Linq;
class Solution
{
    static void Main(String[] args)
    {
 
        var s = Console.ReadLine();
        bool pal=s==new string(s.Reverse().ToArray());
        var left=s.Substring(0,(s.Length-1)/2);
        var right=s.Substring(left.Length+1,left.Length);

        if(pal&&left==new string(left.Reverse().ToArray())&&right==new string(right.Reverse().ToArray())){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");

        }
    }
 
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define all(v) (v).begin(),(v).end()
int main(){
	int n;
	cin>>n;
	vector<double> an(n);
	rep(i,n){
		cin>>an.at(i);
	}
	double ans;
	rep(k,n){
		ans+=(double)1/an.at(k);
	}
	ans=(double)1/ans;
	printf("%.8lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=5e4+5;
char s[N];
int x,y,n,a[N],cntA[N],cntB[N],sa[N],rk[N],tsa[N],A[N],B[N],h[N],dp[N][25];
void solve()
{
    memset(cntA,0,sizeof(cntA));
    for(int i=1;i<=n;i++) cntA[a[i]]++;
    for(int i=1;i<=100;i++) cntA[i]+=cntA[i-1];
    for(int i=n;i>=1;i--) sa[cntA[a[i]]--]=i;
    rk[sa[1]]=1;
    for(int i=2;i<=n;i++)
    {
        rk[sa[i]]=rk[sa[i-1]];
        if(a[sa[i]]!=a[sa[i-1]]) rk[sa[i]]++;
    }
    for(int l=1;rk[sa[n]]<n;l<<=1)
    {
        for(int i=0;i<=n;i++) cntA[i]=cntB[i]=0;
        for(int i=1;i<=n;i++)
        {
            cntA[A[i]=rk[i]]++;
            cntB[B[i]=i+l<=n?rk[i+l]:0]++;
        }
        for(int i=1;i<=n;i++)
            cntB[i]+=cntB[i-1],cntA[i]+=cntA[i-1];
        for(int i=n;i>=1;i--) tsa[cntB[B[i]]--]=i;
        for(int i=n;i>=1;i--) sa[cntA[A[tsa[i]]]--]=tsa[i];
        rk[sa[1]]=1;
        for(int i=2;i<=n;i++)
        {
            rk[sa[i]]=rk[sa[i-1]];
            if(A[sa[i]]!=A[sa[i-1]]||B[sa[i]]!=B[sa[i-1]]) rk[sa[i]]++;
        }
    }
    for(int i=1,j=0;i<=n;i++)
    {
        if(j)j--;
        while(a[i+j]==a[sa[rk[i]-1]+j]) j++;
        h[rk[i]]=j;
    }
}
void st()
{
    for(int i=1;i<=n;i++)
        dp[i][0]=h[i];
    for(int i=1;1<<i<=n;i++)
        for(int j=1;j+(1<<i)-1<=n;j++)
        dp[j][i]=min(dp[j][i-1],dp[j+(1<<(i-1))][i-1]);
}
int query(int l,int r)
{
    int k=log2(r-l+1);
    return min(dp[l][k],dp[r-(1<<k)+1][k]);
}
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++)
        a[i]=s[i]-'a'+1;
    solve();
    st();
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
    {
        int res=query(i+1,j);
        int l=sa[i],r=sa[j];
        if(l>r) swap(l,r);
        if(l+res<=r)
            ans=max(ans,res);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    ll n,m; cin>>n>>m;
    ll x=min(n,m/2);
    ll ans=x;
    m-=x*2;
    ans+=m/4;
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
    int h;
    int w;
    int s[52][52]={};
    int b[52][52]={};

    cin>>h>>w;
   char chr;
   for(int i=1; i<h+1; i++){
	   for(int j=1; j<w+1; j++){
		   cin>>chr;
		   if(chr=='#'){
			   s[i][j]=1;
			   b[i-1][j]+=1;
			   b[i+1][j]+=1;
			   b[i][j+1]+=1;
			   b[i][j-1]+=1;
			   b[i-1][j-1]+=1;
			   b[i+1][j+1]+=1;
			   b[i-1][j+1]+=1;
			   b[i+1][j-1]+=1;
		   }
	   }
   }
   for(int i=1; i<h+1; i++){
	   for(int j=1; j<w+1; j++){
		   if(s[i][j]==1){
			   cout<<"#";
		   }else{
			   cout<<b[i][j];
		   }
	   }cout<<endl;
   }





   }















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=0;i--)
#define p(s) cout<<(s)<<endl
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;


int a,b,c,n;
string s;

int main() {
	cin>>s;
	string s1="CODEFESTIVAL2016";
	REP(i,0,s.size()){
		if(s[i]!=s1[i]) n++;

	}
	p(n);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int H, W, h, w;
        scanf("%d%d%d%d", &H, &W, &h, &w);
        if (W % w == 0 && H % h == 0) {
                puts("No");
                return 0;
        }
        puts("Yes");
        bool unko = false;
        if (W % w == 0) {
                swap(W, H);
                swap(w, h);
                unko = true;
        }
        vector<int> tozan(W, 100000000), gezan(W);
        tozan[w - 1] = -100000000;
        for (int i = w; i < W; i ++) tozan[i] = tozan[i - w] - 1;
        for (int i = 0; i < W; i ++) gezan[i] = tozan[i] + (i ? -tozan[i - 1] : 0);
        if (unko) {
                for (int i = 0; i < W; i ++) {
                        for (int j = 0; j < H; j ++) cout << gezan[i] << ' '; cout << endl;
                }
        } else {
                for (int i = 0; i < H; i ++) {
                        for (int j = 0; j < W; j ++) cout << gezan[j] << ' '; cout << endl;
                }
        }
        return 0;
}



Measured memory_bytes: 2816
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <stack>
#include <numeric>

using namespace std;
typedef pair<int, int> P;

int n,h;

bool pairComp(P& pA, P& pB){
        return pA.second > pB.second;
}

bool pairCompf(P& pA, P& pB){
        return pA.first > pB.first;
}

int main(){
    cin >> n >> h;
    vector<P> v;
    P p;

    for(int i = 0; i < n; i++){
        cin >> p.first >> p.second;
        v.push_back(p);
    }

    sort(v.begin(), v.end(), pairCompf);
    int vmax = 0;
    vmax = v[0].first;
    sort(v.begin(), v.end(), pairComp);

    /*for(auto x : v){
        printf("%d, %d", x.first, x.second);
        cout << "" << endl;
    }
    
    auto x = max(v.begin(), v.end());
    cout << "" << endl;
    */
    bool hflag = 1;
    int cnt = 0;
    for(int i = 0; v[i].second > vmax; i++){
        h -= v[i].second;
        cnt++;
        if(h <= 0){
            hflag = 0;
            break;
        }
    }

    while(hflag){
        h -= vmax;
        cnt++;
        if(h <= 0) hflag = 0;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;

	int mini = INT_MAX;
	int ans = 0;
	FOR_LT(i, 0, n) {
		int a; cin >> a;
		if (mini >= a) {
			ans++;
			mini = a;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  int n,k;cin >> n >> k;
  int dp[n];//dp[i] iにたどり着く最小コスト
  int h[n];rep(i,n){cin >> h[i];dp[i] = 1000000000;}
  dp[0] = 0;
  for(int i=1;i<n;++i){
    for(int j=max(0,i-k);j<i;++j){
      dp[i] = min(dp[j]+abs(h[i]-h[j]),dp[i]);
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
fish = Hash.new(0)
max = 0
max_fishers = []
selected_fisher = nil

n, q = $<.gets.split.map(&:to_i)
q.times do
  a, v = $<.gets.split.map(&:to_i)
  fish[a] += v
  if v > 0
    if fish[a] > max
      max = fish[a]
      puts "#{a} #{max}"
      max_fishers = [a]
      selected_fisher = a
    elsif fish[a] == max
      max_fishers << a
      puts "#{selected_fisher = max_fishers.min} #{max}"
    else
      puts "#{selected_fisher} #{max}"
    end
  else
    if fish[a] - v == max
      if max_fishers.size == 1
        max = fish.values.max
        max_fishers = fish.keys.select {|k| fish[k] == max}
        puts "#{selected_fisher = max_fishers.min} #{max}"
      else
        max_fishers.delete(a)
        puts "#{selected_fisher = max_fishers.min} #{max}"
      end
    else
      puts "#{selected_fisher} #{max}"
    end
  end
end



Measured memory_bytes: 12536
def d_face_produces_unhappiness():
    N, K = [int(i) for i in input().split()]
    S = input()

    # 初期状態で幸福な人数 + 1回の操作で高々2人増やせる。ただしN-1人まで
    score_first = len([1 for i in range(N - 1) if S[i] == S[i + 1]])
    return min(score_first + 2 * K, N - 1)

print(d_face_produces_unhappiness())

Measured memory_bytes: 3956
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    
    table1 = set()
    i = 1
    while i*i <= N:
        if N%i == 0:
            table1.add(i)
            table1.add(N//i)
        i += 1
    
    cnt = 0
    for p in table1:
        if p == 1:
            continue
        n = N
        while n % p == 0:
            n = n // p
        if n % p == 1:
            cnt += 1
    
    table2 = set()
    N -= 1
    j = 1
    while j*j <= N:
        if N % j == 0:
            table2.add(j)
            table2.add(N//j)
        j += 1

    res = cnt + len(table2) - 1     # table2 に含まれる 1 を除外
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 65260
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
using namespace std;
#define NIL -2000000001
#define MAX 2000000000000

int main() {
  int n,m,q;
  scanf("%d %d %d", &n, &m, &q);
  int l, r, LR[n][n];
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      LR[i][j]=0;
    }
  }
  for (int i=0; i<m; i++) {
    scanf("%d %d", &l, &r);
    LR[l-1][r-1]++;
  }
  int P[q], Q[q];
  for (int i=0; i<q; i++) {
    scanf("%d %d", &P[i], &Q[i]);
    P[i]--;
    Q[i]--;
  }

  int C[n][n];
  for (int i=0; i<n; i++) {
    for (int j=0; j<n; j++) {
      C[i][j]=0;
    }
  }

  for (int i=0; i<n; i++) {
    for (int j=i; j<n; j++) {
      if (i == j) {
        C[i][j] = LR[i][j];
      } else {
        C[i][j] = C[i][j-1]+LR[i][j];
      }
    }
  }

  // for (int i=0; i<n; i++) {
  //   for (int j=0; j<n; j++) {
  //     printf("LR[%d][%d]: %d\n", i,j,LR[i][j]);
  //   }
  // }
  // 
  // for (int i=0; i<n; i++) {
  //   for (int j=0; j<n; j++) {
  //     printf("C[%d][%d]: %d\n", i,j,C[i][j]);
  //   }
  // }

  for (int i=0; i<q; i++) {
    int res = 0;
    for (int j=P[i]; j<= Q[i]; j++) {
      if (P[i] == 0) {
        res += C[j][Q[i]];
      } else {
        res += C[j][Q[i]] - C[j][P[i]-1];
      }

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

  return 0;
}


Measured memory_bytes: 3584
def binary_search(v, is_ok):
    """
    ソートしてから使え！！！
    v : list
        ある場所から左が条件を満たさず、右が条件を満たすように並んだ配列
    is_ok(x) : bool
        vの要素xが条件を満たすかどうかを返す関数
    """
    ng = -1             # 条件を満たさないiのうち今わかっている中で最大の値(v[0]が条件を満たすかもしれないので-1から)
    ok = len(v)         # 条件を満たすiのうち今わかっている中で最小の値(v[n-1]が条件を満たさないかもしれないのでnから)
    # okをできるだけ左に移動させてreturnする

    # ...... ng ok ......
    #          | ->
    # こうなるまで
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2

        if is_ok(v[mid]):   # v[mid]はokであることがわかった
            ok = mid        # okを左に移動
        else:               # v[mid]はngであることがわかった
            ng = mid        # ngを右に移動

    return ok



N, D, A = map(int, input().split())
XH = [tuple(map(int, input().split())) for i in range(N)]
XH.sort()
X = [x for x, h in XH]
H = [(h + A - 1) // A for x, h in XH]

yuukou = 0
mou_mukou = [0] * N + [0]
ans = 0

# lを左端としてn個爆弾を使う
def bomb(l, n):
    global ans, yuukou
    ans += n
    yuukou += n
    r = l + 2 * D
    mou_mukou[binary_search(X, lambda x: r < x)] += n

for i in range(N):
    yuukou -= mou_mukou[i]
    H[i] -= yuukou
    if H[i] > 0:
        bomb(X[i], H[i])

print(ans)


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

int main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i,4){
    if(s[i] == '+') ++ans;
    else --ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

using namespace std;

int main()
{
    char s;
    cin>>s;
    if(isupper(s)){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }

    return 0;
}

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

using namespace std;

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

  long long x;
  cin >> x;
  long long i = (x+5)/11; 
  for (; i*6+(i-1)*5 < x; ++i);
  long long res = i*6+(i-1)*5;
  cout << (res-6 >= x ? i*2-2 : i*2-1) << endl;

  return 0;
}



Measured memory_bytes: 384
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let c: i32 = read();
    let b: Vec<i32> = (0..m).map(|_| read()).collect();
    let a: Vec<Vec<i32>> = (0..n).map(|_| (0..m).map(|_| read()).collect()).collect();
    
    let mut ans = 0;

    for a_i in a {
        if a_i.iter().zip(b.iter()).map(|(x, y)| x * y).sum::<i32>() + c > 0 {
            ans += 1;
        }
    }
    
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  char c;
  scanf("%c", &c);
  char ans = (int)c + 1;
  printf("%c\n", ans);
  return 0;
}


Measured memory_bytes: 128
#define NguyenDangQuan the_author
#define my_heart love_you_to_the_moon_and_back

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

bool typetest;
inline void fastIOfileinput()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	typetest = 0;
}

const int N = 5e3 + 3;
ll x, k, d;

void Read()
{
	cin >> x >> k >> d;
}

bool Check(ll v){
	return (((x - v) / d) & 1) == (k & 1);
}

void Solve()
{
	x = abs(x);
	ll v = x % d;
	if((x - v) / d > k)
		cout << x - d * k;
	else{
		if(x - v == d * k)
			cout << v;
		else{
			if(Check(v))
				cout << v;
			else
				cout << abs(v - d);
		}
	}
}

int32_t main()
{
	fastIOfileinput();
	if (typetest)
	{
		int t;
		cin >> t;
		while (t--)
		{
			Read();
			Solve();
		}
	}
	else
	{
		Read();
		Solve();
	}
}

Measured memory_bytes: 3624
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;cin >> N;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    reverse(retu.begin(),retu.end());
    vector<long long> dp(N+5,INF);
    for(int i = 0;i<N;i++){
        *upper_bound(dp.begin(),dp.end(),retu.at(i)) = retu.at(i);
    }
    for(int i = 0;i<N;i++){
        if(dp.at(i) == INF){
            cout << i << endl;
            return 0;
        }
    }
    cout << N << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    int rem = N % (2 * D + 1);
    int at = N / (2 * D + 1);
    if (rem > 0) {
      at++;
    }
    System.out.println(at);
  }
}


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

signed main() {
#ifdef LOCAL
  assert(freopen("a.in", "r", stdin));
#endif
  string s;
  cin >> s;
  cout << s.substr(0, int(s.size()) - 8) << '\n';
}

Measured memory_bytes: 764
#from math import gcd
from fractions import gcd
import copy

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

# 2つの入力を空白で分割し、数値化
A, B = map(int, input().split())

koyakusu = gcd(A, B)

yakusu_list = make_divisors(koyakusu)

rest = copy.deepcopy(yakusu_list)
ans = set()
count = 0

for v in yakusu_list:
    if v == 1:
        ans.add(1)
        continue
    if rest == []:
        break
    new_rest = []
    for r in rest:
        if r == 1:
            continue
        if r == v:
            ans.add(r)
            continue
        if r % v != 0:
            new_rest.append(r)
    rest = new_rest


print(len(ans))

Measured memory_bytes: 5300
open Batteries
let n = read_int ()
let p = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ fun a -> a

let rec loop i ans =
  if i >= n then ans else
  if p.(i) != i+1 then loop (i+1) ans+1 else loop (i+1) ans

let _ = (if loop 0 0 > 2 then "NO" else "YES") |> print_endline


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

int main() {
	int H,W;
	string line;
	cin >> H >> W;
	vector<char>pic(W+2);
	vector<char>out(W+2);
	
	for(int k=0;k<H+2;k++){
		if (k ==0 || k==H+1){
			for(int i= 0;i<W+2;i++){
				out.at(i)='#';
			cout << out.at(i);
			}
			cout << endl;
		}
		
		else {
			cin >> line;
			for (int i=0;i<W;i++){
				pic.at(i+1)= line.at(i);
			}
			
			out.at(0)='#';
			out.at(W+1)='#';
			
			for (int i=1;i<W+1;i++){
				out.at(i)=pic.at(i);
			}
			
			for(int i=0;i<W+2;i++){
			cout << out.at(i);
			}
			cout<< endl;
		}
			
	}
	
	
}

Measured memory_bytes: 256
s = input()

for i in range(1,len(s)+1):
    if i % 2 == 1 and s[i-1] == 'L':
        print('No')
        exit()
    if i % 2 == 0 and s[i-1] == 'R':
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

struct query {
	int t, x, y;
};
int N;
vector<query> V;

int main() {
	cin >> N;
	V.resize(N + 1);
	V[0] = { 0,0,0 };
	for (int n = 1; n <= N; n++) {
		cin >> V[n].t >> V[n].x >> V[n].y;
	}
	for (int n = 1; n <= N; n++) {
		int dx = abs(V[n].x - V[n - 1].x);
		int dy = abs(V[n].y - V[n - 1].y);
		int dt = V[n].t - V[n - 1].t;
		if (dx+dy > dt || (dx + dy) % 2 != dt % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;

int n,a,b,c,d;
char s[N];

bool check(int l,int r) {
	for(int i=l;i<r;i++) if(s[i]=='#'&&s[i+1]=='#') return 0;
	return 1;
}

int main() {
	cin>>n>>a>>b>>c>>d;scanf("%s",s+1);
	if(!check(a,c)||!check(b,d)) puts("No");
	else if(c<d) puts("Yes");
	else {
		bool fl=0;
		for(int i=b-1;i<=d-1;i++) if(s[i]!='#'&&s[i+1]!='#'&&s[i+2]!='#') fl=1;
		puts(fl?"Yes":"No");
	}
	return 0;
}


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

// #define DEBUG
#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

#define EL cout<<endl

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pdd = P<double,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T1,typename T2> using M = map< T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

const int MOD = 1000000007;
const int INF = 1999999999;
const LL INFLL = 999999999999999LL;
const double EPS = 1e-10;

const int DX[8]= {-1,0,1,0,-1,-1,1,1};
const int DY[8]= {0,-1,0,1,-1,1,1,-1};

const double PI=3.141592653589793;
//==================================================================
/* I/O */
//scan
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(Pii *a){scanf("%d",&a->fi);scanf("%d",&a->se);}     //scan for type pair<int, int>
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array

//print 
void PRINT(int a){printf("%d\n",a);}
void PRINT(int *a,int s,char c='\n'){REP(i,s){if(i==s-1){c='\n';}printf("%d%c",a[i],c);}}
void PRINT(Vi a,char c='\n'){REP(i,a.size()){if(i==a.size()-1){c='\n';}printf("%d%c",a[i],c);}}
void PRINT(LL a){printf("%lld\n",a);}
void PRINT(LL *a,int s,char c='\n'){REP(i,s){if(i==s-1){c='\n';}printf("%lld%c",a[i],c);}}
void PRINT(double a){printf("%.15f\n",a);}
void PRINT(double *a,int s,char c='\n'){REP(i,s){if(i==s-1){c='\n';}printf("%f%c",a[i],c);}}
void PRINT(char a){printf("%c\n",a);}
void PRINT(string a){printf("%s\n",a.c_str());}
//==================================================================
int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	char a,b;
	SCAN(&a);SCAN(&b);

	PRINT((a=='H')?((b=='H')?'H':'D'):((b=='H')?'D':'H'));
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/timeb.h>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll LINF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;

int main(){
    int n, k;
    ll mina = LINF, x;
    cin >> n  >> k;
    vector<ll> a(n+10,INF);
    REP(i, n){
        cin >> a[i];
    }
    FOR(i, k-1, n){
        x = a[i] - a[i-k+1] + min(abs(a[i]),abs(a[i-k+1]));
        if(x < mina){
            mina = x;
        }
    }
    
    cout << mina << endl;
}




Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,sum=0;
  string s;
  cin>>s;
  n=s.size();
  r(i,s.size())if(s[i]=='p')sum++;
  cout<<n/2-sum<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  string s; cin >> s;
  reverse(s.begin(), s.end());
  int dp[2][13] = {0}, cur = 1, pre = 0;
  dp[cur][0] = 1;
  for (int i = 0, a = 1; i < s.size(); ++i, a = 10ll * a % 13) {
    swap(pre, cur);
    memset(dp[cur], 0, sizeof(dp[cur]));
    if (s[i] == '?') {
      for (int k = 0; k < 13; ++k) for (int j = 0; j < 10; ++j) {
        (dp[cur][(k + 1ll * j * a) % 13] += dp[pre][k]) %= MOD;
      }
    }
    else {
      for (int k = 0; k < 13; ++k) {
        (dp[cur][(k + 1ll * (s[i] - '0') * a) % 13] += dp[pre][k]) %= MOD;
      }
    }
  }
  cout << dp[cur][5] << '\n';
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int N,M;
	cin>>N>>M;
	vector <int> ls[N+1];
	int A,B;
	for (int i=0;i<M;i++){
	    cin>>A>>B;
	    ls[A].push_back(B);
	    ls[B].push_back(A);
	}
	int ans[N+1];
	for (int i=0;i<=N;i++) ans[i]=-1;
	queue <int> q;
	q.push(1);
	while (!q.empty()){
	    int u=q.front();
	    q.pop();
	    for (int i=0;i<ls[u].size();i++){
	        if(ans[ls[u][i]]==-1){
	            ans[ls[u][i]]=u;
	            q.push(ls[u][i]);
	        }     
	    }
	}
	cout<<"Yes"<<"\n";
	for (int i=2;i<=N;i++)
	    cout<<ans[i]<<"\n";
	return 0;
}

Measured memory_bytes: 10580
using System;


namespace _0000
{
	class Program
	{
		static int Main ( string[] args )
		{
			for (int lp = 1; lp <= 9; lp++)
			{
				for (int lp2 = 1; lp2 <= 9; lp2++)
				{
					Console.WriteLine (lp + "x" + lp2 + "=" + (lp * lp2));
				}
			}


			return 0;
		}
	}
}

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

int main(){	
	int ans=0, a;
	for(int i=0; i<5; ++i){
		scanf(" %d", &a);
		if(a<40) a=40;
		ans+=a;
	}

	printf("%d\n", ans/5);
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    ll n,k;
    cin>>n>>k;
    ll m=n%k;
    ll ans=min(m,k-m);
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int n, a[100005], ans;
int dp[4][100005];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
        dp[1][a[i]] = max(dp[1][a[i]], max(dp[2][a[i]], dp[3][a[i]])) + 1;
        if (a[i] != 1e5)
            dp[1][a[i] + 1] = max(dp[1][a[i] + 1], max(dp[2][a[i] + 1], dp[3][a[i] + 1])) + 1;
        if (a[i] != 0)
            dp[1][a[i] - 1] = max(dp[1][a[i] - 1], max(dp[2][a[i] - 1], dp[3][a[i] - 1])) + 1;
    }
    for (int i = 1; i <= 1e5; i++) {
        ans = max({ans, dp[1][i], dp[2][i], dp[3][i]});
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include<stdlib.h>

#define NIL NULL

struct node{

  struct node *right;

  struct node *left;

  struct node *parent;

  int key;

};

typedef struct node * Node; 
 
Node root;

void insert(int);

void inorder(Node );

void preorder(Node );

Node treeSearch(Node , int);

int main(){

  int n, i, x;

  char com[20];

  Node t;

  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){

    scanf("%s", com);

    if (com[0] == 'i'){
      
      scanf("%d", &x);
      
      insert(x);

    } 
    else if (com[0] == 'p'){
      
      inorder(root);

      printf("\n");

      preorder(root);

      printf("\n");

    }

    else if(com[0] == 'f'){
      scanf("%d", &x);

       t = treeSearch(root, x);

      if ( t != NIL ) 
	printf("yes\n");

      else 
	printf("no\n");
    } 

  }
 
  return 0;
}


 
void insert(int k){

  Node y = NIL;

  Node x = root;

  Node z;
 
  z = malloc(sizeof(struct node));

  z->key = k;

  z->left = NIL;

  z->right = NIL;
 
  while(x != NIL){

    y = x;

    if((z->key) < (x->key))
      x = x->left;
    else 
      x = x->right;
  }

  z->parent = y;
 
  if(y == NIL)
    root = z;

  else if((z->key) < (y->key)) 
    y->left = z;
  else 
    y->right = z;
 
}

void inorder(Node u){

  if (u == NIL)
    return;
 
  inorder(u->left);

  printf(" %d", u->key);

  inorder(u->right);
 
}

void preorder(Node u){

  if (u == NIL)
    return;
 
 printf(" %d",u->key);

 preorder(u->left);

 preorder(u->right);
 
}
 
Node treeSearch(Node u, int k){
  
  Node x;

  x = u;
 
  while(x != NIL && k != (x->key)){

    if(k < (x->key))
      x = (x->left);

    else 
      x = (x->right);
  
  }
 
  return x;
 
}

Measured memory_bytes: 19364
#include <iostream>

using namespace std;

int main()
{
	int A1;
	int A2;
  	int A3;
  	int total;
  
  cin >> A1;
  cin >> A2;
  cin >> A3;
  
  total = A1 + A2 + A3;
  if (total >= 22)
    cout << "bust";
  else
    cout << "win";
  
}

Measured memory_bytes: 256
#include"stdio.h"
int main(){
     int n;
     scanf("%d",&n);
     int a[n];
     for(int i=0;i<n;i++)
     scanf("%d",&a[i]);
     int b[300000];
     int left=150000,right=left+1;
     for(int i=0;i<n;i++){
         if(n%2==(i+1)%2){
             b[left]=a[i];
             left--;
         }else{
             b[right]=a[i];
             right++;
         }
     }
     for(int i=left+1;i<right;i++){
         printf("%d ",b[i]);
     }
     printf("\n");
}


Measured memory_bytes: 3868
class Main{
    public static void main(String[] a){
        for(int cntx = 1; cntx < 10; cntx++){
            for(int cnty = 1; cnty < 10; cnty++){
                System.out.println(cntx+"x"+cnty+"="+(cntx*cnty));
            }
        }
    }
}

Measured memory_bytes: 24076
#include <array>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  array<array<int, 3>, 3> A;
  int N, B;

  for (int i = 0; i < 3; i++) {
    cin >> A[i][0] >> A[i][1] >> A[i][2];
  }
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> B;
    for (size_t j = 0; j < 3; j++) {
      for (size_t k = 0; k < 3; k++) {
        if (B == A[j][k]) {
          A[j][k] = 0;
        }
      }
    }
  }
  for (size_t i = 0; i < 3; i++) {
    if (A[i][0] + A[i][1] + A[i][2] == 0 or A[0][i] + A[1][i] + A[2][i] == 0) {
      cout << "Yes";
      return 0;
    }
  }
  if (A[0][0] + A[1][1] + A[2][2] == 0 or A[0][2] + A[1][1] + A[2][0] == 0) {
    cout << "Yes";
    return 0;
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

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

		int n = scan.nextInt();
		int sum = 0;
		int max = 0;
		for(int i = 0; i < n; i++){
			int l = scan.nextInt();
			sum+=l;
			if(max < l) max = l;
		}
		//		System.err.println(max);
		String ret = ((sum - max) > max) ? "Yes":"No";
		System.out.println(ret);
		
	}
}


Measured memory_bytes: 22612
N = int(input())
W = [input() for i in range(N)]

if len(set(W)) != N:
    print("No")
else:
    bw = W[0]
    for w in W[1:]:
        if w[0] != bw[-1]:
            print("No")
            break
        bw = w
    else:
        print("Yes")


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int a = sc.nextInt();
		double target = (t - a) / 0.006;
		int rtn = 0;
		double currentMin = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			int input = sc.nextInt();
			double diff = Math.abs(target - input);
			if (currentMin > diff) {
				currentMin = diff;
				rtn = i + 1;
			}
		}
		System.out.println(rtn);
	}

}


Measured memory_bytes: 22356