akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.LinkedList;

public class Main {
	public static void main(String[] args) {
		AnInvisibleHand hand = new AnInvisibleHand();
		hand.run();
	}
}

class AnInvisibleHand {
	
	int N;
	long T;
	long[] prices;
	
	AnInvisibleHand() {
		Scanner cin = new Scanner(System.in);
		this.N = cin.nextInt();
		this.T = cin.nextInt();
		this.prices = new long[N];
		for (int i = 0; i < N; i++) {
			prices[i] = cin.nextLong();
		}
	}
	
	void run() {
		
		int[] maxIds = new int[N];
		long maxValue = 0; 
		int maxId = N - 1;
		for (int i = N - 1; i >= 0; i--) {
			if (maxValue < prices[i]) {
				maxId = i;
			}
			maxValue = Math.max(maxValue, prices[i]);
			maxIds[i] = maxId;
		}
		
		long maxValueInAll = 0;
		LinkedList<Long> maxList = new LinkedList<Long>();
		for (int i = 0; i < N; i++) {
			int j = maxIds[i];
			long maxIJ = prices[j] - prices[i];
			maxList.add(maxIJ);
			maxValueInAll = Math.max(maxValueInAll, maxIJ);
		}
		
		int count = 0;
		for (long max: maxList) {
			if (max == maxValueInAll)
				count++;
		}
		
		System.out.println(count);
	}
}


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

