akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Obj[] arr = new Obj[n + 1];
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.i = i;
			o.a = sc.nextInt();
			arr[i] = o;
		}
		sc.close();

		Obj o = new Obj();
		o.i = n;
		o.a = 0;
		arr[n] = o;

		Arrays.sort(arr, (o1, o2) -> {
			if (o1.a != o2.a) {
				return o2.a - o1.a;
			}
			return o2.i - o1.i;
		});

		long[] ans = new long[n];
		int idx = n;
		int size = 0;
		for (int i = 0; i < arr.length - 1; i++) {
			size++;
			Obj o1 = arr[i];
			Obj o2 = arr[i + 1];
			if (o1.a > o2.a) {
				idx = Math.min(idx, o1.i);
				ans[idx] += (long) (o1.a - o2.a) * size;
			}
		}

		Arrays.sort(arr, (o1, o2) -> o1.i - o2.i);
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < n; i++) {
			pw.println(ans[i]);
		}
		pw.flush();
	}

	static class Obj {
		int i, a;
	}
}


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

int gcd(int a, int b)
{
  if (a < b)
    return gcd(b, a);

  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int main()
{
  int64_t a, b;
  int64_t ans;
  cin >> a >> b;
  ans = (a * b) / gcd(a, b);

  cout << ans << endl;
}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

// fn main() {
//   let mut s: Vec<usize> = read::<String>().chars().map(|c| c as usize - '0' as usize).collect();
//   let n = s.len();
//   let mut sum = vec![0; s.len()+1];
//   let mut map = vec![0; 2020];
//   let mut ans = 0;
//   for i in 0..n {
//     sum[i+1] = sum[i] * 10 + s[i];
//     sum[i+1] %= 2019;
//     map[sum[i+1]] += 1;

//   }
//   sum.reverse();
//   println!("{:?}", s);
//   println!("{:?}", sum);
//   println!("{:?}", map);

// }


fn main() {
  let s: Vec<usize> = read::<String>()
                        .chars()
                        .rev()
                        .map(|c| c as usize - '0' as usize)
                        .collect();
  let p = 2019;
  let n = s.len();

  let mut ans = 0;

  let mut sum = vec![0; n+1];
  let mut c = 1;
  for i in 0..n {
    sum[i+1] =  sum[i] + c * s[i];
    sum[i+1] %= p;
    c *= 10;
    c %= p;
  }

  let mut count = vec![0; p];

  for i in 0..n+1 {
    let e = sum[i];
    count[e] += 1;
  } 

  for &c in &count {
    //println!("{} {}", c, (c * (c-1)) / 2);
    ans += ((c-1) * c) / 2;
  }

  //println!("{:?}", sum);
  //println!("{:?}", count);
  println!("{}", ans);
}


Measured memory_bytes: 4964
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  int count = 0;
  int key = 1;
  rep(i, N) {
    int temp;
    cin >> temp;
    if(temp == key) {
      count++;
      key++;
    }
  }
  int ans;
  if(count == 0) ans = -1;
  else ans = N - count;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3552
n = int(input())
a = [i+1 for i in range(n)]
b = [1]
for i in range(1,n):
  b.append(b[-1] + a[i])
c = [0]
for i in range(n-1):
  c.append(c[-1]+b[i])
#print(a)
#print(b)
#print(c)
ans = b[-1] + c[-1]
for _ in range(n-1):
  xy = list(map(int,input().split()))
  xy.sort()
  x,y = xy
  ans -= x * (n+1-y)
print(ans)

Measured memory_bytes: 94324
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)]

lastd = [0]*26
point = 0

for j,k in enumerate(t):
    kk = k-1
    point += s[j][kk]
    lastd[kk] = j+1
    for l in range(26):
        point -= c[l]*(j+1-lastd[l])
    print(point)

Measured memory_bytes: 68600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int A[200000];
int cnt[200001];
int covered[200001];
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		cnt[A[i]]++;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= cnt[i]; j++) {
			if (i - j >= 0) covered[i - j]++;
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (covered[i]) ans++;
	}
	for (int i = 0; i < M; i++) {
		int X, Y;
		cin >> X >> Y;
		int t = A[X - 1];
		A[X - 1] = Y;
		X = t;
		if (X - cnt[X] >= 0) {
			covered[X - cnt[X]]--;
			if (covered[X - cnt[X]] == 0) ans--;
		}
		cnt[X]--;
		cnt[Y]++;
		if (Y - cnt[Y] >= 0) {
			covered[Y - cnt[Y]]++;
			if (covered[Y - cnt[Y]] == 1) ans++;
		}
		cout << N - ans << endl;
	}
}

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

