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

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

int main() {
        long long n, p;
        cin >> n >> p;
        vector<long long> a(n);
        int odd = 0, even = 0;
        rep(i, n) { 
                cin >> a[i];
                if (a[i] & 1) odd ++;
                else even ++;
        }
        if (odd == 0) {
                if (p == 1) cout << 0 << endl;
                else {
                        long long ans = 1;
                        rep(i, n) ans *= 2;
                        cout << ans << endl;
                }
        } else {
                long long ans = 1;
                rep(i, n - 1) ans *= 2;
                cout << ans << endl;
        }
        return 0;
}


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

const int INF = 2002002002;

void solve(long long N, std::string S, std::string T){
    REP(i, N) {
        printf("%c", S[i]);
        printf("%c", T[i]);
    }
    cout << '\n';
}

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, S, T);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
	int K;cin>>K;
	cout<<a[K-1];
}

Measured memory_bytes: 256
//coded by: pranonrahman-------------------------------------
//-----------------------------------------------------------
//-----------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define O_O ios_base::sync_with_stdio(0); cin.tie(NULL)
#define endl '\n'
#define PI acos(-1.0)
#define CASE(n) cout << "Case " << n << ": "
#define CASE_(n) cout << "Case " << n << endl
#define FIXED(n) cout << fixed << setprecision(n)
#define testPrint(n) cout << "test" << n << endl;


int main()
{
    O_O;
    long long t=1;
    //cin >> t;
    long long T = t;
    while(t--)
    {
        //write your code here
        long long n,p;
        cin >> n >> p;
        cout << n-p+1 << endl;

    }
    return 0;
}




Measured memory_bytes: 256
fun main(args: Array<String>) {
    val input = readLine()!!
    println(if (input[0] == input[1] && input[2] == input[3]  && input[0] != input[2] || input[0] == input[2] && input[1] == input[3] && input[0] != input[1]|| input[0] == input[3] && input[2] == input[1] && input[0] != input[1]) "Yes" else "No")
}


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

