akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
  ll n,w;
  cin>>n>>w;
  vll a(n+1),b(n+1);
  vvll dp(n+1,vll(100001,0));
  
  rep(i,n)cin>>a.at(i+1)>>b.at(i+1);
    
    rep(i,n){
        rep(j,w+1){
            if(j>=b.at(i+1)){
                dp.at(i+1).at(j)=max(dp.at(i+1).at(j-b.at(i+1))+a.at(i+1),dp.at(i).at(j));
            }else{
                dp.at(i+1).at(j)=dp.at(i).at(j);
            }
        }
    }
    
 
 
  cout<<dp.at(n).at(w)<<endl;
  
  
}



Measured memory_bytes: 82840
N, P = map(int, input().split())
A = list(map(int, input().split()))
def comb(x, y):
  m = c = 1
  for i in range(y):
    m *= x-i
    c *= y-i
  return m//c
even = odd = 0
for a in A:
  if a%2 == 0:
    even += 1
  else:
    odd += 1
if P == 0:
  ans = 0
  for i in range(0, odd+1, 2):
    ans += comb(odd, i)
  print(pow(2, even) * ans)
else:
  ans = 0
  for i in range(1, odd+1, 2):
    ans += comb(odd, i)
  print(pow(2, even) * ans)

Measured memory_bytes: 61852
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int d, g;
    cin >> d >> g;
    int p[d], c[d];
    rep(i,d) cin >> p[i] >> c[i];
    int ans = 1000000000;

    for(int mask=0; mask<(1<<d); mask++){
        int s=0, num=0, rest_max=-1;
        for(int i=0; i<d; i++){
            if(mask>>i&1){
                s+=100*(i+1)*p[i]+c[i];
                num+=p[i];
            }else{
                rest_max=i;
            }
        }
        if(s<g){
            int s1 = 100*(rest_max+1);
            int need = (g-s+s1-1)/s1;
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
        }
        ans = min(ans,num);
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef pair<int,int> P;
int x,y,i,j,k,mp[1010][1010],cnt[1010][1010],flg,sum,n,m;
P p[1000000];
int main(void)
{
	queue<P> qu;
	char s,d[11]={'1','2','3','4','5','6','7','8','9'};
	int b[11]={1,2,3,4,5,6,7,8,9};
	int xx[8]={1,0,-1,0,1,-1,1,-1};
	int yy[8]={0,1,0,-1,1,-1,-1,1};
	cin>>x>>y;
	for(i=0;i<=x+1;i++) for(j=0;j<=y+1;j++) mp[i][j]=0,cnt[i][j]=0;
	for(i=1;i<=x;i++){
		for(j=1;j<=y;j++){
			cin>>s;
			if(s=='.') qu.push(P(i,j));
			for(k=0;k<9;k++) if(s==d[k]) mp[i][j]=b[k];
		}
	}
	sum=0;
	while(qu.size()!=0){
		k=0; flg=0;
		while(qu.size()!=0){
			p[k]=qu.front();
			qu.pop();
			k++;
		}
		for(i=0;i<k;i++){
			for(j=0;j<8;j++){
				n=p[i].f+xx[j];
				m=p[i].s+yy[j];
				cnt[n][m]++;
				//無くてもいいかも
				if(mp[n][m]!=0&&mp[n][m]<=cnt[n][m]){
					qu.push(P(n,m));
					mp[n][m]=0;
					flg=1;
				}
				
			}
		}/*
		for(i=1;i<=x;i++){
			for(j=1;j<=y;j++){
				if(mp[i][j]!=0&&mp[i][j]<=cnt[i][j]){
					qu.push(P(i,j));
					mp[i][j]=0;
					flg=1;
				}
			}
		}/*
		for(i=1;i<=x;i++){
			for(j=1;j<=y;j++){
				cout<<mp[i][j];
			}
			cout<<endl;
		}
		cout<<endl;*/
		if(flg==1) sum++;
	}
	cout<<sum<<endl;
	return 0;
}


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

using namespace std;

const int N = 10 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int a[N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = n; i >= 0; --i)
        cin >> a[i];

    return true;
}