namespace _3
{
    class Program
    {
        static void Main(string[] args)
        {
            var one = Console.ReadLine();
            int intone = one.Length;

            string flag = "0";

            string[] arrsplit = one.Split(' ');

            string strone = arrsplit[0];
            string strtwo = arrsplit[1];
            string strthree = arrsplit[2];

            if (strone == strtwo)
            {
                flag = "1";
                if(strone == strthree)
                {
                    flag = "0";
                }
            }
            if (strone == strthree)
            {
                flag = "1";
                if (strtwo == strthree)
                {
                    flag = "0";
                }
            }

            if(strtwo == strthree)
            {
                flag = "1";
                if (strone == strthree)
                {
                    flag = "0";
                }
            }


            if (flag == "1") {
                Console.WriteLine("Yes");

            }else
            {
                Console.WriteLine("No");
            }

     
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#define rep(i,n) for(int (i)=0;(i) < (n);(i)++)
#define MAX 110
using namespace std;
vector<int> G[MAX];
bool flag[MAX];

int dfs(int now){
    flag[now]=1;
    int ret = 1;
    rep(i,G[now].size()){
        if(flag[G[now][i]]==0)
            ret = max(ret,dfs(G[now][i])+1);
    }
    flag[now]=0;
    return ret;
}

int main() {
    int n;
    while(scanf("%d",&n),n!=0){
        rep(i,MAX){
            G[i].clear();
            flag[i]=0;
        }
        int x,y;
        rep(i,n){
            scanf("%d %d",&x,&y);
            x--;
            y--;
            G[x].push_back(y);
            G[y].push_back(x);
        }
        rep(i,MAX){
            if(G[i].empty())
                break;
            sort(G[i].begin(),G[i].end());
            G[i].erase(unique(G[i].begin(),G[i].end()),G[i].end());
        }
        int ret = 0;
        rep(i,MAX){
            ret = max(ret,dfs(i));
        }
        printf("%d\n",ret);
    }
    return 0;
}

Measured memory_bytes: 1216
import std.algorithm;
import std.range;
import std.stdio;
import std.string;

immutable int letters = 26;

void main ()
{
	string s;
	while ((s = readln.strip) != "")
	{
		auto a = new int [] [letters];
		foreach (int i, c; s.map !(x => x - 'a').array)
		{
			a[c] ~= i;
		}
		int n = cast (int) (s.length);
		int res = int.max;
		foreach (b; a.filter !(x => !x.empty))
		{
			debug {writeln (b);}
			int cur = b[0];
			foreach (j; 1..b.length)
			{
				cur = max (cur, (b[j] - b[j - 1] - 1));
			}
			cur = max (cur, n - b[$ - 1] - 1);
			res = min (res, cur);
		}
		writeln (res);
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
int main(){
    int n;
    scanf("%d",&n);
    string s;
    cin>>s;
    int cnt=0;
    bool flag=1;
    ll ans=1;
    for(int i=0;i<s.size();i++){
        if(cnt&1){
            if(s[i]=='W'){
                cnt++;
            }
            else{
                ans*=cnt;
                ans%=mod;
                cnt--;
            }
        }
        else{
            if(s[i]=='B'){
                cnt++;
            }
            else{
                ans*=cnt;
                ans%=mod;
                cnt--;
            }
        }
        if(cnt<0){
            flag=0;break;
        }
    }
    //cout<<cnt<<endl;
    if(!flag||cnt!=0){
        printf("0\n");
        return 0;
    }
    for(int i=2;i<=n;i++){
        ans*=i;
        ans%=mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int> > data;
vector<int> mt;
vector<bool> used;
bool tr (int v) {
	if (used[v])  return false;
	used[v] = true;
	for (size_t i=0; i<data[v].size(); ++i) {
		int to = data[v][i];
		if (mt[to] == -1 || tr (mt[to])) {
			mt[to] = v;
			return true;
		}
	}
	return false;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<pair<int, int> > r, b;
    for (int i=0; i < n; i++){
        int x, y;
        cin >> x >> y;
        r.push_back(make_pair(x, y));
        mt.push_back(-1);
        used.push_back(false);
    }
    for (int i=0; i < n; i++){
        int x, y;
        cin >> x >> y;
        b.push_back(make_pair(x, y));
    }
    for (int i=0; i < 2*n; i++){
        vector<int> help;
        data.push_back(help);
    }
    for (int i=0; i < n; i++){
        for (int j=0; j < n; j ++){
            if (r[i].first < b[j].first && r[i].second < b[j].second){
                data[i].push_back(j);
            }
        }
    }
    for (int i=0; i < n; i++){
        fill(used.begin(), used.end(), false);
        tr(i);
    }
    int ans = 0;
    for (int i=0; i <n;i++) ans += (mt[i] != -1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
	
	/**
	 * @param sc 			ÇÝÝÏ
	 * @param field			¹ð\·zñ
	 * @param a, b 			¡Æc
	 * @param construction 	HÌð·_Ì
	 */
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int field[][];
	static int a,b;
	static int construction = 0;
	
	
	public static void main(String[] args) {
		while(read()){
			System.out.println(slove());
			/*for(int i = 0; i < b+2; i++){
				for(int j = 0; j < a+2; j++){
					System.out.print(field[i][j]+"        ");
				}
				System.out.println();
			}*/
		}
	}
	
	static boolean read(){
		/**
		 * XÌÇÝÝB
		 * àµA^eRÆàÉOÈçI¹³¹éB
		 */
		a = sc.nextInt(); b = sc.nextInt();
		if(a == 0 && b == 0)
			return false;
		
		/**
		 * XÌ¶¬Æú»B
		 *@-1Åzñðú»µÄAÀÛÌ¹ð0Åú»B
		 */
		field = new int[b+2][a+2];
		for(int i = 0; i < b+2; i++){
			for(int j = 0; j < a+2; j++){
				field[i][j] = -1;
			}
		}
		
		for(int i = 1; i <= b; i++){
			for(int j = 1; j <= a; j++){
				field[i][j] = 0;
			}
		}
		
		field[b][1] = 1;
		/*for(int i = 1; i<=a; i++){
			field[b][i] = 1;
		}
		for(int i = b; i>=1; i--){
			field[i][1] = 1;
		}*/
		
		/**
		 * HÌð·_ðÇÝñÅA
		 * constructionðfor[vÌâ~ðÉp¢A
		 * HÌð·_ð«ÞB
		 */
		construction = sc.nextInt();
		for(int i = 0; i < construction; i++){
			int x, y;
			x = sc.nextInt(); y = sc.nextInt();
			field[b-y+1][x] = -1;
		}
		
		//field[b][a] = 20;
		return true;
	}

	/**
	 * 		  _____       _____
	 * 		 |-1|-1| E E E |-1|-1|
	 * 		 |-1|0 | E E E |0 |-1|
	 * 		    @@E		@    @E
	 * 			E		@    @E
	 * 			E@@			E
	 * 		 |-1|0 | E E E |0 |-1|
	 * 		 |-1|-1| E E E |-1|-1|
	 * 		  -----       -----
	 **/
	static int slove(){
		for(int i = b; i >= 1; i--){
			for(int j = 1; j <= a; j++){
				if(field[b][1] == -1)
					return 0;
				
				if(field[i][j] == field[b][1]){
					field[i][j] = 1;
				}else if(field[i][j] == -1){
				
				}else if(field[i][j-1] == -1
						&& field[i+1][j] == -1){
					field[i][j] = 0;
				}else if(field[i][j-1] == -1){
					field[i][j] = field[i+1][j];
				}else if(field[i+1][j] == -1){
					field[i][j] = field[i][j-1];
				}else{
					/*
					 * ©ªªHÅàÈ­A
					 * ¶ÆºàHÅÈ©Á½çA
					 * field[i][j] = field[i][j-1] + field[i+1][j];
					 * ©ª@@¶@{@º
					 */
					field[i][j] = field[i+1][j]+field[i][j-1];
				}	
			}
		}		
		return field[1][a];
	}
}

Measured memory_bytes: 12000
a, b, c, d, e, f = map(int, input().split())
maxcon = 0
wans = 0
sans = 0
for i in range(f//(a*100) + 1):
    for j in range((f-i*100*a)//(b*100) + 1):
        for k in range((f-i*100*a-j*100*b)//c + 1):
            for l in range((f-i*100*a-j*100*b-k*c)//d + 1):
                if i+j+k+l != 0 and (k*c+l*d)*(100+e) <= e*(100*(i*a+j*b)+k*c+l*d):
                    con = 100*(k*c+l*d) / (100*(i*a+j*b)+k*c+l*d)
                    maxcon = max(maxcon, con)
                    if con == maxcon:
                        wans = 100*(i*a+j*b)
                        sans = k*c+l*d
print(wans+sans, sans)

Measured memory_bytes: 3064
int_num=int(input())
ans_list = {}
for i in range(int_num):
    input_list=list(map(str,input().split()))
    if input_list[0] == 'insert':
        ans_list[(input_list[1])] = True
    else:
        if (input_list[1]) in ans_list.keys():
            print('yes')
        else:
            print('no')


Measured memory_bytes: 33112
/*
hey stop, don't skip the shit till it's solved
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
string s[3]={"Sunny","Cloudy","Rainy"};
string t;
cin>>t;
for(int i=0;i<3;i++)
{
if(s[i]==t)
{
cout<<s[(i+1)%3]<<endl;
break;
}
}
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

int main(){
	int p;
	int q;
	int r;

	cin >> p;
	cin >> q;
	cin >> r;

	cout << p + q + r - max(p, max(q, r)) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();
const int mod = 1e9 + 7;
int dp[101][100001];
int pre[101][100001];
int main () { _read(); 

      int n,m;
      cin >> n >> m;
      vector<int> v(n+1);
      for( int i = 1; i <= n; ++i) {
            cin >> v[i];
      }
      dp[0][0] = 1;
      for( int i = 1; i <= n; i++) {
            for( int k = 1; k <= m; k++) {
                  (dp[i-1][k] += dp[i-1][k-1]) %= mod;
            }
            for( int k = 0; k <= m; k++) {
                  dp[i][k] = (dp[i-1][k] - ( (k - v[i] - 1) >= 0 ? dp[i-1][k-v[i]-1] : 0) + mod ) % mod;
            }
      }
      cout << dp[n][m] << '\n';
      return 0;
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


Measured memory_bytes: 43100
#include<bits/stdc++.h>
using namespace std;
int n;
string get(int ind){
	cout<<ind<<endl;
	fflush(stdout);
	string s;
	cin>>s;
	return s;
}
int main()
{
	cin>>n;
	string a=get(0);
	if(a=="Vacant")	return 0;
	string b=get(n-1);
	if(b=="vacant")	return 0;
	int lef=1,rig=n-2;
	while(lef<=rig){
		int mid=lef+rig>>1;
		string my=get(mid);
		if(my=="Vacant")return 0;
		if(mid%2==0)
			if(my==a)lef=mid+1;
			else rig=mid-1;
		else if(my==b)lef=mid+1;
			else rig=mid-1;
	}
	return 0;
}

Measured memory_bytes: 852
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>

using namespace std;

#define pb push_back
#define int long long
#define ld long double

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, mx = 0, ans = 0;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++){
        cin >> v[i];
        mx = max(mx, v[i]);
        ans += mx - v[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4780
#include <cstdio>
#include <string>
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <map>
#include <cmath>
using namespace std;

int main () {
    long a, b, c, k, tmpa, tmpb;
    scanf("%ld %ld %ld %ld", &a, &b, &c, &k);
    if (a - b > pow(10, 18.0) || a - b < -pow(10, 18.0)) printf("Unfair\n");
    else {
        if (k%2 == 0) printf("%ld\n", a - b);
        else printf("%ld\n", b - a);
    }
}

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

using namespace std;


int main()
{
	int n, x;
	cin >> n >> x;
	int d = 0;
	int answer = 1;
	for (int i = 0; i < n;i++) {
		int l = 0;
		cin >> l;
		if (d + l > x) {
			break;
		}
		d += l;
		answer++;
	}

	cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

if __name__ == '__main__':
	n = input()
	R = []

	for i in xrange(n):
		R.append(input())
	maxv = -20000000000
	minv = R[0]

	for i in xrange(1, n):
		maxv = max(maxv, R[i] - minv)
		minv = min(minv, R[i])

	print maxv

Measured memory_bytes: 12536
#include <bits/stdc++.h>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
using namespace std;
inline void read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
/*I love Korosensei forever.*/
/**/
int main()
{
	// freopen("test.in","r",stdin);
	// freopen("test.out","w",stdout);
	int a,b,c;
	read(a);read(b);read(c);
	cout<<min(c,b/a);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

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

const int N=2e5+11;
const int M=5e5+1;
const int inf=1e9+1;
const ll INF=1e18;
const ll mod=998244353;
const int dx[4]={0,0,-1,1};
const int dy[4]={-1,1,0,0};

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  ll a,v;
  ll b,w;
  ll t;
  cin>>a>>v;
  cin>>b>>w;
  cin>>t;
  ll dist=abs(a-b);
  dist-=t*v;
  dist+=t*w;
  if(dist>0)cout<<"NO";
  else cout<<"YES";
}


Measured memory_bytes: 3648
#include <stdio.h>

int main() {

    int A[3][3];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            scanf("%d", &A[i][j]);
        }
    }

    int N = 0;
    scanf("%d", &N);

    int b[N];
    for(int i = 0; i < N; i++) {
        scanf("%d", &b[i]);
    }

    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < N; k++) {
                if(A[i][j] == b[k]) {
                    A[i][j] = 0;
                }
            }
        }
    }

    int Bingo = 0;
//    bingo = Bingo(&A);

    for(int i = 0; i < 3; i++) {
        if((A[i][0] == A[i][1]) && (A[i][1] == A[i][2])) {
            Bingo = 1;
        }
    }

    for(int i = 0; i < 3; i++) {
        if((A[0][i] == A[1][i]) && (A[1][i] == A[2][i])) {
            Bingo = 1;
        }
    }

    if((A[0][0] == A[1][1]) && (A[1][1] == A[2][2])) {
        Bingo = 1;
    }
    if((A[0][2] == A[1][1]) && (A[1][1] == A[2][0])) {
        Bingo = 1;
    }

    if(Bingo == 0) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }

    return 0;
}



Measured memory_bytes: 128
s = list(input())
t = "keyence"
a = i = 0

while True:
    if len(s) == i:
        break
    
    if s[i] == t[i]:
        a += 1
    else:
        break
    i += 1

i = len(s) - 1
o = len(t) - 1

while True:
    if a == len(t):
        break
    
    if s[i] == t[o]:
        a += 1
    else:
        break
    i -= 1
    o -= 1

if a == len(t):
    print("YES")
else:
    print("NO")

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

int main(){
    set<int> inp;
    int x,n,a;
    cin>>x>>n;
    while(n--){
        cin>>a;
        inp.insert(a);
    }
    int i=0,ans,flag=1;
    while(true){
        if(!inp.count(x-i)){
            ans=x-i;            
            break;
        }
        else if(!inp.count(x+i)){
            ans = x+i;
            break;
        }
        i++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
void solve() {
    int n,m;
    cin>>n>>m;
    if(n-2>0 and m-2>0) cout<<(n-2)*(m-2);
    else
    {
        if(n-2<0) {
           n=1;
        }
        else n-=2;
        if(m-2<0) {
            m=1;
        }
        else m-=2;
        cout<<n*m;
    }
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //fillprime();

    //int t;cin>>t;while(t--)
        solve();
}

Measured memory_bytes: 3620
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, m) = in.readLine().split("\\s+").map(_.toInt)
    val as = in.readLine().split("\\s+").map(_.toInt)

    val sum = as.sum

    out.println(
      if (as.count(a => a * 4 * m >= sum) >= m) {
        "Yes"
      } else {
        "No"
      }
    )
    out.flush()
  }
}


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

int main(){
    vector<int>cnt(4);
    for(int i = 0; i < 4; i++) {
        cin >> cnt[i];
    }
    sort(cnt.begin(),cnt.end());
    if(cnt[0] == 1 && cnt[1] == 4) {
        if(cnt[2] == 7 && cnt[3] == 9) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}



Measured memory_bytes: 256
def judge(a, b, c):
  return a if a == b == c and a != 's' else 0

while True:
  try:
    s = raw_input()
    for i in range(3):
      result = judge(*s[i:9:3])
      if result: break
      result = judge(*s[3*i:3*i+3])
      if result: break
    else:
      result = s[4] if s[4] != 's' and (judge(*s[0:9:4]) or judge(*s[2:7:2])) else 'd'
  except:
    break
  print result

Measured memory_bytes: 4220
#include <iostream>

using namespace std;

int main() {
  int X;//商品の個数が不足することはない．
  int high_x, low_x;
  int total = 0, n, ans;

  cin >> X;

  high_x = X / 100;
  low_x = X % 100;

  for (int i = 5; i >= 0; i--) {
    n = low_x / i;
    total += n;
    low_x -= i*n;
    if (low_x <= 0) break;
  }

  if (total > high_x) ans = 0;
  else ans = 1;

  cout << ans << endl;

  return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> as(n);
  for(int i=0;i<n;i++){cin>>as.at(i);}
  int max_diff=0;
  for(int i=0;i<n-1;i++){
    for(int j=0;j<n;j++){
      max_diff=max(abs(as.at(i)-as.at(j)), max_diff);
    }
  }
  cout<<max_diff<<endl;
}

Measured memory_bytes: 256
// 解き直し.
// ABC 132解説.
// https://img.atcoder.jp/abc132/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MOD = 1e9 + 7;
const LL MAX_K = 101;
const LL MAX_N = 1e5;
LL dp[MAX_K][MAX_N];

int main() {

    // 1. 入力情報取得.
    LL N, K;
    scanf("%lld %lld", &N, &K);

    // 2. 解説通り.
    // dp[i][x]: 最後の整数が, x であるような i個 の 整数を並べて条件を満たせる場合の数.
    // ex.
    // [入力例]
    // 10 3
    // ※下記, dp[3][XX] については, 計算方法を ()内 に, 記載した.
    // dp[1][1]  = 1, dp[2][1]  = 10, dp[3][1]  = 27 (= dp[2][1] + ... + dp[2][10])
    // dp[1][2]  = 1, dp[2][2]  = 5,  dp[3][2]  = 22 (= dp[2][1] + dp[2][2] + dp[2][3] + dp[2][4] + dp[2][5])
    // dp[1][3]  = 1, dp[2][3]  = 3,  dp[3][3]  = 18 (= dp[2][1] + dp[2][2] + dp[2][3])
    // dp[1][4]  = 1, dp[2][4]  = 2,  dp[3][4]  = 15 (= dp[2][1] + dp[2][2])
    // dp[1][5]  = 1, dp[2][5]  = 2,  dp[3][5]  = 15 (= dp[2][1] + dp[2][2])
    // dp[1][6]  = 1, dp[2][6]  = 1,  dp[3][6]  = 10 (= dp[2][1])
    // dp[1][7]  = 1, dp[2][7]  = 1,  dp[3][7]  = 10 (= dp[2][1])
    // dp[1][8]  = 1, dp[2][8]  = 1,  dp[3][8]  = 10 (= dp[2][1])
    // dp[1][9]  = 1, dp[2][9]  = 1,  dp[3][9]  = 10 (= dp[2][1])
    // dp[1][10] = 1, dp[2][10] = 1,  dp[3][10] = 10 (= dp[2][1])
    // -> dp[3][1] + dp[3][2] + ... + dp[3][9] + dp[3][10] = 147通り と 計算するようである.
    
    // 正解者のソースを確認したところ, "N の 平方数 に 1 を 加算する必要がある" ことが判明.
    // LL nr = sqrt(N + 0.0); // 03.txt, 12.txt で, WA版 となるので, 注意.
    LL nr = sqrt(N + 0.0) + 1;
    LL ir = N / nr;
    for(LL x = 1; x < nr + ir; x++) dp[1][x] = 1;
    
    for(LL k = 2; k <= K; k++){
         
         // 2-1. N ～ r + 1 まで集計.
         // ex.
         // x = 5 に 6 ～ 10, x = 4 に 4 ～ 5 を 集約.
         for(LL x = nr + ir - 1; x >= nr; x--){
             dp[k][x] = dp[k - 1][nr + ir - x] + dp[k][x + 1];
             dp[k][x] %= MOD;
         }
         
         // 2-2. r ～ 1 まで集計.
         // ex.
         // x = 3 ～ 1 までを集計.
         for(LL x = nr - 1; x > 0; x--){
             dp[k][x] = dp[k][x + 1] + dp[k - 1][nr + ir - x] * (N / x - N / (x + 1));
             dp[k][x] %= MOD;
         }
    }
    // for(LL x = 1; x < nr + ir; x++) cout << dp[K][x] << " ";
    // cout << endl;
    
    // 3. 後処理.
    LL ans = 0;
    for(LL x = 1; x < nr; x++)       ans += dp[K][x], ans %= MOD;
    for(LL x = nr; x < nr + ir; x++) ans += dp[K][x] * (N / (nr + ir - x) - N / (nr + ir - x + 1)), ans %= MOD;
    printf("%lld\n", ans);
    return 0;

}

Measured memory_bytes: 77568
N = int(input())
S = list()
for i in range(N):
  S.append(input())
M = int(input())
T = list()
for i in range(M):
  T.append(input())
count = 0
maxcount = 0
for i in range(N):
  count = 0
  for j in range(N):
    if S[i] == S[j]:
      count += 1
  for j in range(M):
    if S[i] == T[j]:
      count -= 1
  if count > maxcount:
    maxcount = count
print(maxcount)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
unsigned short *A,*B;
int i,j,k,n;
int C[VMAX+1];
k=VMAX;
  scanf("%d",&n);

 A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=1;i<=n;i++)
    scanf("%d",&A[i]);

   for(i=0;i<=k;i++)
     C[i] =0;
   
   /* C[i] に i の出現数を記録する */
   for(j=1;j<=n;j++)
     C[A[j]]++;
   
   /* C[i] に i 以下の数の出現数を記録する*/
   for(i=1;i<=k;i++){
     C[i] = C[i] + C[i-1];
   }
   
   for(j=n;j>0;j--){
   B[C[A[j]]] = A[j];
   C[A[j]]--;
   }
   
  
  
  printf("%d",B[1]);
  for(i=2;i<=n;i++)
  printf(" %d",B[i]);
  printf("\n");

  return 0;
}




Measured memory_bytes: 9556
///
// File:  2015.cpp
// Author: ymiyamoto
//
// Created on Sat Dec  2 23:41:55 2017
//

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) break;

    vector<uint64_t> heights;
    heights.push_back(0);
    for (uint32_t i = 1; i <= N; i++) {
      uint32_t h;
      cin >> h;
      h += heights[i - 1];
      heights.push_back(h);
    }

    vector<uint64_t> widths;
    widths.push_back(0);
    for (uint32_t i = 1; i <= M; i++) {
      uint32_t w;
      cin >> w;
      w += widths[i - 1];
      widths.push_back(w);
    }

    vector<uint64_t> hs;
    for (uint32_t i = 0; i < heights.size(); i++) {
      for (uint32_t j = i + 1; j < heights.size(); j++) {
        hs.push_back(heights[j] - heights[i]);
      }
    }

    vector<uint64_t> ws;
    for (uint32_t i = 0; i < widths.size(); i++) {
      for (uint32_t j = i + 1; j < widths.size(); j++) {
        ws.push_back(widths[j] - widths[i]);
      }
    }

    sort(ws.begin(), ws.end());
    uint64_t count = 0;
    for (uint32_t i = 0; i < hs.size(); i++) {
      count += upper_bound(ws.begin(), ws.end(), hs[i]) - lower_bound(ws.begin(), ws.end(), hs[i]);
    }

    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 36836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;
 

int main() {
  ll n,k,r,s,p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;
  vector<char>h(n);
  rep(i,n){
    if(i>=k && t.at(i)==h[i-k]) h[i] = 'x';
    else h[i] = t[i];
  }
  ll ro = 0,sy = 0,pa = 0;
  rep(i,n){
    if(h[i] == 'r') pa++;
    if(h[i] == 's') ro++;
    if(h[i] == 'p') sy++;
  }
  ll ans = r*ro+p*pa+s*sy;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))
last=[0]*26

for day in range(d):
  co=[]
  dla=[]
  down=0
  for (i,j) in zip(last,c):
    down+=i*j
  for (i,j) in zip(last,c):
    dla.append(down-(j*(day-i)))
  for con in range(26):
    co.append(s[day][con]-dla[con]*c[con])
  choice=co.index(max(co))
  last[choice]=day
  print(choice+1)

Measured memory_bytes: 9324
ret = []
while True:
   n, x = map(int, raw_input().split())
   num_arr = [i for i in range(1, n+1)]
   if (n, x) == (0, 0): 
       break   

