akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

long long pow(long long N, long long k) {
    long long res = 1;
    for (int i = 0; i < k; ++i) res *= N;
    return res;
}


long long combination(long long N, long long R){
    if (R < 0 || R > N) return 0;
    if (R == 1) return N;
    else if (R == 2) return N * (N-1) / 2;
    else return N * (N-1) * (N-2) / 6;
}


string N;
ll K;

// i桁目まで見たとして、残りがk回0以外を入れられていて、未満確定ならsmallerはtrueで答えを出す。
ll solve(ll i,ll k,bool smaller) {
    // 途中だがkが0になった。(=残りの桁があっても、0で埋まるので1を返す)
    if (k == 0) return 1;

    // 最後の桁まで走査した(= 最後の桁まで決定した && k != 0 なので 0を返す)
    if ( i == N.size()) return 0;

    // N未満であることが確定しているならば残りの桁は何でも入るので組み合わせを使って返す
    if (smaller) return combination(N.size()-i,k) * pow((ll)9,(ll)k);

    // まだ未満とは限らない場合

    // 今見ている桁に相当するNの値が0なら先に進む。
    if (N[i] == '0') return solve(i+1,k,false);

    // N[i]が0でない場合、 その桁には0,1,...と入る可能性がある。
    // i桁目に0を入れた場合の個数 (明らかにN以下の値になるためフラグはtrueになる)
    auto zero = solve(i+1,k,true);
    // i桁目に0<k<N[i]を満たす様な値を入れた場合(明らかにN以下の値になるためフラグはtrueになる)
    // N[i] == 1ならmidはないし、N[i] == 3ならmidはN[i] == 1,2のことになるので適宜調整をする。
    auto mid =  solve(i+1,k-1,true) * (N[i]- '1');
    // i桁目にN[i]を入れた場合
    auto last = solve(i+1,k-1,false);

    return zero + mid + last;

}

int main() {

    cin >> N;

    cin >> K;


    cout << solve(0,K, false) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
using namespace std;
using P = pair<int, int>;
const int maplen = 2020;
const int offset = 1010;

string ans = "";
vector<vector<bool>> isvisit(maplen, vector<bool>(maplen, false));

void search(int sx, int sy, int tx, int ty){
    isvisit[sx+offset][sy+offset] = false;
    isvisit[tx+offset][ty+offset] = false;
    vector<vector<bool>> isvisit_1(maplen, vector<bool>(maplen, false));
    vector<vector<P>> past(maplen, vector<P>(maplen));

    for(int i = 0; i < maplen; i++){
        for(int j = 0; j < maplen; j++) isvisit_1[i][j] = isvisit[i][j];
    }
    queue<P> Q1;
    Q1.push(make_pair(sx+offset, sy+offset));
    while(!Q1.empty() && !isvisit_1[tx+offset][ty+offset]){
        int curx, cury;
        curx = Q1.front().first;
        cury = Q1.front().second;
        Q1.pop();

        if(cury+1 < maplen && !isvisit_1[curx][cury+1]){
            past[curx][cury+1] = make_pair(curx, cury);
            isvisit_1[curx][cury+1] = true;
            Q1.push(make_pair(curx, cury+1));
        }

        if(cury-1 >= 0 && !isvisit_1[curx][cury-1]){
            past[curx][cury-1] = make_pair(curx, cury);
            isvisit_1[curx][cury-1] = true;
            Q1.push(make_pair(curx, cury-1));
        }

        if(curx+1 < maplen && !isvisit_1[curx+1][cury]){
            past[curx+1][cury] = make_pair(curx, cury);
            isvisit_1[curx+1][cury] = true;
            Q1.push(make_pair(curx+1, cury));
        }

        if(curx-1 >= 0 && !isvisit_1[curx-1][cury]){
            past[curx-1][cury] = make_pair(curx, cury);
            isvisit_1[curx-1][cury] = true;
            Q1.push(make_pair(curx-1, cury));
        }
    }
    stack<char> coans;
    P cur = make_pair(tx+offset, ty+offset);
    while(cur != make_pair(sx+offset, sy+offset)){
        int curx = cur.first;
        int cury = cur.second;
        int pastx = past[curx][cury].first;
        int pasty = past[curx][cury].second;
        isvisit[pastx][pasty] = true;
        if(curx == pastx){
            if(cury > pasty){
                coans.push('U');
            }else{
                coans.push('D');
            }
        }else{
            if(curx > pastx){
                coans.push('R');
            }else{
                coans.push('L');
            }
        }

        cur = make_pair(pastx, pasty);
    }
    while(!coans.empty()){
        ans += coans.top();
        coans.pop();
    }
}

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    search(sx, sy, tx, ty);
    search(tx, ty, sx, sy);
    search(sx, sy, tx, ty);
    search(tx, ty, sx, sy);
    
    cout << ans << endl;
    return 0;
}

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


