akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define double long double
#define pb push_back
#define endl '\n'
#define er erase
#define sz size
#define in insert
using namespace std;

ll n, W, w[105], v[105], dp[105][100005], ans;

int main(){
    cin>>n>>W;
    for(ll i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    for(ll i=0;i<=100000;i++) dp[0][i]=W+1;
    for(ll i=0;i<=n;i++) dp[i][0]=W+1;
    dp[0][0]=0;
    for(ll i=1;i<=n;i++)
        for(ll j=0;j<=100000;j++)
        {
            if(j>=v[i]) dp[i][j]=min(dp[i-1][j], dp[i-1][j-v[i]]+w[i]);
            else dp[i][j]=dp[i-1][j];
            if(dp[i][j]<=W) ans=max(ans, j);
        }
    cout<<ans;
    return 0;
}


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

int n;
int l = 0, r = -1;
set < int > s;

int f( LL a , LL b , LL c ){
	if ( a & 1 ) return 0;
	if ( b & 1 ) return 0;
	if ( c & 1 ) return 0;
	if ( a == b && b == c ) return -1e9;
	return 1 + f(a+(b+c)/2, b+(a+c)/2, c+(b+a)/2);
}

int main(){
	
	LL a,b,c;
	cin >> a >> b >> c;
	int x = f(a,b,c);
	if ( x < 0 ) cout << -1 << endl;
	else cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		int INF = Integer.MAX_VALUE/2;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer>[] edge = new ArrayList[N];
		for(int i = 0; i < N; i++)
		    edge[i] = new ArrayList<>();
		for (int i = 0; i < N-1; i++) {
		    int a = sc.nextInt()-1;
		    int b = sc.nextInt()-1;
		    edge[a].add(b);
		    edge[b].add(a);
		}
		Queue<Integer> q = new ArrayDeque<>();
		q.add(0);
		int[] d1 = new int[N];
		Arrays.fill(d1, 1, N, INF);
		while(q.size() > 0) {
			int x = q.poll();
			for(int y : edge[x]) {
				if(d1[y] == INF) {
					d1[y] = d1[x] + 1;
					q.add(y);
				}
			}
		}
		q.add(N-1);
		int[] d2 = new int[N];
		Arrays.fill(d2, 0, N-1, INF);
		while(q.size() > 0) {
			int x = q.poll();
			for(int y : edge[x]) {
				if(d2[y] == INF) {
					d2[y] = d2[x] + 1;
					q.add(y);
				}
			}
		}
		int fn = 0;
		for(int i = 0; i < N; i++)
			if(d1[i] <= d2[i])
				fn++;
		System.out.println(fn > N-fn ? "Fennec" : "Snuke");
	}

}

Measured memory_bytes: 102236
# 文字列として入力を受け取り、Xを0～9に逐次変えてboolを取る

while 1:
    try:
        ab,s = list(input().split('='))
        a,b = list(ab.split('+'))
        start = 0
        # 第1項,第2項,結果のどれかが一桁ないし頭がXでない場合は1から始める
        if (len(a)>1 and a[0] == 'X') or (len(b)>1 and b[0] == 'X') \
            or (len(s)>1 and s[0] == 'X'): start = 1
        
        flg = 1
        for x in range (start,10):
            new_a = a.replace('X',str(x))
            new_b = b.replace('X',str(x))
            new_s = s.replace('X',str(x))
            if int(new_a)+int(new_b) == int(new_s):
                flg = 0
                print(x)
                break
        if flg: print('NA')

    except: break