   cnt = 0
   for i in range(len(num_arr)):
       for j in range(i + 1, len(num_arr)):
           for k in range(j + 1, len(num_arr)):
               work = num_arr[i] + num_arr[j] + num_arr[k]
               if x == work:
                   cnt += 1
   ret += [cnt]
for i in ret:
    print i

Measured memory_bytes: 6448
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
#define INF 1e9
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }

signed main() {

  int a, b;
  cin >> a >> b;
  int ans = 0;
  if (a == b)
    ans = a + b;
  else {
    if (a < b) {
      ans = b + max(a, b - 1);
    } else {
      ans = a + max(a - 1, b);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
const int M = 1000000007;
int n, m, sign[100002], dis[100002], a, b,Q[100050];
set<int>A[100002];
int main()
{
	cin >> n >> m;
	memset(dis, 127, sizeof(dis));
	while (m--)
	{
		cin >> a >> b;
		A[a].insert(b);
		A[b].insert(a);
	}
	a = 0;
	Q[a++] = 1;
	dis[1] = 0;
	loop(i, 0, a)
	{
		for (auto it : A[Q[i]])
		{
			if (dis[it] > dis[Q[i]]+1)
			{
				sign[it] = Q[i];
				dis[it] = dis[Q[i]] + 1;
				Q[a++] = it;
			}
		}
	}
	bool flag = 0;
	loop(i, 2, n + 1)if (!sign[i]) flag = 1;
	if (flag)
	{
		cout << "No";
		return 0;
	}
	cout << "Yes\n";
	loop(i, 2, n + 1)cout << sign[i] << "\n";
}


Measured memory_bytes: 28208
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N;
char s[MAXN];
int cnt[35];
void Solve() {
    read(N);
    scanf("%s",s + 1);
    for(int i = 1 ; i <= N ; ++i) {
        cnt[s[i] - 'a']++;
    }
    int res = 1;
    for(int i = 0 ; i < 26 ; ++i) {
        res = 1LL * res * (1 + cnt[i]) % MOD;
    }
    res = (res + MOD - 1) % MOD;
    out(res);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  long long M=0,A=0,R=0,C=0,H=0;
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    
    if(S.at(0)=='M')
      M++;
    if(S.at(0)=='A')
      A++;
    if(S.at(0)=='R')
      R++;
    if(S.at(0)=='C')
      C++;
    if(S.at(0)=='H')
      H++;
   
  }
  
  cout<<M*A*R + M*A*C + M*A*H + M*R*C + M*R*H + M*C*H + A*R*C + A*R*H + A*C*H + R*C*H ;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        boolean[][] card = new boolean[4][13];
        for(int i = 0; i<4; i++){
            for(int j = 0; j<13 ;j++){
                card[i][j] = false;
            }
        }
 
        while(n-->0){
            String head = scan.next();
            int figure = 0;
            if(head.equals("S")){
                figure = 0;
            } else if(head.equals("H")){
                figure = 1;
            }else if(head.equals("C")){
                figure = 2;
            }else if(head.equals("D")){
                figure = 3;
            }
            int number = scan.nextInt();
            card[figure][number-1]=true;
        }
        for(int i = 0; i<4; i++){
            for(int j = 0; j<13; j++){
                if(card[i][j]!=true){
                    if(i==0){
                        System.out.println("S"+" "+(j+1));
                    }else if(i==1){
                        System.out.println("H"+" "+(j+1));
                    }else if(i==2){
                        System.out.println("C"+" "+(j+1));
                    }else if(i==3){
                        System.out.println("D"+" "+(j+1));
                    }
 
                }
            }
        }
        scan.close();
    }
}


Measured memory_bytes: 26000
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N;

int main() {
    cin >> N;
    vector<int> cnt(5);
    string march = "MARCH";
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        for (int j = 0; j < 5; j++) if (S[0] == march[j]) cnt[j]++;
    }
    long long ans = 0;
    for (int i = 0; i < (1 << 5); i++) {
        int flag = 0;
        long long tmp = 1;
        for (int j = 0; j < 5; j++) {
            if (i & (1 << j)) {
                ++flag;
                tmp *= cnt[j];
            }
        }
        if (flag == 3) ans += tmp;
    }
    cout << ans << endl;
}





Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        if (a * b % 2 == 0) Console.WriteLine("No");
        else Console.WriteLine("Yes");
    }
}


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

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    rep(i,N) cin >> x[i] >> y[i];
    double d=0;
    rep(i,N) rep(j,N)
        d += hypot(x[i]-x[j], y[i]-y[j]);
    printf("%.8f\n", d/N);
}


