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

int main()
{
    multimap<string, int> m;

    int n;
    cin >> n;

    while (n--)
    {
        int x;
        int y;
        string z, a;

        cin >> x;
        if (x == 0)
        {
            cin >> z >> y;
            m.insert(make_pair(z, y));
            //m[z] = y;
        }
        if (x == 1)
        {
            cin >> z;
            //cout << m[z] << endl;
            for (auto it = m.lower_bound(z); it != m.upper_bound(z); it++)
            {
                if (it->second)
                    cout << it->second << endl;
            }
        }
        if (x == 2)
        {
            cin >> z;
            m.erase(z);
        }
        if (x == 3)
        {
            cin >> z >> a;
            for (auto it = m.lower_bound(z); it != m.upper_bound(a); it++)
            {
                if (it->second)
                    cout << it->first << ' ' << it->second << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 24808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt(),M=sc.nextInt();
		int[][] q = new int[M][2];
		for (int i=0;i<M;i++) {
			q[i][0]=sc.nextInt();
			q[i][1]=sc.nextInt();
		}
		boolean flag = true;
		for (int i=0;i<M;i++) {
			if (N!=1&&q[i][0]==1&&q[i][1]==0) {
				flag = false;
			}
		}
		
		for (int i=0;i<M-1;i++) {
			for (int j=i+1;j<M;j++) {
				if(q[i][0]==q[j][0] && q[i][1]!=q[j][1]) {
					flag = false;
				}
				if(q[i][0]==q[j][0] && q[i][1]==q[j][1]) {
					q[j][0]=0;
				}
			}
		}
		int ans= 0;
		if(flag) {
			for (int i=0;i<M;i++) {
				if (q[i][0]!=0) {
					ans+= q[i][1]*(int)Math.pow(10, N-q[i][0]);
				}
			}
			if(N==3&& ans<100) {
				ans+=100;
			}else if(N==2&& ans<10){
				ans+=10;
			}
			System.out.println(ans);
		}else {
			System.out.println(-1);
		}
		
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int mid,fin,re;
        cin>>mid>>fin>>re;
        int sum=mid+fin;
        if(mid==-1 && fin==-1 && re==-1) break;
        else if(mid==-1 || fin==-1) cout<<"F"<<endl;
        else if(sum>=80) cout<<"A"<<endl;
        else if(sum<80 &&sum>=65) cout<<"B"<<endl;
        else if(sum<65 &&sum>=50) cout<<"C"<<endl;
        else if(sum<50 &&sum>=30){
            if(re>=50) cout<<"C"<<endl;
            else cout<<"D"<<endl;
        }
        else if(sum<30) cout<<"F"<<endl;
    }
}


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

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> D(N+1);

	D[0] = 0;

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

	int ans = 0;
	for (int i = 0; i < N+1; i++) {
		if (D[i] > X) {
			break;
		}
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
h=[int(i) for i in input().split()]
h.append(10**18)
ans=0
tmp=0
for i in range(n):
    if h[i]>=h[i+1]:
        tmp+=1
    else:
        tmp=0
    ans=max(ans,tmp)
ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 14252
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int w[305];

int dp[305][305];
int ans[305];
int main(void){
	for(;;){
		int n;
		scanf("%d",&n);
		if(n==0)break;
		rep(i,n){
			scanf("%d",&w[i]);
		}
		memset(dp,0,sizeof(dp));
		rep(j,n-1){
			if(abs(w[j]-w[j+1])<=1){
				dp[j][j+1]=1;
			}
		}
		reg(k,3,n)reg(i,0,n-k-1){
			int a = i,b=i+k;
			reg(t,a+1,b-1){
				dp[a][b] |= (dp[a][t] & dp[t+1][b]);
			}
			if(a+1<=b-1 && dp[a+1][b-1] && abs(w[a]-w[b])<=1){
				dp[a][b] = 1;
			}
		}
		/*
		rep(i,n){
			reg(j,i+1,n-1){
				printf("%d %d : %d\n",i,j,dp[i][j]);
			}
			//puts("");
		}
		*/
		memset(ans,0,sizeof(ans));
		ans[0]=0;
		reg(i,1,n){
			ans[i] = ans[i-1]+1;
			rep(j,i){
				if(dp[j][i-1])ans[i]=min(ans[i],ans[j]);
			}
		}
		printf("%d\n",n-ans[n]);
	}
	return 0;
}







Measured memory_bytes: 3572
N = int(input())
A = list(map(int, input().split()))

p = 1000
n = 0
for i in range(N-1):
    if A[i+1] > A[i]:
        n += p//A[i]
        p = p % A[i]

    if A[i+1] < A[i]:
        p += n*A[i]
        n = 0

p += n*A[-1]
print(p)


Measured memory_bytes: 9192
#include<stdio.h>

int main(void){

	int a, b, c, d, n, t;

	while (scanf("%d", &n) != EOF){
		t = 0;
		for (d = 0; d <= 9; d++){
			for (c = 0; c <= 9; c++){
				for (b = 0; b <= 9; b++){
					for (a = 0; a <= 9; a++){
						if (a + b + c + d == n){
							t++;
						}

					}
				}
			}
		}
		printf("%d\n", t);
	}
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;



int main()
{
    int n, cnt = 1;
    cin >> n;
    vector <int> a(n, 0);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == cnt) cnt++;
    }
    if ( cnt == 1) cout << -1 << endl;
    else cout << n - cnt + 1<< endl;

    return 0;
}



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

using namespace std;

struct UnionFind{
	int par[200200];
	void init(int N){
		for(int i = 0; i < N; ++i) par[i] = i;
	}
	int find(int x){
		if(x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y){
		x = find(x);
		y = find(y);
		par[x] = y;
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
};

UnionFind uf;

int main(){
	int N;
	scanf("%d", &N);
	int M;
	scanf("%d", &M);
	uf.init(N + M);
	for(int i = 0; i < N; ++i){
		int k;
		scanf("%d", &k);
		for(int j = 0; j < k; ++j){
			int l;
			scanf("%d", &l);
			uf.unite(i, l + N - 1);
		}
	}
	for(int i = 0; i < N; ++i){
		if(!uf.same(0, i)){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,M; cin>>N>>M;
	map<int,int> wa;
	map<int,bool> done;
	int pen=0, ct=0;
	for (int i=0; i<M; i++) {
		int p; string S; cin>>p>>S;
		if(done.count(p))
			continue;
		if(S=="WA") wa[p]++;
		else done[p]=true, pen+=wa[p], ct++;
	}
	cout<<ct<<" "<<pen<<endl;
	return 0;
}

Measured memory_bytes: 9600
#include<stdio.h>
int main()
{
    int a[6],i, min=10,sum=0;
    for(i=1;i<=5;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]%10<min && a[i]%10>0)
        {
            min=a[i]%10;
        }
        sum=(a[i]%10==0?sum+a[i]:sum+a[i]+(10-(a[i]%10)));
    }
    printf("%d\n",sum-10+min);
    return 0;
}


Measured memory_bytes: 128
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: h,w
    integer(int32):: i,j
    character(1),allocatable:: s(:,:)
    logical,allocatable:: bl(:,:), pnt(:,:), see(:,:)

    read*, h,w
    allocate(s(w,h),bl(w,h), pnt(w,h), see(w,h))
    bl(:,:) = .false.
    pnt(:,:) = .false.
    see(:,:) = .false.
    block
        character(w):: inpt_s
        do i = 1, h
            read*, inpt_s
            do j = 1, w
                s(j,i) = inpt_s(j:j)
                if (s(j,i) == '#') bl(j,i) = .true.
            end do
        end do
    end block
    
    block
        integer(int32):: nx,ny
        do
            call next(nx,ny)
            if (nx == 0 .and. ny == 0) exit
            call dfs(nx,ny)
        end do
    end block

    ! do i=1,h
    !     print*, bl(:,i)
    ! end do
    ! do i=1,h
    !     print*, pnt(:,i)
    ! end do
    
    do i = 1, h
        do j = 1, w
            if (.not.(bl(j,i) .eqv. pnt(j,i))) then
                print*, 'No'
                stop
            end if
        end do
    end do
    print*, 'Yes'
contains
    function naka(x,y) result(ret)
        integer(int32),intent(in):: x,y
        logical:: ret

        ret = 1<=x .and. x<=w .and. 1<=y .and. y<=h
    end function


    recursive subroutine dfs(x,y)
        integer(int32),intent(in):: x,y
        integer(int32):: dx,dy

        see(x,y) = .true.

        do dx = -1, 1
            do dy = -1, 1
                if (abs(dx) == abs(dy)) cycle
                if (.not. naka(x+dx,y+dy)) cycle
                if (bl(x+dx,y+dy) .and. .not. pnt(x+dx,y+dy)) then
                    pnt(x,y) = .true.
                    pnt(x+dx,y+dy) = .true.
                    if (.not. see(x+dx,y+dy)) call dfs(x+dx,y+dy)
                end if
            end do
        end do
        
    
    end subroutine
    subroutine next(x,y)
        integer(int32),intent(out):: x,y
        integer(int32):: i,j
        x=0
        y=0
        do i=1,h
            do j = 1, w
                if (bl(j,i) .and. (.not. see(j,i))) then
                    x=j
                    y=i
                    return
                end if
            end do
        end do
    end subroutine
end program name

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int s,w;
  	cin>>s>>w;
  	if(w>=s)
    {
      cout<<"unsafe";
    }
  	else
    {
      cout<<"safe";
    }
	return 0;
}

Measured memory_bytes: 3640
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main 
{
	static class C implements Comparator<Req>
	{
		@Override
		public int compare(Req o1, Req o2) 
		{
			return o1.r - o2.r;
		}
	}
	
	static class Req
	{
		boolean done = false;
		int l;
		int r;
		
		public Req(int l0, int r0)
		{
			l = l0;
			r = r0;
		}
	}
	

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();


		ArrayList<Req> list = new ArrayList<Req>();
		
		for(int i = 0; i < m; i++)
		{
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			list.add(new Req(a,b));
		}
		
		C c = new C();
		list.sort(c);
		
		int dn = 0;
		
		int destroyedl = -99;
		for(int i = 0; i < m; i++)
		{
			Req cur = list.get(i);
			
//			System.out.println("Do " + cur.l + " " + cur.r + ", desl " + destroyedl);
			if(cur.l >= destroyedl)
			{
//				System.out.println("Right before " + cur.r);
				destroyedl = cur.r;
				dn++;
			}
			
		}
		
		System.out.println(dn);

	}






}


Measured memory_bytes: 87260
#include <iostream>
using namespace std;
void getcard(int *card, int n);
void shuffle(int *card, int p, int c);
int main(){
  int n,r;
  while (cin>>n>>r,n|r!=0){
    int card[n+1];
    getcard(card,n);
    for (int i=0;i<r;i++){
      int p,c;
      cin>>p>>c;
      shuffle(card,p,c);
    }
    cout<<card[1]<<endl;
  }
}
void getcard(int *card, int n){
  for (int i=1;i<=n;i++){
    card[i]=n+1-i;
  }
}
void shuffle(int *card, int p, int c){
  int temp[p-1];
  for (int i=0;i<p-1;i++){
    temp[i]=card[i+1];
  }
  for (int i=p;i<p+c;i++){
    card[i-p+1]=card[i];
  }
  for (int i=c+1;i<=c+p-1;i++){
    card[i]=temp[i-c-1];
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi >
const int N=200010;

int main()
{
	ll a,b,c,x,y,r;
	cin>>a>>b>>c>>x>>y;
	r=2ll*max(x,y)*c;
	for(ll i=0;i<=max(x,y);i++)
	{
		r=min(r,2ll*i*c+max(0ll,x-i)*a+max(0ll,y-i)*b);
	}
	cout<<r;
	return 0;
}

Measured memory_bytes: 256
//
// Created on 2020/04/06.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    ll ans = 0;
    int n,k;
    ll r,s,p;
    string t;
    cin>>n>>k;
    cin>>s>>p>>r;
    map<char,ll>point;
    point['p'] = p;
    point['r'] = r;
    point['s'] = s;
    cin>>t;

    for (int i = 0; i < k; ++i) {
        int j;
        for (j = 0; i+j+k < n && i+j<n; j += k) {
            int cnt = 1;

            while(t[i+j] == t[i+j+k]){
                j += k;
                cnt ++;
                if(i+j+k >= n){
                    break;
                }
            }
            ans += ((cnt+1)/2)*point[t[i+j]];
        }
        if(i+j <n){
            if(i+j-k >= 0){
                if(t[i+j-k]!=t[i+j]){
                    ans +=point[t[i+j]];
                }
            }else{
                ans +=point[t[i+j]];
            }
        }


    }

    cout<<ans<<endl;
}


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

int main()
{
    int N; cin >> N;
    vector<ll> A(N); for (auto& a : A) cin >> a;

    ll ans = 0;
    if (find(A.begin(), A.end(), 0) == A.end()) {
        ans = 1;
        for (const auto& a : A) {
            if (a > (ll)1e18 / ans) {
                ans = -1;
                break;
            }
            ans *= a;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	std::set<int> a;
	rep(i,3){
		int n;
		std::cin >> n;
		a.insert(n);
	}
	std::cout << a.size() << std::endl;
	
}

Measured memory_bytes: 256
#include <map>
#include <queue>
#include <iostream>
typedef unsigned long long ull;
using namespace std;
struct state { ull x; int zero, pre, dist, remain; };
bool operator<(const state& s1, const state& s2) { return s1.dist + s1.remain > s2.dist + s2.remain; }
int a, dist[16][16], goals[16], goals2[16]; ull s, goal = 1147797409030816545;
int dir[4] = { 1, 0, -1, 0 };
int solve() {
	if (s == goal) return 0;
	int zz = -1;
	for (int i = 0; i < 16; i++) {
		if (!((s >> (i * 4)) & 15)) zz = i;
	}
	int rr = 0;
	for (int i = 0; i < 16; i++) {
		int ww = ((s >> (i * 4)) & 15);
		if (!ww) continue;
		for (int j = 0; j < 16; j++) {
			if (ww == goals[j]) {
				rr += dist[i][j];
			}
		}
	}
	priority_queue<state> que;
	que.push(state{ s, zz, -99, 0, rr });
	while (!que.empty()) {
		state a = que.top(); que.pop();
		ull v = a.x; int z = a.zero;
		for (int i = 0; i < 4; i++) {
			if (abs(i - a.pre) == 2) continue;
			int dx = dir[i], dy = dir[i ^ 1];
			int e = z + dy * 4 + dx;
			int g = ((v >> (e << 2)) & 15);
			if (0 <= e && e < 16 && (e & 3) - (z & 3) == dx) {
				ull w = v;
				w -= ((1ULL * g) << (e << 2));
				w += ((1ULL * g) << (z << 2));
				int xx = a.remain;
				xx -= dist[e][goals2[g]];
				xx += dist[z][goals2[g]];
				if (w == goal) return a.dist + 1;
				que.push(state{ w, e, i, a.dist + 1, xx });
			}
		}
	}
	return -1;
}
int main() {
	for (int i = 0; i < 16; i++) {
		for (int j = 0; j < 16; j++) {
			dist[i][j] = abs((i >> 2) - (j >> 2)) + abs((i & 3) - (j & 3));
		}
	}
	for (int i = 0; i < 15; i++) goals[i] = i + 1; goals[15] = 0;
	for (int i = 0; i < 16; i++) goals2[goals[i]] = i;
	for (int i = 0; i < 16; i++) {
		cin >> a;
		s += ((1ULL * a) << (i * 4));
	}
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 52132
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n;
  vector<int> a;
  cin >> n;
  int tmp;
  for(int i = 0; i < n; i++){
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  int ret = 0;
  for(int i = 1; i < n; i++){
    ret += a[i] - a[i-1];
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3604
N = int(input())
h = list(map(int,input().split()))
count = 0

while max(h) > 0:
    hmax = max(h)
    hmaxi = h.index(hmax)
    h[hmaxi] -= 1
    count += 1
    for i in range(N-hmaxi-1):
        if hmaxi == N-1:
            break
        elif h[hmaxi+i+1] == hmax:
            h[hmaxi+i+1] -= 1
        else:
            break

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define long long long 
#define pll pair<long, long>
#define x first
#define y second
using namespace std;

long n;
vector<long> ret;

long s(long v) {
    int sum = 0;
    while(v) sum += v % 10, v /= 10; 
    return sum;
}

int main() {
    long a = 1e16, b = 1;
    pll z(a, b);
    for(int len = 12; ~len; --len) {
        for(int i = 999; i >= 100; --i) {
            char ret[20];
            sprintf(ret, "%d", i);
            for(int j = 3; j < len + 3; ++j) ret[j] = '9';
            ret[len+3] = 0;
            long num; sscanf(ret, "%lld", &num);
            pll now(num, s(num));
            if(z.x * now.y >= now.x * z.y)
                swap(z, now), ::ret.emplace_back(num);
        }
    }
    for(long i = 99; i; --i) {
        pll now(i, s(i)); 
        if(z.x * now.y >= now.x * z.y)
            swap(z, now), ret.emplace_back(i); 
    }
    reverse(ret.begin(), ret.end());
    int n; scanf("%d", &n);
    for(int i = 0; i < n; ++i) printf("%lld\n", ret[i]); 
}

Measured memory_bytes: 256
# coding: utf-8


def main():
    n = int(input())
    numbers = list(map(int, input().split(' ')))    

    max_number = max(numbers)
    min_number = min(numbers)
    min_sums = []
    for p in range(min_number, max_number + 1):
        sum_ = 0
        for x in numbers:
            sum_ += (x - p) ** 2
        min_sums.append(sum_)

    print(min(min_sums))

    return 0


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


bool cmp(pair<int,pii> a, pair<int,pii> b){
	if(a.second.first == b.second.first) return a.second.second < b.second.second;
	return a.second.first < b.second.first;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<pair<int,pii>> a(m);
	rep(i,m){
		cin >> a.at(i).second.first >> a.at(i).second.second;
		a.at(i).first = i;
	}
	sort(a.begin(),a.end(),cmp);
	vector<pii> ans(m);
	int k = 1;
	rep(i,m){
		if(i == 0){
			ans.at(a.at(i).first).first = a.at(i).second.first;
			ans.at(a.at(i).first).second = k;
			k++;
		}
		else if(a.at(i).second.first == a.at(i - 1).second.first){
			ans.at(a.at(i).first).first = a.at(i).second.first;
			ans.at(a.at(i).first).second = k;
			k++;
		}
		else{
			k = 1;
			ans.at(a.at(i).first).first = a.at(i).second.first;
			ans.at(a.at(i).first).second = k;
			k++;
		}
	}
	rep(i,m){
		cout << setfill('0') << right << setw(6) << ans.at(i).first;
		cout << setfill('0') << right << setw(6) << ans.at(i).second << endl;
	}
}


Measured memory_bytes: 3456
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

nk = input().split(" ");
n = int(nk[0]);
k = int(nk[1]);
a = input().split(" ");

waru = 10 ** 9 + 7;

for i in range(n) :
	a[i] = int(a[i]);

kaisu = [0] * n;
usiro = [0] * n;

for i in range(n) :
	for j in range(n) :
		if a[i] > a[j] :
			kaisu[i] += 1;
			if i < j :
				usiro[i] += 1;

ans = 0;
for i in range(n) :
	ans += ((((((k-1)%waru) * (k%waru) )%waru) *mod_inv(2,waru)) * (kaisu[i]%waru) + ((k%waru)*(usiro[i]%waru))%waru)%waru;
		
	
print(int(ans%waru));

Measured memory_bytes: 3188
N = int(input())
H = list(map(int,input().split()))

dp = [0]*N
dp[1] = abs(H[0]-H[1])
for i in range(2,N):
    dp[i] = min(abs(H[i]-H[i-1]) + dp[i-1], abs(H[i]-H[i-2]) + dp[i-2])

print(dp[-1])

Measured memory_bytes: 13980
#include<stdio.h>
 
int n,q,x[2001],m;
 
int rec(int i,int sum){
  if(sum == m)return 1;
  if(i >= n)return 0;
  return rec(i + 1,sum) || rec(i + 1,sum + x[i]);
}
 
int main(void){
 
  int i,j;
  
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++)scanf("%d",&x[i]);
  scanf("%d",&q);
  for(i = 0 ; i < q ; i++)
    {
      scanf("%d",&m);
      if(rec(0,0))printf("yes\n");
      else printf("no\n");
    }
  return 0;
}

Measured memory_bytes: 584
#include <iostream>


int main() {
  int m, f, r;
  int mf;
  char grade;

  while (true) {
    std::cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) break;
    mf = m + f;
    if (m == -1 || f == -1) {
      grade = 'F';
    } else if (mf >= 80) {
      grade = 'A';
    } else if (mf >= 65) {
      grade = 'B';
    } else if (mf >= 50) {
      grade = 'C';
    } else if (mf >= 30) {
      if (r >= 50) {
        grade = 'C';
      } else {
        grade = 'D';
      }
    } else {
      grade = 'F';
    }
    std::cout << grade << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3120
n = int(input())
g = [[] for i in range(n)]
for i in range(n):
    *v, = map(int, input().split())
    for j in range(n):
        if v[j] < 0:
            v[j] = 10000
    g[i] = v

ans = 0
t = [0]
v = [i for i in range(1, n)]
while len(t) < n:
    u = [2000, 0, 0]
    for tv in t:
        for vv in v:
            if g[tv][vv] < u[0]:
                u = [g[tv][vv], tv, vv]
    ans += u[0]
    t.append(u[2])
    v.remove(u[2])
print(ans)



Measured memory_bytes: 5716
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

		int count = 0;
		for(int i = 0; i < N; i++){
			final int number = sc.nextInt();
			
			final int limit = (int)(Math.sqrt(number));
			
			boolean not_prime = false;
			for(int j = 2; j <= limit; j++){
				if(number % j == 0){
					not_prime = true;
					break;
				}
			}
			
			count += not_prime ? 0 : 1;
		}
		
		System.out.println(count);
		
	}
}

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

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	int counta = 0,countb = 0,countc = 0;
	int p;
	for(int i = 0; i < n; i++){
		cin >> p;
		if(p <= a)counta++;
		if(p >= a + 1 && p <= b)countb++;
		if(p >= b + 1)countc++;
	}
	cout << min(min(counta,countb),countc) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
cin >> s;
if(s.at(5) == '0' ){
if(s.at(6) == '1' || s.at(6) == '2' || s.at(6) == '3' || s.at(6) == '4'){
cout << "Heisei" << endl;
}
else cout << "TBD" << endl;
}
else cout << "TBD" << endl;
}

Measured memory_bytes: 256
S =input()
T = input()
a = len(S)
x = len(T)
ans = 0
sum_l = []
if a == x:
  for i in range(a):
    if S[i] != T[i]:
      ans += 1
  print(ans)
else:
  for i in range(a-x+1):
    for j in range(x):
      if S[i+j] != T[j]:
        ans += 1
    sum_l.append(ans)
    ans = 0
  print(min(sum_l))


Measured memory_bytes: 8964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N,A,B;
    cin >> N >> A >> B;
    vi P(N);
    in(N,P);
    
    vi a(3,0);
    
    rep(i,N){
        if(P[i] <= A) a[0]++;
        else if(P[i] <= B) a[1]++;
        else a[2]++;
    }
    sort(all(a));
    cout << a[0] << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static final String STABLE="Stable" +
			"";
	public static final String UNSTABLE="Not stable";
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String[] c = new String[n];
		for (int i = 0; i < n; i++) {
			c[i] = in.next();
		}
		bubbleSort(c.clone(),c);
		selectionSort(c.clone(),c);
		in.close();
	}

	private static boolean isStable( String[] in, String[] out) {
	   String s1="";
	   String s2="";
	   int m1=0;
	   int m2=0;
	   for (int i = 0; i<in.length;i++){
	     for (int j = i+1; j<in.length;j++){
	    	 if(Integer.valueOf(in[i].substring(1)).equals(Integer.valueOf(in[j].substring(1)))) {
	    		 s1=in[i];
	    		 s2=in[j];
	    		 for (int a = 0; a<out.length;a++){
	    			 if(out[a].equals(s1)) {
	    				 m1=a;

	    			 }
	    			 if(out[a].equals(s2)) {
	    				 m2=a;

	    			 }
	    		 }
	    		 if(m1>m2) {
	    			 return false;
	    		 }
	    	 }
	     }
	   }
	   return true;
	}

	private static void selectionSort(String[] A,String[] moto) {
		int minj;
		String wk;
		for (int i = 0; i < A.length; i++) {
			minj = i;
			for (int j = i; j < A.length; j++) {
				if (Integer.valueOf(A[j].substring(1)) < Integer.valueOf(A[minj].substring(1))) {

					minj = j;

				}

			}
			if(minj!=i) {
				wk=A[minj];
				A[minj]=A[i];
				A[i]=wk;

			}
		}

		System.out.println(String.join(" ", A));

		System.out.println(isStable(A,moto)? STABLE:UNSTABLE);
	}

	private static void bubbleSort(String[] A,String[] moto) {
		int flg = 1;
		String wk;
		while (flg == 1) {
			flg = 0;
			for (int i = A.length - 1; i > 0; i--) {
				wk = A[i - 1];

				if (Integer.valueOf(A[i].substring(1))  < Integer.valueOf(A[i - 1].substring(1)) ) {
					A[i - 1] = A[i];
					A[i] = wk;

					flg = 1;
				}
			}

		}

		System.out.println(String.join(" ", A));

		System.out.println(isStable(A,moto)? STABLE:UNSTABLE);
	}

}



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

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int H = l[0], N = l[1];
        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

        foreach (var a in A)
            H -= a;

        if (H <= 0)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }
}


Measured memory_bytes: 20064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
double a[200020];
int main(void)
{
    int n,m;
    memset(a,0,sizeof(a));
    double x,mx=0;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%lf",&x);
        a[i]=a[i-1]+(1/x)*(x+1)*x/2;
    }
    for(int i=m;i<=n;i++)
    {
        mx=max(mx,a[i]-a[i-m]);
    }
    printf("%.13f\n",mx);
    return 0;
}