int main() {
    int N;
    cin >> N;

    int n = N % 10;
    switch (n) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            return 0;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            return 0;
        case 3:
            cout << "bon";
            return 0;
    }
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> v(M + 1, vector<int>(2));
  for (int i = 1; i < M + 1; i++) cin >> v[i][0] >> v[i][1];

  map<int, int> m;
  for (int i = 1; i < M + 1; i++) {
    m[v[i][0]]++;
    m[v[i][1]]++;
  }
  for (int i = 1; i < N + 1; i++) {
    cout << m[i] << endl;
  }
}


Measured memory_bytes: 256
//c
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
	
	int t;
	
	cin>>t;
	
	while(t--){
		
		vector<int> x;
		int n, k;
		cin>>n>>k;
		
		int tmp = -1;
		
		for(int i=0; i<n; ++i){
			int a;
			cin>>a;
			
			if(tmp>=0)
				x.push_back(a-tmp);
			
			tmp = a;
		}
		
		sort(x.begin(), x.end(), greater<int>());
		
		int s = 0;
		
		for(int i=k-1; i<x.size(); ++i){
			s += x[i];
		}
		
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

int  okk(int n){
	int p = n%10;
	n/=10;
	while(n>0){
		int tt = n%10;
		n/=10;
		if(abs(tt-p)>1)
			return 0;
		p=tt;
	}
	return 1;
}

int32_t main() { 
    boost;
    int n;
	cin>>n;
	set<int>st;
	vector<int>v;
	for(int i=1;i<10;i++){
		st.insert(i);
		v.push_back(i);
	}
	const int N=1e5+5;
	while(v.size()<N){
		int tt = *st.begin();
		st.erase(tt);

		int rem= tt%10;
		int a = tt*10+rem;
		v.push_back(a);
		st.insert(a);
		if(rem<9){
			a = tt*10 +(rem+1);
			st.insert(a);
			v.push_back(a);
		}
		if(rem>0){
			a = tt*10 +(rem-1);
			st.insert(a);
			v.push_back(a);
		}
	}
	sort(v.begin(),v.end());
	cout<<v[n-1]<<endl;
}           

Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 998244353;
const int maxn = 1e6 + 233;
int p[maxn],u[maxn],vis[maxn],cnt=0;
void init(){
	memset(vis,0,sizeof(vis));
	int n = 1e6;
	u[1] = 1;
	for(int i=2;i<=n;i++){
		if(!vis[i]){p[++cnt] = i;u[i] = -1;}
		for(int j=1;j<=cnt&&i*p[j]<=n;j++){
			if(i%p[j]==0){
				u[i*p[j]] = 0;
				vis[i*p[j]] = 1;
				break;
			}
			else{
				u[i*p[j]] = -u[i];
				vis[i*p[j]] = 1; 
			} 
		}
	}
//	for(int i=1;i<=30;i++)
//		cout<<i<<": "<<u[i]<<" "<<vis[i]<<endl;
	return ;
}
char s[maxn];
int a[maxn];
ll f[maxn];
ll ans = 0;
int main()
{
 	ios::sync_with_stdio(false);
	int n;cin>>n;
	cin>>s;
	for(int i=0;i<n;i++)a[i] = s[i]-'0';
//	for(int i=0;i<n;i++)cout<<a[i];cout<<endl;
	for(int x=1;x<=2*n;x++)
		if((2*n)%x==0&&n%x){
			ll sum = 0,cur = 0;
			bool bad = 0;
			for(int i=0;i<x/2;i++)
				cur = (cur*2+a[i])%mod;
			sum = cur;
			for(int i=0;i<n;i++){
				int t = a[i%(x/2)];
				if((i%x)>=x/2)t ^= 1;
//				cout<<"->"<<i<<" "<<a[i]<<" "<<t<<endl;
				if(t<a[i])break;
				if(t>a[i])bad = 1;
			}
			if(!bad)sum++;
//			cout<<"!"<<x<<" "<<sum<<endl;
			f[x] = (f[x]+sum+mod)%mod;
			ans = (ans+1LL*f[x]*x%mod)%mod;
			for(int i=x+x;i<=2*n;i+=x)
				f[i] = (f[i]+mod-f[x])%mod;
		}
//	for(int x=1;x<=2*n;x++)
//		if((2*n)%x==0&&n%x)
//			ans = (ans+f[x]*x)%mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10496
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            System.out.println("ABC" + br.readLine());

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21204
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;
 
int main()
{
    int n, k;
    cin >> n >> k;
 
    if(n % k == 0)
        cout << 0 << endl;
    else
        cout << 1 << endl;
 
    return 0;
}

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

using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define all(c) c.begin(),c.end()
#define lbd(a,val) lower_bound(all(a),val)
#define ubd(a,val) upper_bound(all(a),val)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define en '\n'
int main()
{
IOS;
int t=1;
//cin>>t;
while(t--)
{
ll n,k;
cin>>n>>k;
ll a,b,c;
ll ans=0;
if(k%2==0)
{
k/=2;
k=n/k;
ll p;
if(k%2==0)
p=k/2;
else
p=k/2+1;
ll q=k-p;
cout<<p*p*p+q*q*q;
}
else
{
k=n/k;
cout<<k*k*k;
}
}
}

Measured memory_bytes: 256
N = int(input())
s = [0 for i in range(N)]
for i in range(N):
    s[i] = input()
count = 0
Aowari = 0
Bhazimari = 0
ABtomoni = 0
for i in range(N):
    count += s[i].count('AB')
    if s[i][-1] == 'A' and s[i][0] == 'B':
        ABtomoni += 1
    elif s[i][-1] == 'A':
        Aowari += 1
    elif s[i][0] == 'B':
        Bhazimari += 1
if ABtomoni > 0:
    if Aowari >0 and Bhazimari >0:
        count += ABtomoni+1
        Aowari -= 1
        Bhazimari -= 1
    elif Aowari > 0 and Bhazimari == 0:
        count += ABtomoni
        Aowari -= 1
    elif Aowari == 0 and Bhazimari > 0:
        count += ABtomoni
        Bhazimari -= 1
    elif Aowari == 0 and Bhazimari == 0:
        count += ABtomoni-1
count += min(Aowari, Bhazimari)
print(count)


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

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=1000005;
//i_am_noob
int n,a[maxn],lpd[maxn],x,y;
bool flag=false;
set<int> st;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    rep(maxn) lpd[i]=-1;
    rep2(i,2,maxn){
        if(lpd[i]==-1){
            lpd[i]=i;
            for(int j=i*i; j<maxn; j+=i) if(lpd[j]==-1) lpd[j]=i;
        }
    }
    rep(n) cin >> a[i];
    rep(n){
        x=a[i];
        while(x>1){
            y=lpd[x];
            if(st.count(y)){
                flag=true;
                break;
            }
            st.insert(y);
            while(x%y==0) x/=y;
        }
        if(flag) break;
    }
    if(!flag){
        print1("pairwise coprime");
        return 0;
    }
    x=0;
    rep(n) x=__gcd(x,a[i]);
    if(x==1){
        print1("setwise coprime");
        return 0;
    }
    print1("not coprime");
    return 0;
}


Measured memory_bytes: 19268
#include<cstdio>
#include<vector>
struct SegmentT{
    int l,r;
    int d;
    SegmentT(){
        d = 0;
    }
};
SegmentT t[1200005];
std::vector<int>point[300005];
int row[300005];

int max(int a,int b){ return a>b?a:b; }

SegmentT merge(SegmentT& u,SegmentT& v){
    SegmentT res;
    res.l = u.l, res.r = v.r;
    res.d = max(u.d,v.d);
    return res;
} 

void build(int p,int l,int r){
    t[p].l = l, t[p].r = r;
    if(l==r){
        t[p].d = 0;
    }
    else{
        int m = (l+r)/2;
        build(2*p,l,m);
        build(2*p+1,m+1,r);
        t[p] = merge(t[2*p],t[2*p+1]);
    }
}

void change(int p,int x,int v){
    if(t[p].l==t[p].r){
        t[p].d += v;
    }
    else{
        int m = (t[p].l+t[p].r)/2;
        if(x<=m) change(2*p,x,v);
        else change(2*p+1,x,v);
        t[p] = merge(t[2*p],t[2*p+1]);
    }
}

int main(){
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    build(1,1,w);
    for(int i = 1; i <= n; i++){
        int x,y;
        scanf("%d%d",&x,&y);
        row[x]++;
        point[x].push_back(y);
        change(1,y,1);
    }
    int ans = 0;
    for(int i = 1; i <= h; i++){
        for(int y: point[i]) change(1,y,-1);
        int cur = row[i]+t[1].d;
        if(cur>ans) ans = cur;
        for(int y: point[i]) change(1,y,1);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 34844
#include<bits/stdc++.h>
typedef long long ll;
const int mod=998244353;
const int maxn=1e5+5;
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
int main()
{ 
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
    	c=c-b;
    	if(c<=0){
    	cout<<"Yes"<<endl;
		break;	
		}
    	a=a-d;
    	if(a<=0)
		{
		cout<<"No"<<endl;
		break;	
		}
	}
	return 0;
 } 

Measured memory_bytes: 3652
import java.util.*

fun main(args:Array<String>){
    val s = readLine()!!
    for(i in 0 until s.length - 1){
        if(s[i] == s[i + 1]){
            println((i + 1).toString() + " " + (i + 2).toString())
            return
        }
    }
    for(i in 0 until s.length - 2){
        if(s[i] == s[i + 2]){
            println((i + 1).toString() + " " + (i + 3).toString())
            return
        }
    }
    println("-1 -1")
}


Measured memory_bytes: 33604
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	string ss;
	cin >> ss;
	cout << ss[0] << ss[1] << ss[2] << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    string s;
    cin>>n>>s;
    if(n>=3200){
        cout<<s;
    }    
    else{
        cout<<"red";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int m,d,k,sum;
int main()
{
	cin>>m>>d;
	for(int i=1;i<=m;i++)
	{
		for(int j=22;j<=d;j++)
		{
            int d1=j/10;
            int d10=j%10;
            if(d1*d10==i&&d10>=2&&d1>=2)
            {
                 sum++;
                 //cout<<sum<<' '<<i<<' '<<j<<endl;
            }
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var K = parseInt(input[0].split(" ")[1]);
  var a = input[1].split(" ").map(i => parseInt(i));
  var dp = new Array(N+1);
  var mod=Math.pow(10,9)+7;
  for(var i=0;i<N+1;i++){
    var tmp=new Array(K+1).fill(0);
    dp[i]=tmp;
  }
  dp[0][0]=1;
  for(var i=0;i<N;i++){
    var sum=0;
    for(var j=0;j<K+1;j++){
      sum+=dp[i][j];
      sum%=mod;
      if(j>a[i]){
        sum+=mod-dp[i][j-a[i]-1];
        sum%=mod;
      }
      dp[i+1][j]=sum;
    }
  }
  var ans=dp[N][K];
  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 113968
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	while (N) {
		vector<string>s(N);
		for (auto &i : s) {
			cin >> i;
			while (i.size() < 10) {
				i.push_back('z' + 1);
			}
		}
		vector<vector<int>>edge(27, vector<int>(27));
		for (int i = 0; i < 26; i++)edge[26][i] = 1;
		for (int i = 1; i < N; i++) {
			for (int j = 0; j < min(s[i - 1].size(), s[i].size()); j++) {
				if (s[i][j] != s[i - 1][j]) {
					edge[s[i - 1][j] - 'a'][s[i][j] - 'a'] = 1;
					break;
				}
			}
		}
		bool flag = true;
		for (int i = 0; i < 27; i++) {
			vector<int>to(27);
			queue<int>Q;
			Q.push(i);
			while (!Q.empty()) {
				int cn = Q.front();
				Q.pop();
				for (int j = 0; j < 27; j++) {
					if (edge[cn][j]) {
						if (!to[j]) {
							to[j] = 1;
							Q.push(j);
						}
					}
				}
			}
			if (to[i])flag = false;
		}
		if (flag)cout << "yes\n";
		else cout << "no\n";
		cin >> N;
	}

}


Measured memory_bytes: 3128
import itertools

n=int(input())
li=[list(map(int,input().split())) for _ in range(n)]
ans,div=[],0

for i in itertools.permutations(range(n),n):
  div+=1
  dis=0
  for a,b in zip(i,i[1:]):
    dis += ((li[b][0]-li[a][0])**2 + (li[b][1]-li[a][1])**2)**0.5
  ans.append(dis)

print(sum(ans)/div)

Measured memory_bytes: 4504
import sys
from bisect import bisect
def input():
	return sys.stdin.buffer.readline()[:-1]

MOD = 998244353
n = int(input())
r = []
for _ in range(n):
	x, d = map(int, input().split())
	r.append((-x, -x-d))
r.sort()

INF = 10**30

class Rmin():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1
		while self.n < size:
			self.n *= 2
		self.node = [INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)//2
			self.node[x] = min(self.node[2*x+1], self.node[2*x+2])
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = INF
		while L<R:
			if R & 1:
				R -= 1
				s = min(s, self.node[R-1])
			if L & 1:
				s = min(s, self.node[L-1])
				L += 1
			L >>= 1
			R >>= 1
		return s

leftmost = Rmin(n)

wait = [r[0][0]]
dp = [[0 for _ in range(2)] for _ in range(n)]#0: いない 1: いる
dp[0] = [1, 1]
leftmost.Update(0, 0)

for i in range(1, n):
	dp[i][1] = (dp[i-1][0] + dp[i-1][1]) % MOD	
	if r[i][1] < wait[-1]:
		b = bisect(wait, r[i][1])
		mi = leftmost.Get(b, i)
		dp[i][0] = dp[mi][0]
		leftmost.Update(i, mi)
	else:
		dp[i][0] = dp[i][1]
		leftmost.Update(i, i)
	wait.append(r[i][0])

print((dp[n-1][0] + dp[n-1][1]) % MOD)

Measured memory_bytes: 125532
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
int main(){
  int x,n,L,i;
  vector<int> l(n);
  cin >> n >> x;
  while(cin >> L){
    l[i]=L;
    i++;
  }
  int count,d;
  rep(i,n){
    d+=l[i];
    count++;
    if(d>x) break;
  }
  cout << count <<endl;
}

Measured memory_bytes: 17148
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 998244353;

using namespace std;

int main() {
  int n;
  cin >> n;
  ll d[n];
  ll ma = 0;
  REP(i, n) {
    cin >> d[i];
    ma = max(ma, d[i]);
  }

  map<ll, ll> m;
  REP(i, n) { m[d[i]]++; }

  if (m[0] >= 2) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = (d[0] == 0 ? 1 : 0);
  FOR(i, 1, ma + 1) {
    REP(j, m[i]) { ans = (ans * m[i - 1]) % MOD; }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7296
function dig(n)
	k = 0
	while 10^k <= n
		k += 1
	end
	k
end

function main()
	n = parse(Int, readline())
	if n == 1
		println(1)
	else
		k = 2
		s = Int[]
		while k <= sqrt(n)
			if n % k == 0
				push!(s,k)
			end
			k += 1
		end
		if length(s) == 0
			print(dig(n))
		else
			maxman = s[length(s)]
			print(max(dig(maxman),dig(div(n,maxman))))
		end
	end
end

main()

Measured memory_bytes: 166180
#include <iostream>
#include <algorithm>
#define MAX 100
using namespace std;

int main(){
	int n;
	int total = 100000;
	
	cin >> n;
	
	for(int i = n; i > 0; i--){
	total = total + (0.05 * total);
	if(total % 1000 != 0){
		total = total - (total % 1000);
		total = total + 1000;
	}
	}
	cout << total << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    ll N;cin>>N;
    ll a[110];
    vector<ll> b(110);
    rep(i,0,N){
        cin>>b.at(i);
        if(i+1<b.at(i)){
            cout<<-1<<endl;
            return 0;
        }
    }
    rep(n,0,N){
        for(int i=N-1-n;i>=0;i--){
            if(b.at(i)==i+1){
                a[N-1-n]=b.at(i);
                b.erase(b.begin()+i);
                break;
            }
        }
    }
    rep(i,0,N){
        cout<<a[i]<<endl;
    }
    
}






Measured memory_bytes: 256
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[] temp = new int[2001];
        int[] ans = new int[4001];
        
        for(int i=0;i<=1000;i++){
        	for(int j=0;j<=1000;j++){
        		temp[i+j]++;
        	}
        }
        for(int i=0;i<=2000;i++){
        	for(int j=0;j<=2000;j++){
        		ans[i+j]+=temp[i]*temp[j]; 
        	}
        }
        
        while(sc.hasNext()){
        	int n = sc.nextInt();
        	System.out.println(ans[n]);
        }
    }
}

Measured memory_bytes: 20632
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (3000L)

using namespace std;

// dpsss[l][r][p] : The score X - Y that is realized when [l, r] is remaining
//                  and it is player p's turn
long dpsss[MAX_N][MAX_N][2];
long us[MAX_N][MAX_N];

void init(long N) {
  for (long l = 0; l < N; l++) {
    for (long r = l; r < N; r++) {
      us[l][r] = 0;
    }
  }
}

long calc_score(const long *as, long N, long l, long r, long p) {
  if (r < l) {
    return 0;
  }
  if (!us[l][r]) {
    dpsss[l][r][0] = max(as[l] + calc_score(as, N, l + 1, r, 1),
                         as[r] + calc_score(as, N, l, r - 1, 1));
    dpsss[l][r][1] = min(-as[l] + calc_score(as, N, l + 1, r, 0),
                         -as[r] + calc_score(as, N, l, r - 1, 0));
    us[l][r] = 1;
  }
  return dpsss[l][r][p];
}

int main() {
  // read inputs
  long N, as[MAX_N];
  scanf("%ld", &N);
  for (long i = 0; i < N; i++) {
    scanf("%ld", &as[i]);
  }

  // solve dp
  printf("%ld\n", calc_score(as, N, 0, N - 1, 0));
}

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

int main(){
  int n, x;
  cin >> n >> x;
  int sum = 0;
  int ans = 1;
  rep(i, n){
    int l;
    cin >> l;
    sum += l;
    if (sum > x) break;
    ans++;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include<algorithm>
#include<stdio.h>
#include<map>
#include<math.h>
#include<stdlib.h>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int a,b;
    
    cin >> a>>b;
    
    if((a + b) == 15){
        cout << "+";
    }else if((a * b) == 15){
        cout << "*";
    }else{
        cout <<"x";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll l, r;
    cin >> l >> r;
    ll i = (l + 2018LL) / 2019LL * 2019LL;
    if (i <= r)
        return cout << 0, 0;
    ll ans = LLONG_MAX;
    ll u = min(r + 1, l + 2019);
    fori(j, l, u) fori(k, j + 1, u) ans = min(ans, (((j % 2019LL) * (k % 2019LL)) % 2019LL));
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MN=110,MV=1e5+10,INF=0x3f3f3f3f;
int n,w,ans;
ll dp[MV];
typedef pair<int,int> P;
P a[MN];
int main()
{
    scanf("%d%d",&n,&w);
    for(int i=0;i<n;i++)
        scanf("%d%d",&a[i].first,&a[i].second);
    memset(dp,INF,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<n;i++)
        for(int j=MV;j>=0;j--)
            if(dp[j]+a[i].first<=w)
            {
                dp[j+a[i].second]=min(dp[j+a[i].second],dp[j]+a[i].first);
                ans=max(ans,j+a[i].second);
            }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < n; i++)

const ll INF = 1LL << 60;


signed main() {

	ll n;
	cin >> n;

	vector<ll>a(n);

	rep(i, n)cin >> a[i];
	sort(a.begin(), a.end());
	ll ans = 0;
	rep(i, n - 2) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] < a[j] + a[k] && a[j] < a[i] + a[k] && a[k] < a[i] + a[j]) {
					ans++;
				}
				else {
					break;
				}
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i + 1
us, vs = 0, sum(a)
uc, vc = 0, n
a.sort()
ans = vs - a[0] * n
for i in range(n):
    us += a[i]
    uc += 1
    vs -= a[i]
    vc -= 1
    b = a[i]
    ans = min(ans, uc * b - us + vs - vc * b)
print(ans)

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

#define ll long long

int main()
{
    ll i, n, x, y, ans, d;
    double dist;

    cin >> n >> d;
    ans=0;
    for(i=0; i<n; i+=1)
    {
        cin >> x >> y;
        dist=sqrt(x*x + y*y);

        if(dist<=d)
            ans+=1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string S,T;
    cin >> S;
    cin >> T;
    if(S == T.substr(0,S.size()) && T.size() == S.size()+1) cout << "Yes" << endl;
    else cout << "No" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<iostream>
using namespace std;
const int MaxN = 1e5 + 5;
char a[MaxN];
int main()
{
	int m;
	long long k;
	cin >> a;
	scanf("%lld", &k);
	long long len = strlen(a);
	long long j = len - 1;
	for(int i = 0; i < len - 1; i++) {
		if(a[i] == 'a') m = 0;
		else m = 'z' - a[i] + 1;
		k = k - m;
		if(k >= 0) a[i] = 'a';
		else k = k + m;
	}  
	k = k % 26; 
	if( k + a[j] > 'z') a[j] = a[j] - 26 + k;
	else a[j] = k + a[j];
	cout << a << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int grid[100][100];
int H, W;

void dfs(int x, int y) {
  int mx[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
  int my[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
  for (int i = 0; i < 8; i++) {
    int _x = x + mx[i];
    int _y = y + my[i];
    if (grid[_x][_y] == 1 && _x >= 0 && _y >= 0 && _x < W && _y < H) {
      grid[_x][_y] = 0;
      dfs(_x, _y);
    }
  }
}

signed main() {
  while (cin >> W >> H, W+H!=0) {
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        cin >> grid[j][i];
      }
    }
 
    int ans = 0; 
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (grid[j][i] == 1) {
          dfs(j,i);
          ans++;
        }
      }
    }

    cout << ans << endl;
  }
}



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

int main()
{
  int a,b;
  cin >> a >> b;
  cout << (a- 1) * (b-1) << endl;
  return 0;
}


Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
s = input()
s = s[::-1]
MOD = 10**9+7
mod13_map = [[i for i in range(13)]]
ma = mod13_map.append
for i in range(1,10**5):
    next_digit = list(map(lambda x:x*10%13,mod13_map[i-1]))
    ma(next_digit)

ret = [1] + [0] * 12 #13で割ってi余る数の合計
for i,v in enumerate(s):
    if v!="?":
        #mod13_map[i][v]だけ、右にシフト
        ret *= 2
        sft = mod13_map[i][int(v)]
        ret = ret[13-sft:26-sft]
    else:
        temp_ret = [0] * 13
        for j in range(10):
            #?がjの場合
            for k,l in enumerate(ret):
                temp_ret[(k+mod13_map[i][j])%13]+=l
        temp_ret = list(map(lambda x:x%MOD,temp_ret))
        ret = temp_ret
print(ret[5]%MOD)


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


int main (){

    string S;
    cin >> S;

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

    for(int i = 0; i < S.size()-1; i++) {
        if(S[i] == S[i+1]) {
            cout << "no" << endl;
            return 0;
        }
    }

    cout << "yes" << endl;

    return 0;
}


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

int n;
double sum = 0.00;

int main(){
	scanf("%d", &n);
	rep(i, n){
		int now;
		scanf("%d", &now);
		sum += (1.00 / (double)(now));
	}
	cout << fixed << setprecision(12) << (1.00 / sum) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
//ll lin(){ll x;scanf("%d",&x);return x;}
int main(){
    int n=in();
    vector<double> v(n);
    rep(i,n){
        double d;
        cin>>d;
        v[i]=d;
    }
    sort(All(v));
    double tmp=v[0];
    rep(i,n-1){
        tmp=(tmp+v[i+1])/2;
    }
    cout<<tmp<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

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

bool iswhite(char c)
{
    return (c == 'W' || c == 'w');
}

bool isblack(char c)
{
    return (c == 'B' || c == 'b');
}

void expand(char a[51][51])
{
    bool ischanged = false;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == '.') continue;
            for(int k = 0; k < 4; k++){
                int nx = i + dx[k], ny = j + dy[k];
                if(nx < 0 || nx >= h || ny < 0 || ny >= w || a[nx][ny] == 'B' || a[nx][ny] == 'W') continue;
                if(iswhite(a[i][j])){
                    if(a[nx][ny] == '.') a[nx][ny] = 'w';
                    else if(isblack(a[nx][ny])) a[nx][ny] = 'X';
                    else continue;
                } else if(isblack(a[i][j])){
                    if(a[nx][ny] == '.') a[nx][ny] = 'b';
                    else if(iswhite(a[nx][ny])) a[nx][ny] = 'X';
                    else continue;
                } else {
                    if(a[nx][ny] == '.' || a[nx][ny] == 'w' || a[nx][ny] == 'b') a[nx][ny] = 'X';
                    else continue;
                }
                ischanged = true;
            }
        }
    }
    if(ischanged) expand(a);
    else return;
}

void solve(char a[51][51])
{
    expand(a);
    int wnum = 0, bnum = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == 'w') wnum++;
            else if(a[i][j] == 'b') bnum++;
            // cout << a[i][j];
        }
        // cout << endl;
    }
    cout << bnum << " " << wnum << endl;
    return;
}

int main()
{
    while(1){
        cin >> w >> h;
        if(w == 0 && h == 0) break;
        char a[51][51];
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> a[i][j];
            }
        }
        solve(a);
    }
    return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int v[51];
    rep(i, N) cin >> v[i];
    sort(v, v + N);
    double ans = v[0];
    rep(i, N - 1) {
        ans = (ans + v[i + 1]) / 2.0;
    }
    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}


Measured memory_bytes: 256
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line().split_whitespace().map(|s| s.to_string()).collect()
    }

    pub struct Reader {
        buf: VecDeque<String>
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader {buf: VecDeque::new()}
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T where T: FromStr, T::Err: Debug {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }

        pub fn nextN<T>(&mut self, n: usize) -> Vec<T> where T: FromStr, T::Err: Debug {
            let mut vec: Vec<T> = Vec::with_capacity(n);
            for i in 0..n {
                vec.push(self.next());
            }
            vec
        }
    }
}