Measured memory_bytes: 3700
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int A,B;
const int c[5]={0,300000,200000,100000,0};
int main(){
	A=read(),B=read();
	if(A==1&&B==1){
		return !printf("1000000\n");
	}
	A=min(A,4),B=min(B,4);
	printf("%d\n",c[A]+c[B]);
	return 0;
}



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


int main(){
  string s,t;
  cin>>s>>t;
  if(t.length()==s.length()+1){
    for(int i=0;i<s.length();i++){
      if(!(s[i]==t[i])){
        cout<<"No";
        return 0;
      } 
      }
      cout<<"Yes";

  }else{cout<<"No";}


  }

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

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

  int pass=0, sea=0;
  for(int i=1; i<=n; i++){
    char c;
    cin>>c;
    if(c=='a'){
      if(pass<a+b){
        pass++;
        cout<<"Yes"<<endl;
      }else cout<<"No"<<endl;
    }else if(c=='b'){
      sea++;
      if(pass<a+b && sea<=b){
        pass++;
        cout<<"Yes"<<endl;
      }else cout<<"No"<<endl;
    }else cout<<"No"<<endl;
  }
}


Measured memory_bytes: 640
N, M = map(int,input().split())
v = []
for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    v.append((x,y))

for i in range(10**N):
    s = str(i)
    if len(s) != N:
        continue
    if all(s[a] == str(b) for a,b in v):
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(){
    int flag = 1, i, j, n, count = 0, s[200], key;
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) scanf("%d", &s[i]);
    for ( i = 0; i < n - 1; i++ ) {
        flag = i;
        for ( j = i; j < n; j++ ) {
            if ( s[j] < s[flag]) flag = j;
        }
        key = s[i];
        s[i] = s[flag];
        s[flag] = key; 
        if ( i != flag ) count++;
    }
    printf("%d", s[0]);
    for ( i = 1; i < n; i++ ) {
        printf(" %d", s[i]);
    }
    printf("\n%d\n", count);
    return 0;
}

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