void solve() {
    set<int> ans;

    auto gcd = [](int a, int b) {
        for (; a != 0; b %= a, swap(a, b)) { }
        return b;
    };

    auto g = abs(a[n]);

    for (int i = 0; i < n; ++i)
        g = gcd(g, abs(a[i]));

    for (int i = 2; i * i <= g; ++i)
        for (; g % i == 0; g /= i)
            ans.insert(i);

    if (g != 1)
        ans.insert(g);

    auto prime = [](int p) {
        for (int i = 2; i * i <= p; ++i)
            if (p % i == 0)
                return false;

        return true;
    };

    for (int p = 2; p < N; ++p)
        if (prime(p) && a[0] % p == 0) {
            bool flag = true;

            for (int r = 0; r < p - 1 && flag; ++r) {
                auto cur = 0ll;

                for (int i = 0; r + i * (p - 1) <= n; ++i)
                    cur += a[r + i * (p - 1)];

                if (cur % p != 0)
                    flag = false;
            }

            if (flag)
                ans.insert(p);
        }

    for (const auto& i : ans)
        cout << i << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class ABC0125_A2 {
    private static void Main(string[] args) {
        var inputs = new List<string>() {
            Console.ReadLine().Trim(),
            Console.ReadLine().Trim(),
            Console.ReadLine().Trim(),
        };

        Prepare(inputs);
    }

    private static void Prepare(List<string> inputs) {
        var numOfJewel = int.Parse(inputs[0]);
        var values = ConvertStrsToIntArray(inputs[1].Split());
        var costs = ConvertStrsToIntArray(inputs[2].Split());

        Compute(numOfJewel, values, costs);
    }

    private static void Compute(int numOfJewel, int[] values, int[] costs) {
        var profit = 0;

        for (var index = 0; index < numOfJewel; index++) {
            if (values[index] > costs[index])
                profit += values[index] - costs[index];
        }

        OutputAnswer(profit.ToString());
    }

    private static void OutputAnswer(string text) => Console.WriteLine(text);
    private static int[] ConvertStrsToIntArray(IEnumerable<string> texts) => texts.Select(x => int.Parse(x)).ToArray();
}


Measured memory_bytes: 13268
H, W, K = map(int, input().split(' '))
S = []
for i in range(H):
    S.append(list(input()))

sep = []
flg = 0

for i in range(H):
    if "#" in S[i]:
        for j in range(W):
                if S[i][j] == "#" and flg >= 1:
                    sep.append([i, j-1])
                elif S[i][j] == "#":
                    flg += 1
                if j == W-1:
                        sep.append([i, j])
        flg = 0
for x in range(len(sep)):
    if sep[x][0] == sep[-1][0] and sep[x][0] < H-1:
        sep[x][0] = H-1
sep_r = sep[::-1]
ans = [([0]*W) for _ in range(H)]
num = 1

for k in range(len(sep)):
    if  k == 0:
        rx = 0
        ry = 0
    else:
        if sep[k-1][0] != sep[k][0]:
            rx = sep[k-1][0]+1
        if sep[k-1][1] != W-1:
            ry = sep[k-1][1]+1
        else:
            ry = 0
    for i in range(rx, sep[k][0]+1):
        for j in range(ry, sep[k][1]+1):
            ans[i][j] = num
            if i == sep[k][0] and j == sep[k][1]:
                num += 1
                break
        else:
            continue 
        break

for a in ans:
    print(*a)

Measured memory_bytes: 18632
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;

int main() {
	string x, y;
	int num, xnum = 0, ynum = 0;
	cin >> num;
	for (int i = 0; i < num; i++) {
		cin >> x >> y;
		if (x[0] - 'a' > y[0] - 'a') {
			xnum += 3;
		}
		else if (x[0] - 'a' < y[0] - 'a') {
			ynum += 3;
		}else {
			for (int j = 0; j < x.size(); j++) {
				if (x[j] - 'a' > y[j] - 'a') {
					xnum += 3;
					break;
				}
				else if (x[j] - 'a' < y[j] - 'a') {
					ynum += 3;
					break;
				}
				if (x.size() - 1 == j) {
					if (x.size() > y.size())xnum += 3;
					if (x.size() < y.size())ynum += 3;
					if (x.size() == y.size()) {
						xnum += 1;
						ynum += 1;
					}
				}
			}
		}
	}
	cout << xnum << " "<< ynum << endl;

	return 0;
}

Measured memory_bytes: 3176
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<vector<int>> g;
vector<ll> c;

vector<int> ans;
int idx;

void dfs(int v, int p){
	ans[v] = c[idx--];
	for(auto nv : g[v]){
		if(nv == p) continue;
		dfs(nv, v);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	g.resize(n);
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	ll sum = 0, mx = 0;
	c.resize(n);
	rep(i,n){
		cin >> c[i];
		sum += c[i];
		chmax(mx, c[i]);
	}
	cout << sum - mx << endl;
	sort(c.begin(), c.end());
	ans.resize(n);
	idx = n-1;
	dfs(0, -1);
	rep(i,n) cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 4520
N, M = map(int, input().split())
food = [0 for _ in range(M + 1)]
for _ in range(N):
    lst = list(map(int, input().split()))
    for item in lst[1:]:
        food[item] += 1
ans = 0
for item in food:
    if item == N:
        ans += 1
print(ans)

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

int main(){
  long long int N ,ans = 0 ;
  string S ;
  cin >> N ;
  for(int i = 1; i < 10; i++){
    if(N % i == 0 && N / i > 0 && N / i < 10) ans++;
  }
  if(ans > 0) cout << "Yes" <<endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long A, B, C;
  cin >> A >> B >> C;
  if (A + B >= C) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main()
{

int n;
cin>>n;
string s;
cin>>s;
  int i,j,c=1;
 if(n==1)
 {
     cout<<1;
     return 0;
 }
 for(i=1;i<n;i++)
 {
     if(s[i]!=s[i-1]) c++;
 }
 cout<<c;

}






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

int main()
{
  ll n,k;
  cin>>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  ll l=0,r=1000000005;
  while(r>l+1)
  {
    ll m=l+r;
    m/=2;
    ll op=0;
    for(ll i=0;i<n;i++)
      op+=(a[i]-1)/m;
    if(op<=k)
      r=m;
    else
      l=m;
  }
  cout<<r;
}

Measured memory_bytes: 5108
#include <iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
	long long n;
	cin >> n;
	int A[11], b = 0;
	for (int i = 1; n > 0; i++) {
		A[i] = n % 10;
		n = n / 10;
		b++;
	}
	int m = 1000;
	for (int i = b; i > 2; i--) {
		int a = 100 * A[i] + A[i - 1] * 10 + A[i-2];
		if (m > max(753 - a, a - 753)) m = max(753 - a, a - 753);
	}
	cout << m;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	static int counter;
	static ArrayList<Integer> list;

	public static void main(final String[] args) {
		final Scanner scanner = new Scanner(System.in);
		counter = scanner.nextInt();
		list = new ArrayList<>();
		for (int i = 0; i < counter; i++) {
			list.add(scanner.nextInt());
		}
		
		int min = 100000000;
		while (list.size() != 1) {
			min = Collections.min(list);
			for (int i = 0; i < list.size(); i++) {
				int j = list.get(i) % min;
				if (j == 0) {
					list.remove(i);
					i--;
				} else {
					list.set(i,j);
				}
			}
			list.add(min);
		}
		System.out.println(min);
		scanner.close();
	}
}

Measured memory_bytes: 60144
#include <iostream>
using namespace std;
#define MAX_N 100010
const int INF = 1e9;
int n;
int dp[MAX_N];

int main() {
    cin >> n;
    for (int i = 0; i < MAX_N; i++) dp[i] = INF;
    
    dp[0] = 0;
    for (int i = 0; i < MAX_N; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + 1);
        for (int j = 6; i + j <= n; j*=6) dp[i + j] = min(dp[i + j], dp[i] + 1);
        for (int k = 9; i + k <= n; k*=9) dp[i + k] = min(dp[i + k], dp[i] + 1);
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 640
include Math
require 'tsort'

loop do
	n = gets.to_i
	break if n == 0
	xs, ys, xt, yt = gets.split.map(&:to_i)

	walls = []
	n.times do
		x, y, r = gets.split.map(&:to_i)
		contain_s = ((x - xs) ** 2 + (y - ys) ** 2 < r ** 2)
		contain_t = ((x - xt) ** 2 + (y - yt) ** 2 < r ** 2)
		next if contain_s && contain_t
		if contain_s
			walls << [x, y, r, :s]
		elsif contain_t
			walls << [x, y, r, :t]
		end
	end
	
	if walls.empty?
		puts 0
		next
	end

	class Hash
		include TSort
		alias :tsort_each_node :each_key
		def tsort_each_child(i)
			self[i].each {|j| yield j}
		end
	end

	graph = {}
	(0..walls.size-1).each {|i| graph[i] = []}

	(0..walls.size-1).to_a.permutation(2) do |i, j|
		x1, y1, r1, c1 = walls[i]
		x2, y2, r2, c2 = walls[j]

		case [c1, c2]
		when [:s, :s]
			if r1 < r2 && (x1 - x2) ** 2 + (y1 - y2) ** 2 < (r2 - r1) ** 2
				graph[i] << j
			end
		when [:s, :t]
			if (x1 - x2) ** 2 + (y1 - y2) ** 2 > (r1 + r2) ** 2
				graph[i] << j
			end
		when [:t ,:t]
			if r1 > r2 && (x1 - x2) ** 2 + (y1 - y2) ** 2 < (r1 - r2) ** 2
				graph[i] << j
			end
		else
		end
	end
    
	ts = graph.tsort
	path_len = {}
	ts.each do |i|
		if graph[i].empty?
			path_len[i] = 1
		else
			path_len[i] = graph[i].map{|j| path_len[j]}.max + 1
		end
	end
	p path_len.values.max
end

Measured memory_bytes: 27648
#include<iostream>  
#include<cstdio>  
using namespace std;  
  
const int MAX = 100000;  
const int maxnum = 1000000010;  
struct Card {  
    char suit;  
    int value;  
};  
  
Card L[MAX / 2 + 2], R[MAX / 2 + 2];  
  
// 排序和合并  
void merge(Card A[], int n,int left, int mid, int right) {  
    int n1 = mid - left;  
    int n2 = right - mid;  
    for (int i = 0; i < n1; i++) {  
        L[i].suit = A[left + i].suit;  
        L[i].value = A[left + i].value;  
    }  
    for (int i = 0; i < n2; i++) {  
        R[i].suit = A[mid + i].suit;  
        R[i].value = A[mid + i].value;  
    }  
  
    // 两个局部数组最后添加一个比较大的数  
    L[n1].value = R[n2].value = maxnum;  
    int i = 0, j = 0;  
    // 合并  
    for (int k = left; k < right; k++) {  
        if (L[i].value <= R[j].value)  
            A[k] = L[i++];  
        else  
            A[k] = R[j++];  
    }  
}  
// 分割  
void mergeSort(Card A[], int n, int left, int right) {  
    if (left + 1 < right) {  
        int mid = (left + right) / 2;  
        mergeSort(A, n ,left, mid);  
        mergeSort(A, n, mid, right);  
        merge(A, n, left, mid, right);  
    }  
}  
  
// 分割  
int partition(Card A[],int p, int r) {  
    Card x = A[r];  
    int i = p - 1;  
    for (int j = p; j < r; j++) {  
        if (A[j].value <= x.value) {  
            i++;  
            swap(A[i], A[j]);  
        }  
    }  
    swap(A[i + 1], A[r]);  
    return i + 1;  
}  
  
// 快速排序  
void quickSort(Card A[], int p, int r) {  
    int q;  
    if (p < r) {  
        q = partition(A, p, r);  
        quickSort(A, p, q - 1);  
        quickSort(A, q + 1, r);  
    }  
}  
  
// 归并排序法是稳定排序，快速排序后的花色和其比较则可得知排序是否稳定的  
bool isStable(struct Card C1[], struct Card C2[], int n) {  
    for (int i = 0; i < n; i++) {  
        if (C1[i].suit != C2[i].suit)  
            return false;  
    }  
    return true;  
}  
Card C1[MAX], C2[MAX];  
int main() {  
    int n;  
    scanf("%d", &n);  
    getchar();  
    for (int i = 0; i < n; i++) {  
        scanf("%c %d", &C1[i].suit, &C1[i].value);  
        getchar();  
        C2[i] = C1[i];  
    }  
    // 对于C1数列进行归并排序，对C2数列进行快速排序，然后比较两者排序后的花色  
    // 则可得知快速排序是否稳定  
    mergeSort(C1, n, 0 ,n);  
    quickSort(C2, 0, n -1);  
  
    if (isStable(C1, C2, n))  
        printf("Stable\n");  
    else  
        printf("Not stable\n");  
  
    for (int i = 0; i < n; i++)  
        printf("%c %d\n", C2[i].suit, C2[i].value);  
    return 0;  
}  


Measured memory_bytes: 5548
#include<cstdio>
#include<algorithm>
using namespace std;
int Q[1010000][2],head,tail,D[810][810];
int n,m,K,sx,sy;
char p[810][810];
void Ins(int x,int y,int d){
	if(D[x][y]<=d||p[x][y]!='.'){
		return;
	}
	D[x][y]=d;
	tail++;
	Q[tail][0]=x,Q[tail][1]=y;
} 
int main(){
	int i,j,x,y;
	scanf("%d%d%d",&n,&m,&K);
	for(i=1;i<=n;i++){
		scanf("%s",p[i]+1);
		for(j=1;j<=m;j++){
			if(p[i][j]=='S'){
				sx=i,sy=j,p[i][j]='.';
			}
			D[i][j]=1e9;
		}
	}
	Ins(sx,sy,0);
	while(head<tail){
		head++;
		x=Q[head][0],y=Q[head][1];
		Ins(x+1,y,D[x][y]+1);
		Ins(x,y+1,D[x][y]+1);
		Ins(x-1,y,D[x][y]+1);
		Ins(x,y-1,D[x][y]+1);
	}
	int res=1e9;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(D[i][j]<=K){
				res=min(res,1+(min(min(i-1,n-i),min(j-1,m-j))+K-1)/K);
			}
		}
	}
	printf("%d\n",res);
}

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

int main(void){
    int n;
    cin >> n;
    while(n >= 0){
        if(n%4 == 0){
            cout << "Yes" << endl;
            return 0;
        }
        n -= 7;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 32
char s[N][N] = {};
int u[N][N];
int dy[4] = {1, 0, -1, 0};
int dx[4] = {0, 1, 0, -1};
queue<pii> que;
int calc(int a, int b){
	DEBUG("start from (%d, %d)\n", a, b);
	REP(i, N) fill(u[i], u[i]+N, -1);
	que.emplace(a, b);
	u[a][b] = 0;
	int ans = 0;
	while(que.size()){
		int i = que.front().first, j = que.front().second; que.pop();
		DEBUG("  (%d, %d): %d\n", i, j, u[i][j]);
		LAR(ans, u[i][j]);
		REP(k, 4){
			int c = i + dy[k], d = j + dx[k];
			if(s[c][d] != '.') continue;
			if(~u[c][d]) continue;
			u[c][d] = u[i][j] + 1;
			que.emplace(c, d);
		}
	}
	return ans;
}

int main(){
	int h, w; scanf("%d%d", &h, &w);
	REP(i, h) scanf("%s", s[i+1]+1);
	int ans = 0;
	FOR(i, 1, h+1){
		FOR(j, 1, w+1){
			if(s[i][j] == '.') LAR(ans, calc(i, j));
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
n, m, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
ans = 0
n.times do
  a = gets.split.map(&:to_i)
  ans += 1 if a.zip(b).inject(0) { |sum, x| sum += x[0] * x[1] } + c > 0
end

puts ans


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

typedef long long ll;

ll N;
ll A[100];
ll ans = 0;
bool F;

int main()
{
    scanf("%lld",&N);
    for(int i = 0; i < N; i++)
    {
        scanf("%lld",&A[i]);
    }
    while(1)
    {
        F = false;
        for(int i = 0; i < N; i++)
        {
            if(A[i] + ans >= N)
            {
                F = true;
                ll mem = (A[i] + ans) / N;
                A[i] -= mem * (N + 1);//自分の分を減らす
                ans += mem;
            }
        }
        if(!F)break;
        //printf("%lld\n",ans);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
def read_input():
    a, b = map(int, input().split())
    s = input()
    return a, b, s

def check_digit(s, n):
    if len(s) != n:
        return False

    for c in s:
        if c not in '1234567890':
            return False
    return True


def submit():
    a, b, s = read_input()

    former = s[:a]
    hi = s[a]
    latter = s[a+1:]

    if check_digit(former, a) and hi == '-' and check_digit(latter, b):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    submit()


Measured memory_bytes: 3064
#include <stdio.h>

int main() {
	char a[12];
	scanf("%s", a);
	for(size_t b=0; b<6; b++) {
		if(a[b*2] == 0) {
			printf("Yes");
			return 0;
		} else if(a[b*2] != 'h' || a[b*2+1] != 'i') {
			printf("No");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var lists = Console.ReadLine()
                .Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)
                .Select(x => int.Parse(x))
                .ToArray();
            if (lists[0] + lists[1]>=lists[2])
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) std::cin >> a.at(i);
  long long sum = std::accumulate(a.begin(), a.end(), 0LL);
  std::vector<long long> lft(n + 1, 0), rgt(n + 1, 0);
  lft[1] = a[0];
  for (int i = 2; i <= n; i++) {
    lft[i] = lft[i - 2] + a[i - 1];
  }
  rgt[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; i--) {
    rgt[i] = rgt[i + 2] + a[i];
  }
  auto cal = [&] (int i) {
    long long ret = sum;
    if (i > 0) ret -= 2 * lft.at(i - 1);
    if (i < n - 1) ret -= 2 * rgt.at(i + 1);
    return ret;
  };
  for (int i = 0; i < n; i++) {
    if (i > 0) std::cout << " ";
    std::cout << cal(i);
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sec second
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define MOD (1000000007ll)
#define ALL(x) x.begin(), x.end()
using namespace std;
bool cmp(const pair<ll, ll> &first, const pair<ll, ll> &second)
{
    return first.second < second.second;
}
int main()
{
    int n;
    cin >> n;
    vector<pair<ll, ll>> v;
    ll all = 0;
    ll t[n];
    rep(i, n)
    {
        ll a, b;
        cin >> a >> b;
        all += a;
        t[i] = a + b;
    }
    sort(t, t + n, greater<ll>());
    ll ans = all;
    rep(i, n)
    {
        if (i % 2 == 0)
            continue;
        ans -= t[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int n,max,min;
	long int sum=0;
	min=INT_MAX;
	max=INT_MIN;
	scanf("%d",&n);
	char *input=(char*)malloc(n*(sizeof(int)+sizeof(' ') ) );
	scanf("\n%[^\n]",input);

	char *p=input;
	int digitcount=0;
	for(int i=0;i<n;i++){
		for(digitcount=0;*(p+digitcount)!=0x20&&*(p+digitcount)!=0x00;digitcount++){
			//空白区切りまでポインタのインデックスを進める
		}
		char num[11]={0};
		strncpy(num,p,digitcount);
		int number =atoi(num);
		if(number>max){
			max=number;
		}
		if(number<min){
			min=number;
		}
		sum+=number;
		p+=digitcount+1;
	}


	printf("%d %d %ld\n",min,max,sum);

	return 0;
}



Measured memory_bytes: 2112
def Z(S):
    n = len(S)
    LCP = [0]*n
    i = 1
    j = c = 0
    # c : 最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        # i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i+LCP[i-c] < c+LCP[c]:
            LCP[i] = LCP[i-c]
        else:
            j = max(0, c+LCP[c]-i)
            while i+j < n and S[j] == S[i+j]: j+=1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP

a = 0
n, s = open(0)
for i in range(int(n)):
    for j, l in enumerate(Z(s[i:])):
        a = max(a, min(l, j))
print(a)

Measured memory_bytes: 49372
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

type edge struct {
	to, cost int
}

type node struct {
	to   []edge
	cost int
}

func dfs(from, prev, cnt int, n []node) {
	n[from].cost = cnt
	for _, v := range n[from].to {
		if v.to == prev {
			continue
		}
		dfs(v.to, from, cnt+v.cost, n)
	}
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	n := make([]node, N)
	for i := 0; i < N-1; i++ {
		f, t, c := getInt()-1, getInt()-1, getInt()
		n[f].to = append(n[f].to, edge{t, c})
		n[t].to = append(n[t].to, edge{f, c})
	}
	Q, K := getInt(), getInt()
	dfs(K-1, -1, 0, n)

	for i := 0; i < Q; i++ {
		x, y := getInt()-1, getInt()-1
		out(n[x].cost + n[y].cost)
	}
}


Measured memory_bytes: 42368
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
    input! {
        n:usize,k:usize,
        a:[usize;n]
    }
    for i in k..n {
        if a[i] > a[i - k] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[100100];
li b[100100];
pair<li, PI> abab[100100];

int main() {
    cin >> n;
    rin{
        cin >> a[i] >> b[i];
        abab[i] = {a[i] + b[i], {a[i], b[i]}};
    }
    sort(abab, abab + n);
    li res = 0;
    for (li i = n - 1; i >= 0; --i) {
        if ((n - 1 - i) % 2 == 0) {
            res += abab[i].S.F;
        } else {
            res -= abab[i].S.S;
        }
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define debug cout<<"debug"<<endl;
#define ll long long 
const ll mod=1e9+7;
const ll maxn=1e5+10;
using namespace std;

ll v[maxn];
ll n,k;
ll ans;
ll fac[maxn],finv[maxn];
ll maxv[maxn],minv[maxn]; 

int cmp(ll x,ll y)
{
	return x>y;
}
ll quickpow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans*=a,ans%=mod;
		b>>=1,a*=a,a%=mod;
	}
	return ans%mod;
}
void calfac()
{
	fac[0]=finv[0]=1;
	for(int i=1;i<=n;i++)
	{
		fac[i]=fac[i-1]*i%mod;
		finv[i]=quickpow(fac[i],mod-2);
	}
}
ll calc(int N,int C)
{
	return fac[N]*finv[N-C]%mod*finv[C]%mod;
} 
int main()
{
	ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>v[i];
	calfac();
	if(k==1)
	{
		cout<<0<<endl;
		return 0;		
	}
	sort(v+1,v+n+1,cmp);
	for(int i=1;i<=n-k+1;i++) maxv[i]=calc(n-i,k-1)%mod;
	for(int i=n;i>=k;i--) minv[i]=maxv[n-i+1]%mod;
	for(int i=1;i<=n-k+1;i++) ans+=maxv[i]*v[i],ans%=mod; 
	for(int i=k;i<=n;i++) ans-=(minv[i]*v[i]%mod),ans%=mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
N, M = map(int, input().split())
Ne = [[] for _ in range(N)]
C = [0] * N
for i in range(M):
    A, B = map(int, input().split())
    Ne[A-1].append(B-1)
    Ne[B-1].append(A-1)
c=0
l = []
for i in range(N):
    if C[i] == 0:
        c+=1
        l.append(i)
        while len(l)>0:
            v=l.pop()
            C[v] = c
            for j in Ne[v]:
                if C[j] == 0:
                    l.append(j)
print(c-1)


Measured memory_bytes: 86840
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  char graph[128];
  while(cin >> N,N){
    for(int i = 0;i < 128;i++)graph[i] = i;
    char a,b;
    for(int i = 0;i < N;i++){
      scanf(" %c %c",&a,&b);
      graph[a] = b;
    }
    cin >> M;
    for(int i = 0;i < M;i++){
      scanf(" %c",&a);
      cout << graph[a];
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

#define ll long long int
#define vi vector<int>
#define prec fixed<<precision(10)
#define mod 1000000007
#define set(x) __builtin_popcount(x)
#define ffs(x) __builtin_ffs(x)

vector<int> graph[100001];
vector<int> vis1(100001,0);
vector<int> col(100001,0);
map<pair<int,int>,int> mp;
void dfs(int src){
	vis1[src]=1;
	for(auto child: graph[src]){
		if(vis1[child]!=1){
			if((mp[make_pair(child,src)])%2==1)
			 col[child]=1-col[src];
			else col[child]=col[src];
			dfs(child);
		}
	}
}


int main(){
col[1]=1;
	int e;
	cin >> e;
	int a;
	for(int i=0;i<e-1;i++){
		int c,d,k;
		cin >> c >> d >> k;
		graph[c].push_back(d);
		graph[d].push_back(c);
		mp[make_pair(c,d)]=k;
		mp[make_pair(d,c)]=k;
	}
 	dfs(1);
 	for(int i=1;i<=e;i++)cout << col[i] <<'\n';
 }

Measured memory_bytes: 23552
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

x=list(input())
n=len(x)
l=[]
for i in range(n):
    if x[i]=="S":
        l.append("S")
    else:
        if len(l)==0:
            l.append("T")
        elif l[-1]=="S":
            l.pop()
        else:
            l.append("T")
print(len(l))

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

int dp[1001][1001];

int main(){
	int case_number = 1;
	while(1){
		int W, N;
		scanf("%d%d", &W, &N);
		if(W == 0) break;

		int v, w;
		for(int i = 1; i <= N; ++i){
			scanf("%d,%d", &v, &w);
			for(int j = 0; j <= W; ++j){
				if(j < w){
					dp[i][j] = dp[i-1][j];
				}
				else{
					dp[i][j] = max(dp[i-1][j], dp[i-1][j-w] + v);
				}
			}
		}

		int answ = 0;
		for(int j = 0; j <= W; ++j){
			if(dp[N][j] > dp[N][answ]){
				answ = j;
			}
		}

		printf("Case %d:\n%d\n%d\n", case_number, dp[N][answ], answ);
		++case_number;
	}
}

Measured memory_bytes: 4940
#include<stdio.h>
#include<math.h>
int zet(long long int a){
  int cnt = 0;
  while(a > 0){
    a /= 10;
    cnt++;
  }
  return cnt;
}

int main(){
  long long int N,ans = 1,i;
  scanf("%lld",&N);
  for(i = 2;i <= sqrt(N);i++){
    if(N % i == 0){
      ans = i;
    }
  }
  printf("%lld",zet(N / ans));
  return 0;
}

Measured memory_bytes: 128
x1,y1,x2,y2,n,*a=`dd`.split.map &:to_i
xf=yf=1
x1>x2&&(x1,x2,xf=x2,x1,-1)
y1>y2&&(y1,y2,yf=y2,y1,-1)
v=a.each_slice(2).select{|x,y|x1<=x&&x<=x2&&y1<=y&&y<=y2}.map{|x,y|[x*xf,y*yf]}.sort
d=[1<<30]*s=v.size
v.each{|x,y|i=(0...s).bsearch{|i|d[i]>=y};d[i]=y}
n=(0...s).bsearch{|i|d[i]>=1<<30}||s
p 100.0*(x2-x1+y2-y1)-20*n+5*(n+(n>[x2-x1,y2-y1].min ? 1:0))*Math::PI

Measured memory_bytes: 44020
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
X=[]
Y=[]
for i in range(N):
  if V[i]>C[i]:
    X.append(V[i])
    Y.append(C[i])
x=sum(X)
y=sum(Y)
print(x-y)
  
  


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	while(cin>>n>>m,n) 
	{
		int ps[11];
		for(int i = 0; i < 11; ++i)
		{
			ps[i]=0;
		}
		for(int i = 0; i < n; ++i)
		{
			int d,p;
			cin>>d>>p;
			ps[p]+=d;
		}
		for(int i = 10; 0 <= i; --i)
		{
			if(m>=ps[i])
			{
				m-=ps[i];
				ps[i]=0;
			}
			else
			{
				ps[i]-=m;
				m=0;
			}
		}
		int ans=0;
		for(int i = 0; i < 11; ++i)
		{
			ans+=ps[i]*i;
		}
		cout<<ans<<endl;
	}
  return 0;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    int s;
    cin >> s;
    unordered_set<int> prev;
    FOR(i, 2, 1000000 + 100) {
        prev.insert(s);

        if (s % 2 == 0) s /= 2;
        else s = 3 * s + 1;
        if (prev.find(s) != end(prev))
            return i;

    }

    return -1;
}


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

    cout << solve() << endl;
//    solve();

    return 0;
}


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

int n, m, a[10];

int main(){
    cin >> n >> m;
    for (int i = 0; i < m; i++) cin >> a[i];
    for (int i = n; i < 1000000; i++){
        string s;
        stringstream ss;
        ss << i;
        ss >> s;
        bool check = true;
        for (int j = 0; j < s.size(); j++)
            for (int k = 0; k < m; k++)
                if (s[j] - '0' == a[k]) check = false;
        if (check){
            cout << s;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m,x,y;
char c[1010][1010];
int col[1010];
void out(int xi,int yi)
{
	//cout <<xi<<" "<<yi<<" ###########\n";
	for (int i=0;i<yi;i++) col[i]=y;
	for (int i=yi;i<m;i++) col[i]=n-y;
	for (int i=0;i<xi;i++)
	{
		int t=x;
		for (int j=0;j<m;j++)
		{
			if (col[j] && t) t--,c[i][j]='0',col[j]--;
			else c[i][j]='1'; 
			//cout <<i<<" "<<j<<" "<<t<<" "<<col[j]<<" A##\n";
		}
	}
	for (int i=xi;i<n;i++)
	{
		int t=x;
		for (int j=0;j<m;j++)
		{
			if (!col[j] && t) t--,c[i][j]='1';
			else col[j]--,c[i][j]='0'; 
			//cout <<i<<" "<<j<<" "<<t<<" "<<col[j]<<" B##\n";
		}
	}
	for (int i=0;i<n;i++)
		if (count(c[i],c[i]+m,'0')!=x && count(c[i],c[i]+m,'0')!=m-x)
			return;
	for (int i=0;i<n;i++) if (col[i]) return;
	for (int i=0;i<n;i++) printf("%s\n",c[i]);
	exit(0);
} 
int main()
{
	scanf("%d%d%d%d",&n,&m,&x,&y);
	for (int i=0;i<=n;i++)
	{
		for (int j=0;j<=m;j++)
			if (i*x+(n-i)*(m-x)==j*y+(m-j)*(n-y)) out(i,j);
	}
	cout <<"-1";
	return 0;
} 

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> X(N);
	for (int i = 0; i < N; i++) cin >> X[i];
	int sum = 1000000;
	for (int P = 1; P <= 100; P++) {
		int stamina = 0;
		for (int i = 0; i < N; i++) {
			stamina += (X[i] - P) * (X[i] - P);
		}
		sum = min(sum, stamina);
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ws(x) cerr << #x << " is " << x << endl;
#define pb(x) push_back(x)
#define ats(x) cout << x << "\n";

typedef long long ll;
typedef vector<int> vi;
typedef pair <int, int> pii;
typedef vector<pii> vii;

const int INF = INT_MAX;

vector <int> adj;

int main()
{
    FAST_IO;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int sk;
        cin >> sk;
        adj.pb(sk);
    }
    int curr = 0;
    int ans = 0;
    int st = adj[0];
    for (int i = 1; i < n; i++){
        if (adj[i] <= st){
            curr++;
            st = adj[i];
        }
        else {
            ans = max(curr, ans);
            curr = 0;
            st = adj[i];
        }
    }
    ans = max(curr, ans);
    ats(ans);
    return 0;
}




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

int main() {
  int M, D;
  cin >> M >> D;

  int cnt = 0;
  for (int i = 1; i <= M; i++) {
    for (int j = 2; j <= D; j++) {
      if (i == (j / 10) * (j % 10) && (j / 10) >= 2 && (j % 10) >= 2) cnt++;
    }
  }

  cout << cnt << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n), a(n);
    rep(i, n){
        cin >> p[i];
        a[i] = p[i];
    }
    sort(a.begin(), a.end());
    int cnt = 0;
    rep(i,n){
        if(p[i] != a[i]){
            cnt++;
        }
    }
    if(cnt == 2 || cnt == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from heapq import *

"""
とりあえず何通りあるかを数える：各頂点を通る時点での場合の数
最後に衝突する方法を除外する：頂点での衝突、辺での衝突
辺での衝突：距離を見れば分かる
"""

MOD = 10 ** 9 + 7

N,M = map(int,input().split())
S,T = map(int,input().split())
graph = [[] for _ in range(N+1)]
for _ in range(M):
    u,v,d = map(int,input().split())
    graph[u].append((v,d))
    graph[v].append((u,d))

def dijkstra(S):
    # 距離、パスの個数を返す
    INF = 10 ** 15
    dist = [INF] * (N+1)
    cnt_path = [0] * (N+1)
    cnt_path[S] = 1
    q = [(0,S)] # 距離、場所
    while q:
        d,x = heappop(q)
        if dist[x] < d:
            continue
        dist[x] = d
        for y,dy in graph[x]:
            if d + dy > dist[y]:
                continue
            if d + dy == dist[y]:
                cnt_path[y] += cnt_path[x]
                continue
            cnt_path[y] = cnt_path[x]
            dist[y] = d + dy
            heappush(q,(d+dy,y))
    return dist, cnt_path

dist_S, cnt_path_S = dijkstra(S)
dist_T, cnt_path_T = dijkstra(T)

D = dist_S[T]
# 最短路の組
answer = cnt_path_S[T] * cnt_path_T[S]
# 頂点での衝突
for x in range(1,N+1):
    if dist_S[x] == dist_T[x]:
        t = cnt_path_S[x] * cnt_path_T[x] % MOD
        answer -= t * t % MOD
# 辺での衝突。S側がx、T側がy
for x in range(1,N+1):
    for y,d in graph[x]:
        dx = dist_S[x]
        dy = dist_T[y]
        if dx + dy + d == D and dx + d > dy and dy + d > dx:
            t = cnt_path_S[x] * cnt_path_T[y] % MOD
            answer -= t * t % MOD

answer %= MOD
print(answer)



Measured memory_bytes: 86392
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  string s;
  cin >> s;

  int ans = 10000;
  for(int i = 0;i < 26;i++) {
    char ch = i + 'a';
    int num = 0;
    string S = s;
    while(1) {
      bool all = true;
      for(int i = 0;i < S.size();i++) {
        if(S.at(i) != ch) all = false;
      }
      
      if(all) break;
      
      string t;
      for(int i = 0;i < S.size()-1;i++) {
        if(S.at(i) == ch || S.at(i+1) == ch) t.push_back(ch);
        else  t.push_back(S.at(i));
      }

      S = t;
      num++;
    }
    ans = min(ans,num);
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
my $N = <>;
my $A = <>;
my $B = <>;
my $C = <>;

if ( $A eq $B and $A eq $C ) {
    print 0; exit;
}

my @A = split('', $A);
my @B = split('', $B);
my @C = split('', $C);

my $count = 0;

for my $i ( 0..$N-1 ) {
    my %hash = ();
    $hash{ $A[$i] } = 1;
    $hash{ $B[$i] } = 1;
    $hash{ $C[$i] } = 1;

    my $tmp = scalar (keys %hash);
    $count += $tmp-1;
}

print $count ;

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    int l[k],r[k];
    int b=0,e=k-1;
    int ind=-1;
    for(int i=0;i<n && b<k;i++){
        if(s[i]=='o' && i>ind){
            l[b]=i;
            b++;
            ind=i+c;
        }
 
    }
 
    ind=n;
    for(int i=n-1;i>=0 && e>=0;i--){
        if(s[i]=='o' && i<ind){
            r[e]=i;
            e--;
            ind=i-c;
        }
    }
    
    for(int i=0;i<k;i++){
        if(l[i]==r[i])cout<<l[i]+1<<endl;
        
    }
 
	return 0;
}

Measured memory_bytes: 3332
#include <stdio.h>

int main(void){
  int a=100000;
  int n,i;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
      a=a*1.05;
      if(a%1000!=0){
          a=a+1000;
          a/=1000;
          a*=1000;
      }
  }
  printf("%d\n",a);
  
  return 0;
}



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

vector<vector<ll>> P(100005);
vector<vector<ll>> L(100005);
vector<ll> used_L(100005, 0);
vector<ll> used_P(100005, 0);

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

  ll N; cin >> N;
  ll M; cin >> M;
  for (ll i = 0; i < N; i++) {
    ll K; cin >> K;
    for (ll j = 0; j < K; j++) {
      ll l; cin >> l;
      P[i].emplace_back(l);
      L[l].emplace_back(i);
    }
  }

  queue<ll> q;
  q.emplace(0);
  while (!q.empty()) {
    ll p = q.front(); q.pop();
    for (ll nl: P[p]) {
      if (used_L[nl] == 0) {
        used_L[nl] = 1;
        for (ll np: L[nl]) {
          if (used_P[np] == 0) {
            used_P[np] = 1;
            q.emplace(np);
          }
        }
      }
    }
  }
  string ans = "YES";
  for (ll i = 0; i < N; i++) {
    if (used_P[i] == 0) {
      ans ="NO";
      break;
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 14208
#include<stdio.h>
int main(void)
{
    int 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;
    scanf("%d %d %d %d %d %d\n%d %d %d %d %d %d\n%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j,&k,&l,&m,&n,&o,&p,&q,&r);
    s=3600*a+60*b+c;
    t=3600*d+60*e+f;
    u=3600*g+60*h+i;
    V=3600*j+60*k+l;
    w=3600*m+60*n+o;
    x=3600*p+60*q+r;
    y=t-s;z=V-u;A=x-w;
    B=y/3600;C=y/60-B*60;D=y-B*3600-C*60;
    E=z/3600;F=z/60-E*60;G=z-E*3600-F*60;
    H=A/3600;I=A/60-H*60;J=A-H*3600-I*60;
    printf("%d %d %d\n%d %d %d\n%d %d %d\n",B,C,D,E,F,G,H,I,J);
    return 0;
}

Measured memory_bytes: 600
import sys

input = sys.stdin.readline

N, M = map(int, input().split())

Pm = [0] * M
Ym = [0] * M
ym = [0] * M

Am = [''] * M
Cn = [0] * N

D = {}

for i in range(M):
    P, Y = map(int, input().split())

    Pm[i], Ym[i] = P, Y

    ym[i] = Y

    D[Y] = i

ym.sort()

for i in range(M):
    k = D[ym[i]]

    # 0-indexed
    Cn[Pm[k] - 1] += 1
    Am[k] = str(Pm[k]).rjust(6, '0') + str(Cn[Pm[k] - 1]).rjust(6, '0')

for i in range(M):
    print(Am[i])


Measured memory_bytes: 30640
n=int(input())
s=input()
bres=0
wres=0
blst=[]
wlst=[]
for i in range(n):
    if s[i]=='#':
        bres+=1
    blst.append(bres)
for i in range(n-1,-1,-1):
    if s[i]=='.':
        wres+=1
    wlst.append(wres)
wlst=wlst[::-1]
ans=10**9
blst.insert(0,0)
wlst.insert(n,0)
for i in range(n+1):
    ans=min(blst[i]+wlst[i],ans)
print(ans)

Measured memory_bytes: 14568
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
tv = []
ans = 0
for i in range(n):
    tv.append(v[i] - c[i])
tv.sort()
tv = reversed(tv)
for i in tv:
    if i > 0:
        ans += i
print(ans)


Measured memory_bytes: 3060
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i32 a, b, w;
    std::cin >> w >> a >> b;
    std::cout << std::max(i32{0}, std::abs(a-b)-w) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
using ll = long long;
const ll INF = 1e9;

int main() {
    int n;
    cin >> n;
    vector<int> b = {};
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (n % 2 == 0) {
            if(i % 2 == 0) b.push_back(a);
            else b.insert(b.begin(), a);
        } else {
            if (i % 2 == 1) b.push_back(a);
            else b.insert(b.begin(), a);
        }
    }

    for (int i = 0; i < n; i++) cout << b[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    REP(i,n) cout<<a[i]<<(i<n-1 ? " " : "");
    cout<<endl;
    for(int i=1;i<n;i++){
        int v = a[i];
        int j=i-1;
        while(j>=0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        REP(i,n) cout<<a[i]<<(i<n-1 ? " " : "");
        cout<<endl;
    }
}


Measured memory_bytes: 3216
n, k = map(int, input().split())
lis = list(map(int, input().split()))
c1, c2 = 0, 0
for i in range(n):
        for j in range(n):
                if lis[i] > lis[j]:
                        c2 += 1
                        if j > i:
                                c1 += 1
ans = c1*k + c2*k*(k-1)//2
print(ans % 1000000007)

Measured memory_bytes: 3188
#!/usr/bin/env python3
n = int(input())
rl = [[0, 0]] * n
for i in range(n):
    x, l = map(int, input().split())
    rl[i] = [x + l, x - l]
rl.sort()
l = [0] * n
r = [0] * n
for i in range(n):
    r[i], l[i] = rl[i]
ans = 1
p = 0
for i in range(1, n):
    if r[p] <= l[i]:
        ans += 1
        p = i
print(ans)


Measured memory_bytes: 25376