mod data {
    pub struct UnionFind {
        root : Vec<usize>
    }

    impl UnionFind {
        pub fn new(size : usize) -> UnionFind {
            UnionFind {root : (0..size).collect()}
        }

        pub fn find(&mut self, x : usize) -> usize {
            let xroot = self.root[x];
            if x != xroot {
                self.root[x] = self.find(xroot);
            }
            self.root[x]
        }

        pub fn unite(&mut self, x : usize, y : usize) {
            let xroot = self.find(x);
            self.root[xroot] = self.find(y);
        }

        pub fn same(&mut self, x : usize, y : usize) -> bool {
            self.find(x) == self.find(y)
        }
    }
}

fn with_large_stack(func : fn() -> ()) {
    use std::thread::Builder;
    let builder = Builder::new();
    let th = builder.stack_size(10000000);

    th.spawn(move || {
        func();
    }).unwrap().join();
}

fn main() {
    with_large_stack(_main);
}

fn _main() {
    let mut reader = reader::Reader::new();

    let n = reader.next();
    let a = reader.nextN::<i32>(n);

    println!("{}", a.iter().max().unwrap() - a.iter().min().unwrap());
}

Measured memory_bytes: 8572
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked

int inp() {
	int x = 0, f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

ll inp_ll() {
	ll x = 0; int f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

template<class T>
bool read(T &x)
{
	x = 0;
	char ch = getchar();
	if (ch == EOF) return 0;
	for(; !isdigit(ch); )
	{
		ch = getchar();
		if (ch == EOF) return 0;
	}
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return 1;
}

template<class T>
void write(T x)
{
	static char s[22];
	static char *it = s+20;
	static char *end = s+20;
	if (!x)
		*-- it = '0';
	while (x)
	{
		*-- it = x%10+'0';
		x /= 10;
	}
	for (; it < end; ++ it)
		putchar(*it);
}

template<class T>
void writeln(T x)
{
	write(x);
	putchar('\n');
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 5010;

int main()
{
	
	int n;
	cin >> n;
	cout << 3*n*n << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
ll S(ll x)//sum of the digits of s
{
	int r=0;
	while(x)
		r+=x%10,x/=10;
	return r;
}
int main()
{
	ll K;
	cin>>K;
	ll cur = 2,p = 1;
	while(K)
	{
		ll n = cur * p - 1;
		ll m = ceil((double)cur/10.0) * p * 10 - 1;
		if(n * S(m) > m * S(n))
		{
			cur = ceil((double)cur/10.0);
			p *= 10;
		}
		else
		{
			cout<<n<<endl;
			K--;
			cur++;
		}
		// printf("cur = %lld,p = %lld\n",cur,p);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();

        out.println(H*W - W*h - H*w + w*h);
    }
}


Measured memory_bytes: 24020
from collections import deque
# input() reads a string with a line of input, stripping the '\n' (newline) at the end.
# This is all you need for most Kickstart problems.
#t = int(input())  # read a line with a single integer
for i in range(1, 2):
  s, w = [int(s) for s in input().split(" ")]  # read a list of integers, 2 in this case
  #print("Case #{}: {} {}".format(i, n + m, n * m))
  # check out .format's specification for more form1atting options
def test_cae():
  if w > s or  w==s:
    print("unsafe")
  else:
    print("safe")


test_cae()


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define INF 1e18
ll N,K;
ll A[202020];
ll dp[202020][5];
ll i, j, k,ans;

int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    fornum(i,0,N+8){
        fornum(j,0,4){
            dp[i][j] = -INF;
        }
    }
    if(N%2==0){
        dp[0][1] = 0;
    }else{
        dp[0][2] = 0;
    }
    fornum(i,0,N){
        fornum(j,0,3){
            dp[i + 2][j] = max(dp[i + 2][j], dp[i][j] + A[i]);
            if(j>0){
                dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j]);
            }
        }
    }
    printf("%lld\n", max(dp[N - 1][2], max(dp[N][1], dp[N + 1][0])));

    return 0;
}

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

int main() {
  int ans = 0;
  char temp;
  string s;

  cin >> s;
  temp = s[0];

  for (int i = 1; i < s.size(); i++) {
    if (s[i] != temp) {
      ans++;
      temp = s[i];
    }
  }

  cout << ans;

  return 0;
}

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

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

    int num = atoi(S.c_str());

    int num1 = num / 100;
    int num2 = num % 100;

    int num1check;
    int num2check;

    /*
    1~12ならM    2
    ０以外ならY   1
    その他         ０
    */

    if(num1 > 0 && num1 < 13){
        num1check = 2;
    }else{
        num1check = 0;
    }

    if(num2 > 0 && num2 < 13){
        num2check = 2;
    }else{
        num2check = 0;
    }

    if(num1check == 2 && num2check == 2){
        cout << "AMBIGUOUS" << endl;
    }else if(num1check == 2){
        cout << "MMYY" << endl;
    }else if(num2check == 2){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }


    return 0;
}

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