Measured memory_bytes: 5604
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B;
    cin >> A >> B;

    ll ans = 0;
    for(ll i = A; i <= B; i++){
        if(i / 10000 == i % 10 && (i / 1000) % 10 == (i / 10) % 10){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N,K;
  string S;
  cin>>N>>K>>S;
  if(S[K-1]=='A')S[K-1]='a';
  else if(S[K-1]=='B')S[K-1]='b';
  else if(S[K-1]=='C')S[K-1]='c';
  cout<<S<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;
ll gcd(ll a, ll b);
int main(){
cin.tie(0);
ll n;
cin>>n;
ll d[n][2];
    for(ll i=0;i<n;i++){
        cin>>d[i][0]>>d[i][1];
    }
    for(ll i=0;i<n-2;i++){
        if(d[i][0]==d[i][1]&&d[i+1][0]==d[i+1][1]&&d[i+2][0]==d[i+2][1]){
            cout<<"Yes";
            return 0;
        }
    }
cout<<"No";
return 0;
}






ll gcd(ll a, ll b){

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

}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;

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


void Main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll zentai = b - a + 1;
  ll c_wari = b / c - (a - 1) / c;
  ll d_wari = b / d - (a - 1) / d;
  ll cd_lcm = c * d / gcd(c, d);
  ll kaburi_wari = b / cd_lcm - (a - 1) / cd_lcm;

  // COUT(zentai);
  // COUT(c_wari);
  // COUT(d_wari);
  // COUT(cd_lcm);

  COUT(zentai - c_wari - d_wari + kaburi_wari);

}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
5 2
3 1 2 5
2 2 3
1 0
*/


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int mod=1e9+7;
template<typename T=int>
T gi() {
    T x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
string to_string(string s) { return '"'+s+'"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b?"true":"false"); }
template<typename A,typename B> string to_string(pair<A,B> p) {
    return "("+to_string(p.fi)+","+to_string(p.se)+")";
}
template<typename T> string to_string(T v) {
    int fst=1;string ret="{";
    for(auto x:v) {
        if(!fst) ret+=",";
        fst=0,ret+=to_string(x);
    }
    ret+="}";return ret;
}
void dbg_out() { cerr<<endl; }
template<typename Head,typename... Tail> void dbg_out(Head H,Tail... T) {
    cerr<<" "<<to_string(H);
    dbg_out(T...);
}
#define dbg(...) cerr<<"{"<<#__VA_ARGS__<<"}:",dbg_out(__VA_ARGS__)

template<typename T>
int qpow(int a,T b) {
    int ret=1;
    while(b) {
        if(b&1) ret=1ll*ret*a%mod;
        a=1ll*a*a%mod,b>>=1;
    }
    return ret;
}

const int N=1e6+10;

int n,f[N];

int main() {
    n=gi();
    f[n]=n;
    int sum=0;
    for(int i=n-1;i;i--) {
        inc(sum,f[i+3]);
        f[i]=f[i+1];
        inc(f[i],1ll*(n-1)*(n-1)%mod);
        inc(f[i],sum);
        inc(f[i],n-max(n-i,2)+1);
    }
    printf("%d\n",f[1]);
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  string ans="";
  while(n)
  {
    long long int k=n/26;
    long long int x=n%26;
    if(x==0)
    {
      k--;
      ans=(char)('z')+ans;

    }
    else
      ans=(char)(('a'+x-1))+ans;
    n=k;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include <string.h>

int main() {
	char s[101], w[101], q[101];
	int a, as, ans = 0, i, o = 0, u;
	
	scanf("%s", s);
	
	a = strlen(s);
	
	as = a / 2;
	
	for(i = 0;i < as;i++) {
		o++;
		q[i] = s[i];
		w[i] = s[a-o];
	}
	
	for(u = 0;u < as;u++) {	
		if(s[u] != w[u])	ans = ans + 1;
	}
	
	printf("%d", ans);
	
	return 0;
	
}	

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    char i;
    int n,j;
    cin >> n;
    int card[5][14] ={};
    for( int k = 0; k < n; k++){
        cin >> i;
        if(i == 'S'){
            cin >> j;
            card[1][j] = 1;
        }
        else if(i =='H'){
            cin >> j;
            card[2][j] = 1;
        }
        else if(i == 'C'){
            cin >> j;
            card[3][j] = 1;
        }
        else if(i == 'D'){
            cin >> j;
            card[4][j] = 1;
        }
    }
    for(int a = 1; a <= 4; a++){
        for(int b = 1; b <= 13; b ++){
            if(card[a][b] == 0){
                if(a == 1){
                    cout << "S" << " " << b << endl;
                }
                else if(a == 2){
                    cout << "H" << " " << b<< endl;
                }
                else if(a == 3){
                    cout << "C" << " " << b << endl;
                }
                else if (a == 4){
                    cout << "D" << " " << b << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
    ll n, d;
    vector<vector<ll>> vec;

    cin >> n >> d;

    for (ll i = 0; i < n; i++){
        vector<ll> tmp(d);
        for (ll j = 0; j < d; j++)
        {
            cin >> tmp[j];
        }
        vec.push_back(tmp);
    }

    int total = 0;
    for (ll a = 0; a < n; a++)
    {
        for (ll b = a + 1; b < n; b++){
            float sum = 0;
            for (ll c = 0; c < d; c++){
                sum += pow(abs(vec.at(a)[c] - vec.at(b)[c]), 2.0);
            }
            float dist = sqrt(sum);
            if (dist == floor(dist))
                total++;
        }
    }

    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 300001;
int len, k, val[51], ans, prefi[51];
int main(){
	cin >> len >> k;
	for(int i = 1;i <= len;++i)cin >> val[i];
	for(int i = 1;i <= len;++i)prefi[i] = prefi[i - 1] + val[i];
	for(int l = 0;l <= min(k, len);++l){
		for(int r = 0;r + l <= min(k, len);++r){
			int res = prefi[l] + prefi[len] - prefi[len - r], bye = k - l - r;
			priority_queue < int > gar;
			for(int i = 1;i <= l;++i){
				if(val[i] < 0){
					gar.push(val[i]);
					if(gar.size() > bye)gar.pop();
				}
			}
			for(int i = 0;i < r;++i){
				if(val[len - i] < 0){
					gar.push(val[len - i]);
					if(gar.size() > bye)gar.pop();
				}
			}
			while(gar.size()){
				res -= gar.top();
				gar.pop();
			}
			ans = max(ans, res);
		}
	}
	cout << ans << '\n';
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int K = cin.nextInt();
        if (K % 2 == 0)
        {
            Console.WriteLine(K / 2 * K / 2);
        }
        else
        {
            Console.WriteLine(K / 2 * (K / 2 + 1));
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}



Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;int c=0,i;
 for(i=0;i<s.length()-1;i++){
    if(s[i]=='h'){
      if(s[i+1]=='i') c++;
    }
 }
  if(2*c==s.length()){
  cout<<"Yes";
  }
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
const int N=505;
char a[N][N],b[N][N];
int main (){
	int n,m;scanf ("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf ("%s",a[i]+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			b[i][j]=a[i][j];
	for (int i=1;i<=n;i+=2)
		for (int j=1;j<m;j++)
			a[i][j]='#';
	for (int i=2;i<=n;i+=2)
		for (int j=2;j<=m;j++)
			b[i][j]='#';
	for (int i=1;i<=n;i++) a[i][1]='#';
	for (int i=1;i<=n;i++) b[i][m]='#';
	for (int i=1;i<=n;i++,puts(""))
		for (int j=1;j<=m;j++)
			printf ("%c",a[i][j]);
	puts("");
	for (int i=1;i<=n;i++,puts(""))
		for (int j=1;j<=m;j++)
			printf ("%c",b[i][j]);
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,n){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"
#define pii pair<int,int>
#define PI 3.141592653589793

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int H,W,D; cin>>H>>W>>D;
  pii p[H*W+1];
  REP(i,H){
    REP(j,W){
      int a; cin>>a;
      p[a] = make_pair(i,j);
    }
  }
  
  int d[H*W+1] = {0};
  for(int i=D+1; i<=H*W; ++i){
    d[i] = d[i-D] + abs(p[i].first-p[i-D].first) + abs( p[i].second-p[i-D].second );
  }
  
  int Q; cin>>Q;
  REP(count,Q){
    int L,R; cin>>L>>R;
    ll ans = d[R]-d[L];
    cout << ans << "\n";
  }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
string fyes="Yay";
string fno=":(";
int n;
int x[55],y[55];
signed main(){
	cin>>n;
	rep(i,n)cin>>x[i]>>y[i];
	int ans=n;
	rep(i,n-1){
		for(int j=i+1;j<n;j++){
			int p=x[j]-x[i];
			int q=y[j]-y[i];
			int cnt=n;
			rep(k,n){
				rep(l,n){
					if(x[l]-x[k]==p&&y[l]-y[k]==q)cnt--;
				}
			}
			ans=min(ans,cnt);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
	long N, T, i;
	scanf("%ld %ld", &N, &T);
	long A[N] , min = pow(10, 9), max = 0, change = 1;
	
	
	for(i = 0; i < N; i ++){
		scanf("%ld" , &A[i]);
		if(A[i] < min){
			min = A[i];
			continue;
		}
		if(A[i] - min == max) change ++;
		
		if(A[i] - min > max){
			max = A[i] - min;
			change = 1;
		}
		
		
}
	
	printf("%ld\n" ,change);
	return 0;
}
	

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
int main() {
	ios::sync_with_stdio(false);

	ll N; cin >> N;
	string S; cin >> S;

	vvl L (sz(S), vl(sz(S), 0));

	FOR(i,0,sz(S)) {
		FOR(j,0,sz(S)) {
			if (S[i] == S[j]) {
				if (i == 0 || j == 0) {
					L[i][j] = 0;
					if (i != j) {
						L[i][j] = 1;
					}
				} else {
					if (i + L[i-1][j-1] < j) {
						// habe noch platz
						L[i][j] = L[i-1][j-1] + 1;
					} else if (i + L[i-1][j-1] == j) {
						// schneide den vordersten ab
						L[i][j] = L[i-1][j-1];
					}
				}
			}
		}
	}
	ll maxi = 0;
	FOR(i,0,sz(S)) {
		FOR(j,0,sz(S)) {
			maxi = max(maxi, L[i][j]);
//			cerr << L[i][j] << " ";
		}
//		cerr << endl;
	}
//	cerr << endl;
	cout << maxi << endl;

	return 0;
}


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

const int maxn = 100005;

int n;
int p[maxn], a[maxn], b[maxn];

signed main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) 
		scanf("%d", &p[i]);
	for (int i = 1; i <= n; ++i)
		a[i] = 40000 * i;
	for (int i = 1; i <= n; ++i)
		b[p[i]] = (n - p[i] + 1) * 40000 + i;
	for (int i = 1; i <= n; ++i)
		printf("%d ", a[i]);
	printf("\n");
	for (int i = 1; i <= n; ++i)
		printf("%d ", b[i]);
	printf("\n");
}


Measured memory_bytes: 4064
import java.util.Scanner;

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

        int[][][] kousya = new int[4][3][10];

        for(int i=0; i<n;i++){
            int b = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            int v = sc.nextInt();
            kousya[b-1][f-1][r-1] += v;
        }

        for(int i=0; i<4;i++){
            for(int j=0; j<3; j++){
                for(int k=0; k<10; k++){
                    System.out.print(" "+ kousya[i][j][k]);
                }
                System.out.println("");
            }
            if(i!=3)
                System.out.println("####################");
        }
    }
}


Measured memory_bytes: 29256
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int n, res = 0, x = 1;
  cin >> n;
  while (x < n && res < 20) {
    res++;
    x *= 3;
  }
  cout << res << el;
}

Measured memory_bytes: 1160
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
LL ans,n,k;
void solve()
{
    cin>>n>>k;
    for(LL i=0;i<k;i++)
        {ll a;cin>>a;ans+=a;}
   if(ans<n)
    cout<<"No"<<endl;
else
    cout<<"Yes"<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
using namespace std;

int compar(const long long *val1, const long long *val2);

int main(void)
{
    long long N, i, x = 0, y = 0;
    cin >> N;
    long long A[N];

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

    qsort(A, N, sizeof(long long), (int (*)(const void *, const void *))compar);

    for (i = 0; i < N-1; i++)
    {
        if (A[i] == A[i+1])
        {
            x = A[i];
            i += 2;
            break;
        }
    }

    for (; i < N-1; i++)
    {
        if (A[i] == A[i+1])
        {
            y = A[i];
            break;
        }
    }

    cout << x * y << endl;

    return 0;
}

int compar(const long long *val1, const long long *val2)
{
    if (*val1 > *val2)
    {
        return -1;
    }
    else if (*val1 == *val2)
    {
        return 0;
    }
    else
    {
        return 1;
    }
}

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <numeric>

#include <queue>
#include <vector>
using namespace std;
 
#define numof(array)  (sizeof (array) / sizeof *(array))

const int INF = 1000000007;
const int MAX_V = 1000007;
 
typedef long long ll;
typedef pair<int, int> P; //first: ???????????¢???second: ??????????????? 

struct edge{
    int to;
    int cost;
};

int V=0;
vector<edge > G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> > qu;
  fill(d, d + V, INF);
  d[s] = 0;
  qu.push(P(0,s));
  while(!qu.empty()){
    P p = qu.top(); qu.pop();
    int v = p.second;    
    if(d[v] < p.first) continue;
    for(int i = 0; i < G[v].size(); i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
	d[e.to] = d[v] + e.cost;
	qu.push(P( d[e.to], e.to ));
      }
    }
  }
}


int main(){

  int E,r;
  cin >> V >> E >> r;
  for(int i = 0 ; i < E; i++){
    int s , t , d;
    cin >> s >> t >> d;
    edge e = {t,d};
    //    e.to = t; e.cost = d;
    G[s].push_back(e);
  }
  dijkstra(r);
  for(int i = 0; i < V ; i++){
    if (d[i] == INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 34260
#include<bits/stdc++.h>
using namespace std;
bool cmp(pair<int,int> a,pair<int,int> b)
{
  return a.first<=b.first;
}
int main()
{
  long long int n,k;
  cin>>n>>k;
  vector<pair<int,int>> v(n); 
  for(auto &i:v) cin>>i.first>>i.second;
  sort(v.begin(),v.end());
  long long int c=0;
  for(int i=0;i<n;i++)
  {
    
     c+=v[i].second;
    if(k<=c)
    {cout<<v[i].first;
     break;
    }
  }
  return 0;
}


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

int main(void) {
  string s;
  int j;
  while(1) {
    getline(cin, s);
    if(s == "END OF INPUT") break;
    j = 0;
    for(int i = 0; i < s.length(); i++) {
      if(s[i] == ' ') {
	cout << j;
	j = 0;
      } else {
	j++;
      }
    }
    cout << j << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int n,m;
string s[100];
int sum[101][10010];
main()
{
	int ans,cnt=1e9;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>s[i];
		for(int j=0;j<n;j++)sum[i][j+1]=sum[i][j]+(s[i][j]=='W');
	}
	for(int i=-1;i<=n;i++)
	{
		int now=0;
		for(int j=0;j<m;j++)
		{
			now+=i-0+1-sum[j][i+1];
			now+=sum[j][n]-sum[j][i+1];
		}
		if(cnt>now)
		{
			cnt=now;
			ans=i+1;
		}
	}
	cout<<ans<<" "<<ans+1<<endl;
}



Measured memory_bytes: 8504
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())

if r >= s and s >= p:
    strong_list = ["r", "s", "p"]
    opp_list = ["s", "p", "r"]
    strong_list_num = [r, s, p]
elif r >= p and p >= s:
    strong_list = ["r", "p", "s"]
    opp_list = ["s", "r", "p"]
    strong_list_num = [r, p, s]
elif s >= p and p >= r:
    strong_list = ["s", "p", "r"]
    opp_list = ["p", "r", "s"]
    strong_list_num = [s, p, r]
elif s >= r and r >= p:
    strong_list = ["s", "r", "p"]
    opp_list = ["p", "s", "r"]
    strong_list_num = [s, r, p]
elif p >= r and r >= s:
    strong_list = ["p", "r", "s"]
    opp_list = ["r", "s", "p"]
    strong_list_num = [p, r, s]
else:
    strong_list = ["p", "s", "r"]
    opp_list = ["r", "p", "s"]
    strong_list_num = [p, s, r]

my_hands = [0] * n
sum = 0
for ct in range(3):
    my_current_hand = strong_list[ct]
    opp_current_hand = opp_list[ct]
    for i in range(n):
        if not t[i] == opp_current_hand:
            continue
        elif i-k < 0:
            my_hands[i] = my_current_hand
            sum += strong_list_num[ct]
        elif not my_hands[i-k] == my_current_hand:
            my_hands[i] = my_current_hand
            sum += strong_list_num[ct]
print(sum)

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

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N;
int H[MAX_N];

int dp[MAX_N];

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> H[n];
  }

  fill(dp,dp+N,INF_LL_MAX);
  dp[0] = 0;

  REP(n,N) {
    int next = min(n+1, N-1);
    dp[next] = min(dp[next], dp[n]+abs(H[n] - H[next]));
    next = min(n+2, N-1);
    dp[next] = min(dp[next], dp[n]+abs(H[n] - H[next]));
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 int main(){
 ll n, x, t ; cin>>n>>x>>t ;
 ll ans= (n+x-1)/x ;
 cout<<ans*t<<endl ;
   return 0 ;
 }



Measured memory_bytes: 3628
import java.io.*;
import java.util.StringTokenizer;
import java.util.ArrayList;

class Point {
    double x,y;
    Point(double x,double y) {
	this.x = x;
	this.y = y;
    }
}

class Main {
    public static void main(String args[]) {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String buf;

	try {
	    ArrayList<Point> array = new ArrayList<Point>();
	    while ((buf = br.readLine())!=null) {
		StringTokenizer st = new StringTokenizer(buf,",");
		array.add(new Point(Double.parseDouble(st.nextToken()),Double.parseDouble(st.nextToken())));
	    }
	    double S = 0;
	    for (int i=1;i<array.size()-1;i++) {
		double a = dist(array.get(0),array.get(i));
		double b = dist(array.get(i),array.get(i+1));
		double c = dist(array.get(0),array.get(i+1));
		double z = (a+b+c)/2;
	        S += Math.sqrt(z*(z-a)*(z-b)*(z-c));
	    }
	    System.out.println(S);
	} catch (Exception e) {
	    e.printStackTrace();
	}
    }

    public static double dist(Point p1,Point p2) {
	return Math.sqrt(Math.pow(p2.x-p1.x,2)+Math.pow(p2.y-p1.y,2));
    }

    public static void quicksort(int low,int high,ArrayList<Point> a) {
       	if (high>low) {
       	     int mid = (low+high)/2;
       	     double x = a.get(mid).x;
       	     int i = low;
       	     int j = high;
       	     while (a.get(i).x<x) i++;
       	     while (a.get(j).x>x) j--;
       	     if (i<=j) {
		 Point t = a.get(i);
		 a.set(i,a.get(j));
		 a.set(j,t);
		 i++;j--;
	     }
	     quicksort(low,j,a);
	     quicksort(i,high,a);
       	}
    }

    public static void sorty(int n,ArrayList<Point> a) {
	for (int i=1;i<n;i++) {
	    int j = i-1;
	    while (a.get(j).x==a.get(j+1).x&&a.get(j).y>a.get(j+1).y) {
		Point t = a.get(j+1);
		a.set(j+1,a.get(j));
		a.set(j,t);
		j--;
		if (j<0) break;
	    }
	}
    }
}

Measured memory_bytes: 15096
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> B;
int dp[2][1<<18];
map<B,int> mb[2];
B mxor(B a,B b){
  B res(a);
  for(int i=0;i<(int)a.size();i++) res[i]=a[i]^b[i];
  return res;
}
void dfs(bool f,int i,B c,int d,int l,vector<B>& b){
  //cout<<f<<" "<<i<<" "<<c.size()<<":"<<d<<" "<<l<<endl;
  mb[f][c]=max(mb[f][c],d);
  if(i<l){
    dfs(f,i+1,c,d,l,b);
    dfs(f,i+1,mxor(c,b[i]),d+1,l,b);
  }
}
signed main(){
  int n,m;
  while(cin>>n>>m,n||m){
    string s[n];
    for(int i=0;i<n;i++) cin>>s[i];
    if(n<=30){
      mb[0].clear();
      mb[1].clear();
      vector<B> b(n);
      for(int i=0;i<n;i++){
	b[i]=vector<int>(m,0);
	for(int j=0;j<m;j++)
	  if(s[i][j]=='1') b[i][j]=1;
      }
      int k=n/2;
      dfs(0,0,B(m,0),0,k,b);
      dfs(1,k,B(m,0),0,n,b);
      int ans=0;
      for(auto x:mb[0]){
	B c=x.first;
	int p=x.second;
	//for(int j:c) cout<<j;cout<<endl;
	//cout<<c.size()<<" "<<p<<endl;
	//cout<<mb[1].count(c)<<endl;
	if(mb[1].count(c)) ans=max(ans,p+mb[1][c]);
      }
      cout<<ans<<endl;
      continue;
    }
    assert(m<18);
    int b[n];
    for(int i=0;i<n;i++){
      b[i]=0;
      for(int j=0;j<m;j++)
	if(s[i][j]=='1') b[i]+=1<<j;
    }
    
    memset(dp,-1,sizeof(dp));
    dp[0][0]=0;
    for(int i=0;i<n;i++){
      bool f=i%2;
      memset(dp[!f],-1,sizeof(dp[!f]));
      for(int j=0;j<(1<<m);j++){
	if(dp[f][j]<0) continue;
	dp[!f][j]=max(dp[!f][j],dp[f][j]);
	dp[!f][j^b[i]]=max(dp[!f][j^b[i]],dp[f][j]+1);
      }
    }
    cout<<dp[n%2][0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 11724
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;

int main(){
    long long N; cin >> N;
    map<long long, long long> m{};
    for(long long i=0;i<N;i++) {
        long long n; cin >> n; m[n]++;
    }
    
    int count=0;
    long long a=0; long long b=0;
    map<long long, long long> ::reverse_iterator i;
    for(i=m.rbegin();i!= m.rend();i++){
        if(i->second>=4){
            if(a==0) {a=i->first; b=i->first;}
            else{ b=i->first;}
            count=2;
        }else if(i->second>=2){
            if(count==0) a=i->first;
            else b = i->first;
            count++;
        }
        if(count==2) break;
    }
    cout << a*b << endl;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int N;
	cin >> N;
	cout << N * 800 - N / 15 * 200 << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
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();
    if(a <= b){
      System.out.println("unsafe");
    }else{
      System.out.println("safe");      
    }
  }
}

Measured memory_bytes: 35776
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld\n",x)
#define print2(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 333333

struct BinaryIndexed {
  ll num;
  vll bit;

  BinaryIndexed(ll x = MAX) {
	num = x;
	bit.resize(x + 1, 0);
  }

  ll sum(ll i) {
	ll ret = 0;
	while (i > 0) {
	  ret += bit[i];
	  i -= i & -i;
	}
	return ret;
  }

  void add(ll i, ll x) {
	if (i == 0) cout << "access 0 index" << endl;
	while (i <= num) {
	  bit[i] += x;
	  i += i & -i;
	}
  }
};

int main(void) {
  cin >> n;
  vll a, sum;
  MAP comp;
  BinaryIndexed BIT;

  ll cur = 0;
  sum.pb(cur);
  rep(i, n) {
	scan(tmp);
	cur += tmp;
	a.pb(tmp);
	sum.pb(cur);
  }

  UNIQUE(sum);
  rep(i, sum.size()) comp[sum[i]] = i + 1;

  cur = 0;
  BIT.add(comp[cur], 1);
  rep(i, n) {
	cur += a[i];
	cnt = BIT.sum(comp[cur]);
	if (comp[cur] != 1) cnt -= BIT.sum(comp[cur] - 1);
	ans += cnt;
	BIT.add(comp[cur], 1);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18532
#include <bits/stdc++.h>
using namespace std;
long long n, a, ans;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n; 
for (int i=1; i<=n; i++){
	cin >> a;
	if (a%2 and i%2) ans++;
} cout << ans;
return 0;
}


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

const int INF = 1e9 + 7;

int main(){
	int n,m,l;
	cin >> n >> m >> l;
	
	vector<vector<int>> d(n, vector<int>(n,INF));
	
	rep(i,m){
		int a,b,c;
		cin >> a >> b >> c;
		--a; --b;
		d[a][b] = c;
		d[b][a] = c;
	}
	rep(i,n) d[i][i] = 0;
	
	rep(k,n) rep(i,n) rep(j,n) d[i][j] = min( d[i][j], d[i][k] + d[k][j] );

	vector<vector<int>> d2(n, vector<int>(n,INF));
	
	rep(i,n){
		rep(j,n){
			if( d[i][j] <= l) d2[i][j] = 1;
		}
	}
	
	rep(i,n) d2[i][i] = 0;
	
	rep(k,n) rep(i,n) rep(j,n) d2[i][j] = min( d2[i][j], d2[i][k] + d2[k][j] );
	
	int q;
	cin >> q;
	
	rep(i,q){
		int s,t;
		cin >> s >> t;
		--s; --t;
		
		int ans = 0;
		ans = d2[s][t] - 1;
		if(d2[s][t] == INF) ans = -1;
		cout << ans << endl;
	}
	
	return 0;
}

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

#define hey(x) cerr << #x << " : " << x << "\n";
#define int long long int
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int, int> >
#define vvpi vector<vector<pair<int, int> > >
#define all(v) (v).begin(), (v).end()   
#define rall(v) (v).rbegin(), (v).rend()
#define pii pair<int, int>
#define pb push_back
#define SZ(x) (int)(x).size()
#define inf 1e12
#define F first
#define S second
#define fill(v, val) memset((v), val, sizeof(v))
#define PI 3.1415926535897932384626
#define out cout << fixed << setprecision(12)
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define hey2(x, y) cerr << #x << " : " << x << "," << #y << " : " << y << '\n';

const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const double pi = acos(-1);

void read(vi &a) {
    for(int &i : a)
        cin >> i;
}
void print(vi &a) {
    for(int i : a)
        cerr << i << ' ';
    cerr << '\n';
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi h(n);
    read(h);
    vi dp(n + 1, inf);
    dp[0] = 0;
    for(int i = 1; i < n; ++i) {
        for(int j = max(0LL, i - 2); j < i; ++j) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1];
    return 0;
}


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

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

  std::vector<int> iv;

  int t;
  for(int i=0; i<3; ++i) {
    std::cin >> t;
    iv.push_back(t);
  }

  std::sort(iv.begin(), iv.end());

  if(iv[0]==5 && iv[1]==5 && iv[2]==7) {
    std::cout << "YES\n";
  } else {
    std::cout << "NO\n";
  }

  return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

int col[N];
vector<pair<int, int>> g[N];

void dfs(int u, int c, int p) {
  col[u] = c;
  for (auto v : g[u]) if (v.first != p) {
    if (v.second % 2) {
      dfs(v.first, c == 1 ? 0 : 1, u);
    } else {
      dfs(v.first, c, u);
    }
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  dfs(1, 0, -1);
  for (int i = 1; i <= n; i++) {
    printf("%d\n", col[i]);
  }
  return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

ll a[1000006];
ll K;

int main()
{
    cin >> K;
    a[0] = 0;
    for(int i = 1;i <= K;i++)
    {
        a[i] = (10*a[i-1]+7) % K;
        if(a[i] == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 10920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1e7
vector<ll> g[100005];
ll vis[100005];

void dfs(ll u,ll pt){
    vis[u] = 1;
    for(auto it : g[u]){
        if(it == pt || vis[it])
            continue;
        dfs(it,u);
    }
}
void solve()
{   
    ll n,m;
    cin>>n>>m;
    for(int i =0;i<=n;i++){
        g[i].clear();
        vis[i] = 0;
    }
    // vector<ll> g[n+1];
    for(int i =0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        // cout<<"next0";
        g[a].pb(b);
        g[b].pb(a);
    }
    // cout<<"hi0\n";
    ll cnt = 0;
    for(ll i = 1; i<=n; i++){
        
        if(vis[i]==0)
        {   //cout<<"his";
            dfs(i,-1);
            // cout<<"hi\n";
            cnt++;
        }
    }
    // cout<<cnt;
    if(cnt==0){
        cout<<"0\n";return;
    }
    cout<<cnt-1<<'\n';

}
int main(){
    // IOS;
    int tt;
    tt = 1;
    // cin>>tt;
    int i = 1;
    while(tt--){
        // cout<<"tc "<<i<<" ";
        solve();
        i++;
    }
    return 0;
}


Measured memory_bytes: 11368
x = gets.to_i

def prime?(n)
  if n <= 1
    false
  end

  (2..Math.sqrt(n)).each do |x|
    if n % x == 0
      return false
    end
  end

  true
end


(x..Float::INFINITY).each do |n|
  if prime? n
    puts n
    break
  end
end


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, h, w;
	cin >> n >> h >> w;
	
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		
		if( a >= h && b >= w ) ans += min(a / h, b / w);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    vector<ll> x(n);
    rep(i,n) cin>>x[i];
    ll ans=0;

    for(int i=1;i<n;i++){
        ll dis=x[i]-x[i-1];
        if(dis*a<b){
            ans+=a*dis;
        }        
        else{
            ans+=b;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

int		main(void)
{
	int a;

	cin >> a;
	cout << a + pow(a, 2) + pow(a, 3) << endl;
}



Measured memory_bytes: 4172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k, a, b;
  string ans;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      ans = "OK";
      break;
    }
    ans = "NG";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
"use strict";

const input = require("fs").readFileSync("/dev/stdin", "utf8");
const inputs = input.split("\n");

const N   = Number(inputs[0]);
const As = inputs[1].split(" ").map(Number);
const Bs = inputs[2].split(" ").map(Number);

const main = (N, As, Bs) => {
    let killed = 0;
    // Bs の数字の大きい順に処理

    let remain = As[As.length - 1];
    for (let i = (Bs.length - 1); i >= 0; i--) {
        // 前のループで余ったモンスターの処理を試みる
        if (remain >= Bs[i]) {
            // 全ループのモンスター処理で残勇者0
            killed += Bs[i];
            remain = As[i];
            continue;
        } else {
            // 余力有り
            Bs[i] -= remain;
            killed += remain;
            if (As[i] >= Bs[i]) {
                remain = As[i] - Bs[i];
                killed += Bs[i];
            } else {
                remain = 0;
                killed += As[i];
            }
        }
    }

    return killed;
};
console.log(main(N, As, Bs));

Measured memory_bytes: 35732
using System;
using System.Linq;


namespace ATC
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] Input = Console.ReadLine().Split(' ');

            int N = int.Parse(Input[0])-1;//都市の数
            int M = int.Parse(Input[1])-1;//橋の数

            var CityA = new int[M+1];
            var CityB = new int[M+1];
            var CityN = new int[N+1];


            for(int h = 0; h<=M; h++)
            {
                string[] input = Console.ReadLine().Split(' ');
                CityA[h] = System.Int32.Parse(input[0]);
                CityB[h] = System.Int32.Parse(input[1]);
            }

            for(int i = 0; i<=N; i++)
            {
                CityN[i] = 0;

                for(int j = 0; j<= M; j++)
                {
                    if(CityB[j] == i+1)
                    {
                        CityN[i]++;
                    }
                    if (CityA[j] == i + 1)
                    {
                        CityN[i]++;
                    }

                }

                Console.WriteLine(CityN[i]);
            }
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    
    
    int main() {
     
     char ch;
     int counter[26] = {0};
     
     while(cin >> ch){ //ここでchがアルファベットなら、数える
        
        char h = tolower(ch);
        
        int num = h - 'a';
        counter[num]++;
      }
      
      for(int i = 0; i < 26; i++){
      	 //数値からアスキーコード？
      	 char h = 'a' + i;
        printf("%c %c %d\n",h,':',counter[i]);
      }
     return 0;
    }


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

int main()
{
	ll n;
	cin >> n;
	vector<ll> a;
	ll m = n;
	for(ll i = 2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			m *= (i-1);
			m /= i;
		}
		while(n%i==0)
		{
			n/=i;
		}
	}
	if(n!=1)
	{
		m*=(n-1);
		m /= n;
	}
	cout<<m<<endl;

}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = 101;
		int sum = 0;
		for (int i=1; i<=n; i++) {
			int s = sc.nextInt();
			sum += s;
			if (s % 10 != 0 && s < min) {
				min = s;
			}
		}
		if (sum % 10 != 0) {
			System.out.println(sum);
		} else if (min == 101) {
			System.out.println(0);
		} else {
			System.out.println(sum-min);
		}
		sc.close();
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main() {
    int n,t;
    cin>>n>>t;
    vector<int> ts(n);
    rep(i,n) cin>>ts.at(i);
    ts.push_back(2000000010);
    long long ans=0;
    rep(i,n) ans+=(min)(t,ts.at(i+1)-ts.at(i));
    cout<<ans<<endl;
}


Measured memory_bytes: 1792