akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] map = new int[N * 2];
		for (int i = 0; i < N * 2; i++) {
			map[i] = sc.nextInt();
		}
		
		Arrays.sort(map);
		
		int max = 0;
		for (int i = 0; i < N * 2; i+=2) {
			max += Math.min(map[i], map[i + 1]);
		}
		
		System.out.println(max);
		
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int a[13]={-1,31,29,31,30,31,30,31,31,30,31,30,31},x,y;
int main()
{
	cin>>x>>y;
	if(a[x]==a[y])cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll> x(n);
    rep(i,n) cin>>x.at(i);
    
    ll ans=0;
    rep(i,n-1){
        ll d=x.at(i+1)-x.at(i);
        ans+=min(b,d*a);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
int main(void){
  puts("1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1");
}

Measured memory_bytes: 1504
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int N;
string s;
int dp[512345][4];

int main() {
	cin >> N >> s;
	
	REP(i, s.size()) s[i] -= '0';
	
	vector<pii> v; // 0-0, 1-1, 0-0, ...
	int p = 0, c = 0;
	while (p < N) {
		int type = s[p];
		int c = 0;
		while (p < N && s[p] == type) c++, p++;
		v.push_back(pii(type, c));
	}
	
	int prevone = 0;
	p = 0;
	while (p < v.size()) {
		if (v[p].fi == 1) {
			prevone = v[p++].se;
			continue;
		}
		
		int nextone = 0;
		if (p < v.size() - 1) nextone = v[p + 1].se;
		
		REP(i, 4) chmax(dp[p + 2][0], dp[p][i]);
		
		if (v[p].se == 1) {
			if (nextone > 0 && prevone > 0) {
				chmax(dp[p + 2][1], dp[p][0] + prevone);
				if (prevone > 1) chmax(dp[p + 2][1], dp[p][1] + prevone - 1);
				chmax(dp[p + 2][1], dp[p][3] + 1);
				
				chmax(dp[p + 2][2], dp[p][0] + nextone);
				if (prevone > 1) chmax(dp[p + 2][2], dp[p][1] + nextone);
				chmax(dp[p + 2][2], dp[p][3] + nextone);
				
				chmax(dp[p + 2][3], dp[p][0] + nextone - 1);
				if (prevone > 1) chmax(dp[p + 2][3], dp[p][1] + nextone - 1);
				chmax(dp[p + 2][3], dp[p][3] + nextone - 1);
			}
		}
			
		prevone = nextone;
		p += 2;
	}
	
	int ans = 0;
	REP(i, 4) chmax(ans, dp[p][i]);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
int main(){

	long long a;
	cin>>a;
	long long ar[a];
	for(int i=0;i<a;i++){
		cin>>ar[i];
	}
	sort(ar,ar+a);
	reverse(ar,ar+a);
	long long sum=0;
	for(int i=0;i<a;i++){
		if(i%2==0){
			sum+=ar[i];
		}
		else{
			sum-=ar[i];
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define d(x) ((x)*(x))

int main(){
	int n,s[3];
	scanf("%d",&n);
	for(;n>0;n--){
		scanf("%d %d %d",&s[0],&s[1],&s[2]);
		if( (d(s[0])+d(s[1]) == d(s[2]))||
			(d(s[0])+d(s[2]) == d(s[1]))||
			(d(s[1])+d(s[2]) == d(s[0])) ){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int dp[3010][3010];

int main()
{
	ios::sync_with_stdio(false);	
	cin.tie(0);
	
	string s,t;
	cin>>s>>t;
	
	for(int i=1;i<=s.size();i++)
		for(int j=1;j<=t.size();j++)
			if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j], dp[i][j-1]);
	
	string res="";	
	int i=s.size();
	int j=t.size();	
	while(i!=0 && j!=0)
	{
		if(s[i-1]==t[j-1])
			res+=s[i-1], i--, j--;
		else
		{
			if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
	}
	
	
	for(int i=res.size()-1;i>=0;i--)
		cout<<res[i];
	
	
	return 0;
}


Measured memory_bytes: 35584
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

int v[(1<<18)+7];
int w[(1<<18)+7];
int dp[(1<<9)+13][111111];

void solve()
{
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> v[i] >> w[i];

  memset(dp,0,sizeof(dp));

  int C = 9;
  int L = 1e5;

  for (int i = 1; i <= min(n,(1<<C)-1); i++)
  {
    dp[i][0] = 0;
    if (i > 1)
    {
      for (int j = 0; j <= L; j++)
      {
        dp[i][j] = max(dp[i][j],dp[i/2][j]);
      }
    }
    dp[i][w[i]] = max(dp[i][w[i]],v[i]);
    if (i > 1)
    {
      for (int j = 0; j <= L; j++)
      {
        if (j+w[i] <= L)
          dp[i][j+w[i]] = max(dp[i][j+w[i]],dp[i/2][j]+v[i]);
      }
    }
    for (int j = 1; j <= L; j++)
    {
      dp[i][j] = max(dp[i][j],dp[i][j-1]);
    }
  }

  int q;
  cin >> q;
  while(q--)
  {
    int u, tot;
    cin >> u >> tot;
    vpii extras;
    while (u > (1<<C)-1)
    {
      extras.pb({v[u],w[u]});
      u >>= 1;
    }

    int ans = 0;
    for (int i = 0; i < (1<<extras.size()); i++)
    {
      int totw = 0, totv = 0;
      for (int j = 0; j < extras.size(); j++)
      {
        if (i&(1<<j))
        {
          totw += extras[j].s;
          totv += extras[j].f;
        }
      }
      if (totw <= tot)
      {
        ans = max(ans,totv+dp[u][tot-totw]);
      }
    }
    cout << ans << endl;
  }


}

int main()
{
  ios_base::sync_with_stdio(false);
  // Remove for interactive problems
  //cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
  {
      solve();
  }
}



Measured memory_bytes: 233516
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        int c = (n*(n-1))/2;
        int d = (m*(m-1))/2;

        System.out.println(c+d);

    }
}



Measured memory_bytes: 35660
//ABC 052-D
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	int Town;
	long  Teleport, Distance[100000], Walk, ans = 0;
	cin >> Town >> Walk >> Teleport >> Distance[0];

	for (int i = 1; i < Town; i++) {
		cin >> Distance[i];
		ans += min(Teleport,Walk*(Distance[i] - Distance[i - 1]));
	}
	cout << ans << endl;
}



Measured memory_bytes: 1024
import java.util.Scanner;
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 = b - a - 1;
		int x = 1;
		int anc = 0;
		for(int i = 0;i<c;i++) {
			anc = anc + x;
			x++;
		}
		System.out.print(anc - a);;
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
#define endl '\n'

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 998244353;

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n, -1){}
    bool unite(int x, int y) {
        if ((x = root(x)) != (y = root(y))){
            if (d[y] < d[x]) swap(x, y);
            d[x] += d[y]; d[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y){return root(x) == root(y);}
    int root(int x){return d[x] < 0 ? x : d[x] = root(d[x]);}
    int size(int x=-1) {return x<0 ? d.size() : -d[root(x)];}
};

int T, n, m;

int solve() {
    vector<pii> p, a, b;
    REP(i, n) {
        int x;
        cin >> x;
        a.emplace_back(x, i);
    }
    REP(i, n) {
        int x;
        cin >> x;
        b.emplace_back(x, i);
    }
    sort(ALL(a));
    sort(ALL(b));
    UnionFind uf(n);
    int req = 0;
    REP(i, n) {
        if (a[i].first > b[i].first) return 0;
        req += uf.unite(a[i].second, b[i].second);
    }
    REP(i, n - 1) {
        if (a[i + 1].first <= b[i].first) return 1;
    }
    return req <= n - 2;
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n){
        cout << (solve() ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 2548
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<vector>

using namespace std;

#define INF (1<<30)
#define ll long long

	ll dp[1000100][2];//前でやったか？
		ll a[1000100];

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

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

	fill_n(*dp,1000100*2,-INF);
	for(int d = n;d != -1;d--){
		for(int before = 0;before < 2;before++){
			if(d == n){
				dp[d][before] = 0;
			}else{
				ll now = a[d];
				if(before == 1)now*=-1;
				dp[d][before] = dp[d+1][0]+now;
				if(d != n-1){
					dp[d][before] = max(dp[d][before], dp[d+1][1]+(now*(-1)));
				}
			}
		}
	}
	cout << dp[0][0] << endl;
}

Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 2e5 + 5;

int n, m, a, b, now, maxim;
int mark[N], freq[N];
bool vis[N];
vt<int> v[N];

void DFS(int x) {
    if(vis[x]) return;
    // cout << "DFS(" << x << ")\n";
    vis[x] = true;
    mark[x] = now;
    for(int u : v[x]) {
        DFS(u);
    }
}

void solve() {
    cin >> n >> m;
    while(m--) {
        cin >> a >> b;
        v[a].pb(b);
        v[b].pb(a);
    }
    now = 1;
    memset(mark, -1, sizeof(mark));
    for(int i = 1; i <= n; i++) {
        if(mark[i] != -1) continue;
        DFS(i);
        now++;
    }
    now--;
    maxim = -INF;
    for(int i = 1; i <= n; i++) {
        freq[mark[i]]++;
        maxim = max(maxim, freq[mark[i]]);
    }
    cout << maxim << "\n";
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

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

int main() {
  int N;
  cin >> N;
  bool ans = false;
  for (int i = 0; i < 100; ++i) {
    for (int j = 0; j < 100; ++j) {
      if (i * 4 + j * 7 == N) {
        ans = true;
      }
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    int prefix = Integer.parseInt(s.substring(0, 2));
    int suffix = Integer.parseInt(s.substring(2, 4));

    if (prefix >= 1 && prefix <= 12 && suffix >= 1 && suffix <= 12)
      System.out.println("AMBIGUOUS");
    else if (prefix >= 1 && prefix <= 12)
      System.out.println("MMYY");
    else if (suffix >= 1 && suffix <= 12)
      System.out.println("YYMM");
    else
      System.out.println("NA");
  }
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

string s;

int main(){
	while(getline(cin,s)){
		if(s=="END OF INPUT")return 0;
		int cur=0,l=0;
		while(cur<s.size()){
			if(s[cur++]==' '){cout<<l;l=0;}
			else l++;
		}
		cout<<l<<endl;
	}
}

Measured memory_bytes: 0
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string[] cin = Console.ReadLine().Split();
        int n = int.Parse(cin[0]);
        int k = int.Parse(cin[1]);
        List<int> l = Console.ReadLine().Split().Select(i => int.Parse(i)).ToList();

        l.Sort();
        int ans = 0;
        for (int i = 0; i < k; i++)
        {
            ans += l[l.Count - i - 1];
        }
        Console.WriteLine(ans);
    }
}

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

int main() {

  long long int n, m;
  cin >> n >> m;

  long long int ans[51] = {};

  for ( long long int i = 0; i < m; i++ ) {

    long long int a, b;
    cin >> a >> b;
    ans[a]++;
    ans[b]++;

  }

  for ( long long int i = 1; i <= n; i++ ) {
    cout << ans[i] << endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
int main() {
    string s;cin>>s;
    cout<<s;
    if(s.back()=='s') cout<<"es";
    else cout<<"s";
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		long a,b,g,l;
		while(sc.hasNext())
		{
			a = sc.nextLong();
			b = sc.nextLong();
			g = gcd(a,b);
			l = (a*b)/g;
			System.out.println(g + " " + l);
		}
	}

	private static long gcd(long a, long b) {
		if(a==0) return b;
		else if(b==0) return a;
		return gcd(b,a%b);
	}
}

Measured memory_bytes: 12000
package main

import (
	"fmt"
	"sort"
)

func kagamiMochi(inputArray []int) int {
	sort.Ints(inputArray)
	j := 0
	for i := 1; i < len(inputArray); i++ {
		if inputArray[j] == inputArray[i] {
			continue
		}
		j++
		inputArray[j] = inputArray[i]
	}
	return j + 1
}

func main() {
	var N int
	var num int
	fmt.Scan(&N)
	inputArray := []int{}
	for i := 0; i < N; i++ {

		fmt.Scan(&num)
		inputArray = append(inputArray, num)
	}
	fmt.Println(kagamiMochi(inputArray))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	string str;
	cin>>str;
	int mf=0,mb=0,yf=0,yb=0;
	if((str[0]=='1'&&(str[1]>='0'&&str[1]<='2'))||(str[0]=='0'&&(str[1]>='1'&&str[1]<='9')))
		mf=1;
	if((str[2]=='1'&&(str[3]>='0'&&str[3]<='2'))||(str[2]=='0'&&(str[3]>='1'&&str[3]<='9')))
		mb=1;
	if((str[0]>='0'&&str[0]<='9')&&(str[1]>='0'&&str[1]<='9'))
		yf=1;
	if((str[2]>='0'&&str[2]<='9')&&(str[3]>='0'&&str[3]<='9'))
		yb=1;
	if((mf&&yb)&&(yf&&mb))
		cout<<"AMBIGUOUS"<<endl;
	else if(mf&&yb)
		cout<<"MMYY"<<endl;
	else if(yf&&mb)
		cout<<"YYMM"<<endl;
	else
		cout<<"NA"<<endl;
	

	return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	private static int a, b;
	
	private static void solve(){
		int c = a + b;
		System.out.println(Integer.toString(c).length());
	}
	
	public static void main(String[] args) throws Exception{
//		File file = new File("in.txt");
//		Scanner in = new Scanner(file);	
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			a = in.nextInt();
			b = in.nextInt();
			solve();
		}
	}
}

Measured memory_bytes: 20424
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int n;

    cin >>n ;

    if(n%1000!=0){
        cout << 1000- (n%1000) << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}



Measured memory_bytes: 3628
package main

import (
	"fmt"
)

func main() {
	var windowWidth int
	var curtainWidth int
	fmt.Scanf("%d %d", &windowWidth, &curtainWidth)

	result := 0
	if (curtainWidth * 2) < windowWidth {
		result = windowWidth - (curtainWidth * 2)
	}

	fmt.Printf("%d", result)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define f first
#define s second
#define int long long
using namespace std;
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	int n;
	cin >> n;
	string st[n];
	int a[n];
	for(int i=0;i<n;i++){
		// string st;
		cin >> st[i];
		cin >> a[i];
	}
	string x;
	cin >> x;
	int sum=0,flag=0;
	for(int i=0;i<n;i++){
		if(flag)
			sum+=a[i];
		if(st[i]==x)
			flag=1;
	}
	cout << sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  lol a, b;
  cin >> a >> b;
  lol memo, nasu = gcd(a, b), ans = 1;
  memo = nasu;
  for(lol i = 2;i * i <= nasu;i ++){
    if(memo % i == 0){
      ans ++;
      while(memo % i == 0){
	memo /= i;
      }
    }
  }
  if(memo != 1){
    ans ++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int n; cin >> n;
    vector<P> red(n), blue(n);
    vector<bool> check(n,false);
    rep(i,n) {
        int x, y; cin >> x >> y;
        red[i] = P(y,x);
    }
    rep(i,n) {
        int x, y; cin >> x >> y;
        blue[i] = P(x,y);
    }
    sort(all(blue));
    sort(all(red));
    int ct = 0;
    for (auto &p: blue) {
        int index = lower_bound(all(red),P(p.second,-inf))-red.begin();
        for (int i = index-1; i >= 0; i--) {
            if (red[i].second >= p.first) continue;
            if (!check[i]) {
                check[i] = true;
                ct++;
                break;
            }
        }
    }
    cout << ct << endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string inputbuf1 = Console.ReadLine();
            string inputbuf2 = Console.ReadLine();
            //string inputbuf1 = "5 3";
            //string inputbuf2 = "ABCAB";

            string[] inputdata = inputbuf1.Split(' ');
            int N = Convert.ToInt32(inputdata[0]);
            int K = Convert.ToInt32(inputdata[1]);
            string outstr = inputbuf2.Substring(0, K-1 ) + Char.ToLower(inputbuf2[K-1]);
            outstr = outstr + inputbuf2.Substring(K);


            Console.WriteLine(outstr);
            //Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<functional>
#include<utility>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
  char miria [256];
  cin >> miria;
  printf("%s\n",strcmp(miria,"2019/04/30")>0 ? "TBD" : "Heisei");
  /*if(strcmp(miria,"2019/04/30")>0){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }*/
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    ll ax = abs(x);

    ll INF = (ll)1e17;
    ll kd = k * min(d, INF / k);
    if (ax - kd > 0) {
        cout << ax - kd << endl;
        return 0;
    }

    ll i = ax / d;
    if ((k - i) % 2 == 0) {
        cout << ax - d * i << endl;
    } else {
        cout << abs(ax - d * i - d) << endl;
    }
}


Measured memory_bytes: 3568
import collections
n=int(input())
v = []
for _ in range(n):
    s = input()
    v.append(s)


c = collections.Counter(v)
x = 0
u = []
for t in c.most_common():
    if x>0 and t[1] != x:
        break
    else:
        x = t[1]
        u.append(t[0])

for s in sorted(u):
    print(s)


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

int n, m;

void sitA( char *ch ){
	for(int i=1; i<=n; i++){
		if( ch[i] == '#' ){
			ch[i] = 'A';
			return;
		}
	}
}

void sitB( char *ch ){
	for(int i=n; i>0; i--){
		if( ch[i] == '#' && ch[i-1]!='A' && ch[i+1]!='A' ){
			ch[i] = 'B';
			return;
		}
	}
	for(int i=1; i<=n; i++){
		if( ch[i] == '#' ){
			ch[i] = 'B';
			return;
		}
	}
}

void sitC( char *ch ){
	for(int i=1; i<=n; i++){
		if( ch[i]!='#' ){
			if( ch[i+1] == '#' ){
				ch[i+1] = 'C';
				return;
			}
			else if( ch[i-1] == '#' ){
				ch[i-1] = 'C';
				return;
			}
		}
	}
	int k = (n%2 ? (n+1)/2 : n/2+1);
	ch[k] = 'C';
}

void sitD( char *ch ){
	int md=0, mi=1;
	for(int i=1; i<=n; i++){
		if( ch[i] == '#' ){
			int dl=1, dr=1;
			for(; ch[i-dl]=='#'||ch[i-dl]=='x'; dl++)
				if( ch[i-dl]=='x' ){ dl = 500; break; }
			for(; ch[i+dr]=='#'||ch[i+dr]=='x'; dr++)
				if( ch[i+dr]=='x' ){ dr = 500; break; }
			int d = min( dl, dr );
			if( d > md ){
				md = d;
				mi = i;
			}
		}
	}
	ch[mi] = 'D';
}

int main(){
	while( cin >> n >> m, n||m ){
		char chairs[102];
		for(int i=0; i<=n; i++) chairs[i] = '#';
		chairs[0] = chairs[n+1] = 'x';
		for(int i=0; i<m; i++){
			char c;
			cin >> c;
			switch(c){
			case 'A': sitA(chairs); break;
			case 'B': sitB(chairs); break;
			case 'C': sitC(chairs); break;
			case 'D': sitD(chairs); break;
			}
		}
		for(int i=1; i<=n; i++)	cout << chairs[i];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>

int main() {
    std::string s;
    std::cin >> s;

    int n = s.length();
    for (int i = 0; i <= n; ++i) {
        for (int j = i; j <= n; ++j) {
            std::string t = s.substr(0, i) + s.substr(j);

            if (t == "keyence") {
                std::cout << "YES" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "NO" << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
 
using namespace std;

vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define MOD 1000000007
#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 1e5 + 5;

int arr[N];

void solve(){
  int n;
  cin >> n;
  map<string, int> mp;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    mp[s] += 1;
  }
  cout << "AC x " << mp["AC"] << "\n";
  cout << "WA x " << mp["WA"] << "\n";
  cout << "TLE x " << mp["TLE"] << "\n";
  cout << "RE x " << mp["RE"] << "\n";

}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

bool isDAG(vector<vector<int>>& G) {
  int N = G.size();
  vector<bool> vis(N);

  std::function<bool(int, unordered_set<int>&)> dfs = [&](int curr, unordered_set<int>& st) {
    for(auto&& e: G[curr]) {
      if(st.count(e)) return false;
      if(vis[e]) continue;
      st.insert(e);
      vis[e] = 1;
      if(!dfs(e, st)) return false;
      st.erase(e);
    }
    return true;
  };

  rep(e, N) {
    vis[e] = 1;
    unordered_set<int> st = {e};
    if(!dfs(e, st)) return false;
  }
  return true;
}

int main() {

  int M, N; cin >> M >> N;

  // テ・ツ青?」ツつケテ」ツつュテ」ツδォテヲツッツ偲」ツ?ォテ」ツつウテ」ツδ榲」ツδウテ」ツδ嘉」ツ?ョテ・ツ個コテゥツ鳴禿」ツつ津ヲツ個?」ツ?、
  vector<vector<pair<int, int>>> cmd_sect(N, vector<pair<int, int>>(M, {0, inf}));

  rep(cmd_idx, M) {
    int K; cin >> K;
    rep(_, K) {
      int skill; cin >> skill; skill--;
      string op; cin >> op;
      int threshold; cin >> threshold;
      if(op == ">=") {
        cmd_sect[skill][cmd_idx].first = max(cmd_sect[skill][cmd_idx].first, threshold);
      } else {
        cmd_sect[skill][cmd_idx].second = min(cmd_sect[skill][cmd_idx].second, threshold);
      }
      if(cmd_sect[skill][cmd_idx].first > cmd_sect[skill][cmd_idx].second) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  vector<vector<int>> G(M);
  
  rep(i, N) {
    rep(a, M) rep(b, M) {
      if(a == b) continue;
      if(cmd_sect[i][a].second < cmd_sect[i][b].first)
        G[a].push_back(b);
    }
  }

  rep(i, M) {
    sort(all(G[i]));
    G[i].erase(unique(all(G[i])), G[i].end());
  }

  cout << (isDAG(G) ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3992
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  int nI;
  scanf("%d", &nI);
  std::vector<int> its(nI);
  for (int i = 0; i < nI; ++i) {
    scanf("%d", &its[i]);
  }
  std::vector<long long> maxSumIfOp(nI + 1);
  std::vector<long long> prefixMax(nI + 1);
  maxSumIfOp[2] = 1LL * -its[0] - its[1];
  prefixMax[2] = std::max(maxSumIfOp[2], 1LL * its[0] + its[1]);
  if (nI >= 3) {
    maxSumIfOp[3] = maxSumIfOp[2] + 2 * its[1] - its[2];
    maxSumIfOp[3] = std::max(maxSumIfOp[3], 1LL * its[0] - its[1] - its[2]);
    prefixMax[3] = std::max(prefixMax[2] + its[2], maxSumIfOp[3]);
  }
  for (int i = 4; i <= nI; ++i) {
    maxSumIfOp[i] = std::max(maxSumIfOp[i], maxSumIfOp[i - 1] + 2 * its[i - 2] - its[i - 1]);
    maxSumIfOp[i] = std::max(maxSumIfOp[i], prefixMax[i - 2] - its[i - 2] - its[i - 1]);
    prefixMax[i] = std::max(prefixMax[i - 1] + its[i - 1], maxSumIfOp[i]);
  }
  printf("%lld\n", prefixMax[nI]);
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
int main(){
int N,Q;
  cin>>N>>Q;
  Graph G(N);
  for(int i=0;i<N-1;i++){
  int a,b;
    cin>>a>>b; a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
   }map<int,int64_t>M;
  for(int i=0;i<Q;i++){
  int p; int64_t x;
    cin>>p>>x;p--;
    if(M.count(p))
      M.at(p)+=x;
    else
      M[p]=x;
  }vector<int64_t>X(N,-1);
  X.at(0)=0;
  if(M.count(0))
    X.at(0)+=M.at(0);
  queue<int>que;
  que.push(0);
  while(!que.empty()){
  int u=que.front();
    que.pop();
    for(auto v:G[u]){
      if(X.at(v)!=-1)
        continue;
      else{
    X.at(v)=X.at(u);
      if(M.count(v))
        X.at(v)+=M.at(v);
      que.push(v);
      }
    }
  
  }for(int i=0;i<N-1;i++)
    cout<<X.at(i)<<" ";
  cout<<X.at(N-1)<<endl;
   return 0;
}


Measured memory_bytes: 28024
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

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

  cout<< s.substr(0,4) << " " << s.substr(4,8) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
int M=1e9+7;
using namespace std;
int main()
{
	ll sum=0;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
	sum+=(int)(s[i]-48);
	if(sum%9)
	cout<<"No";
	else
	cout<<"Yes";
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int s=0,t=0,a;
	rep(i,0,4){
		cin>>a; s+=a;
	}
	rep(i,0,4){
		cin>>a; t+=a;
	}
	o(max(s,t));
}

Measured memory_bytes: 1160
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
a = inpl()
a.sort()
b = []
for i in range(m-1):
    b.append(a[i+1]-a[i])
b.sort(reverse = True)
print(sum(b[n-1:]))

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

signed main(){
    ll x,y;cin>>x>>y;
    if(x%y==0)cout<<-1<<endl;
    else cout<<x<<endl;
}

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

int main(){
  int n,m;
  vector<int> v;
  int ans;

  while(1){
    cin >> n >> m; 
    if(!n && !m)break;

    ans = 0;
    v.resize(n);
    for(int i=0;i<n;i++){
      cin >> v[i];
      ans += v[i];
    }
    sort(v.begin(),v.end());
    for(int i=v.size()-m;i>=0;i-=m){
      ans -= v[i];
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)

# A and B will be less than 119


def main():
    X = int(input().strip())
    for A in range(-119, 120):
        for B in range(-119, 120):
            if A ** 5 - B ** 5 == X:
                return "{} {}".format(A, B)

    else:
        return "Invalid X"


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)


int main() {
	int n, m;
	while(1) {
		cin >> n;
		if(n == 0) break;
		
		char ch[26], CH[26];
		char num[10];
		rep(i,26) {
			ch[i] = (char)('a' + i);
			CH[i] = (char)('A' + i);
		}
		rep(i,10) {
			num[i] = (char)('0' + i);
		}

		char c, nc;
		rep(i,n) {
			cin >> c >> nc;
			if(islower(c)) {
				ch[c - 'a'] = nc;
			} else if(isupper(c)) {
				CH[c - 'A'] = nc;
			} else {
				num[c - '0'] = nc;
			}
		}
		cin >> m;
		rep(i,m) {
			cin >> c;
			if(islower(c)) {
				cout << ch[c - 'a'];
			} else if(isupper(c)) {
				cout << CH[c - 'A'];
			} else {
				cout << num[c - '0'];
			}
		}
		cout << endl;
	}
	return 0;
}

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


int main(void){
	int N;
	cin >> N;
	int Cx,Cy,H,si;
	vector<int> x(N),y(N),h(N);
	for(int i=0;i<N;i++){
		cin >> x[i] >> y[i] >> h[i];
		if(h[i]>0) si=i;
	}
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			int H = h[si]+abs(x[si]-i)+abs(y[si]-j);
			bool ok = true;
			for(int k=0;k<N;k++){
				if(h[k]>0&&H-h[k]!=abs(i-x[k])+abs(j-y[k]))ok=false;
				if(h[k]==0&&H>abs(i-x[k])+abs(j-y[k]))ok = false;
			}
			if(ok)Cx=i,Cy=j;
		}
	}
	printf("%d %d %d\n",Cx,Cy,h[si]+abs(x[si]-Cx)+abs(y[si]-Cy));
}

Measured memory_bytes: 256
let pow_base x y mult =
  let rec f m n odd b = match n with
      0 -> 1
    | 1 -> mult m odd
    | _ -> let t = if n mod 2 = 1 then mult odd b else odd
           in f (mult m m) (n/2) t (mult b b)
  in f x y 1 x;;

let mpow x y z =
  let mult x1 y1 = ((x1 mod z)*(y1 mod z)) mod z in
  pow_base x y mult;;

let pow x y = pow_base x y ( * );;

let is_composite d n s =
  let l = [2;3;5;7] in
  let rec loop a = match a with
      [] -> false
    | h::t -> if (mpow h d n) = 1 then loop t
              else
                if not (let rec loop2 = function
                    i when i = s -> false
                  | i -> if mpow h ((pow 2 i) * d) n = n-1 then true
                         else loop2 (i+1) in loop2 0) then true
                else
                  loop t
  in loop l;;

let is_prime n = match n with
    2|3|5|7 -> true
    | n ->
       if n=1 || n mod 2 = 0 || n mod 3 = 0 || n mod 5 = 0 || n mod 7 = 0 then
         false
       else begin
           let rec loop d s = match (d, s) with
               (d, s) when d mod 2 = 1 -> (d,s)
             | (d, s) -> loop (d asr 1) (s+1) in
           let (d,s) =  loop (n-1) 0 in
           not (is_composite d n s)
         end;;

let () =
  let n = read_int () in
  let rec read ct = function
      0 -> ct
    | i ->
       let m = read_int () in
       read (if is_prime m then ct+1 else ct) (i-1)
  in
  Printf.printf "%d\n" (read 0 n)

Measured memory_bytes: 4384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    int len=s.size();
    bool flag=false;
    for(int i=0;i<len;i++){
        int cnt=0;
        for(int j=0;j<len;j++){
            if(t[j]==s[(j+i)%len])cnt++;
        }
        if(cnt==len)flag=true;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int mo=998244353;
const int N=200005;
int n;
vector<int> e[N];
int q[N],dS[N],dT[N];
int mx[N],f[N][9],tmp[9];
int bfs(int S,int *d){
	For(i,1,n) d[i]=-1;
	int h=0,t=1;
	q[1]=S; d[S]=0;
	while (h!=t){
		int x=q[++h];
		for (auto i:e[x])
			if (d[i]==-1){
				d[i]=d[x]+1;
				q[++t]=i;
			}
	}
	return q[t];
}
void DP(int x,int fa){
	mx[x]=0;
	for (auto i:e[x]) if (i!=fa)
		DP(i,x),mx[x]=max(mx[x],mx[i]);
	f[x][mx[x]==0?4:0]=1;
	for (auto i:e[x]) if (i!=fa){
		memset(tmp,0,sizeof(tmp));
		For(j,0,8) For(k,0,8){
			int ek=(mx[i]==mx[x]?k:0);
			int nv=min(j%3+ek%3,2)+3*min(j/3+ek/3,2);
			tmp[nv]=(tmp[nv]+1ll*f[x][j]*f[i][k])%mo;
		} 
		memcpy(f[x],tmp,sizeof(f[x]));
	}
	//cout<<mx[x]<<endl;
	if (fa){
		memset(tmp,0,sizeof(tmp));
		For(j,0,8){
			int v1=0,v2=j%3,v3=j/3*3;
			tmp[v1]=(tmp[v1]+f[x][j])%mo;
			tmp[v2]=(tmp[v2]+f[x][j])%mo;
			tmp[v3]=(tmp[v3]+f[x][j])%mo;
		}
		memcpy(f[x],tmp,sizeof(tmp));
		++mx[x];
	}
}
int main(){
	scanf("%d",&n);
	For(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].PB(y); e[y].PB(x);
	}
	int S=bfs(1,dS);
	int T=bfs(S,dS);
	bfs(T,dT);
	For(i,1,n)
		if (dS[i]==dS[T]/2||dT[i]==dT[S]/2)
			if (dS[i]+dT[i]==dT[S])
				q[++*q]=i;
	if (*q==1){
		DP(q[1],0);
		printf("%lld\n",1ll*f[q[1]][4]*(mo+1)/2%mo);
	}
	else{
		DP(q[2],q[1]);
		DP(q[1],q[2]);
		printf("%lld\n",1ll*f[q[1]][1]*f[q[2]][3]%mo);
	}
}
/*
    5
    |
4-3-2-1-6

f[i][0/1][0/1]的方案数
*/

Measured memory_bytes: 26880
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Diagnostics;

class Program
{

    public void Slove()
    {
        int n = int.Parse(Console.ReadLine());
        int[] hs = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] imos = new int[hs.Length];
        foreach(int i in Enumerable.Range(0, hs.Length))
        {
            imos[i] = hs[i];
            if(i != 0)
                imos[i] -= hs[i - 1];
        }
        int count = imos.Where(x => x > 0).Sum();
        //Console.WriteLine(string.Join(",",imos));
        Console.WriteLine(count);
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 13396
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int a, b;
	cin >> a >> b;

	if (a <= b + b) {
		cout << 0 << endl;
	} else {
		cout << a - (b + b) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N,M;
  cin>>N;vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);sort(a.begin(),a.end());
  cin>>M;vector<int> b(M);
  for(int i=0;i<M;i++)cin>>b.at(i);sort(b.begin(),b.end());
  
  int s=-1,flag=0;
  for(int i=0;i<M;i++){
    for(int j=s+1;j<N;j++){
      if(b.at(i)==a.at(j)){
        s=j;
        break;
      }
      if(j==N-1){
        flag++;
        i=M;
      }
    }
  }
  if(flag==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cinttypes>

using ul = unsigned long;


int main(){
	ul n;
	std::cin >> n;
	std::vector<ul> an(n);
	
	ul tmax{0};//連続とみなせる数列中の最大値を保存
	//[1..tmax]

	for( auto& e : an )
	{
		std::cin >> e;
		if( e == (tmax+1) )
			++tmax;
	}

	if( tmax == 0 )
		std::cout << "-1";
	else
		std::cout << n - tmax << "\n";


	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	ll x[n],y[n];
	REP(i,n){
		cin >> x[i] >> y[i];
	}
	map<P, int> mp;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			mp[P(x[j] - x[i], y[j] - y[i])]++;
			mp[P(x[i] - x[j], y[i] - y[j])]++;
		}
	}
	int mx = 0;
	for(auto i : mp){
		if(i.second > mx){
			mx = i.second;
		}
	}
	cout << n - mx << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;
constexpr int mod = 1e9 + 7;

using mat = vector<vector<ll>>;

mat mul(const mat& a, const mat& b){
  int m = a.size(), n = a[0].size(), l = b.size();

  mat c = mat(m, vector<ll>(l, 0));
  REP(i, m)REP(j, l)REP(k, n){
    (c[i][j] += a[i][k] * b[k][j] % mod) %= mod;
  }

  return c;
}

mat pow(const mat& a, const ll n){
  if(n == 0){
    int m = a.size();
    mat e = mat(m, vector<ll>(m, 0LL));
    REP(i, m)REP(j, m){
      if(i == j) e[i][j] = 1LL;
    }

    return e;
  } else {
    mat tmp = pow(a, n / 2);
    if(n % 2) return mul(mul(tmp, tmp), a);
    else return mul(tmp, tmp);
  }
}

int main(){
  ll n, k; cin >> n >> k;
  mat a = mat(n, vector<ll>(n, 0));
  REP(i, n)REP(j, n) cin >> a[i][j];

  mat ret = pow(a, k);

  ll ans = 0;
  REP(i, n)REP(j, n){
    (ans += ret[i][j]) %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;

const int INF = 100000000;





int main(int argc, char *args[]) {
	string S;
	cin >> S;

	string T = "ACGT";

	int ans = 0;
	int now = 0;

	for (int i = 0; i < S.size(); i++) {
		bool flag = false;
		for (int j = 0; j < T.size(); j++) {
			if (S[i] == T[j])flag = true;
		}
		if (flag) {
			now++;
			ans = max(ans, now);
		}
		else {
			now = 0;
		}
		
	}
	cout << ans << endl;
}

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

int	main(void)
{
	long long x;
  	long long money = 100;
	long long year = 0;
	cin >> x;

	while (money < x)
	{
		money = money + (money / 100);
		year++;
	}
	cout << year << endl;

	return (0);
}

Measured memory_bytes: 3628