int a, b;

int main(void){
  // Here your code !
  scanf("%d", &a);
  scanf("%d", &b);

  if (a <= 8 && b <= 8) {
    printf("Yay!\n");
  }
  else {
    printf(":(\n");
  }

  return 0;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N;
  cin >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0.0));
  dp[0][0] = 1.0;
  for (int64_t used = 1; used <= N; ++used) {
    double p;
    cin >> p;
    for (int64_t omote = 0; omote <= used; ++omote) {
      dp[used][omote] = dp[used - 1][omote] * (1.0 - p) + dp[used - 1][omote - 1] * p;
    }
  }
  double result = 0.0;
  for (int64_t omote = (N + 1) / 2; omote <= N; ++omote) {
    result += dp[N][omote];
  }
  cout << std::setprecision(20) << result << endl;
  return 0;
}


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

if (n<=9):
  print(n)

elif (n<=99):
  print(9)

elif (n<=999):
  print(n-90)

elif (n<=9999):
  print(909)
  
elif (n<=99999):
  print(n-9090)
  
else:
  print(90909)


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(d)]
    t = [int(input()) for _ in range(d)]
    last = [0 for _ in range(26)]
    score = 0

    for di in range(1, d + 1):
        ti = t[di - 1]
        score += s[di - 1][ti - 1]

        last[ti - 1] = di

        for j, cj in enumerate(c, 1):
            score -= cj * (di - last[j - 1])

        print(score)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9240
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef pair<ll,ll> PLL;