int main() {
	// your code goes here
	string s,t;
	cin>>s>>t;
	int l1 = s.length();
	int l2 = t.length();
	
	vector<vector<int>> dp(l1+1,vector<int>(l2+1,0));
	for(int i=0;i<=l1;i++)
	{
	    for(int j=0;j<=l2;j++)
	    {
	        if(i==0 || j==0)
	            dp[i][j]=0;
	        else if(s[i-1]==t[j-1])
	            dp[i][j] = 1+dp[i-1][j-1];
	       else
	            dp[i][j]= max(dp[i][j-1],dp[i-1][j]);
	        
	    }
	}
	
	int i = l1,j=l2;
	string ans="";
	while(i>0 && j>0)
	{
	    if(s[i-1]==t[j-1])
	    {
	        ans.push_back(s[i-1]);
	        i--;
	        j--;
	    }
	    else if(dp[i][j-1]>=dp[i-1][j])
	    {
	        j--;
	    }
	    else
	        i--;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
	return 0;
}


Measured memory_bytes: 35712
class Program
{
    static void Main(string[] args)
    {
        string line = System.Console.ReadLine().Trim();


        string[] Data = line.Split(' ');

        int A = int.Parse(Data[0]);
        int B = int.Parse(Data[1]);

        if(A> B)
        {
            if(A !=1 && B ==1)
            {
                System.Console.WriteLine("Bob");
            }
            else
            {
                System.Console.WriteLine("Alice");
            }
        }
        else if(A == B)
        {
            System.Console.WriteLine("Draw");
        }
        else
        {
            if(A ==1 && B !=1)
            {
                System.Console.WriteLine("Alice");

            }
            else
            {
                System.Console.WriteLine("Bob");
            }
        }      
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	vector<long double> x(n), y(n);
	REP(i, n)
		cin >> x[i] >> y[i];
	long double dist = 0;
	REP(i, n - 1) {
		for (int j = i + 1; j < n; j++) {
			dist += sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
		}
	}
	cout << setprecision(10)  << dist / (n / (long double)2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
void yes(bool c) { if (c)print("Yes"); else print("No"); };

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

void solve() {
    ll X; cin >> X;
    vll ds = divisor(X);
    // rep(i,ds.size()){
    //     cout << ds[i] << " ";
    // }
    // cout << endl;
    // int ans_a,ans_b;
    for(auto d:ds){
        // print("d");
        // print(d);
        rng(a,1,100000){
            int b = a-d;
            
            // print(a);
            // print(b);
            ll left = pow(a,5)-pow(b,5);
            // cout << left << endl;
            if(left == X) {
                cout << a << " " << b << endl;
                return;
            } 
            //else if(left>1000000000) break;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);

    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 4216
#include<bits/stdc++.h>
int main()
{
    long long a,b,c,ans=0;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(a<=c) c-=a,ans+=a,a=0;
    else ans+=c,a-=c,c=0;
    if(b<=c) ans+=2*b,c-=b,b=0;
    else ans+=2*c,b-=c,c=0;
    if(b) ans+=b,b=0;
    if(c)
        ans++;
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int H,W;
  int i,j;
  cin >> H >> W;
  vector<vector<char>> d(H, vector<char>(W));
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      cin >> d.at(i).at(j);
    }
  }
  for(i=0;i<(H+2);i++){
    for(j=0;j<(W+2);j++){
      if(i==0 || i==(H+1) || j==0 || j==(W+1)){
        cout << '#';
      }
      else{
        cout << d.at(i-1).at(j-1);
      }
    }
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split(' '))
s = [[0 for i in range(y)] for j in range(x)]

for i in range(x):
    s[i] = list(map(str, input().split(' ')))

c = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']

flag = False

for i in range(x):
    if flag == False:
        for j in range(y):
            if s[i][j] == "snuke":          
                print(c[j], end="")
                print(i+1)
                flag = True
                break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

const ll mod=998244353;



int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  vvll lr(k,vll(2,0));
  rep(i,k){
    cin>>lr[i][0]>>lr[i][1];
  }
  vll d(n*2,0);
  d[0]=1;
  d[1]=-1;
  ll now=0;
  rep(i,n){
    now+=d[i];
    now%=mod;
    rep(j,k){
      if(i+lr[j][0]<n){
        d[i+lr[j][0]]+=now;
        d[i+lr[j][0]]%=mod;
      }
      if(i+lr[j][1]+1<n){
        d[i+lr[j][1]+1]-=now;
        d[i+lr[j][1]+1]%=mod;
      }
    }
  }
  cout<<(now%mod+mod)%mod<<endl;
}


Measured memory_bytes: 6360
#include <iostream>

using i64 = long long;

const i64 MOD = 998244353;
const i64 Inv2 = -MOD / 2;

i64 pow(i64 a, i64 k) {
	i64 t = 1;
	for (; k; a = a * a % MOD, k >>= 1)
		if (k & 1) t = t * a % MOD;
	return t;
}

const int N = 1 << 18 | 7;

int n;
i64 p[N], s, q[N];

void fwt_xor(i64 f[], int n, int on) {
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < 1 << n; ++j)
			if (j >> i & 1)
				( f[j ^ 1 << i] += f[j] ) %= MOD, ( f[j] = f[j ^ 1 << i] - 2 * f[j] ) %= MOD;
		if (on == 1) continue;
		for (int i = 0; i < 1 << n; ++i)
			( f[i] *= Inv2 ) %= MOD;
	}
}

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < 1 << n; ++i)
		scanf("%lld", p + i), s += p[i];
	s = pow(s, MOD - 2);
	for (int i = 0; i < 1 << n; ++i)
		p[i] = p[i] * s % MOD;
	--p[0];
	std::fill(q, q + (1 << n), -1);
	q[0] += 1 << n;

	fwt_xor(p, n, 1), fwt_xor(q, n, 1);
	for (int i = 0; i < 1 << n; ++i)
		q[i] = q[i] * pow(p[i], MOD - 2) % MOD;
	fwt_xor(q, n, -1);

	for (int i = 0; i < 1 << n; ++i)
		printf("%lld\n", (q[i] - q[0] + MOD * 2) % MOD);
	return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n,t;
    cin >> n >> t;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    vector<int> amax(n,-1);
    vector<int> amin(n, INT_MAX);

    amax[n-1] = a[n-1];
    for (int i=1; i<n; i++) amax[n-1-i] = max(amax[n-i], a[n-1-i]);

    map<int,int> mp;
    for (int i=0; i<n; i++) {
        mp[amax[i] - a[i]]++;
    }

    int ans = 0;
    int _max = -1;
    for (const auto &item : mp) {
        if (item.first > _max) {
            _max = item.first;
            ans = item.second;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	int x;
	cin>>x;
	cout<<(1^x);	
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);

//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	static int a[]= {0,-1,0,1};
	static int b[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static int K;
	public static void main(String[] args) {
		long vv=sc.nextLong();


		ArrayList<Long> cc = new ArrayList<>();
		for(long i=1;Math.pow(i,2)<=vv;i++) {
			if(vv%i==0) {
				if(i!=1)cc.add(i);
				if(vv/i!=i)cc.add(vv/i);
			}
		}
		
		for(long i=1;Math.pow(i, 2)<=vv-1;i++) {
			if((vv-1)%i==0) {
				if(i!=1)cc.add(i);
				if((vv-1)/i!=i)cc.add((vv-1)/i);
			}
		}
		Collections.sort(cc);
		int ctn=0;
		for(long i:cc) {
			long v=vv;
			while(v%i==0) {
				v=v/i;
			}
			if(v%i==1) {
				ctn++;
			}
		}
		p(ctn);
	}
	

	

	
	
	
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    if(n%2 != 0){
        cout << 0 << endl;
        return 0;
    }
    ll t = 5,num = 1,ans = 0;
    while(true){
        ll keta = n/t;
        keta /= 2;
        if(keta == 0){
            break;
        }
        ans += keta;
        t *= 5;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

string subsum(int* A,int n,int m){
  bitset<2010> E(1);

  rep(i,0,n){
    E |= (E<<A[i]);
  }

  if(E.test(m)) return "yes";
  else return "no";
}

int main(){
  int k; cin>>k;
  set<int> r;
  set<P> c;
  rep(i,0,k){
    int x,y; cin>>x>>y;
    r.insert(x);
    c.insert(make_pair(x,y));
  }

  int con[8];
  rep(i,0,8) con[i]=i;
  //各行のどこにクイーンがいるか
  sort(con,con+8);

  do{
    vector<vector<bool>> grid(8,vector<bool>(8,false));
    bool able=true;
    //各行での処理
    rep(i,0,8){
      if(!able) break;

      //指定されたやつだったら
      if(r.count(i)){
        if(c.count(make_pair(i,con[i]))){
          grid[i][con[i]]=true;
        }
        else able=false;
      }

      grid[i][con[i]]=true;
      //各方面へ伸ばしていく
      rep(a,1,8){
        int rc=con[i]+a;
        int lc=con[i]-a;
        int br=i+a;
        int ur=i-a;
        //被った瞬間アウトに
        if(rc<=7&&br<=7&&grid[br][rc]==true) able=false;
        if(rc<=7&&ur>=0&&grid[ur][rc]==true) able=false;
        if(lc>=0&&br<=7&&grid[br][lc]==true) able=false;
        if(lc>=0&&ur>=0&&grid[ur][lc]==true) able=false;
      }
    }

    if(able){
      rep(i,0,8){
        rep(j,0,8){
          //if(j!=0) cout<<" ";
          if(grid[i][j]) cout<<"Q";
          else cout<<".";
          if(j==7) cout<<endl;
        }
      }

      return 0;
    }

  }while(next_permutation(con,con+8));



}




Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;cin>>n;
	int d[n];
	rep(i,n) cin>>d[i];

	sort(d,d+n);

	int ans=d[n/2]-d[n/2-1];

	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
double memo[301][301][301];
int n;
double func(int cnt3, int cnt2, int cnt1) {
    if (memo[cnt3][cnt2][cnt1] > 0) {
        return memo[cnt3][cnt2][cnt1];
    }
    double ans = 1;
    if (cnt3 > 0) {
        ans += (double(cnt3) / n) * func(cnt3 - 1, cnt2 + 1, cnt1);
    }
    if (cnt2 > 0) {
        ans += (double(cnt2) / n) * func(cnt3, cnt2 - 1, cnt1 + 1);
    }
    if (cnt1 > 0) {
        ans += (double(cnt1) / n) * func(cnt3, cnt2, cnt1 - 1);
    }
    if (cnt3 == 0 && cnt2 == 0 && cnt1 == 0) {
        return 0;
    }
    memo[cnt3][cnt2][cnt1] = (ans) / (1 - double(n - cnt3 - cnt2 - cnt1) / n);
    return memo[cnt3][cnt2][cnt1];
}
signed main() {
    cin >> n;
    Fill(memo, -1);
    map<int, int> cnt;
    REP(i, n) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    cout << func(cnt[3], cnt[2], cnt[1]) << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N,M;
void input()
{
    cin>>N>>M;
    return;
}

void solve()
{
    string ans="Yes";
    if(N>M) ans="No";
    cout<<ans<<endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
n,m,X,Y=map(int,input().split())
x_List=list(map(int,input().split()))
y_List=list(map(int,input().split()))
x_List.append(X)
y_List.append(Y)
ans=''
if max(x_List)<min(y_List):
  ans='No War'
else:
  ans='War'
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] ary = sc.next().toCharArray();
		String str = "";
		for (char c : ary) {
			if(c == '0') str += "0";
			if(c == '1') str += "1";
			if(c == 'B' && !str.equals("")) {
				str = str.substring(0,str.length()-1);
			}
		}
		System.out.println(str);
	}
}

Measured memory_bytes: 22484
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char str[2][55]={0};
    scanf("%s", str[0]);
    scanf("%s", str[1]);

    char str2[105]={0};
    long i;
    for(i=0; i<104; i++) {
        if(i%2==0) {
            str2[i]=str[0][i/2];
        }
        else {
            str2[i]=str[1][i/2];
        }
        if(str2[i]==0) break;
    }
    printf("%s\n", str2);

    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
main (){
      string s;
      cin >> s;
      
      int k,j;
      for (int i = 0; i < s.size(); i++)
       if (s[i] == 'A') {j = i; break;}
       
       for (int i = s.size() - 1; i >= 0; i--)
              if (s[i] == 'Z') {k = i; break;}
              
       cout<<k - j + 1;
}

Measured memory_bytes: 640
#include <cmath>
#include <vector>
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

struct hasi{
  int s,t;
  double nagasa;
  bool operator < ( const hasi &H ) const {
    return nagasa < H.nagasa;
  }
};

int n;
double x[1000],y[1000],z[1000],r[1000];

int uni_tabetai[1000];
int mituketa(int x){
  if( x == uni_tabetai[x] ) return x;
  return uni_tabetai[x] = mituketa(uni_tabetai[x]);
}

void nakayosi(int x,int y){
  x = mituketa(x);
  y = mituketa(y);
  if( x == y ) 
    {
    }
  else 
    {
      uni_tabetai[x] = y;
    }
}

double kannsuu(double a,double b,double c){
  return sqrt(a*a+b*b+c*c);
}

int
main() {
  while( cin >> n ) {
    if( n == 0 ) break;
    for(int rupu=0;rupu<n;rupu++) 
      {
	uni_tabetai[rupu] = rupu;
	int i = rupu;
	cin>>x[i]>>y[i]>>z[i]>>r[i];
      }

    vector<hasi> hairetu;
    for(int _1=0;_1<n;_1++) {
      for(int _2=_1+1;_2<n;_2++) {
	double nagasa = kannsuu(x[_1]-x[_2],y[_1]-y[_2],z[_1]-z[_2]);
	if( nagasa > r[_1]+r[_2] ) 
	  hairetu.push_back((hasi){_1,_2,nagasa-r[_1]-r[_2]});
	else 
	  nakayosi(_1,_2);
      }
    }
    sort(hairetu.begin(),hairetu.end());
    double ko_ko_ = 0;
    for(int i=0;i<hairetu.size();i++){
      int iti = hairetu[i].s;
      int ni  = hairetu[i].t;
      if( mituketa(iti) != mituketa(ni) ) {
	nakayosi(iti,ni);
	ko_ko_ += hairetu[i].nagasa;
      }
    }
    printf("%.3f\n",ko_ko_);
  }
  return 0;
}

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

public class Main {


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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String Origin = br.readLine();
        String Serch = br.readLine();

        String[] origin = Origin.split("");
        String[] serch = Serch.split("");
        int plusi = PlusI(serch);

        int Origin_length = origin.length;
       // System.out.println( SameString(serch) );
        for(int i = 0 ; i < origin.length; ){


           int equal_point = Origin.indexOf(Serch , i);

           if(equal_point>-1){
        	   System.out.println(equal_point);
        	   i = equal_point+1;
           }
           else{
        	   i++;
           }

        }


    }


    public static int PlusI(  String[] Serch ){


    	for(int j = 0; j < Serch.length; j++ ){

    	    if( Serch[j].equals(Serch[0]) && 0 < j){
    	    	return j;
    	    }

    	}


        return Serch.length;


    }


    public static boolean SearchWord(String[] Origin , String[] Serch , int i){


    	boolean SerchCheck = false;
    	for(int j = i , k = 0; k < Serch.length; j++ , k++){

    	    if( Serch[k].equals(Origin[j]) ){
    	    	SerchCheck = true;
    	    }
    	    else{
    	    	return false;
    	    }



    	}


    	return SerchCheck;

    }


    public static boolean SameString(String[] Serch ){


    	boolean SerchCheck = false;
    	for(int i = 0 ; i < Serch.length; i++){

    	    if( Serch[0].equals(Serch[i]) ){
    	    	SerchCheck = true;
    	    }
    	    else{
    	    	return false;
    	    }



    	}


    	return SerchCheck;

    }



}

Measured memory_bytes: 24952
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s[100005];
    int n,c1=0,c2=0,c3=0,c4=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
       cin>>s[i];
       if(s[i]=="AC")
        c1++;
       else if(s[i]=="WA")
        c2++;
       else if(s[i]=="TLE")
        c3++;
        else if(s[i]=="RE")
        c4++;
    }
    cout<<"AC x "<<c1<<endl<<"WA x "<<c2<<endl<<"TLE x "<<c3<<endl<<"RE x "<<c4<<endl;

}



Measured memory_bytes: 6728
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		scanner.close();
		int x = 0;
		int y = 0;
		int z = 0;
		for(int i = 0; i < 3; i++) {
			char c = s.charAt(i);
			if(c == 'a') {
				x ++;
			}else if(c == 'b') {
				y ++;
			}else if(c == 'c') {
				z ++;
			}
		}
		if(x == 1 && y == 1 && z == 1) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

using namespace std;

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


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

int main(){
	
	int arr;
	int flag = 1;
	
	scanf("%d", &arr);
	
	if(arr % 10 == arr/100){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
#define si(x) scanf("%d", &(x))

#define eps 1e-8
#define mod 998244353

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 100010
int n, m;
unordered_map<int, int> cnt, need;

int main() {
    cin >> n;
    int a;
    for (int i = 0; i < n; ++i) {
        si(a);
        ++cnt[a];
    }
    cin >> m;
    if (m > n) {
        cout << "NO";
        return 0;
    }
    for (int i = 0; i < m; ++i) {
        si(a);
        ++need[a];
    }
    for (auto item : need) {
        if (cnt[item.first] < item.second) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}

Measured memory_bytes: 16712
#include<stdio.h>
int main()
{	int n,W;
 	scanf("%d %d",&n,&W);
 	int i,j,w[n],v[n];
 	for(i=0;i<n;i++)
    {
      scanf("%d %d",&w[i],&v[i]);
    }
 	long long dp[n][W+1];
 	for(i=0;i<n;i++)
    {	dp[i][0]=0;
    }
 	for(i=0;i<n;i++)
    	{	for(j=1;j<=W;j++)
    		{	if(i==0)
				{
					if(j<w[i])
					dp[i][j]=0;
					else
					dp[i][j]=v[0];
				}
				else
				{
      				if(j<w[i])
          			dp[i][j]=dp[i-1][j];
      				else 
        			{
          				if(dp[i-1][j]>=dp[i-1][j-w[i]]+v[i])
              				dp[i][j]=dp[i-1][j];
          				else
              				dp[i][j]=dp[i-1][j-w[i]]+v[i];
        			}  
    			}
    		}
		}	
 	printf("%lld",dp[n-1][W]);
 	return 0;
}

Measured memory_bytes: 78336
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
#define int long long
using namespace std;
const int MOD=1e9+7;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
int n,a[100010];
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	sort(a+1,a+n+1);
	if(n&1){
		if(a[1]!=0)return puts("0")&0;
		for(int i=2;i<=n;i+=2)if(a[i]!=i||a[i+1]!=i)return puts("0")&0;
	}else{
		for(int i=1;i<=n;i+=2)if(a[i]!=i||a[i+1]!=i)return puts("0")&0;
	}
	int ans=1;
	for(int i=1;i<=n/2;i++)ans=(ans*2)%MOD;
	printf("%lld",ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
int main(){
  ll n,p;
  cin >> n >> p;
  ll ans=1,cp=p;
  for(ll i=2;i*i<=p;i++){
    ll j=0;
    while(cp%i==0){
      cp/=i;
      j++;
      if(j%n==0){
        ans*=i;
      }
    }
  }
  if(n==1){
    ans=p;
  }
  cout << ans;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<ll> p(m);
    vector<string> s(m);
    REP(i, m) cin >> p[i] >> s[i], p[i]--;

    vector<bool> ac(n);
    vector<ll> cnt(n);
    REP(i, m) {
        if(s[i] == "AC") {
            ac[p[i]] = true;
        } else if(!ac[p[i]]) {
            cnt[p[i]]++;
        }
    }

    ll num = 0, pen = 0;
    REP(i, n) {
        if(ac[i]) num++, pen += cnt[i]; 
    }
    cout << num << " " << pen << endl;

    return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>

int main(void){
	float w;
	while(scanf("%f",&w)!=EOF){
		if(w<=48.00){printf("light fly\n");}
		else if(w<=51.00){printf("fly\n");}
		else if(w<=54.00){printf("bantam\n");}
		else if(w<=57.00){printf("feather\n");}
		else if(w<=60.00){printf("light\n");}
		else if(w<=64.00){printf("light welter\n");}
		else if(w<=69.00){printf("welter\n");}
		else if(w<=75.00){printf("light middle\n");}
		else if(w<=81.00){printf("middle\n");}
		else if(w<=91.00){printf("light heavy\n");}
		else {printf("heavy\n");}
	}
	return 0;
}

Measured memory_bytes: 604
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def judge(s,g):
    t=g[0] - s[0]
    x=g[1] - s[1]
    y=g[2] - s[2]
    eprint('x,y,t ',end=':\n')
    eprint(x,y,t)
    if (abs(x)+abs(y))%2 == t%2 and (abs(x)+abs(y))<=t:
        return True
    else:
        return False


def main():
    n = int(input().strip())
    txy=[(0,0,0)]
    for i in range(n):
        tmp1, tmp2, tmp3 = map(int,input().strip().split())
        txy.append((tmp1,tmp2,tmp3))
    txy.sort()
    n+=1

    for i in range(0,n-1):
        if judge(txy[i], txy[i+1]) != True:
            print("No")
            return
    print("Yes")

        




if __name__ == '__main__':
    main()

Measured memory_bytes: 100824
S = input()

m = 0
cnt = 0

for s in S:
    if s in 'A':
        cnt += 1
    elif s in 'C':
        cnt += 1
    elif s in 'G':
        cnt += 1
    elif s in 'T':
        cnt += 1
    else:
        cnt = 0
    m = max(m, cnt)
print(m)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

public class Main {

	static FastScanner sc = new FastScanner();

	public static void main(String[] args) throws Exception {
		int[] I = new int[256];
		double[] en = new double[257];
		StringBuilder sb = new StringBuilder();
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			for (int i = 0; i < N; ++i) {
				double v = 1.0 * (i + 1) / N;
				en[i + 1] = -v * Math.log(v);
				I[i] = sc.nextInt();
			}
			double best = Double.MAX_VALUE;
			int bs = 0;
			int ba = 0;
			int bc = 0;
			for (int s = 0; s < 16; ++s) {
				for (int a = 0; a < 16; ++a) {
					OUT: for (int c = 0; c < 16; ++c) {
						int[] hist = new int[256];
						int r = s;
						for (int i = 0; i < N; ++i) {
							r = (a * r + c) & 0xFF;
							hist[(I[i] + r) & 0xFF]++;
						}
						double e = 0;
						for (int i = 0; i < 256; ++i) {
							if (hist[i] != 0) {
								e += en[hist[i]];
								if (e >= best - 1e-10) continue OUT;
							}
						}
						best = e;
						bs = s;
						ba = a;
						bc = c;
					}
				}
			}
			sb.append(bs + " " + ba + " " + bc + "\n");
		}
		System.out.print(sb);
	}

	static class FastScanner {
		Reader input;

		FastScanner() {
			this.input = new BufferedReader(new InputStreamReader(System.in));
		}

		int nextInt() throws IOException {
			int sign = 1;
			int b = input.read();
			while ((b < '0' || '9' < b) && b != '-' && b != '+') {
				b = input.read();
			}
			if (b == '-') {
				sign = -1;
				b = input.read();
			} else if (b == '+') {
				b = input.read();
			}
			int ret = b - '0';
			while (true) {
				b = input.read();
				if (b < '0' || '9' < b) return ret * sign;
				ret *= 10;
				ret += b - '0';
			}
		}
	}

}

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

using namespace std;

typedef struct SONG {
  string title;
  int second;
} song_t;

int main(void) {
  int n; cin >> n;
  song_t playlist[n];

  for (int i = 0; i < n; i++) {
    string str;
    int t;
    cin >> str >> t;
    
    playlist[i].second = t;
    playlist[i].title = str;
  }
  
  int time = 0;
  string lastOfNiwangokunHeard; cin >> lastOfNiwangokunHeard;
  bool isSleep = false;
  for (int i = 0; i < n; i++) {
    if (isSleep) {
      time += playlist[i].second;
      continue;
    }
    if (lastOfNiwangokunHeard == playlist[i].title) {
      isSleep = true;
    }
  }

  cout << time << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a * b << newl;
}

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

using namespace std;

#define MODULO 1000000007

using vi = vector<int>;
using ll = long long;

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int T = 1;
	int streak = 0;

	cin >> T;

	for (int t = 0; t < T; t++) {
		int c, d;

		cin >> c >> d;

		if (c == d) streak++;
		else streak = 0;

		if (streak == 3) {
			cout << "Yes" << endl;
			break;
		}

		if (t == T - 1) cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 3632
N,M=map(int,raw_input().split())
A=[raw_input() for _ in range(N)]
B=[raw_input() for _ in range(M)]

for i in range(N-M+1):
    index=A[i].find(B[0])
    if index==-1:
        continue
    for j in range(M):
        if A[i+j][index:index+M] !=B[j]:
            break
    else :
        print "Yes"
        break
else:
    print "No"
    

Measured memory_bytes: 2568
#include <stdio.h>

int main(void)
{
    int a, b, c, i, count;
    char buf[256];
    fgets(buf, 256, stdin);
    sscanf(buf, "%d %d %d", &a, &b, &c);
    count = 0;
    for (i = a; i <= b; ++i)
    {
        if (c % i == 0) {
            ++count;
        }
    }
    printf("%d\n", count);
    return 0;
}



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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i=0; i<n; ++i) cin >> a[i];
	vector<int> dp(n+2,INT_MAX);
	dp[0] = 0;
	for (int i=0; i<n; ++i){
		dp[i+1] = min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
		dp[i+2] = min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
	}
	cout << dp[n-1];
	return 0;
}


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

ll b(ll n, vector<ll> a) {
  sort(a.begin(), a.end());
  return abs(a[n-1] - a[0]);
}

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i =0;i<n;i++) {
    cin >> a[i];
  }
  cout << b(n, a);
}

Measured memory_bytes: 3560
/*  -*- coding: utf-8 -*-
 *
 * 2780.cc: Best Matched Pair
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

bool sequential(int n) {
  int d0 = n % 10;
  n /= 10;
  while (n) {
    int d1 = n % 10;
    if (d1 + 1 != d0) return false;
    d0--;
    n /= 10;
  }
  return true;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  int maxprd = -1;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      int prd = as[i] * as[j];
      if (maxprd < prd && sequential(prd))
	maxprd = prd;
    }

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



Measured memory_bytes: 3212
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader input = new BufferedReader (new InputStreamReader (System.in));
		
		for(;;)
		{
			String[] numberStr = input.readLine().split(" ");
			
			int max = Integer.parseInt(numberStr[0]);
			
			int sum = Integer.parseInt(numberStr[1]);
			
			if((max == 0)&&(sum == 0))
			{
				break;
			}
			
			int set = 0;
			
			for(int oneNum = 1; oneNum <= max - 2; oneNum++)
			{
				for(int twoNum = oneNum + 1; twoNum <= max + 1; twoNum++)
				{
					for(int threeNum = twoNum + 1; threeNum <= max; threeNum++)
					{
						if(oneNum + twoNum + threeNum == sum)
						{
							set++;
						}
					}
				}
			}
			
			System.out.println(set);
		}
	}
}



Measured memory_bytes: 24500
package main
import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

const MAX_LENGTH int = 2*10e5
const INFINT int = 10e9
var A []int = make([]int, MAX_LENGTH)
var L []int = make([]int, MAX_LENGTH/2 + 2)
var R []int = make([]int, MAX_LENGTH/2 + 2)


func merge(left, mid, right int) int64 {
	var count int64
	n1 := mid - left
	n2 := right - mid
	for i:=0; i<n1; i++ {
		L[i] = A[left+i]
	}
	L[n1] = INFINT
	for j:=0; j<n2; j++ {
		R[j] = A[mid+j]
	}
	R[n2] = INFINT
	i := 0
	j := 0
	for k:=left; k<right; k++ {
		if L[i] <= R[j] {
			A[k] = L[i]
			i += 1
		} else {
			A[k] = R[j]
			j += 1
			count += int64(n1-i)
		}
	}
	return count
}

func mergeSort(left, right int) int64 {
	if left + 1 < right	 {
		mid := (left + right) / 2
		v1 := mergeSort(left, mid)
		v2 := mergeSort(mid, right)
		v3 := merge(left, mid, right)
		return v1+v2+v3
	} else {
		return 0
	}
}

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}


func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	N := nextInt(scanner)
	for i:=0; i<N; i++ {
		A[i] = nextInt(scanner)
	}
	fmt.Println(mergeSort(0, N))
}


Measured memory_bytes: 16028
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
    int N, x;
    int c = 0;
    int a[110];
    cin >> N >> x;
    for(int i = 0; i < N; i++) cin >> a[i];
    sort(a,a+N);
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += a[i];
        if(sum > x) break;
        c++;
    }

    if(sum >= x) cout << c << endl;
    else cout << c - 1 << endl;

    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
template<class T>void addmod(T &a, ll b){a=(a+b)%MODV;}
template<class T>void mulmod(T &a, ll b){a=(a*b)%MODV;}
template<class T>bool domin(T &a, const T &b){return a>b?a=b,1:0;}
template<class T>bool domax(T &a, const T &b){return a<b?a=b,1:0;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf("%lld",&a);return a;}
dbl gdbl(){dbl a;scanf("%lf",&a);return a;}
long double gldbl(){long double a;scanf("%Lf",&a);return a;}


int main() {
  int n=gi();
  vector<vi> a(2,vi(n)), ans(2,vi(n,0));

  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      a[i][j]=gi();
    }
  }
  ans[1][n-1]=a[1][n-1];
  ans[0][n-1]=a[0][n-1]+a[1][n-1];
  for(int i=n-2;i>=0;i--){
    ans[1][i]=ans[1][i+1]+a[1][i];
    ans[0][i]=ans[0][i+1]+a[0][i];
    domax(ans[0][i],ans[1][i]+a[0][i]);
  }
  cout<<ans[0][0]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    char s[4];
    char t[4];
    scanf("%s",s);
    scanf("%s",t);
    int ans=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]==t[i]) ans++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
n = int(input())
li = [list(map(int,input().split())) for i in range(n)]

li.sort(key=lambda x:x[1])
time = 0
flag = 'Yes'

for i in li:
  time += i[0]
  if i[1]<time:
    flag = 'No'
    break

print(flag)


Measured memory_bytes: 53728
#include <iostream>




using namespace std;

int main() {

    int N; cin >> N;
    int a[200000+1];
    int ans[200000+1] = {0};
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    for(int i = 0; i < N; i++){
        int index = a[i];
        ans[index]++;
    }


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

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

pair<int,int> func(int x){
    int a=x%10;
    int b=0;
    while(x){
        b=x;
        x/=10;
    }
    return pair<int,int>(a,b);
}
int main() {
  int N;
  cin>>N;
  map<pair<int,int>,int>Q;
  for(int i=1;i<=N;i++){
      Q[func(i)]++;
  }
  int64_t cnt=0;
  for(int i=1;i<=N;i++){
      pair<int,int>S=func(i);
      pair<int,int>f(S.second,S.first);
      cnt+=Q[f];
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3628