akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

int n, m;
int A, B, C, cnt;
ll a[MAX], b[MAX], c[MAX], d[MAX], s1[MAX], s2[MAX];

int main()
{
    cin >> n >> m >> A >> B >> C;
    for(int i = 1; i <= A; i++) scanf("%lld", &a[i]);
    for(int i = 1; i <= B; i++) scanf("%lld", &b[i]);
    for(int i = 1; i <= C; i++) scanf("%lld", &c[i]);
    sort(a+1, a+A+1, greater<int>()), sort(b+1, b+B+1, greater<int>()), sort(c+1, c+C+1, greater<int>());
    for(int i = 1; i <= C; i++){
        s1[i] = s1[i-1]+c[i];
    }
    for(int i = 1; i <= min(A, n); i++) d[++cnt] = a[i];
    for(int i = 1; i <= min(B, m); i++) d[++cnt] = b[i];
    sort(d+1, d+cnt+1, greater<int>());
    for(int i = 1; i <= cnt; i++){
        s2[i] = s2[i-1]+d[i];
    }
    ll ans = -1e18;
    for(int i = 0; i <= C; i++){
        if(i > n+m) break;
        ll s = s1[i]+s2[n+m-i];
        ans = max(ans, s);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 20096
import sys
import collections

size = sys.stdin.readline().split(' ')
S = int(size[0])
H = int(size[1])


data = sys.stdin.readlines()
for i in range(len(data)):
	data[i] = [j.replace('\n','') for j in data[i]]


if S == 1 and H == 1:
	if data[0][0] == ".":
		data[0][0] = "0"
elif S == 1 and H > 1:
	for j in range(H):
		if data[0][j] == "#":
			continue
		else:
			if j == 0:
				list = [data[0][j+1]]
				count = str(list.count("#"))
				data[0][j] = count
			elif j == (H-1):
				list = [data[0][j-1]]
				count = str(list.count("#"))
				data[0][j] = count
			else:
				list = [data[0][j-1], data[0][j+1]]
				count = str(list.count("#"))
				data[0][j] = count
elif S > 1 and H == 1:
	for i in range(S):
		if data[i][0] == "#":
			continue
		else:
			if i == 0:
				list = [data[i+1][0]]
				count = str(list.count("#"))
				data[i][0] = count
			elif i == (S-1):
				list = [data[i-1][0]]
				count = str(list.count("#"))
				data[i][0] = count	
			else:
				list = [data[i-1][0], data[i+1][0]]
				count = str(list.count("#"))
				data[i][0] = count					
else:
	for i in range(S):
		for j in range(H):
			if data[i][j] == "#":
				continue
			else:
				#上左
				if i == 0 and j == 0:
					list = [data[i+1][j], data[i+1][j+1], data[i][j+1]]
					count = str(list.count("#"))
					data[i][j] = count
				#下右
				elif i == (S-1) and j == (H-1):
					list = [data[i-1][j], data[i-1][j-1], data[i][j-1]]
					count = str(list.count("#"))
					data[i][j] = count
				# 上右
				elif i == 0 and j == (H-1):
					list = [data[i][j-1], data[i+1][j-1], data[i+1][j]]
					count = str(list.count("#"))
					data[i][j] = count
				# 下左
				elif i == (S-1) and j == 0:
					list = [data[i-1][j], data[i-1][j+1], data[i][j+1]]
					count = str(list.count("#"))
					data[i][j] = count
				# 左
				elif (1 <= i < (S-1)) and j == 0:
					list = [data[i-1][j], data[i-1][j+1], data[i][j+1], data[i+1][j+1], data[i+1][j]]
					count = str(list.count("#"))
					data[i][j] = count
				# 右
				elif (1 <= i < (S-1)) and j == (H-1):
					list = [data[i-1][j], data[i-1][j-1], data[i][j-1], data[i+1][j-1], data[i+1][j]]
					count = str(list.count("#"))
					data[i][j] = count
				# 上
				elif i == 0 and (1<= j < (H-1)):
					list = [data[i][j-1], data[i+1][j-1], data[i+1][j], data[i+1][j+1], data[i][j+1]]
					count = str(list.count("#"))
					data[i][j] = count
				# 下
				elif i == (S-1) and (1<= j < (H-1)):
					list = [data[i][j-1], data[i-1][j-1], data[i-1][j], data[i-1][j+1], data[i][j+1]]
					count = str(list.count("#"))
					data[i][j] = count
				# 真ん中
				else:
					list = [data[i][j-1], data[i-1][j-1],data[i-1][j],data[i-1][j+1],data[i][j+1],data[i+1][j+1],data[i+1][j],data[i+1][j-1]]
					count = str(list.count("#"))
					data[i][j] = count



for i in range(len(data)):
	ans = str(data[i]).replace('[', '').replace(']', '').replace(',', '').replace("'", '').replace(' ', '')
	print(ans)

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

int W, H, x, y, r;

int main() {
  cin >> W >> H >> x >> y >> r;
  if(x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){
      cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3088
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String a = sc.next();
	String b = sc.next();
	if(a.length() > b.length()) {
		System.out.println("GREATER");
	}
	if(a.length() < b.length()) {
		System.out.println("LESS");
	}
	if(a.length() == b.length()) {
		if(a.compareTo(b) > 0) {
			System.out.println("GREATER");
		}
		if(a.compareTo(b) < 0) {
			System.out.println("LESS");
		}
		if(a.compareTo(b) == 0) {
			System.out.println("EQUAL");
		}
	}
}
}

Measured memory_bytes: 23376
fun main(args:Array<String>):Unit {
    while (true){
        val n = readLine()!!.trim().toInt()
        if (n == 0) return
        val buildingA = Building(readLine()!!.trim().split(' ').map(String::toInt).map{when(it){
            0 -> Wall.Normal
            1 -> Wall.Step(0)
            else -> Wall.Wet(0)
        }}.toTypedArray())
        val buildingB = Building(readLine()!!.trim().split(' ').map(String::toInt).map{when(it){
            0 -> Wall.Normal
            1 -> Wall.Step(0)
            else -> Wall.Wet(0)
        }}.toTypedArray())
        search(buildingA, buildingB)
        search(buildingB, buildingA)
        val min = minOf(buildingA.minTopFloor(), buildingB.minTopFloor())
        println(
                if (min == Int.MAX_VALUE) "NA"
                else min
        )
    }
}
class Building(private val mWall:Array<Wall>){
    init{
        var prev = 0
        for (i in 0 until mWall.size){
            when(mWall[i]){
                is Wall.Wet -> mWall[i] = Wall.Wet(prev)
                else -> {
                    prev = i
                }
            }
        }
        prev = mWall.size
        for (i in (0 until mWall.size).reversed()){
            when(mWall[i]){
                is Wall.Step -> mWall[i] = Wall.Step(prev - 1)
                else -> {
                    prev = i
                }
            }
        }
    }
    private val mMinStep = Array(mWall.size){Int.MAX_VALUE}
    fun minStep(floor:Int):Int = mMinStep[floor]
    fun setMinStep(floor:Int, step:Int):Unit {
        mMinStep[floor] = step
    }
    fun floorState(floor:Int):Wall = mWall[floor]
    val top:Int = mWall.size - 1
    fun minTopFloor():Int {
        return when(mWall.last()){
            is Wall.Wet -> Int.MAX_VALUE
            else -> mMinStep.last()
        }
    }
}
fun search(current:Building, other:Building, floor:Int = 0, step:Int = 0):Unit {
    if (floor > current.top) return
    if (current.minStep(floor) <= step) return
    current.setMinStep(floor, step)
    val floorState = current.floorState(floor)
    when(floorState){
        is Wall.Wet -> search(current, other, floorState.floor, step)
        is Wall.Step -> {
            search(current, other, floorState.floor, step)
            listOf(0, 1, 2).forEach { search(other, current, floorState.floor + it, step + 1) }
        }
        Wall.Normal -> listOf(0, 1, 2).forEach { search(other, current, floor + it, step + 1) }
    }
}
sealed class Wall{
    class Wet(val floor:Int):Wall()
    class Step(val floor:Int):Wall()
    object Normal:Wall()
}


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

using namespace std;

const int maxn = 5*(int)1e5+100;
int n, a[maxn], b[maxn], t[maxn*70], lt[maxn*70], rt[maxn*70], tVal[maxn*70], tot;
int lst[maxn];    //记录离散化后数组的上次出现位置
int q;

void init() {
    tot = 0;
    memset(lst, -1, sizeof(lst));
}
int build(int l, int r) {
    int node = ++tot;
    tVal[node] = 0;
    int mid = (l + r) >> 1;
    if (l < r) {
        lt[node] = build(l, mid);
        rt[node] = build(mid+1, r);
    }
    return node;
}
int update(int l, int r, int par, int p, int val) {
    int node = ++tot;
    lt[node] = lt[par]; rt[node] = rt[par]; tVal[node] = tVal[par] + val;
    int mid = (l + r) >> 1;
    if (l < r) {
        if (p <= mid) lt[node] = update(l, mid, lt[par], p, val);
        else rt[node] = update(mid+1, r, rt[par], p, val);
    }
    return node;
}
int query(int l, int r, int p, int node) {
    if (l == r) return tVal[node];
    int mid = (l + r) >> 1;
    if (p <= mid) return (query(l, mid, p, lt[node]) + tVal[rt[node]]);
    else return query(mid+1, r, p, rt[node]);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    init();
    cin >> n >> q;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b + 1, b + 1 + n);
    int len = unique(b + 1, b + 1 + n) - b;
    for (int i = 1; i <= n; ++i)
        a[i] = lower_bound(b + 1, b + 1 + len, a[i]) - b;

    t[0] = build(1, n);
    for (int i = 1; i <= n; ++i) {
        if (lst[a[i]] == -1) t[i] = update(1, n, t[i-1], i, 1);
        else {
            int temp = update(1, n, t[i-1], lst[a[i]], -1);
            t[i] = update(1, n, temp, i, 1);
        }
        lst[a[i]] = i;
    }
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << query(1, n, l, t[r]) << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256616
#include<iostream>
using namespace std;
int main()
{
    int k,S;
    cin>>k;

   string s;
   cin>>s;

   S=s.length();

   for(int i = 0 ; i<S ; i++)
   {
       cout<<s[i];
       if(i>=k-1)
       {
          if(k==S) break;

           else {
                cout<<"..." ;
           break;
           }
       }


   }



}


Measured memory_bytes: 3608
#include <stdio.h>
 
int main(void)
{
	int i,j,k,n,m,l,a[100][100],b[100][100];
	long int s;
	scanf("%d%d%d",&n,&m,&l);
	
	for(i=0;i<n;i++)
	for(j=0;j<m;j++)
	scanf("%d",&a[i][j]);

	for(i=0;i<m;i++)
	for(j=0;j<l;j++)
	scanf("%d",&b[i][j]);
 
	for(i=0;i<n;i++)
	for(j=0;j<l;j++){
	s = 0;
	for(k=0;k<m;k++)
	s += a[i][k] * b[k][j] ;
	
	printf("%ld", s);
	if(j+1 == l)
	printf("\n");
	
	else printf(" ");
	}
return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,a[300000];
ll ans=0;
multiset<int,greater<int> > sl,sr;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
    }
    sort(a,a+n,greater<int>());
    ans=a[0];
    sl.insert(a[1]);
    sr.insert(a[1]);
    for(int i=2;i<n;i++){
        int l=*(sl.begin()),r=*(sr.begin());
        if(l>r){
            sl.erase(sl.begin());
            sl.insert(a[i]);sl.insert(a[i]);
            ans+=l;
        }else{
            sr.erase(sr.begin());
            sr.insert(a[i]);sr.insert(a[i]);
            ans+=r;
        }
        //cout<<l<<" "<<r<<" "<<ans<<endl;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 13976
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int val[1005][1005];
int main()
{
	int i,j,n;
	scanf("%d",&n);
	int B=0;
	for(i=1;i<=1000;i++)
		if(i*(i-1)/2==n)
		{
			B=i;
			break;
		}
	if(B==0)
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	printf("%d\n",B);
	int cntz=0;
	memset(val,0,sizeof(val));
	for(i=1;i<=B;i++)
	{
		for(j=1;j<=B-1;j++)
			if(val[i][j]==0)
			{
				cntz++;
				val[i][j]=cntz;
			}
		printf("%d ",B-1);
		for(j=i+1;j<=B;j++)
			val[j][i]=val[i][j-1];
		for(j=1;j<B;j++)printf("%d ",val[i][j]);
		printf("\n");
	}
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main(){
    long N;cin>>N;
    map<long,long> mp;
    for(int i=0;i<N;i++){
        long l;cin>>l;
        mp[l]++;
    }
    auto begin=mp.begin();
    auto end=mp.end();
    long sum=0;
    for(auto i=begin;i!=end;i++){
        auto ii=i;
        ii++;
        for(auto j=ii;j!=end;j++){
            auto jj=j;
            jj++;
            for(auto k=jj;k!=end;k++){
                if((k->first)<(i->first)+(j->first)){
                    sum+=(k->second*i->second*j->second);
                }
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fi0 for(ll i=0;i<n;i++)
void solve()
{
    int n,m;
    cin>>n>>m;
    if(n==m){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}
int main()
{
   /// int t;cin>>t;while(t--){
        solve();

}


Measured memory_bytes: 3604
H, W = STDIN.gets.split(" ").map(&:to_i)
a = []
H.times do
  a << STDIN.gets.split(" ").map(&:to_i)
end

# def dump(a)
#   puts "#" * 10
#   a.each do |r|
#     puts r.join(" ")
#   end
# end
# dump(a)

order = []
for i in 0...H do
  for j in 0...(W-1) do
    next if a[i][j] % 2 == 0
    a[i][j] -= 1
    a[i][j+1] += 1
    order << [i, j, i, j+1].map { |i| i + 1 }.join(" ")
  end
end

for i in 0...(H-1) do
  j = W-1
  next if a[i][j] % 2 == 0
  a[i][j] -= 1
  a[i+1][j] += 1
  order <<  [i, j, i+1, j].map { |i| i + 1 }.join(" ")
end
# dump(a)

puts order.size
puts order.join("\n")

Measured memory_bytes: 35196
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    // L(T)
    {
        ll ans = 0;
        in(n);
        in(p);
        string s;
        cin >> s;
        vector<ll> cnt(p + 90);
        ll l = s.length();

        if (p == 2)
        {
            fw(i, 0, n)
            {
                if ((s[i] - '0') % 2 == 0)
                {
                    ans += i + 1;
                }
            }
        }
        else if (p == 5)
        {
            fw(i, 0, n)
            {
                if ((s[i] - '0') % 5 == 0)
                    ans += i + 1;
            }
        }
        else
        {
            ll suf = 0;
            cnt[suf]++;
            ll pot = 1;
            fb(i, l - 1, 0)
            {
                ll dig = s[i] - '0';
                suf = (suf + dig * pot) % p;
                pot = 10 * pot % p;
                ans += cnt[suf];
                cnt[suf]++;
            }
            // map<ll, ll> mp;
            // mp[suf]++;
            // fb(i, n - 1, 0)
            // {
            //     suf = (suf + (s[i] - '0') * pot) % p;
            //     ans += mp[suf];
            //     mp[suf]++;
            //     pot = 10 * pot % p;
            // }
        }
        cout << ans << endl;
    }
    return 0;
}

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




int main()
{
	int n;
	cin>>n;
	int i,L[n];
	for(i=0;i<n;i++) cin>>L[i];
	sort(L,L+n);
	long long int ans=0;
	int j,k;
	sort(L,L+n);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(L[i]+L[j]>L[k]) ans++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int t[n], x[n], y[n];
  rep(i,n) cin>>t[i]>>x[i]>>y[i];
  string ans = "Yes";
  int ti = 0, nx = 0, ny = 0;
  rep(i,n) {
    int dd = abs(x[i] - nx) + abs(y[i] - ny);
    int dt = t[i] - ti;
    if(dd > dt || dd % 2 != dt % 2) {
      ans = "No";
      break;
    } else {
      ti = t[i];
      nx = x[i];
      ny = y[i];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1000000007;

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

    llong N;
    cin >> N;
    vector<llong> A(N);
    for (llong i = 0; i < N; i++) {
        llong tmp;
        cin >> tmp;
        A[i] = tmp;
    }

    vector<llong> used(N + 1, 0); // 0番目は3,1番目に0の使用個数を入れる
    used[0] = 3;

    llong ans = 1;
    for (llong i = 0; i < N; i++) {
        llong num_index = A[i] + 1;
        if (used[num_index] == 0) {
            ans *= used[num_index - 1];
            ans %= MOD;
        } else {
            ans *= used[num_index - 1] - used[num_index];
            ans %= MOD;
        }
        used[num_index]++;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1792
//package kadai3;
import java.util.*;
public class Main {
	public boolean overlap(int[][] table, int h, int v) { //????±????????????????????????????????????????????????????
		for(int i = 0; i < table.length; i++) {
			if(table[h][v] == table[i][v] && i != h) return false;
		}
		return true;
	}
	void doIt() {
		Scanner sc = new Scanner(System.in);
		Main check = new Main();
		int N = sc.nextInt();
		int[] point = new int[N];
		int[][] num = new int[N][3]; 
		for(int i = 0; i < N; i++) {
			num[i][0] = sc.nextInt();
			num[i][1] = sc.nextInt(); 
			num[i][2] = sc.nextInt();
		}
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < N; j++) {
				if(check.overlap(num, j, i)) point[j] += num[j][i];
			}
		}
		for(int i = 0; i < N; i++) System.out.println(point[i]);
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}

Measured memory_bytes: 20788
#include <stdio.h>

using namespace std;

int main()
{
 int A=1,B=1,C=1,D=1;
 scanf ("%d%d%d%d",&A,&B,&C,&D);
  if ((A*B) == (C*D))
    printf ("%d\n",A*B);
      else if ((A*B)>(C*D))
    printf ("%d\n",A*B);
    else printf ("%d\n",C*D);
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int>v(N);
  vector<int>z(N);
  vector<int>count(N);
  int max =0;
  int sum =0;
  string s;
  for(int i=0;i<N;i++){
      cin>>v.at(i);
      cin>>z.at(i);
      count.at(i)=v.at(i)-z.at(i);
      //cout<<count.at(i)<<endl;
      if(count.at(i)!=0){
          max=0;
      }else{
          max++;
      }if(max==3){
          break;
      }
     // cout<<max<<endl;
     // cout<<max<<" "<<sum<<endl;
      if(sum==3){
          string s="Yes";
      }else{
          string s="No";
      }
  }
  //cout<<max<<endl;
  if(max>=3){
      cout<<"Yes"<<endl;
  }else{
      cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << n * n << endl;
}


Measured memory_bytes: 256
while (True):
    try:
        n=input()
    except:
        break
    count=0
    for i1 in range(10):
        n1=n-i1
        if n1<0 or n1>27: continue
        for i2 in range(10):
            n2=n1-i2
            if n2<0 or n2>18: continue
            for i3 in range(10):
                n3=n2-i3
                if n3<0 or n3>9: continue
                count+=1
    print count

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N;
  cin >> N;
  vector<ll>A(N);
  rep(i,N){
    cin >> A[i];
  }
  ll j = 1;
  rep(i,N){
    if(A[i] == j){
      j++;
    }
  }
  if(j == 1){
    cout << "-1";
  }
  else{
    cout << N - j + 1;
  }
}

Measured memory_bytes: 4852
H, W = map(int, input().split())
A = [[0 for i in range(W)] for j in range(H)]
maze = [input() for i in range(H)]
X = []
for i in range(H):
  for j in range(W):
    if maze[i][j] == '.':
      p = [i, j]
      Al = [p]
      luck = 0
      A[p[0]][p[1]] = -1
      while Al != []:
        luck += 1
        n = len(Al)
        for m in range(n):
          if Al[0][0] > 0 and maze[Al[0][0]-1][Al[0][1]] == '.' and A[Al[0][0]-1][Al[0][1]] == 0:
            A[Al[0][0]-1][Al[0][1]] = luck
            Al.append([Al[0][0]-1, Al[0][1]])
          if Al[0][0] < H - 1 and maze[Al[0][0]+1][Al[0][1]] == '.' and A[Al[0][0]+1][Al[0][1]] == 0:
            A[Al[0][0]+1][Al[0][1]] = luck
            Al.append([Al[0][0]+1, Al[0][1]])
          if Al[0][1] > 0 and maze[Al[0][0]][Al[0][1]-1] == '.' and A[Al[0][0]][Al[0][1]-1] == 0:
            A[Al[0][0]][Al[0][1]-1] = luck
            Al.append([Al[0][0], Al[0][1]-1])
          if Al[0][1] < W - 1 and maze[Al[0][0]][Al[0][1]+1] == '.' and A[Al[0][0]][Al[0][1]+1] == 0:
            A[Al[0][0]][Al[0][1]+1] = luck
            Al.append([Al[0][0], Al[0][1]+1])
          Al = Al[1:]
      X.append(luck-1)
      A = [[0 for i in range(W)] for j in range(H)]
print(max(X))

Measured memory_bytes: 3192
n = gets.chomp.to_i
hsh = {}
class Node
  attr_reader :id
  attr_accessor :children,:parent, :depth, :type
  def initialize(id)
    @id = id
    @parent = -1
    @depth = 0
    @type = nil
    @children = []
  end
 
  def leaf?
    @children.empty?
  end
end
 
def identify(node, depth, node_list)
  node.depth = depth
  if node.parent == -1
    node.type = 'root'
  elsif node.leaf?
      node.type = 'leaf'
  else
    node.type = 'internal node'
  end
  node.children.each do |i|
    identify(node_list[i], depth + 1, node_list)
  end
end
 
n.times do |index|
  hsh[index] = Node.new(index)
end
  
n.times do
  arr = gets.chomp.split.map(&:to_i)
  id = arr.shift
  num = arr.shift
  hsh[id].children = arr if num > 0
  arr.each do |item|
    hsh[item].parent = id
  end
end
 
root = hsh.select{|key, val| val.parent == -1}
identify(root.values[0], 0, hsh)
  
hsh.each do |key, node|
  puts "node #{node.id}: parent = #{node.parent}, depth = #{node.depth}, #{node.type}, #{node.children}"
end


Measured memory_bytes: 40060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int S[2000], T[2000];
	rep(i, N) cin >> S[i];
	rep(i, M) cin >> T[i];

	int mod = 1e9 + 7;
	int dps[2001][2001];

	rep(i, M + 1) dps[0][i] = 1;
	rep1(i, N) {
		dps[i][0] = 1;
		rep1(j, M) {
			if (S[i - 1] == T[j - 1]) dps[i][j] = (dps[i - 1][j] + dps[i][j - 1]) % mod;
			else dps[i][j] = ((ll)dps[i - 1][j] + dps[i][j - 1] - dps[i - 1][j - 1] + mod) % mod;
		}
	}
	co(dps[N][M]);

	Would you please return 0;
}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

bool dp[100005][2];
bool mark[100005][2];
int v[105], n;

bool f(int i, int p) {
	if(i == 0) return false;
	if(mark[i][p]) return dp[i][p];
	mark[i][p] = true;

	bool ret = false;

	for(int l = 0; l < n; l++) {
		if(i-v[l] < 0) continue;
		if(!f(i-v[l], p^1)) {
			ret = true;
			break;
		}
	}

	return dp[i][p] = ret;
}

int main() {
	int k;
	
	scanf("%d%d", &n, &k);

	for(int i = 0; i < n; i++)
		scanf("%d", &v[i]);

	printf("%s\n", f(k,0) ? "First" : "Second");
	
    return 0;
}

Measured memory_bytes: 6912
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int ans = 0;
		for(int i=0; i<5; i++) {
			int x = sc.nextInt();
			if(x==0)
				ans = i+1;
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 26980
#include <cstdio>
#include <algorithm>

using namespace std;

int n, a[100][100], sum[101][101];

int main()
{
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    
    sum[1][1] = a[0][0];
    
    for(int i = 2; i <= n; i++)
    {
        sum[1][i] = sum[1][i - 1] + a[0][i - 1];
        sum[i][1] = sum[i - 1][1] + a[i - 1][0];
    }
    
    for(int i = 2; i <= n; i++)
    {
        for(int j = 2; j <= n; j++)
        {
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i - 1][j - 1];
        }
    }
    
    int ret = -1000000001;
    
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            for(int k = i; k <= n; k++)
            {
                for(int l = j; l <= n; l++)
                {
                    ret = max(ret, sum[k][l] + sum[i - 1][j - 1] - sum[i - 1][l] - sum[k][j - 1]);
                }
            }
        }
    }
    
    printf("%d\n", ret);
    
    return 0;
}

Measured memory_bytes: 2804
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll n;
  ll v;
  std::cin >> n;

  std::map< ll, ll > counter0;
  std::map< ll, ll > counter1;
  std::vector< ll > vv(n, 0);
  for (ll i = 0; i < n; i++) {
    std::cin >> v;
    if (i % 2 == 0) {
      counter0[v]++;
    } else {
      counter1[v]++;
    }
  }

  std::pair< ll, ll > num0(std::make_pair(0, 0));
  std::pair< ll, ll > num1(std::make_pair(0, 0));
  for (std::map< ll, ll >::iterator it = counter0.begin(); it != counter0.end(); it++) {
    if (num0.second < it->second) {
      num0 = *it;
    }
  }
  for (std::map< ll, ll >::iterator it = counter1.begin(); it != counter1.end(); it++) {
    if (num1.second < it->second) {
      num1 = *it;
    }
  }

  ll num0_second = num0.second;
  ll num1_second = num1.second;

  if (num0.first == num1.first) {
    counter0.erase(num0.first);
    counter1.erase(num1.first);

    std::pair< ll, ll > num0_2(0, 0);
    std::pair< ll, ll > num1_2(0, 0);
    if (!counter0.empty()) {
      for (std::map< ll, ll >::iterator it = counter0.begin(); it != counter0.end(); it++) {
	if (num0_2.second < it->second) {
	  num0_2 = *it;
	}
      }
    }
    if (!counter1.empty()) {
      for (std::map< ll, ll >::iterator it = counter1.begin(); it != counter1.end(); it++) {
	if (num1_2.second < it->second) {
	  num1_2 = *it;
	}
      }
    }
    ll a = num0_second   + num1_2.second;
    ll b = num0_2.second + num1_second;

    //std::cout << num0_second << " " << num1_2.second << std::endl;
    //std::cout << num0_2.second << " " << num1_second << std::endl;

    if (a <= b) {
      num0_second = num0_2.second;
    } else {
      num1_second = num1_2.second;
    }
  }

  ll ans = n - num0_second - num1_second;
  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 7296
N = int(input())
A, B = tuple(map(int, input().split()))
P = list(map(int, input().split()))
first = [p for p in P if p <= A]
second = [p for p in P if A + 1 <= p <= B]
third = [p for p in P if B + 1 <= p]
print(min(len(first), len(second), len(third)))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	string S;
	cin >> S;

	auto mod = (unsigned long long)1e9 + 7;
	vector<unsigned long long> sumNum(S.length() + 1);
	vector<unsigned long long> sumC(S.length() + 1);
	vector<unsigned long long> sumB(S.length() + 1);

	auto sum = 1ull;
	sumNum[S.length()] = 1;
	for (auto i = (int)S.length() - 1; i >= 0; --i)
	{
		auto current = S[i];
		if (current == '?')
		{
			sum = sum * 3 % mod;
		}
		sumNum[i] = sum;
	}

	sum = 0;
	for (auto i = (int)S.length() - 1; i >= 0; --i)
	{
		auto current = S[i];
		if (current == 'C')
		{
			sum = (sum + sumNum[i + 1]) % mod;
		}
		else if (current == '?')
		{
			sum = (sum * 3 % mod + sumNum[i + 1]) % mod;
		}
		sumC[i] = sum;
	}

	sum = 0;
	for (auto i = (int)S.length() - 1; i >= 0; --i)
	{
		auto current = S[i];
		if (current == 'B')
		{
			sum = (sum + sumC[i + 1]) % mod;
		}
		else if (current == '?')
		{
			sum = (sum * 3 % mod + sumC[i + 1]) % mod;
		}

		sumB[i] = sum;
	}

	auto result = 0ull;
	for (auto i = (int)S.length() - 1; i >= 0; --i)
	{
		auto current = S[i];
		if (current == 'A')
		{
			result = (result + sumB[i + 1]) % mod;
		}
		else if (current == '?')
		{
			result = (result * 3 % mod + sumB[i + 1]) % mod;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int N = 1e5 + 5;
int n, d;
char s[N];
bool ok(int len){
    if(len & 1) return 0;
    rep(i,1,len/2) if(s[i] != s[len/2+i]) return 0;
    return 1;
}

int main(){
    scanf("%d", &n);
    scanf("%s", s+1);
    int len = strlen(s+1);
    printf("%s\n", ok(len)?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 5e+5+5;

int n,q,D;
int d[N];
int A[N],B[N];

int main(){
	n=get();D=get();
	fo(i,1,n)d[i]=get();
	A[0]=D;
	fo(i,1,n)A[i]=min(abs(A[i-1]-d[i]),A[i-1]);
	B[n+1]=1;
	fd(i,n,1){
		if (B[i+1]<=d[i]/2)B[i]=B[i+1];
		else B[i]=B[i+1]+d[i];
	}
	q=get();
	fo(i,1,q){
		int x=get();
		if (A[x-1]>=B[x+1])printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 7808
// ARC094
// D - Worst Case

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int Q;

ll solve(ll a, ll b) {
    if (a > b) {
        swap(a, b);
    }

    if (b - a <= 1) {
        return 2 * a - 2;
    }
    ll c = sqrt(a * b);
    if (c * c == a * b) {
        c--;
    }
    if (c * (c + 1) >= a * b) {
        return 2 * c - 2;
    }
    return 2 * c - 1;
}

int main() {
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        ll a, b;
        cin >> a >> b;

        cout << solve(a, b) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll a, b, c;
	cin >> a >> b >> c;
	cout << max((ll)0, (c - (a - b)));
}


Measured memory_bytes: 256
<?php
$n = (int)trim(fgets(STDIN));
$s = trim(fgets(STDIN));

$left = 0;
$right = 1;

$max = 0;
while ($right <= $n) {
	$length = $right-$left;
	$tmp = substr($s, $left, $length);
	// echo $tmp , PHP_EOL;
	if (strpos($s, $tmp, $right) !== false) {
		$max = max($max, $length);
		$right += 1;
	}else{
		$left += 1;
		if ($right === $left) {
			$right += 1;
		}
	}
}
echo $max;

Measured memory_bytes: 4856
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int K = GetInt();
		string[] P = GetStrings(N);

		int[] cnt = new int[26];
		for(int i = 0; i < N; i++)
			cnt[(int)(P[i][0] - 'A')]++;

		var pq = new PriorityQueue<int>(26, (x, y) => y - x);
		for(int i = 0; i < 26; i++)
			if(cnt[i] > 0)
				pq.Push(cnt[i]);
		
		int ans = 0;
		while(pq.Size >= K)
		{
			var tmp = new List<int>();
			for(int i = 0; i < K; i++)
			{
				int rest = pq.Pop() - 1;
				if(rest > 0)
					tmp.Add(rest);
			}
			foreach(int x in tmp)
				pq.Push(x);

			ans++;
		}

		Console.WriteLine(ans);
	}
}


public class PriorityQueue<T>
{
	public long Size { get; private set; } = 0;
	public long MaxSize { get; private set; } = 0;
	private T[] m_heap;
	private Comparison<T> Comp = null;
	
	public PriorityQueue(long maxSize, Comparison<T> comp)
	{
		if(maxSize <= 0)
			throw new Exception();
		MaxSize = maxSize;
		m_heap = new T[maxSize];

		Comp = comp;
	}
	
	public void Push(T x)
	{
		if(Size == MaxSize)
		{
			T[] new_heap = new T[MaxSize << 1];
			Array.Copy(m_heap, new_heap, MaxSize);
			m_heap = new_heap;
			MaxSize <<= 1;
		}
		
		long i = Size++;
		while(i > 0)
		{
			long p = (i - 1)/2;
			if(Comp(m_heap[p], x) <= 0)
				break;
			m_heap[i] = m_heap[p];
			i = p;			
		}
		m_heap[i] = x;		
	}
	
	public T Pop()
	{
		if(Size == 0)
			throw new Exception("Queue is empty.");
		
		T result = m_heap[0];
		T x = m_heap[--Size];
		long i = 0;
		while(i * 2 + 1 < Size)
		{
			long c1 = i * 2 + 1, c2 = i * 2 + 2;
			if(c2 < Size && Comp(m_heap[c2], m_heap[c1]) < 0)
				c1 = c2;
			if(Comp(m_heap[c1], x) >= 0)
				break;
			m_heap[i] = m_heap[c1];
			i = c1;
		}
		m_heap[i] = x;
		
		return result;		
	}	
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 15584
#include <iostream>
#include<math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)



int main() {
    double R;
    cin >> R;
    
    cout << R * 6.28318530717958623200 << endl;
    
    return 0;
}

Measured memory_bytes: 3784
#!/usr/bin/env python3
import sys


def solve(O: str, E: str):
    password = ''
    for i in range(len(O)):
        password += O[i]
        if len(E) > i:
            password+= E[i]
    print(password)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    O = next(tokens)  # type: str
    E = next(tokens)  # type: str
    solve(O, E)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=100009;
  
int main()
{
    int n,x;
    map<int,int>cnt;
    cin>>n;
    while(n--){ 
        cin>>x;
        cnt[x]++;
        if(cnt[x]==2){ 
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
        

    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
int main(){
    int a,b,c,d,e,f;
    while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)){
        double y=(double)(c*d-a*f)/(double)(b*d-a*e);
        if(a!=0)
        printf("%.3f %.3f\n",(c-b*y)/a,y);
        else
        printf("%.3f %.3f\n",(f-e*y)/d,y);
    }
}


Measured memory_bytes: 2704
n=int(input())
L=list(map(int,input().split()))
x=int(sum(L)/n)

ans=0
ans1=0
ans2=0
for i in L:
    ans+=pow(i-x,2)
    ans1+=pow(i-x-1,2)
    ans2+=pow(i-x+1,2)

print(min(ans,ans1,ans2))

Measured memory_bytes: 3064
/*
  AOJ 2588
  Title:
  @kankichi573
*/
#include <stdio.h>

int e1,e2;
char op[2];

main()
{
        scanf("%d ",&e1);
        while(1)
        {    
                scanf("%s",op);

                if(*op=='=')   
                {
                        printf("%d\n",e1);
                        break;
                }
                scanf("%d",&e2);

                if(*op=='+')
                        e1+=e2;
                if(*op=='-')
                        e1-=e2;
                if(*op=='*')
                        e1*=e2;
                if(*op=='/')
                        e1/=e2;
        }
  return(0);
}

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

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 300
#define LL long long
#define INF 0x3f3f3f3f
int N,M,Q,L;
bool vis[MAXN+5];
int dp[MAXN+5][MAXN+5],Dist[MAXN+5][MAXN+5];

int main(){
    N=read(),M=read(),L=read();
    memset(dp,0x3f,sizeof dp);
    memset(Dist,0x3f,sizeof Dist);
    for(int i=1;i<=M;i++){
        int u=read(),v=read();
        Dist[u][v]=Dist[v][u]=read();
    }
    for(int k=1;k<=N;k++)
        for(int i=1;i<=N;i++)
            for(int j=1;j<=N;j++)
                if(i!=j&&j!=k)
                    Dist[i][j]=min(Dist[i][j],Dist[i][k]+Dist[k][j]);
    for(int i=1;i<=N;i++){
        queue<int> Q;
        Q.push(i);
        dp[i][i]=0;
        while(!Q.empty()){
            int u=Q.front();Q.pop();
            for(int v=1;v<=N;v++)
                if(Dist[u][v]<=L){
                    if(dp[i][v]>dp[i][u]+1){
                        dp[i][v]=dp[i][u]+1;
                        Q.push(v);
                    }
                }
        }
    }
    Q=read();
    while(Q--){
        int S=read(),T=read(),Ans=INF;
        for(int i=1;i<=N;i++)
            if(Dist[i][T]<=L)
                Ans=min(Ans,dp[S][i]);
        printf("%d\n",Ans==INF?-1:Ans);
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    ll x;
    cin >> x;
    ll y = 0;
    ll cur = 100;
    while (1) {
        if (cur >= x) break;
        cur += (cur / 100);
        y++;
    }
    cout << y << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
    ll a, b, c, d, n, k, x;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "YES";



    cin  >> n >> a >> b ;

    ans = min(n*a, b);




    std::cout << ans << endl; 
    // std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n,ab,ans,a[200005];
int main(){
	n=read();
	for(int i=0;i<n;i++)
		a[i]=read(),ans+=a[i]==1;
	if(ans==0)return puts("-1"),0;
	ans=0,ab=1;
	for(int i=0;i<n;i++){
		while(i<n and a[i]!=ab)i++,ans++;
		ab++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
const int maxn=2007;
const int mod=1e9+7;

int a[maxn];

int main()
{
//    freopen("input.txt","r",stdin);
    
	ll n,k;
	cin>>n>>k;
	ll temp1=0,temp2=0;
	for(ll i=0;i<n;i++) cin>>a[i];
	for(ll i=0;i<n;i++)
	{
		for(ll j=i+1;j<n;j++)
		{
			if(a[i]>a[j]) temp1++;
		}
	}
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			if(a[i]>a[j]) temp2++;
		}
	}
	cout<<(((k*(k-1)/2)%mod*temp2%mod)%mod+(temp1*k)%mod)%mod<<endl;
    
    return 0;
}
//%和*、/的优先级相同，计算的时候从左向右即可 














Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=505;
int n,k,sum,a[N],b[N],l[N],r[N];
bool judge(int m)
{
    int ans=0,tot=0;
    for(int i=1;i<=n;i++)
        b[i]=a[i]%m;
    sort(b+1,b+1+n);
    for(int i=1;i<=n;i++)
        l[i]=l[i-1]+b[i];
    for(int i=n;i>=1;i--)
        r[i]=r[i+1]+(m-b[i]);
    for(int i=1;i<n;i++)
        if(l[i]==r[i+1]&&l[i]<=k) return true;
    return false;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),sum+=a[i];
    int ans=1;
    for(int i=1;i*i<=sum;i++)
        if(sum%i==0)
    {
        if(judge(i))
            ans=max(ans,i);
        if(judge(sum/i))
            ans=max(ans,sum/i);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
# 最初に入れておくとinputが早くなる
#import numpy as np
import sys
input = sys.stdin.readline

n, l = map(int, input().split())
azi = []
minn = n+l-1
for i in range(1, n+1):
    azi.append(i + l - 1)
    if (abs(minn) >= abs(i + l - 1)):
        minn = i + l - 1
print(sum(azi)-minn)
#arr = np.array(azi)
#ab = np.abs(arr)

#print(sum(azi) - azi[np.where(ab == ab.min()).tolist()[0]])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++) 
#define FOR(i,ini,n) for(int i=(ini);i<(n);i++)
#define SZ(x) (int)x.size()

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a,b;
	while(cin >> a >> b){
		REP(i,SZ(a)){
			cout << a[i];
			if(i != SZ(b)) cout << b[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    readInputLine()
    val Ls = readInputLine().split(" ").map{it.toInt()}.toList().sortedDescending()
    
    if (Ls.first() < Ls.drop(1).sum()) {
        println("Yes")
    } else {
        println("No")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


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

int N;
int A[210];

int main() {
  cin >> N;
  for (int i=0; i< N; ++i) cin >> A[i];
  int res = 0;
  
  while (true) {
    bool exist_odd = false;
    for (int i=0; i<N; ++i) {
      if (A[i] % 2 != 0) exist_odd = true;
    }
    
    if (exist_odd) break;
    
    for (int i = 0; i < N; ++i){
		A[i] /= 2;
    }
    ++res;
  }
    
  cout << res << endl;
}

Measured memory_bytes: 256
from sys import stdin
import math
import itertools

n = int(stdin.readline().rstrip())
p = [int(x) for x in stdin.readline().rstrip().split()]
q = [int(x) for x in stdin.readline().rstrip().split()]

nn = []
for i in range(n):
    nn.append(i + 1)

l = itertools.permutations(nn, n)

pp = 0
qq = 0
for i in range(n):
    pp += p[i] * (10 ** (n - i - 1))
    qq += q[i] * (10 ** (n - i - 1))

a = 1
b = 1
ar = 0
br = 0
for v in l:
    vv = 0
    for i in range(n):
        vv += v[i] * (10 ** (n - i - 1))
    if pp == vv:
        ar = a
    else:
        a += 1
    if qq == vv:
        br = b
    else:
        b += 1
    
print(abs(ar - br))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[100001];
	a[1]=1;
	for(int i=2;i<=9;i++)
		a[i]=a[i-1]+1;
	for(int i=10;i<=99;i++)
		a[i]=a[i-1];
	for(int i=100;i<=999;i++)
		a[i]=a[i-1]+1;
	for(int i=1000;i<=9999;i++)
		a[i]=a[i-1];
	for(int i=10000;i<=99999;i++)
		a[i]=a[i-1]+1;

	a[100000]=a[99999];

	cout<<a[n]<<endl;


	return 0;
}

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

int main(){
  char c_1[3],c_2[3],c_3[3];
  cin>>c_1;
  cin>>c_2;
  cin>>c_3;
  cout<<c_1[0]<<c_2[1]<<c_3[2]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r, c, k; cin >> r >> c >> k;
  vector<vector<ll>> A(r, vector<ll>(c));
  rep(i, k) {
    int r, c; ll v;
    cin >> r >> c >> v;
    r--; c--;
    A[r][c] = v;
  }
  vector<vector<vector<ll>>> dp(4, vector<vector<ll>>(r+1, vector<ll>(c+1)));
  rep(i, r) {
    rep(j, c) {
      rep(k, 4) {
        chmax(dp[k][i][j+1], dp[k][i][j]);
        if(k < 3) chmax(dp[k+1][i][j+1], dp[k][i][j]+A[i][j]);
      }
    }
    rep(j, c) {
      rep(k, 4) {
        chmax(dp[0][i+1][j+1], dp[k][i][j+1]);
        if(i < r-1) chmax(dp[1][i+1][j+1], dp[k][i][j+1]+A[i+1][j]);
      }
    }
  }
  ll ans = 0;
  rep(k, 4) chmax(ans, dp[k][r][c]);
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 425696