#define REP(x,l,u) for(ll x = l; x < u; x++)
#define RREP(x,l,u) for(ll x = l; x >= u; x--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mst(x,v) memset(x, v, sizeof(x))

string to_string(string s) {return s;}
string to_string(char c) {string s = string(1, c);return s;}
template <typename A, typename B> string to_string(pair<A,B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(vector<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }
template <typename A> string to_string(set<A> v) { string s = "("; int first = 1; for (A a : v) { if (!first) { s += ", "; } first = 0; s += to_string(a); } s += ")"; return s; }

void debug_out() {cerr << endl;}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

void in() {}
template <typename A> void in(A & x) { cin >> x; }
template <typename A, typename B> void in(pair<A,B> & x) { in(x.first); in(x.second); }
template <typename A> void in(vector<A> & x) { REP(i,0,(ll)x.size()) in(x[i]); }
template <typename Head, typename... Tail> void in(Head & H, Tail & ... T) {in(H); in(T...); }

#ifndef ONLINE_JUDGE
#define debug(...) do { cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__); } while (false)
#else
#define debug(...) do { } while (false)
#endif

const ll inf = (ll)1e18 + 5;
ll mod = 1e9+7;


VVLL operator*(VVLL a, VVLL b) {
	VVLL c(a.size(), VLL(b[0].size()));
	
	REP(i,0,a.size()) {
		REP(j,0,a[0].size()) {
			REP(k,0,b[0].size()) {
				c[i][k] += a[i][j] * b[j][k];
				c[i][k] %= mod;
			}
		}
	}
	
	return c;			
}

VVLL operator^(VVLL a, ll k) {
	if (k == 0) {
		VVLL b(a.size(), VLL(a.size()));
		REP(i,0,a.size()) b[i][i] = 1;
		return b;
	}
	VVLL half = a ^ (k / 2);
	half = half * half;
	if (k % 2) {
		half = half * a;
	}
	return half;
}

ll pow(ll a, ll b) {
	if (b == 0) return 1;
	ll h = pow(a, b/2);
	ll ans = b % 2 ? h * h % mod * a : h * h;
	ans %= mod;
	return ans;
}

void solve() {
	ll n, a, b;
	in(n,a,b,mod);

	VLL count(19);
	RREP(d,18,1) {
		// i will add however many d digit numbers there are
		ll l = 0, r = n;
		ll limit = stoll(string(d, '9'));
		
		while (l < r) {
			ll m = (l+r)/2;

			if (a+m*b <= limit) l = m+1;
			else r = m;
		}
		count[d] = l;
	}
	RREP(i,18,1) {
		count[i] -= count[i-1];
	}

	ll ans = 0;
	ll cur = a;
	REP(i,1,19) {
		VVLL A = {
			{pow(10LL,i), 1, 0},
			{0, 1, b%mod},
			{0,0,1}
		};
		VVLL x = {{ans},{cur},{1}};
		
		VVLL Apow = A^(count[i]);
		VVLL res = Apow*x;

		ans = res[0][0];
		cur = res[1][0];
	}
	cout << ans << endl;
}

signed main() {
	ll t = 1;
	REP(i,0,t) solve();
	return 0;
}

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

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> A(n);
  for(int i = 0; i < n; ++i) {
	scanf("%d", &A[i]);
  }

  int q = partition(A, 0, n - 1);
  for(int i = 0; i < n; ++i) {
	if(i == q) printf("[%d]", A[i]);
	else printf("%d", A[i]);

	cout << (i < n - 1 ? " " : "\n");
  }
  return 0;
}