int main() {
  string S, answer;
  int i;
  cin >> S;
  
  answer = "Yes";
  
  if(S.size() % 2 != 0){
    answer = "No";
  }
  else if(S.size() == 0){
    answer = "No";
  }
  else{
    for(int i = 0;i < S.size();i++){
      if(i % 2 == 0 && S.at(i) != 'h'){
        answer = "No";
      }
      if(i % 2 == 1 && S.at(i) != 'i'){
    	answer = "No";
      }
    }
  }
  
  
  cout << answer << endl;
  
 
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    

    int n;
    cin>>n;
    ll ans=0;
    ffor(i,1,n+1)
    {
        ffor(j,1,n+1)
        {
            ffor(k,1,n+1)
            {
                ans+=__gcd(__gcd(i,j),k);
            }
        }
    }
    cout<<ans;
    
    return 0;
}



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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

struct edge{
    LL from,to,cost;
    bool operator<(const edge &e) const {
        return (this->to < e.to or this->from < e.from or this->cost < e.cost);
    }
};


int main(int argc, char const* argv[])
{
    LL n,m;
    cin >> n >> m;
    VVL dp(n,VL(n,INT32_MAX));
    vector<edge> edges;
    for (int i = 0; i < n; i++) {
        dp[i][i] = 0;
    }
    for (int i = 0; i < m; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        edges.push_back(edge{a,b,c});
        dp[a][b] = c;
        dp[b][a] = c;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                dp[j][k] = min(dp[j][k],dp[j][i] + dp[i][k]);
            }
        }
    }

	LL ans = m;

	for (auto&& e : edges) {
		for (int s = 0; s < n; s++) {
			for (int g = 0; g < n; g++) {
				if (dp[s][e.from] + e.cost + dp[e.to][g] == dp[s][g]) {
					ans--;
					s = n; g = n; // 2重ループから脱出
				}
			}
		}
	}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#ABC-131-B
N, L = map(int, input().split())
full_apple = 0
for i in range(N):
    full_apple += (L + i)
notfull_apple = 10 ** 9

for i in range(N):
    test_apple = full_apple - (L + i)
    if abs(full_apple - notfull_apple) > abs(full_apple - test_apple):
        notfull_apple = test_apple

print(notfull_apple)

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