/* clang-format off */
// #define int long long
// #define double long double
struct Fast {Fast() {cin.tie(0); ios::sync_with_stdio(false);}} fast;

template <typename T> inline size_t maxElement(T beginIt, T endIt) { return max_element(beginIt, endIt); }
template <typename T> inline size_t minElement(T beginIt, T endIt) { return min_element(beginIt, endIt); }
template <typename T> inline size_t maxIndex(T beginIt, T endIt) { return distance(beginIt, *max_element(beginIt, endIt)); }
template <typename T> inline size_t minIndex(T beginIt, T endIt) { return distance(beginIt, *min_element(beginIt, endIt)); }
template <typename T> inline int sum(T beginIt, T endIt) { return accumulate(beginIt, endIt, 0); }
template <typename T> inline int mean(T beginIt, T endIt) { return sum(beginIt, endIt) / distance(beginIt, endIt); }
template <typename T> inline void debug(T x) { cerr << x << " " << "(L:" << __LINE__ << ")" << endl; }
/* clang-format on */

signed main(void) {
  /* */
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  // double num; // num
  // num = 0; // count, result
  // num = numeric_limits<double>::min(); // max
  // num = numeric_limits<double>::max(); // min
  int N, M;
  array<int, 100000> A;
  string S, T;
  /* */

  cin >> S;
  cin >> T;
  for (int i = 0; i < S.length(); ++i) {
    if (S == T) {
      cout << "Yes" << endl;
      return 0;
    }
    S = S.back() + S.substr(0, S.length() - 1);
  }

  cout << "No" << endl;
  // cout << num << endl;
  // cout << fixed << setprecision(10) << num << endl;
  return 0;
}


Measured memory_bytes: 256