Measured memory_bytes: 3152
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e6 + 3;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

int n;
int L;
int x[maxn];
int dp[maxn][20];

void solve()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x[i]);
	}
	scanf("%d",&L);
	x[n+1] = 2e9;
	for(int i=1;i<=n;i++)
	{
		dp[i][0] = lower_bound(x+1,x+n+2,x[i]+L+1) - (x+1);
		//cout<<x[i]+L<<" "<<i<<" "<<dp[i][0]<<endl;
	}
	int step = 1;
	for(step =1;(1<<step)<=n;step++)
	{
		for(int k=1;k<=n;k++)
		{
			dp[k][step]=dp[dp[k][step-1]][step-1];
		}
	}
	int q;
	scanf("%d",&q);
	while(q--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(a>b)
			swap(a,b);
		int ans=0;
		//cout<<"step"<<step<<endl;

		for(int i=step-1;i>=0;i--)
		{
			if(dp[a][i] < b)
			{
				ans += (1<<i);
				a = dp[a][i];
			}
			//cout<<ans<<endl;
			//cout<<"a:"<<a<<endl;
			//cout<<"i:"<<i<<endl;
			//cout<<"dp[a][i]:"<<dp[a][i]<<endl;
		}
		while(a<b)
		{
			ans++;
			a=dp[a][0];
		}
		printf("%d\n",ans);
	}
}