int main () {
  int n, x; cin >> n >> x;
  
  int a[n];
  int ans =0;
  for ( int i=0; i<n; i++)	cin >>a[i];
  sort(a,a+n);
  
  for (int i=0; i<n; i++) {
    x -= a[i];
    if (x<0) break;
    ans++;
  }
  cout << ((x>0) ? ans-1 : ans) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    vint x(5);
    int ans;
    for (size_t i = 0; i < 5;i++)
    {
        cin>>x[i];
        if(x[i]==0)
        {
            ans = i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
import bisect


n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cumA = [0]
cumB = []

a_sum = 0
for a in A:
    a_sum += a
    cumA.append(a_sum)

b_sum = 0
for b in B:
    b_sum += b
    cumB.append(b_sum)


candidates = []
for i, aa in enumerate(cumA):
    if aa > k:
        break

    residue = k - aa
    j = bisect.bisect_right(cumB, residue)
    candidates.append(i + j)

print(max(candidates))

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    int count = 0;
    for (int i=a; i <= b; i++) {
        if (c % i == 0) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3092
/*2019/09/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
/*
int asc_t(const void *a,const void *b){return ((struct_t*)a)->member - ((struct_t*)b)->member;}
int desc_t(const void *a,const void *b){return ((struct_t*)b)->member - ((struct_t*)a)->member;}
*/
int main(){
    int n;
    int cnt=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        if(i%2!=0){
            cnt++;
        }
    }
    printf("%.9lf\n",(double)cnt/(double)n);
    return 0;
}

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

num_chouten=0

for i in range(n):
    num_chouten+=((i+1)*(n-i))

num_hen=0
for _ in range(n-1):
    u,v=map(int,input().split())

    minnum=min(u,v)
    maxnum=max(u,v)

    num_hen+=minnum*(n-maxnum+1)

print(num_chouten-num_hen)

Measured memory_bytes: 74260
import java.util.Scanner;

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

        int n = sc.nextInt();

        int ans = 0;
        int maxHeight = 0;
        for (int i = 0; i < n; i++) {
            int h = sc.nextInt();
            if (h >= maxHeight) {
                ans++;
                maxHeight = h;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 25044
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
void September9() {
	int n;
	cin >> n;

	if (n % 10 == 9 || (n - (n % 10)) == 90) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}
int main() {

	September9();
	return 0;
}


Measured memory_bytes: 764
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
cnt=0
for i in range(n):
    ab=0
    for j in range(m):
        ab+=a[i][j]*b[j]
    if ab+c>0:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    N = int(input())
    s = input()
    t = input()

    for i in range(N):
        if s[i:] == t[:N-i]:
            print(N+i)
            return
    print(2*N)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long size_of_beaf[2000] = {};
long long size_of_all[2000] = {};
long long calc(long long a, long long b) {
	if (b == 0) return 0;
	if (a == 0) {
		assert(b == 0 || b == 1);
		if (b == 0) return 0;
		return 1;
	}
	if (b <= 1) return 0;
	b--;
	if (b <= size_of_all[a - 1]) {
		return calc(a - 1, b);
	}
	long long ans = size_of_beaf[a - 1];
	b -= size_of_all[a - 1];
	b--;
	ans++;
	if (b <= size_of_all[a - 1]) {
		return calc(a - 1, b) + size_of_beaf[a-1] + 1LL;
	}
	ans += size_of_beaf[a - 1];
	b -= size_of_all[a - 1];
	b--;
	assert(b == 0);
	return ans;
}
int main(){
#define int long long
	long long n, x;
	cin >> n >> x;
	size_of_beaf[0] = 1;
	size_of_all[0] = 1;
	for (int i = 0; i < n+1; ++i) {
		size_of_beaf[i + 1] = size_of_beaf[i] * 2LL + 1LL;
		size_of_all[i + 1] = size_of_all[i] * 2LL + 3LL;
	}
	cout << calc(n, x) << endl;
	return 0;
}

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

int solve(vector<int> &h,int n) {
    vector<int> dp(n+1);
    dp[1] = 0;
    dp[2] = abs(h[1]-h[2]);
    for(int i=3;i<=n;i++) {
        int option1 = dp[i-1] + abs(h[i]-h[i-1]);
        int option2 = dp[i-2] + abs(h[i]-h[i-2]);
        dp[i] = min(option1,option2);
    }
    return dp[n];
}

int main() {
	int n;
	cin>>n;
	vector<int> h(n+1);
	for(int i=1;i<=n;i++) {
	    cin>>h[i];
	}
	cout<<solve(h,n);
	return 0;
}


Measured memory_bytes: 4060
import numpy as np

n, k = map(int, input().split())

A = np.array(input().split(), np.int64)

A.sort()

posA = A[A > 0]
negA = A[A < 0]
zeros = (A==0).sum()

left = -10**18
right = 10**18

while left+1 < right:
    num = (left+right)//2
    
    less_count = 0
    
    if num >= 0:
        less_count += zeros * n
    
    limit_pair_for_pos = num // posA
    limit_idxs = np.searchsorted(A, limit_pair_for_pos, side='right')
    less_count += limit_idxs.sum()

    limit_pair_for_neg = -(num // -negA)
    limit_idxs = n - np.searchsorted(A, limit_pair_for_neg, side='left')
    less_count += limit_idxs.sum()

    duplicate_cases = (A**2 <= num).sum()
    less_count -= duplicate_cases
    less_count //= 2
    
    if less_count >= k:
        right = num
    else:
        left = num

print(right)

Measured memory_bytes: 34580
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int >graph[100001];
bool visited[100001];
int depth[100001];
void dfs(int n)
{  //cout<<n<<endl;
    if(!visited[n])
    {
        visited[n]=true;
        for(auto it:graph[n])
        {
            if(!visited[it])
             dfs(it);

             depth[n]=max(depth[it]+1,depth[n]);
        }
    }
}

signed main()
{
 int n,m;
 cin>>n>>m;
 for(int i=0;i<m;i++)
 {
     int a,b;
     cin>>a>>b;
     graph[a].push_back(b);
 }
     memset(depth,0,sizeof(depth));
     memset(visited,false,sizeof(visited));
        for(int i=1;i<=n;i++)
        {
            if(!visited[i])
            {
                dfs(i);
            }
        }
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            ans=max(ans,depth[i]);
        }
        cout<<ans<<endl;

    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int sLen = (int)s.size();
    int tLen = (int)t.size();

    vector<string> ans;
    for (int i = 0; i <= sLen - tLen; i++)
    {
        bool isOk = true;
        for (int j = 0; j < tLen; j++)
        {
            if (!(s.at(i + j) == '?' || s.at(i + j) == t.at(j))) isOk = false;
        }

        if (isOk) {
            string a = s;
            for (int j = 0; j < tLen; j++)
            {
                a.at(i + j) = t.at(j);
            }
            
            for (int j = 0; j < sLen; j++)
            {
                if (a.at(j) == '?') a.at(j) = 'a';
            }
            
            ans.push_back(a);
        }
    }
    
    if ((int)ans.size() == 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

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

    cout << ans.at(0) << endl;
}

Measured memory_bytes: 256
////////////////////////////////////
////////////////////////////////////
////                            ////
////                            ////
////     Please give me AC!     ////
////     Please give me AC!     ////
////                            ////
////                            ////
////////////////////////////////////
////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
const int MOD=13;
int mod_pow(int x,int y){//x^yを返す//計算量は0(log(y))
  int t=x,r=1;
  while(y){
    if(y%2){r=r*t%MOD;}
    y>>=1;
    t=t*t%MOD;
  }
  return r;
}
int main(){
  string S;
  cin>>S;
  long long dp[100020][26];
  int mod=1e9+7;
  for(int i=1;i<=(int)S.size();i++){
    if(S.at(i-1)=='?'){
      for(int j=0;j<13;j++){
        if(i==1 && j<10){
          int w=(int)S.size()-1;
          int a=mod_pow(10,w)*j;
          a%=13;
          dp[1][a]=1;
        }
        else if(i>1){
          for(int k=0;k<10;k++){
            int w=(int)S.size()-i;
            int a=mod_pow(10,w)*k;
            a%=13;
            dp[i][j]+=dp[i-1][(j-a+13)%13];
            dp[i][j]%=mod;
          }
        }
      }
    }
    else{
      if(i==1){
        int w=(int)S.size()-i;
        int a=mod_pow(10,w)*(S.at(i-1)-'0');
        a%=13;
        dp[1][a]=1;
      }
      else{
        int w=(int)S.size()-i;
        int a=mod_pow(10,w)*(S.at(i-1)-'0');
        a%=13;
        for(int j=0;j<13;j++){
          dp[i][j]=dp[i-1][(j-a+13)%13];
        }
      }
    }
  }
  cout<<dp[(int)S.size()][5]<<endl;
}

Measured memory_bytes: 24048
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> P;
int main(void){
    int n, m;
    long long id[100000];
    vector<P> v[100000];
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int p, y;
        cin >> p >> y;
        v[--p].push_back(P(y, i));
    }
    for(int i=0;i<n;i++){
        sort(v[i].begin(), v[i].end());
        for(int j=0;j<v[i].size();j++){
            id[v[i][j].second] = (long long)(i+1)*1000000 + j+1;
        }
    }
    
    cout << setfill('0') << right;
    for(int i=0;i<m;i++){
        cout << setw(12) << id[i] << endl;
    }
    
}


Measured memory_bytes: 7808
'''
1.全完する問題をbit全探索で選ぶ
2.残った問題に対して、1問辺り点が高い順に解いてく
'''

d,g=map(int,input().split())
PC=[list(map(int,input().split())) for _ in range(d)]

n=len(PC)
ans=float('inf')
for i in range(2**n):
  point,cnt=0,0
  for j in range(n): # 全完する問題選択
    if i>>j & 1:
      point+=(j+1)*100*PC[j][0] + PC[j][1]
      cnt+=PC[j][0]
  if point>=g:
    ans=min(ans,cnt)
  else:
    for j in range(n-1,-1,-1): # 1問の点が高い問題解いてく
      if i>>j & 1: # すでに全完してたら飛ばす
        continue
      else:
        for k in range(PC[j][0]):
          if point>=g:
            ans=min(ans,cnt)
            break
          point+=(j+1)*100
          cnt+=1
print(ans)

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

typedef long long ll;

int main(){
    char x,y;
    cin >> x >> y;
    char ans;
    if(x == y){
        ans = '=';
    } else if(x > y){
        ans = '>';
    } else { 
        ans = '<';
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,m,h,ans=1e9,cnt,r[222],dt[222][222];
int main()
{
	cin>>n>>m>>h;
	for(int i=0;i<222;i++)
	{
		for(int j=0;j<222;j++)
		{
			dt[i][j]=1e9;
		}
	}
	for(int i=0;i<h;i++)
	{
		cin>>r[i];
	}
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		dt[a][b]=c;
		dt[b][a]=c;
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(dt[i][k]+dt[k][j]<dt[i][j])
				{
					dt[i][j]=dt[i][k]+dt[k][j];
				}
			}
		}
	}
	sort(r,r+h);
	do
	{
		cnt=0;
		for(int i=0;i<h-1;i++)
		{
			cnt+=dt[r[i]][r[i+1]];
		}
		ans=min(ans,cnt);
	}
	while(next_permutation(r,r+h));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;

int a,b,v1,v2;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> a >> b;

    int ans = 1;

    while( ans <= 1e6 ){
        v1 = (ans+ans)/25;
        v2 = ans/10;
        if( v1 == a && v2 == b ){
            cout << ans;
            return 0;
        }
        ans++;
    }

    cout << "-1";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() 
{
	long n,i,j,ans=99999999;
	long under=0,up=0,sum=0;
  	cin >> n;
  	int w[n+1];

  	for(i=0;i<n;i++){
		cin >> w[i];
		sum += w[i];
  	}
   	for(i=0;i<n;i++){
   		under+=w[i];
   		if(ans>=abs(under-(sum-under))){
   			ans=abs(under-(sum-under));
   		}	
  	}

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

Measured memory_bytes: 256
#include<stdio.h>
char f[6][6],s[6],i,j,a,y,x,p,b;
int main()
{
	for(;i<9;++i,b=!b){
		scanf("%s",s);
		for(j=0;j<4+b;++j)
			a=s[j]-48,f[i/2][j]|=a<<1+b,f[i/2+b][j+!b]|=a<<3-b*3;
	}
	do{
		while(!((f[y][x]>>(p=(p+1)%4))&1));
		putchar("URDL"[p]);
		x+=p?2-p:0;
		y+=p==3?0:p-1;
		p=(p+2)%4;
	}while(y|x|f[0][0]==6&p==3);
	return!puts(""); 
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)cin>>a[i];
    bool dp[k+1]={false};
    for(i=0;i<n;i++)
    {
        for(j=1;j<=k;j++)
        {
            bool roh=true;
            for(ll x=0;x<=i;x++)
            {
                if(j>=a[x])
                {
                    roh&=dp[j-a[x]];
                }
            }
            dp[j]=!roh;
        }
    }
    //for(i=0;i<=k;i++)cout<<dp[i]<<" ";
    if(dp[k])cout<<"First";
    else cout<<"Second";
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()

int main() {
  string s;
  cin >> s;
  int ans = 0;
  bitset<100000> ss(s);
  for(int i = 0; i < s.size() - 1; i++) {
    if(ss[i + 1] == ss[i]) {
      ss[i + 1].flip();
      ans++;
    }
  }
  reverse(all(s));
  int ans2 = 0;
  bitset<100000> sss(s);
  for(int i = 0; i < s.size() - 1; i++) {
    if(sss[i + 1] == sss[i]) {
      sss[i + 1].flip();
      ans2++;
    }
  }
  cout << min(ans, ans2) << endl;
}


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

int main() {
	int n, x, ct = 0, l;
	cin >> n >> x;
	for (int i = 0; i < n; i++)
	{
		cin >> l;
		ct += l;
		if (ct > x)
		{
			cout << i + 1;
			return 0;
		}
	}
	if (ct <= x)
	{
		cout << n + 1;
		return 0;
	}
	else
	{
		cout << 0;
		return 0;
	}
}

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

int main()
{
	int64_t n, q;
	cin >> n >> q;
	vector<int64_t> ts(q), us(q), vs(q);
	for (int64_t i = 0; i < q; i++)
	{
		cin >> ts[i] >> us[i] >> vs[i];
	}

	dsu d(n);

	for (int64_t i = 0; i < q; i++)
	{
		if (ts[i] == 1)
		{
			cout << d.same(us[i], vs[i]) << endl;
		}
		else
		{
			d.merge(us[i], vs[i]);
		}
	}

	return 0;
}

Measured memory_bytes: 8288
#include <iostream>
#include <string>


using namespace std;


const int SIZE = 26;


int main()
{
	int alphabet_box[SIZE];
	string str;

	// 初期化
	for(int i = 0; i < SIZE; i++)
		alphabet_box[i] = 0;

	// 入力
	while(cin >> str){
		// カウント処理
		for(int i = 0; i < str.length(); i++){
			if('A' <= str[i] && str[i] <= 'Z' || 'a' <= str[i] && str[i] <= 'z'){
				if('A' <= str[i] && str[i] <= 'Z')
					str[i] += 32;

				alphabet_box[str[i] - 97]++;
			}
		}
	}

	// 出力
	for(int i = 0; i < SIZE; i++)
		cout << (char)(97 + i) << " : " << alphabet_box[i] << endl;

	return 0;
}


Measured memory_bytes: 3220
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    A, B = list(map(int, input().split()))
    if (A + B) % 2 == 0:
        print(int((A+B) / 2))
    else:
        print("IMPOSSIBLE")

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
from sys import stdin
na=lambda: map(int,stdin.readline().split())

n,m=map(int,input().split())
a=sorted(list(na()))
l=[list(na()) for i in range(m)]
l=sorted(l,key=lambda x:x[1], reverse=True)

p=0
comp=[]
for b,c in l:
  comp+=[c]*b
  p+=b
  if p>=n:
    break

ans=0
for i in range(n):
  if i<len(comp):
    ans+=max(a[i],comp[i])
  else:
    ans+=a[i]
print(ans)

Measured memory_bytes: 33696
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	while (1)
	{
		cin >> n;
		if (n == 0)
			break;
		int dice[6] = { 1, 2, 3, 5, 4, 6 };
		string str;
		int sum = 1;
		for (int i = 0; i != n; ++i)
		{
			cin >> str;
			if (str == "North")
			{
				int temp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[3];
				dice[3] = temp;
			}
			if (str == "South")
			{
				int temp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[1];
				dice[1] = temp;
			}
			if (str == "East")
			{
				int temp = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[2];
				dice[2] = temp;
			}
			if (str == "West")
			{
				int temp = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[4];
				dice[4] = temp;
			}
			if (str == "Right")
			{
				int temp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[3];
				dice[3] = dice[4];
				dice[4] = temp;
			}
			if (str == "Left")
			{
				int temp = dice[1];
				dice[1] = dice[4];
				dice[4] = dice[3];
				dice[3] = dice[2];
				dice[2] = temp;
			}
			sum += dice[0];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX = 510000;


int main(){
  ll N,K,Q;
  cin>>N>>K>>Q;
  ll memo[N];
  rep(i,N){
  	memo[i]=K-Q;
  }
  rep(i,Q){
  	ll a;
    cin >>a;a--;
    memo[a]+=1;
  }
  ll winner=0;
  rep(i,N){
    if(memo[i]>0){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
  }
}

Measured memory_bytes: 1408
from collections import deque
s = input()
q = int(input())
que = deque([s])
flg=False
for _ in range(q):
    a = list(input().split())
    if a[0]=='1':
        flg=not(flg)
#        s=s[::-1]
    else:
        if flg and a[1]=='1' or not flg and a[1]=='2':
            que.append(a[2])
        else:
            que.appendleft(a[2])

ans = ''.join(que)

if flg:
    ans = ans[::-1]
print(ans)

Measured memory_bytes: 6900
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    int N,ans=1,count,temp,max=0;
    cin >>N;

    for(int i=1;i<=N;i++){
        temp=i;
        count=0;
        while(1){
            if(temp%2==0){
                count++;
                temp/=2;
            }else{
                break;
            }
        }
        if(count>max){
            ans=i;
            max=count;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

bool compare(int a, int b, int c, int d) {
    if(a * a + b * b != c * c + d * d) return (a * a + b * b < c * c + d * d);
    return a < c;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int H, W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        int ansh = 1e3;
        int answ = 1e3;
        for(int h = 1; h <= 150; h++) {
            for(int w = h + 1; w <= 150; w++) {
                if(compare(H, W, h, w) && compare(h, w, ansh, answ)) {
                    ansh = h;
                    answ = w;
                }
            }
        }
        cout << ansh << " " << answ << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
using System;
class Program
{
    static void Main()
    {
        while (true)
        {
            string[] str = Console.ReadLine().Split(' ');
            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);
            if (x == 0 && y == 0) break;
            if (x > y) Console.WriteLine("{0} {1}", y, x);
            if (x < y) Console.WriteLine("{0} {1}", x, y);
            if (x == y) Console.WriteLine("{0} {1}", x, y);
        }
    }
}


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

int main(){
  int n;
  cin>>n;
  int a[n];
  int mx=-1;
  long long total=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    mx=max(a[i],mx);
    total+=(mx-a[i]);
  }
  cout<<total<<endl;
}

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

typedef long long int lli;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string a, b;
    cin >> a >> b;

    lli counter = 0;

    for(int i = 0; i < a.length(); i++)
    {
        if(a[i] != b[i])
            counter++;
    }

    cout << counter << endl;
}


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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define ss second
#define ff first
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,A,B) for(int i=A;i<=B;i++)
#define mod 998244353
#define MOD (1000*1000*1000+7)
#define v1d vector<int>
#define v2d vector<vector<int>>
#define vip vector<pair<int,int> >
#define v1s vector<string>
#define pa pair<int,int>
#define print(v) for(auto i:v)cout<<i<<" ";cout<<"\n";
#define endl '\n'
#define input(b,n) for(int i=1;i<=n;i++)cin>>b[i];
#define Sort(v) sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v) v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s= bitset<64>(a).to_string();

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define fbo find_by_order // iterator to the kth element
#define ook order_of_key  //number of items that are strictly smaller than our item k
#define T pair<int, int>
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>

bool pallin(string s){
    int n = s.length();
    int i = 0, j = n-1;
    while(i <= j){
        if(s[i] != s[j])return false;
        i++;
        j--;
    }
    return true;
}

void solve(){
    int n;cin>>n;
    n = n*n*n;
    double ans = n/27.0;
    cout<<fixed<<ans;
    
}

int32_t  main(){ 
    IOS;
    cout.precision(15);
    int t=1;//cin>>t;
    while(t--){
        solve();
    }








}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>

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

int main()
{
	int N,X,p=0,r=1;
	cin>>N>>X;
	for(int i=0;i<N;i++)
	{
		int l;
		cin>>l;
		p+=l;
		if(p<=X)r++;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 256
#include <cstdio>

#define square(a) a * a

int main(void)
{
    int e1, e2, dia;
    int rec, diamond;
    
    rec = diamond = 0;
    while (scanf("%d,%d,%d", &e1, &e2, &dia) != EOF){
        if ((square(e1) + square(e2)) == square(dia)){
            rec++;
        }
        else if (e1 == e2) diamond++;
    }
    
    printf("%d\n%d\n", rec, diamond);
}

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

using namespace std;

string dp[11][1 << 10];
bool made[11][1 << 10] = {0};

void proc(string s, int i, int j) {
	if ( !made[i][j] || s.size() < dp[i][j].size() || (s.size() == dp[i][j].size() && s < dp[i][j]) ) {
		dp[i][j] = s;
	}
	made[i][j] = true;
}
string cat(string s1, string s2) {
	if (s1.size() >= s2.size()) {
		for (int i = 0; i <= s1.size()-s2.size(); ++i) {
			bool f = true;
			for (int j = 0; j < s2.size(); ++j) {
				if (s1[i+j] != s2[j]) {
					f = false;
					break;
				}
			}
			if (f) {
				return s1;
			}
		}
	}

	int len = 0;
	for (int k = min(s1.size(), s2.size()); k >= 0; --k) {
		bool f = true;
		for (int i = 0; i < k; ++i) {
			if (s1[s1.size()-k+i] != s2[i]) {
				f = false;
				break;
			}
		}
		if (f) {
			len = k;
			break;
		}
	}
	return s1 + s2.substr(len);
}

int N;
string s[10];
bool used[10] = {0};
string ans;
void dfs(int n, string str) {
	if ( str.size() < ans.size() || (str.size() == ans.size() && str < ans) ) {
		if (n == N) {
			ans = str;
		}
		else {
			if (str <= ans.substr(0, str.size())) {
				for (int i = 0; i < N; ++i) {
					if (!used[i]) {
						used[i] = true;
						dfs(n+1, cat(str, s[i]));
						used[i] = false;
					}
				}
			}
		}
	}
}
int main() {
	while ( cin >> N, N ) {
		fill(&made[0][0], &made[0][0]+11*(1 << 10), false);

		for (int i = 0; i < N; ++i) {
			cin >> s[i];
		}

		made[0][0] = true; dp[0][0] = "";
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < (1 << N); ++j) {
				if (made[i][j]) {
					for (int k = 0; k < N; ++k) {
						if ((j & (1 << k)) == 0) {
							int nj = j | (1 << k);
							proc(cat(dp[i][j], s[k]), i+1, nj);
							proc(cat(s[k], dp[i][j]), i+1, nj);
						}
					}
				}
			}
		}
		ans = dp[N][(1 << N)-1];

//		cout << ans << endl;
		dfs(0, "");
		cout << ans << endl;
	}
}

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

#define ll long long
int main() {
  int N;
  cin >> N;
  
  
  vector<ll> A(N), B(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  
  ll ans = 0;
  
  for (int i = N-1; i >= 0; i--) {
    if ((A[i]+ans) % B[i]) {
      ans += B[i] - ((A[i]+ans) % B[i]);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4800
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeSet;


public class Main {
	static int N;
	static int[] K;
	static String S;
	
	static char[] station = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 
							 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
			
	static private void solve()
	{
		StringBuilder sb = new StringBuilder();
		ArrayList<String> list = new ArrayList<String>();
		for (int i = 0; i < station.length; i++) {
			list.add(station[i] + "");
		}
		
		int keyindex = 0;
		for (int i = 0; i < S.length(); i++) {
			
			int index = list.indexOf(S.substring(i, i+1));
			
			index -= K[keyindex];
			if(index < 0) index += 52;
			
			sb.append(station[index]);
			keyindex++;
			if (keyindex == N) {
				keyindex = 0;
			}
		}
		
		System.out.println(sb.toString());
	}
	
	static public void main(String[] args)
	{
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			N = sca.nextInt();
			if(N == 0) break;
			
			K = new int[N];
			for (int i = 0; i < N; i++) {
				K[i] = sca.nextInt();
			}
			
			S = sca.next();

			solve();
		}
	}
}

Measured memory_bytes: 24880
m,d = gets.split.map(&:to_i)
ans = []
m.times do |v|
	v = v+1
	d.times do |w|
		w = w +1
		if w  >=10
			w = w.to_s.split("").map(&:to_i)
		else
			w = "0" + w.to_s
			w = w.to_s.split("").map(&:to_i)
		end
		if w[0] >= 2 && w[1] >= 2 && w[0] * w[1] == v
			ans.push(1)
		end
	end
end
p ans.count



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll h,w;
  cin>>h>>w;
  pair<ll,ll> start,goal;
  cin>>start.first>>start.second;
  cin>>goal.first>>goal.second;
  start.first--;start.second--;
  goal.first--;goal.second--;

  vector<string> field(h);
  for(auto&& e: field) 
  {
    cin>>e;
  }

  vector<vector<ll>> cost(h,
    vector<ll>(w,-1));
  deque<pair<ll,ll>> next;
  cost[start.first][start.second]=0;
  next.push_front(start);

  while(!next.empty())
  {
    ll x=next.front().first;
    ll y=next.front().second;
    next.pop_front();

    for (int i = -2; i <= 2; ++i)
    {
      for (int j = -2; j <= 2; ++j)
      {
        if(i==0&&j==0) continue;
        ll nx=x+i,ny=y+j;
        if(nx<0||ny<0||nx>=h||ny>=w) continue;
        if(field[nx][ny]=='#') continue;
        if(abs(i)+abs(j)==1)
        {
          if(cost[nx][ny]==-1)
          {
            cost[nx][ny]=cost[x][y];
            next.push_front({nx,ny});
          }
          else if(cost[nx][ny]>cost[x][y])
          {
            cost[nx][ny]=cost[x][y];
            next.push_front({nx,ny});
          }
        }
        else
        {
          if(cost[nx][ny]<0)
          {
            cost[nx][ny]=cost[x][y]+1;
            next.push_back({nx,ny});
          }
          else if(cost[nx][ny]>cost[x][y]+1)
          {
            cost[nx][ny]=cost[x][y]+1;
            next.push_back({nx,ny});          
          }
        }
      }
    }
  }
  
  // for (int i = 0; i < h; ++i)
  // {
  //   for (int j = 0; j < w; ++j)
  //   {
  //     cout<<cost[i][j]<<" ";
  //   }
  //   cout<<endl;
  // }

  cout<<cost[goal.first][goal.second]<<endl;
}

Measured memory_bytes: 13580
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
using namespace std;


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

    string s,t;
    cin>>s>>t;
    map<int,set<int>> st,ts;
    rep(i,s.size()){
        int ch=s[i]-'a';int tt=t[i]-'a';
        st[ch].insert(tt);
        ts[tt].insert(ch);
    }

    rep(i,26){
        if(st[i].size()>=2||ts[i].size()>=2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;




    return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll z = *x;
  *x = *y;
  *y = z;
}
void print(vector<ll> vec){
  ll length = (ll)vec.size();
  rep(i,length){
    if(i != 0){cout << " ";}
    cout << vec[i];
  }
  cout << endl;
}

int main(){
  string s;
  cin >> s;
  ll len = s.size();
  vector<ll> dep(len+1);
  ll height = 0;
  ll maxheight = 0;
  dep[0] = 0;
  rep(i,len){
    if(s[i] == '/'){
      height++;
    }else if(s[i] == '_'){

    }else{
      height--;
    }
    chmax(maxheight,height);
    dep[i+1] = maxheight - height;
  }
  maxheight = 0;
  height = 0;
  dep[len] = 0;
  for(ll i = len-1-i;i>=0;i--){
    if(s[i] == '/'){
      height--;
    }else if(s[i] == '_'){

    }else{
      height++;
    }
    chmax(maxheight,height);
    chmin(dep[i],maxheight-height);
  }
  vector<ll> ans;
  ll sum = 0;
  tmp1 = 0;
  rep(i,len+1){
    if(dep[i] > 0){
      tmp1 += dep[i];
    }else{
      if(tmp1 > 0){
        ans.push_back(tmp1);
        sum += tmp1;
        tmp1 = 0;
      }
    }
  }
  if(tmp1 > 0){
    ans.push_back(tmp1);
    sum += tmp1;
    tmp1 = 0;
  }
  cout << sum << endl;
  ll k = ans.size();
  cout << k;
  rep(i,k){
    if(i == 0){cout << " ";}
    if(i != k-1){cout << ans[i] << " ";}
    else{
      cout << ans[i];
    }
  }
  cout << endl;
}



Measured memory_bytes: 3292
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  int N,ans=1000000;
  string s,t;
  cin>>N>>s>>t;
  for(int i=0;i<N;i++){
    if(t.substr(0,i)==s.substr(N-i)){
      ans=min(ans,2*N-i);
    }
  }
  if(s==t)ans=min(ans,N);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import math
from decimal import *
import sys
A,B,C = map(int,input().split())
a_d = Decimal(A)
b_d = Decimal(B)
c_d = Decimal(C)
if(a_d.sqrt() + b_d.sqrt() < c_d.sqrt()):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5076
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int h,w;
	int x,y;
	cin >> h >> w;
	cin >> x >> y;
	cout << (h-x) * (w-y) << endl;

	return 0;
}


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

int temp[1048577]={};
int x[4]={0,3,5,7};
int tempnum= 0;
void puttotemp(int k){
	temp[tempnum] = k;
	tempnum++;
}
void maketemp(int n,int k){
	//kに3と5と7を足す
	//nは桁数
	if(n > 10){
		return;
	}
	puttotemp(k*10+3);
	maketemp(n+1,k*10+3);
	puttotemp(k*10+5);
	maketemp(n+1,k*10+5);
	puttotemp(k*10+7);   
	maketemp(n+1,k*10+7);
}

int main(void){
	int N;
	scanf("%d",&N);
	int i,j,x;
	int flag,threeflag,fiveflag,sevenflag;
	char s[11];
	snprintf(s,11,"%d",N);//sにはNが入る
	int n = strlen(s);//nにはNの桁数が入る
	int ans = 0;
	maketemp(1,0);
	//printf("n = %d\n",n);
	for(i=0;i<1048576;i++){
		if( N >= temp[i]){
		}else{
			continue;
		}
		//sの0行目から753かどうか調べる
		snprintf(s,11,"%d",temp[i]);//
		flag = 0;threeflag=0;fiveflag=0;sevenflag=0;
		for(j=0;j<strlen(s);j++){
			if(s[j]=='7'){
				sevenflag=1;
			}else if(s[j]=='5'){
				fiveflag = 1;
			}else if(s[j]=='3'){
				threeflag= 1;
			}else{
				flag = -1;
			}
		}
		if(flag == 0 && sevenflag==1 && fiveflag ==1 && threeflag ==1){
			ans++;
		}
		
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main(){
	int a,b,i;
	char c;
	vector<int>x,y;
	while (1){
		cin>>a>>c>>b;
		if (a==0&&b==0) break;
		x.push_back(a);
		y.push_back(b);
	}
	set<int> z(y.begin(),y.end());
	while (cin>>a){
		for (i=0;i<(int)x.size();i++){
			if (x[i]==a) break;
		}
		b=1;
		set<int>::reverse_iterator it=z.rbegin();
		while (*it!=y[i]){
			it++;
			b++;
		}
		cout<<b<<endl;
	}
}

Measured memory_bytes: 1216
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int A, B, C, D; cin >> A >> B >> C >> D;
  cout << max(A * B, C * D) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n, s, r[20000];
  while (true) {
    cin >> n >> s;
    if (n == 0 && s == 0)
      break;
    for (int i = 0; i < n; i++)
      cin >> r[i];
    int result = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < i; j++)
        if (r[i] + r[j] > s)
          result++;
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 1204