Measured memory_bytes: 1792
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int k = scanner.nextInt();
        final List<Long> list = IntStream.range(0, k)
                .mapToObj(i -> scanner.nextLong())
                .collect(Collectors.toList());

        Collections.reverse(list);
        if (list.get(0) != 2) {
            System.out.println(-1);
            return;
        }

        long min = 2;
        long max = 2;
        for (final long value : list) {
            min = (min + value - 1) / value * value;
            max = max / value * value + value - 1;
        }

        if (min > max) {
            System.out.println(-1);
        } else {
            System.out.println(min + " " + max);
        }
    }
}


Measured memory_bytes: 63096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int mod=998244353;
#define mp make_pair
#define pb push_back
int main(){ 
	double t,n,b,c,d;
	cin>>t;
	double a=3.141592653;
	cout<<2*a*t<<endl;
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned long long u64;
const int N=50;
int n, k, s, t, a[N], cnt;
u64 set[2*N], com[N+1][N+1], ans;
void dfs(int x, int nmust, int nmay, u64 must, u64 may) {
	if(nmust>k) return;
	while(x<cnt && (set[x]&must)) ++x;
	if(x==cnt) {
		int tmp=std::min(k, nmay)-nmust;
		ans+=com[nmay-nmust][tmp];
		return;
	}
	u64 cur=set[x]&may;
	if(cur==0) return;
	for(; cur; cur&=cur-1) {
		int id=__builtin_ctzll(cur);
		dfs(x+1, nmust+1, nmay, must|1llu<<id, may);
		--nmay;
		may^=1llu<<id;
	}
}
void gg() {
	puts("0");
	exit(0);
}
int main() {
	std::random_device dev;
	std::mt19937 rng(dev());
	scanf("%d%d%d%d", &n, &k, &s, &t);
	for(int i=0; i<n; ++i) {
		scanf("%d", a+i);
		if((a[i]&s)!=s || (a[i]|t)!=t) {
			--i;
			--n;
		}
	}
	if(n==0) gg();
	for(int i=0; i<=n; ++i) {
		com[i][0]=com[i][i]=1;
		for(int j=1; j<i; ++j)
			com[i][j]=com[i-1][j-1]+com[i-1][j];
	}
	for(int i=0; i<=n; ++i) {
		for(int j=1; j<=i; ++j)
			com[i][j]+=com[i][j-1];
	}
	for(int i=0; i<18; ++i) {
		int ss=s>>i&1, tt=t>>i&1;
		if(ss!=tt) {
			u64 cur=0;
			for(int j=0; j<n; ++j) {
				if(~a[j]>>i&1) cur|=1llu<<j;
			}
			set[cnt++]=cur;
			if(!cur) gg();
			cur=0;
			for(int j=0; j<n; ++j) {
				if(a[j]>>i&1) cur|=1llu<<j;
			}
			set[cnt++]=cur;
			if(!cur) gg();
		}
	}
	dfs(0, 0, n, 0, (1llu<<n)-1);
	printf("%llu\n", ans);
	return 0;
}



Measured memory_bytes: 3788
#include <iostream>

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

using namespace std;

int main()
{
	int n,a;
	cin >> n;
	bool colors[8];
	int above_red = 0;
	
	REP(i,8){
		colors[i] = false;
	}
	
	REP(i,n){
		cin >> a;
		if (a>=3200){
			above_red += 1;
		}else{
			colors[a/400] = true;
		}
	}
	
	int min_color_variety=0;
	int max_color_variety=0;
	
	REP(i,8){
		if (colors[i]){
			min_color_variety += 1;
		}
	}
	
	if (above_red>0){
		max_color_variety = min_color_variety+above_red;
	}else{
		max_color_variety = min_color_variety;
	}
	
	if (min_color_variety==0){
		min_color_variety = 1;
	}

	
	cout << min_color_variety << " " << max_color_variety << "\n";
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<int> A(N);
    Graph x(N), y(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        for(int j = 0; j < A[i]; j++) {
            int X, Y; cin >> X >> Y;
            X--;
            x[i].push_back(X);
            y[i].push_back(Y);
        }
    }
    int ans = 0;
    for(int b = 0; b < (1 << 15); b++) {
        if(b == (1 << N)) break;
        bitset<15> bit(b);
        bool judge = true;
        for(int u = 0; u < N; u++) {
            if(!bit.test(u)) continue;
            for(int v = 0; v < A[u]; v++) if((bit.test(x[u][v]) ^ y[u][v])) judge = false;
        }
        if(judge) ans = max(ans, (int)bit.count());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	int l,flag;
	char a[10];
	while(~scanf("%s",a+1)){
		flag=0;
		l=strlen(a+1);
		for(int i=1;i<=l-1;i++){
			if(a[i]=='A'&&a[i+1]=='C') flag=1;
		}
		if(flag==1) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 256
N,M=map(int, input().split())
A=list(map(int, input().split()))
B = {}
C = {}
for i in range(M):
    B[i],C[i]=map(int, input().split())

high_scores = sorted(C.items(), key=lambda x:x[1], reverse=True)

sum_b = 0
for score in high_scores:
    sum_b += B[score[0]]
    if N < sum_b:
        A += [score[1]] *  (B[score[0]]-sum_b+N)
        break
    else:
        A += [score[1]] *  B[score[0]]

A.sort(reverse=True)
A = A[:N]

print(sum(A))

Measured memory_bytes: 38692
import java.io.*
import java.util.*

fun solve(N: Long, K: Long, A: LongArray){
    val a = A.groupBy{ it }.map{ it.value.size }.sorted()
    println(a.slice(0 until (a.size-K).toInt()).sum())
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val K = sc.next().toLong()
    val A = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        A[i] = sc.next().toLong()
    }
    solve(N, K, A)
}



Measured memory_bytes: 86304
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(); //整数の数
    int[] x = new int[n];
    for (int i=0; i<n; i++) { //整数を読み込む
        x[i] = sc.nextInt();
    }
    int max = Integer.MIN_VALUE; //最小値で初期化
    int min = x[0]; //一番最初に入力した整数で初期化
    for (int i=1; i<n; i++) {
        max = Math.max(max, x[i]- min);
        min = Math.min(min, x[i]);
    }
    System.out.println(max); //最大値を出力
    }
}


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

#define nax 100009
#define FOR(i,n,m) for(int i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back

typedef vector<int> vi;

int main(){
	int n; cin>>n;
	int a[nax][3],dp[nax][3];

	REP(i,n){
		REP(j,3) cin>>a[i][j];
	}

	REP(i,3) dp[0][i] = a[0][i];

	FOR(i,1,n){
		REP(j,3){
			dp[i][j] = max(dp[i-1][(j+1)%3]+a[i][j],
							dp[i-1][(j+2)%3]+a[i][j]);
		}
	}

	int m = 0;
	REP(i,3) m = max(dp[n-1][i],m);

	cout<<m;

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define loop(j, n) for(int i=j; i<=n; ++i)
using namespace std;

void printArray(int*, int, int);
void printCharArray(char*, int, int);
void ruffleSort(int*, int);

int t; 

int main(int argc, char const *argv[])
{   
    IOS;
    int n;
    cin >> n;
    int a[n];
    loop(0, n-1) cin >> a[i];
    ruffleSort(a, n);
    int ans=0;
    for(int i=0; i<n; ++i) {
        for(int j=i+1; j<n; ++j) {
            for(int k=j+1; k<n; ++k) {
                if(a[i]!=a[j] && a[j]!=a[k]) {
                    if(a[i]+a[j]>a[k]) ++ans;
                }
            }
        }
    }
    cout << ans;
    return 0;
}

void printArray(int *a, int start, int end) {
    for(int i=start; i<=end; ++i) {
        cout << *(a+i) << ' ';
    }
}

void printCharArray(char *a, int start, int end) {
    for(int i=start; i<=end; ++i) {
        cout << *(a+i) << ' ';
    }
}

void ruffleSort(int *a, int n) {
    unsigned seed=0;
    shuffle(a, a+n, default_random_engine(seed));
    sort(a, a+n);
}

Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;
using Int = long long;

constexpr double EPS = 1e-10;
constexpr long long MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    string S; cin >> S;
    if (S.length() % 2) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < S.length(); i++) {
        if (i % 2) {
            if (S[i] != 'i') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S[i] != 'h') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using Graph=vector<vector<int>>;

vector<int> cnt;
void dfs(Graph& G, int v, int p){
    for(auto nv:G[v]){
        if(nv==p) continue;
        cnt[nv]+=cnt[v];
        dfs(G,nv,v);
    }
}

int main(){
    int n,q;
    cin>>n>>q;
    Graph G(n);
    cnt.assign(n,0);
    for(int i=0;i<n-1;++i){
        int a,b;
        cin>>a>>b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int i=0;i<q;++i){
        int p,x;
        cin>>p>>x;
        --p;
        cnt[p]+=x;
    }
    dfs(G,0,-1);
    for(int i=0;i<n;++i) cout<<cnt[i]<<" ";
}

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a * n, b) << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
ps = list(map(int, input().split()))
cs = list(map(int, input().split()))

to_do = []
res = -float('inf')
for i in range(1,n+1):
    tmp_idx = i
    tmp_val = 0
    tmp_dic = {i:(0,0,i)}
    for j in range(1,min(n+1,k+1)):
        tmp_idx = ps[tmp_idx-1]
        tmp_val += cs[tmp_idx-1]
        res = max(res,tmp_val)
        if tmp_idx not in tmp_dic:
            tmp_dic[tmp_idx] = (j,tmp_val,tmp_idx)
        else:
            if tmp_val > tmp_dic[tmp_idx][1]:
                to_do.append([i,tmp_dic[tmp_idx][0],tmp_dic[tmp_idx][2],tmp_dic[tmp_idx][1],j-tmp_dic[tmp_idx][0],tmp_val-tmp_dic[tmp_idx][1]])
            break

for do in to_do:
    itr = (k - do[1]) // do[4]
    if itr > 0:
        itr -= 1
    remain = k - do[1] - do[4] * itr
    tmp_res = do[3] + itr * do[5]
    res = max(res,tmp_res)
    now = do[2]
    for i in range(remain):
        now = ps[now-1]
        tmp_res += cs[now-1]
        res = max(res, tmp_res)
print(res)

Measured memory_bytes: 221720
def sdiff(s1, s2):
  score = 0
  for i in range(0, len(s2)):
    if s1[i] != s2[i]: score += 1
  return score

S = input()
T = input()
Ans = len(T)

for i in range(0, len(S) - len(T) + 1):
  Ans = min(sdiff(S[i:], T), Ans)

print(Ans)

Measured memory_bytes: 8976
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<unordered_map>
#define int long long
const int inf=1145141919810893;
const int mod=1000000007;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
int N,M,K;
int ans[300000];
signed main(){
	int i,j;
	cin>>N>>M;
	int u=1;
	for(i=0;i<M;i++)
		u*=2;
	cout<<(100*(N-M)+1900*M)*u<<endl;
}

Measured memory_bytes: 764
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern
let (n, k) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n k -> (n, k)

let p = read_line () |> split_string |> List.map int_of_string |> Array.of_list
  |> Array.map (fun i -> float (i * (i + 1)) /. float (i * 2))

let rec loop i s m =
  if i = n then Printf.printf "%f\n" m
  else 
    let s = s +. p.(i) -. if i < k then 0. else p.(i - k) in
    loop (i + 1) s (max s m)

let () = loop 0 0. 0.

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

bool in_range(int p, int x, int y){
    if (x > y) swap(x, y);
    return x <= p && p <= y;
}

int main(){
    int n, K;
    cin >> n >> K;
    vector<ll> x(n), y(n);
    rep(i, n)
        cin >> x[i] >> y[i];
    ll ans = 4e18;
    rep(i, n)rep(k, n){
        for(int j = i; j < n; j++){
            for(int l = k; l < n; l++){
                int res = 0;
                rep(m, n){
                    if (in_range(x[m], x[i], x[j])&&
                    in_range(y[m], y[k], y[l]))
                        res++;
                }
                if (res >= K) 
                    ans = min(ans, abs((x[j] - x[i]) * (y[l] - y[k])));
            }
        }
    }
    cout << max(ans, 1ll) << endl;
}

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

using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a >= 13)
    cout << b << endl;
  else if (a >= 6)
    cout << b / 2 << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;