int main()
{
    solve();
	return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>
#include <inttypes.h>

char N[128];
int K;

int64_t memo[128][2][2][16];

int64_t search(int pos, int sati, int zero, int left) {
	int64_t answer = 0;
	int i;
	if (left < 0) return 0;
	if (N[pos] == '\0') return !zero && left == 0;
	if (memo[pos][sati][zero][left]) return ~memo[pos][sati][zero][left];

	for (i = 0; i <= 9; i++) {
		if (sati && i > (N[pos] - '0')) break;
		answer += search(pos + 1, sati && i >= (N[pos] - '0'), zero && i == 0, left - (i != 0));
	}

	return ~(memo[pos][sati][zero][left] = ~answer);
}

int main(void) {
	if (scanf("%127s", N) != 1) return 1;
	if (scanf("%d", &K) != 1) return 1;
	printf("%" PRId64 "\n", search(0, 1, 1, K));
	return 0;
}


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


int main(){
  int n;
  string s[10000];
  int c[3];//b?? 0 ??a 1 b?a 2
  int ans=0;
  c[0]=c[1]=c[2]=0;
  cin>>n;
  rep(i,n) cin>>s[i];
  rep(i,n){
    if(s[i][0]=='B'){
      if(s[i][s[i].size()-1]=='A') c[2]++;
      else c[0]++;
    }
    else if(s[i][s[i].size()-1]=='A') c[1]++;
    rep(j,s[i].size()-1 ){
      if(s[i][j]=='A' && s[i][j+1]=='B') ans++;
    }
  }
  // cout<<c[0]<<" "<<c[1]<<" "<<c[2]<<endl;
  if(c[2]!=0){
    ans+=c[2]-1;
    if(c[1]!=0){ans++;c[1]--;}
    if(c[0]!=0){ans++;c[0]--;}
  }
  ans+=min(c[0],c[1]);
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(void){
    
    int k,a=0;
    cin>>k;
    for(int i=100;i>0;i--){
        i--;
        if(k/i>0) a+=k-i;
    }
    
    cout<<a<<endl;
    return 0;
    
}

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

void Main() {
    // input
    int N;
    cin >> N;


    // translate
    int pay = 0;
    while (pay < N) {
        pay += 1000;
    }
    int ans = pay - N;


    // output
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    long long n, i;

    long long a[100010];
   
    long long b[100010];

    long long am = 0;

    long long mb = 0;
   
      
    scanf("%lld", &n );
   
    for( i = 0 ; i < n ; i = i + 1 ){
   
         scanf("%lld %lld", &a[i], &b[i] );

         if( a[i] > am ) {

             am = a[i];

             mb = b[i];

             }        

         }
         


    printf("%lld\n", am + mb );


    return 0;
                                                          
}

Measured memory_bytes: 1664
// abc141_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << endl;
  else if (s == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  return 0;
}


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

int main(void){
    int N, temp = 0;
  cin >> N;
  if(N >= 10){
    temp = N % 10;
  }
  else{
    temp = N;
  }
  
  if(temp == 3){
    cout << "bon" << endl;
  }
  else if((temp == 0) || (temp == 6) || (temp == 1) || (temp == 8)){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3632
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
 
		int s1 = a * b;
		int s2 = c * d;
 
		if (s1 >= s2) {
			System.out.println(s1);
		} else {
			System.out.println(s2);
		}
	}
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
bool ok(int x){
    int d=0;
    while(x){
        d++;
        x/=10;
    }
    return d%2;
}
int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=ok(i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256