const int MAX=1e5+10;
//int final_ans=0;
vector<int>v[MAX];
int in_degree[MAX];
int dist[MAX];
bool visited[MAX];

void do_dfs(int start)
{
	visited[start]=true;
	//cout<<start<<' ';
	for(int i=0;i<v[start].size();i++)
	{
		dist[v[start][i]]=max(dist[v[start][i]],dist[start]+1);
		--in_degree[v[start][i]];
		if(in_degree[v[start][i]]==0)
		{
			do_dfs(v[start][i]);
			//debug(v[start][i]);
		}
	
	}
//	 for(int b:v[start])
//	 {
//	 	dist[b]=max(dist[b],dist[start]+1);
//	 	in_degree[b]--;
//	 	if(in_degree[b]==0)
//	 	{
//	 		do_dfs(b);
//	 	}
//	 }
}

void solve()
{
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<m;i++)
	{
		ll x,y;
		cin>>x>>y;
		v[x].push_back(y);
		in_degree[y]++;
	}
	// for(ll i=0;i<=n;i++)
	// {
	// 	for(ll j=0;j<v[i].size();j++)
	// 	{
	// 		cout<<v[i][j]<<' ';
	// 	}
	// 	cout<<'\n';
	// }
	
	for(int i=1;i<=n;i++){
		if(visited[i]==false && in_degree[i]==0)
			do_dfs(i);
	}
	int final_ans=0;
	for(int i=1;i<=n;i++)
	{
		final_ans=max(final_ans,dist[i]);
	}
	cout<<final_ans<<'\n';

}

int main()
{
	int t;
	t=1;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T;
  cin >> S >> T;

  //cout << T.substr(0, S.length()) << endl;
  
  if (T.substr(0, S.length()) == S) {
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    long long a,b;
    cin >> a >> b;
    for(int i=1; i<b+1; i++){
        if((a*i)%b==0){
            cout << a*i << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int a[N] , dp[N][4];

void go()
{
	cin >> n;

	fo(i,1,n+1) cin >> a[i];

	dp[1][0] = a[1];
	dp[1][1] = dp[1][2] = dp[1][3] = -inf;
	dp[2][0] = max( a[2] , dp[1][0] );
	dp[2][1] = a[2];
	dp[3][0] = dp[1][0] + a[3];
	dp[3][1] = max({ dp[1][0] , dp[2][0] , dp[3][0]} );
	dp[3][2] = a[3];

	fo(i,4,n+1)
	{
		dp[i][0] = dp[i-2][0] + a[i];
		dp[i][1] = max( { dp[i-2][1] + a[i] , dp[i-3][0] + a[i]  });
		dp[i][2] = max( { dp[i-2][2] + a[i] , dp[i-3][1] + a[i] , dp[i-4][0] + a[i] } );
	}

	int ans = 0;

	if( n&1 ) ans = max({ dp[n][2] , dp[n-1][1] , dp[n-2][0] } );
	else ans = max( dp[n][1] , dp[n-1][0] );

	cout << ans << endl;
}

int32_t main()
{
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

Measured memory_bytes: 16112
#include <stdio.h>
using namespace std;
int main ( )
{
int a , b , c , d ;
scanf ("%d%d%d%d " , &a , &b , &c , &d ) ;
int x = c - a , y = d - b ;
printf ("%d %d %d %d\n " , c - y , d + x , a - y , b + x ) ;
}

Measured memory_bytes: 128