akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long int INF = 3 * 1e17;

int main(){
    long long int n, k;
    cin >> n >> k;

    vector<int> a(n);
    map<int, vector<long long int>> mp;
    for(int i=0; i<n; i++){
        cin >> a[i];

        if(mp.find(a[i]) != mp.end()) mp[a[i]].push_back(i);
        if(mp.find(a[i]) == mp.end()) mp[a[i]] = {i};
    }

    vector<vector<long long int>> table(n, vector<long long int>(60));// 2 * 10^17 < 2^58
    for(int i=0; i<n; i++){
        mp[a[i]].push_back(mp[a[i]][0] + n);
        table[i][0] = (mp[a[i]][1] + 1) - i;

        mp[a[i]].erase(mp[a[i]].begin());
    }
    
    for(int j=0; j+1<60; j++){
        for(int i=0; i<n; i++){
            table[i][j+1] = min(INF, table[i][j] + table[(i + table[i][j]) % n][j]);
        }
    }

    int x = 0;
    long long int y = n*k;
    while(1){
        int nx = lower_bound(table[x].begin(), table[x].end(), y+1) - table[x].begin();
        if(nx == 0) break;

        y -= table[x][nx-1];
        x = (x + table[x][nx-1]) % n;
    }

    set<int> num;
    stack<int> st;
    for(int i=x; i<n; i++){
        if(num.find(a[i]) == num.end()){
            st.push(a[i]);
            num.insert(a[i]);
        }
        else{
            while(st.top() != a[i]){
                num.erase(st.top());
                st.pop();
            }
            num.erase(st.top());
            st.pop();
        }
    }

    vector<int> ans;
    while(st.empty() == false){
        ans.push_back(st.top());
        st.pop();
    }
    reverse(ans.begin(), ans.end());
    for(int i=0; i<(int)ans.size(); i++){
        cout << ans[i];
        if(i == (int)ans.size()-1) break;
        else cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 138580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" \
                              << "\n";

int main()
{
  vector<int> a(5);
  int ans = 0;
  int m, tmp = 10;
  REP(i, 5)
  {
    cin >> a.at(i);
    if (tmp > a.at(i) % 10 && a.at(i) % 10!=0)
    {
      tmp = a.at(i) % 10;
      m = i;
    }
  }
  REP(i, 5)
  {

    if (a.at(i) % 10 != 0 && i != m)
    {
      a.at(i) = (int)(a.at(i) / 10 + 1) * 10;
    }
    ans += a.at(i);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
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;}
char field[55][55];
int main() {
  int H, W; cin >> H >> W;
  for(int h=1; h<H+1; ++h) {
    for(int w=1; w<W+1; ++w) {
      cin >> field[h][w];
    }
  }
  for(int h=1; h<H+1; ++h) {
    for(int w=1; w<W+1; ++w) {
      if(field[h][w] == '.') {
        int cnt = 0;
        for(int i=h-1; i<=h+1; ++i) {
          for(int j=w-1; j<=w+1; ++j) {
            if(field[i][j] == '#') ++cnt;
          }
        }
        field[h][w] = '0'+cnt;
      }
    }
  }
  for(int h=1; h<H+1; ++h) {
    for(int w=1; w<W+1; ++w) {
      printf("%c",field[h][w]);
    }
    cout << endl;
  }
}


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

int main(){
  string w; cin >> w;
  sort(w.begin(),w.end());
  bool judge=true;
  for(int i=0; i<w.size(); i=i+2){
    if(w[i]==w[i+1]) continue;
    else judge=false;
  }  
  cout << ( judge ? "Yes" : "No" ) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
ll n,k;
ll h[100000],memo[100000];
ll dp(ll i){
	if(i == n-1) return 0;
	if(memo[i] != -1) return memo[i];
	ll ret = INT_MAX;
	for(int j=1;j<=k;j++){
		if(i+j<n)
			ret = min(ret,dp(i+j)+abs(h[i]-h[i+j]));
	}
	memo[i] = ret;
	return ret;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	memset(memo,-1,sizeof(memo));
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>h[i];
	dp(0);
	cout<<memo[0]<<"\n";
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100001], answer=0, n;
int main ()
{
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+2*n);
	for(int i=1;i<=2*n;i+=2){
		answer+=a[i];
	}
	cout<<answer<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 1000000007
#define MOD 1e9+7
int main(){
  //input
  lint n,i;cin>>n;bool ans=true;
  vint t(n);vint x(n);vint y(n);
  for(i=0;i<n;i++){
    cin>>t[i]>>x[i]>>y[i];
  }
  //caricurate
  vint pt(n);vint px(n);vint py(n);
  pt[0]=t[0];px[0]=x[0];py[0]=y[0];
  for(i=1;i<n;i++){
    pt[i]=t[i]-t[i-1];
    px[i]=abs(x[i]-x[i-1]);
    py[i]=abs(y[i]-y[i-1]);
  }
  for(i=0;i<n;i++){
   if(((pt[i]%2)!=((px[i]+py[i])%2))||(px[i]+py[i]>pt[i])){
   ans=false;break;
   }
  }
  //output
   cout<<(ans?"Yes":"No")<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <complex>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;
const D EPS = 1e-9;    // 許容誤差。問題によって変える
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
D dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積　cross(a,b) = |a||b|sinθ
D cross(P a, P b) {
  return (conj(a)*b).Y;
}

// 点の進行方向
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

/* 交差判定　直線・線分は縮退してはならない。接する場合は交差するとみなす。isecはintersectの略 */

// 直線と点
bool isecLP(P a1, P a2, P b) {
  return abs(ccw(a1, a2, b)) != 1;  // return EQ(cross(a2-a1, b-a1), 0); と等価
}

// 直線と直線
bool isNotParallel(P a1, P a2, P b1, P b2) {
  return !isecLP(a2-a1, b2-b1, 0);
}

int main() {
  int n;
  cin >> n;
  rep(_,n) {
    VP ps(4);
    rep(i,4) {
      D x,y;
      cin >> x >> y;
      ps[i] = P(x,y);
    }
    cout << (isNotParallel(ps[0], ps[1], ps[2], ps[3]) ? "NO" : "YES") << endl;
  }
  return 0;
}

Measured memory_bytes: 1248
a,b,c,x=[int(input()) for i in range(4)]
cnt=0
for i in range(a+1):
	if 500*i>x:break
	for j in range(b+1):
		if 500*i+100*j>x:break
		if (x-500*i-100*j)<=50*c:cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    ll n,k;
    cin>>n>>k;
    vi v(n);
    rep(i,0,n)
    {
        cin>>v[i];
    }
    sort(all(v));

    k=min(k,n);
    ll ans=0;
    rep(i,0,n-k)
    {
        ans+=v[i];
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4732
n = int(input())
a = list(int(input()) for i in range(2**n))
b = []
i = 0
while n > 0:
    while i < 2**n:
        if a[i] > a[i+1]:
            b.append(a[i]-a[i+1])
        elif a[i] < a[i+1]:
            b.append(a[i+1]-a[i])
        else:
            b.append(a[i])
        i += 2
    a = list(b)
    b.clear()
    n -= 1
    i = 0
print(a[0])

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> ac(n, false);
  vector<int> wa(n, 0);
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (s == "AC") {
      ac[p] = true;
    } else {
      if (!ac[p]) {
        wa[p]++;
      }
    }
  }
  int corct = 0;
  int penl = 0;
  for (int i = 0; i < n; i++) {
    if (ac[i]) {
      corct++;
      penl += wa[i];
    }
  }
  cout << corct << " " << penl << endl;
}


Measured memory_bytes: 640
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] In = Console.ReadLine().Split(' ');
            int[] H = new int[n];
            for (int i = 0; i < n; i++)
            {
                H[i] = int.Parse(In[i]);
            }
            int[] S = new int[n - 1];//subtraction
            for(int i = 0; i <= n - 2; i++)
            {
                S[i] = H[i] - H[i + 1];
            }
            int max = 0;
            int cnt = 0;
            for(int i = 0; i <= n - 2; i++)
            {
                if (S[i] >= 0)
                {
                    cnt++;
                    if (cnt > max) max = cnt;
                }
                else { cnt = 0; }
            }
            Console.WriteLine(max);
        }
    }
}

//TLE
//namespace C
//{
//    class Program
//    {
//        static void Main(string[] args)
//        {
//            int n = int.Parse(Console.ReadLine());
//            string[] In = Console.ReadLine().Split(' ');
//            int[] H = new int[n];
//            for(int i = 0; i < n; i++)
//            {
//                H[i] = int.Parse(In[i]);
//            }
//            int max = 0;
//            for(int i = 0; i <= n-2; i++)
//            {
//                int cnt = 0;
//                int temp =i;
//                for(int j = i + 1; j <= n - 1; j++)
//                {
//                    if (H[temp] >= H[j])
//                    {
//                        cnt++;
//                        temp = j;
//                    }
//                    else break;
//                }
//                if (cnt > max) max = cnt;
//            }
//            Console.WriteLine(max);
//        }
//    }
//}


Measured memory_bytes: 39132
n, m, l = map(int, input().split())
a = [[0 for j in range(m)] for i in range(n)]
b = [[0 for k in range(l)] for j in range(m)]
c = [[0 for k in range(l)] for i in range(n)]

for i in range(n):
  a[i] = list(map(int, input().split()))
for i in range(m):
  b[i] = list(map(int, input().split()))
for i in range(n):
  for k in range(l):
    sum = 0
    for j in range(m):
      sum += a[i][j] * b[j][k]
    c[i][k] = sum
    if k == 0:
      print(c[i][k], end = "")
    else:
      print("", c[i][k], end = "")
  print()


Measured memory_bytes: 7160
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int H,W;
int N;
int a[10005];
int s[105][105];

signed main(){
    cin>>H>>W;
    cin>>N;
    for(int i=0;i<N;++i)cin>>a[i];
    int n = 0;
    for(int h=0;h<H;++h){
        if(h%2==0){
            for(int w=0;w<W;++w){
                a[n]--;
                s[h][w]=n+1;
                if(a[n]==0)n++;
            }
        }
        else for(int w=W-1;w>=0;--w){
            a[n]--;
            s[h][w]=n+1;
            if(a[n]==0)n++;
        }
    }

    for(int h=0;h<H;++h){
        for(int w=0;w<W;++w){
            cout<<s[h][w];
            if(w!=W-1)cout<<" ";
        }
        cout<<endl;
    }

}


Measured memory_bytes: 512
#include <stdio.h>

long long ModSum(int N){
  int i;
  long long S;
  S = 0;
  for(i = N - 1;i >= 0;i--) S += i;
  return S;
}

int main(void){
  int N;
  scanf("%d", &N);
  printf("%lld\n", ModSum(N));
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K;
  cin >> N >> K;
  int kei = 1;
  for(int i=0; i<N; i++){
    kei = min(kei*2,kei+K);
  }
  cout << kei << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 10000000
#define rep(i,a,b) for(ll (i)=a;(i)<(ll)(b);(i)++)
using ipair = pair<ll,ll>;

int main(){
    ll N;
    cin >> N;
    ll idx=1;
    ll sum=0;
    while(1){
        ll tmp = sum + pow(26,idx);
        if(tmp>=N) break;
        idx ++;
        sum = tmp;
    }
    ll dif = N-sum-1;
    string ans ="";
    for(int i=0;i<idx;i++) ans = ans + "a";
    
    ll cnt=idx-1;
    while(cnt>=0){
        ll sup = dif/pow(26,cnt);
        dif -= sup * pow(26,cnt);
        ans[idx-1-cnt] = sup + 'a';
        cnt --;
    }
    cout << ans << endl;
}

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

int main(){
      int N,K,X,Y,ans=0;cin >> N >> K >> X >> Y;
      for(int i = 0;i<N;i++){
            if(i>=K){
                  ans += Y;
            }else{
                 ans += X;
            }
      }
     cout << ans << endl;
} 

Measured memory_bytes: 256
d = {}

for i in range(3):
    a = input().split()
    for j in range(3):
        d[a[j]] = (i,j)
t = [[0 for _ in range(3)] for _ in range(3)]
n = int(input())
for i in range(n):
    b = input()
    if(b in d):t[d[b][0]][d[b][1]] = 1
for i in range(3):
    if(t[0][i] + t[1][i] + t[2][i] == 3):
        print('Yes')
        exit()
    if(t[i][0] + t[i][1] + t[i][2] == 3):
        print('Yes')
        exit()
if(t[0][0]+t[1][1]+t[2][2] == 3):
    print('Yes')
    exit()
if(t[0][2]+t[1][1]+t[2][0] == 3):
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 3064
a, b = map(int, input().split())
result = []
while (a or b):
    if (a > b):
        temp = a
        a = b
        b = temp
    result.append((a, b))
    a, b = map(int, input().split())

for item in result:
    print(item[0], end = ' ')
    print(item[1])


Measured memory_bytes: 6164
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int[] a = new int[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		
		int cnt = 0;
		
		Map<Integer,Integer> map = new HashMap<>();
		
		for(int i = 0; i < n; i++) {
			if(!map.containsKey(a[i])) {
				map.put(a[i], 0);
			}
			
			map.put(a[i], map.get(a[i])+1);
			
			
		}
		
		for(int s: map.keySet()) {
			if(map.get(s)%2!=0) {
				cnt++;
			}
		}
		System.out.println(cnt);
		
		
	}

}


Measured memory_bytes: 64928
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define mp make_pair
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

void solve()
{
	lli k, n, i, j, c=0, s=0, mn=INT_MAX;
	cin>>k>>n;
    lli arr[n];
    for(i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);


    s=arr[n-1] - arr[0];
    mn=s;
   for(i=1;i<n;i++)
   {
   	  c=arr[n-1]-arr[i] + (k+arr[i-1]) - arr[n-1];

   	  mn=min(mn,c);

   }
   cout<<mn<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

		solve();
	return 0;
}




Measured memory_bytes: 1792
import java.util.*;
import java.io.*;

class Main{
  public static StringBuilder bl = new StringBuilder();
  public static int n;
  public static int M[][];
  public static final int INFTY = (int)Double.POSITIVE_INFINITY;
  public static final int WHITE = 0;
  public static final int GRAY = 1;
  public static final int BLACK = 2;
  public static List<List<Pair>> adj = new ArrayList<List<Pair>>();
  // public static ArrayList<ArrayList<Map<Integer,Integer>>> adj;
  public static void main(String args[])throws Exception{
    Scanner sc = new Scanner(System.in);
    int k,u,v,c;
    n = sc.nextInt();
    // adj = new ArrayList<ArrayList<Map<Integer,Integer>>>();
    // for(int i = 0 ; i < n; i++){
    //   for(int j = 0; j < n; j++){
    //     M[i][j] = INFTY;
    //   }
    // }
    for(int i = 0 ;i<n; i++){
      adj.add(new ArrayList<Pair>());
      // String s[] = br.readLine().split("\\s+");
      // Map<Integer,Integer> map = new HashMap<Integer,Integer>();
      // ArrayList<Map<Integer,Integer>>adj1 = new ArrayList<Map<Integer,Integer>>();
      u = sc.nextInt();
      k = sc.nextInt();
      for(int j =0; j<k; j++){
        v = sc.nextInt();
        c = sc.nextInt();
        adj.get(u).add(new Pair(v, c));
        // map.put(v,c);
      }
      // adj1.add(map);
      // adj.add(adj1);
    }
    dijkstra();
  }

  static void dijkstra(){
    // Map<Integer,Integer> map = new HashMap<Integer,Integer>();
    // Map<Integer,Integer> map1 = new HashMap<Integer,Integer>();
    // ArrayList<Map<Integer,Integer>>PQ = new ArrayList<Map<Integer,Integer>>();
    int color[] = new int[n];
    int d[] = new int[n];
    PriorityQueue<Pair> PQ = new PriorityQueue<Pair>();
    PQ.add(new Pair(0, 0));
    for(int i = 0; i<n; i++){
      d[i] = INFTY;
      color[i] = WHITE;
    }
    //arrays.fill(d,INFTY)でもok
    d[0] = 0;
    // map.put(0,0);
    // PQ.add(map);
    // color[0] = GRAY;
    while(PQ.isEmpty() != true){
      // map.put(PQ.get(0),PQ.remove());
      Pair f = PQ.poll();
      int u = f.second;
      color[u] = BLACK;

      if(d[u] < f.first*(-1))continue;
      for(int i = 0; i<adj.get(u).size(); i++){
        int v = adj.get(u).get(i).first;
        if(color[v] == BLACK)continue;
        int sec = adj.get(u).get(i).second;
        if(d[v] > d[u] + sec){
          d[v] = d[u] + sec;
          PQ.add(new Pair(d[v], v));
        }
      }
    }
    for(int i = 0; i<n; i++){
      bl.append(i).append(" ").append(d[i]).append("\n");
    }
    System.out.print(bl);
  }
}

class Pair implements Comparable<Pair> {
  int first;
  int second;
  public Pair(int first, int second) {
    super();
    this.first = first;
    this.second = second;
  }
  public int compareTo(Pair o) {
      return this.first - o.first;
  }

}


Measured memory_bytes: 274504
#include <bits/stdc++.h>
#define ll long long
#define P pair<int,int>
#define MAX_N 200002
using namespace std;

int main(){
    bool flag = true;
    int n;
    cin>>n;
    vector<int> A[n+1];
    map<int, int> mp;
    for(int i = 0; i <n; i++){
        int a;
        cin>>a;
        if(mp.find(a) != mp.end()){
            flag = false;
            break;
        }else{
            mp[a] = 1;
        }
    }
    if(flag) cout<< "YES" <<endl;
    else cout<< "NO" <<endl;
    return 0;
}

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

int main() {
    char A, B;
    cin >> A >> B;
    if(A < B) {
        cout << "<" << endl;
    } else if(A > B) {
        cout << ">" << endl;
    } else if(A == B) {
        cout << "=" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<climits>
#include<string.h>
using namespace std;

int main(){
    int n;
    while(cin>>n,n){;
    vector<int>v;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        v.push_back(s.length());
    }
    int nee[5]={5,7,5,7,7};
    for(int i=0;i<v.size();i++){
        int cur=0,ne=0,no=0;
        for(int j=i;j<v.size();j++){
            //cout<<i<<" "<<j<<" "<<cur<<" "<<ne<<endl;
            if(cur+v[j]>nee[ne]){
                break;
            }
            if(cur+v[j]==nee[ne]){
                if(ne==4){
                    cout<<i+1<<endl;
                    goto ne;
                } else {
                    cur=0;ne++;
                }
            } else {
                cur+=v[j];
            }
        }
    }
        ne:;}
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#include<vector>
#define LL long long
using namespace std;
LL n; int m; vector<int> A;
void solve(LL n)
{
	int p=++m; if(n==1) return ;
	if(n&1) A.push_back(p),solve(n-1);
	else solve(n/2),A.push_back(p);
}
int main()
{
	int i;
	cin>>n; n++,solve(n);
	printf("%d\n",2*A.size());
	for(i=0;i<A.size();i++)
		printf("%d ",A.size()-A[i]+1);
	for(i=0;i<A.size();i++)
		printf("%d ",i+1);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
// #include <bits/stdc++.h>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
typedef long long LL;
const int N = 5005;
const int K=31;  
const int M=10921000; 
const LL INF = (1LL<<40); 
const LL MOD = 998244353;
int n,m;
char s[N];
int main ()
{
    while (~scanf("%s",s))
    {
        int l = strlen(s);
        for (int i=0;i<l-8;i++)
            printf("%c", s[i]);
        printf("\n");
    }
    return 0;
}

/*



*/

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val N = sc.nextInt
    val A = Array.fill[Int](N)(sc.nextInt)
    val X0 = A.filter(x => x % 2 != 0).length
    val X4 = A.filter(x => x % 4 == 0).length
    val X2 = N - X0 - X4
    if ((if (X2 != 0) (0) else (-1)) + X0 <= X4) (println("Yes")) else (println("No"))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 55968
#include <iostream>

using namespace std;

long long int gcd(long long int x, long long int y) {
  if (x < y) {
    return gcd(y, x);
  }

  if (y == 0) {
    return x;
  }

  return gcd(y, x%y);
}

long long int lcm(long long int x, long long int y) {
  return x*y/gcd(x, y);
}

int main(void) {
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;

  long long int cnt_b = b - b/c - b/d + b/lcm(c, d);
  long long int cnt_a = (a-1) - (a-1)/c - (a-1)/d + (a-1)/lcm(c, d);

  cout << cnt_b - cnt_a << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
A=[]
for _ in range(N):
    time_req,end=map(int, sys.stdin.readline().split()) #所要時間、締め切り
    A.append((end,time_req))
A.sort()

cur=0   #現在の時刻

for end,time_req in A:
    cur+=time_req
    if cur<=end:    #締め切りまでに仕事が終わる
        pass
    else:           #締め切りまでに仕事が終わらない場合
        print "No"
        quit()
else:
    print "Yes"

Measured memory_bytes: 53020
#include<iostream>
#include<cstring>

using namespace std;

const int maxn=1e6;
int A[maxn];

int parent(int i){
	return i/2;
}

int left(int i){
	return 2*i;
}

int right(int i)
{
	return 2*i+1;
}

int main()
{
	int H;
	cin>>H;
	memset(A,0,sizeof(A));
	for(int i=1;i<=H;i++)cin>>A[i];
	for(int i=1;i<=H;i++){
		cout<<"node "<<i<<": key = "<<A[i]<<", ";
		if(parent(i)>=1){
			cout<<"parent key = "<<A[parent(i)]<<", ";
		}
		if(left(i)<=H){
			cout<<"left key = "<<A[left(i)]<<", ";
		}
		if(right(i)<=H){
			cout<<"right key = "<<A[right(i)]<<", ";
		}
		cout<<endl;
	}
	return 0;	
}


Measured memory_bytes: 7008
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((a>=1)&&(a<=10^4) &&(b>=1)&&(b<=10^4)&&(c>=1)&&(c<=10^4)&&(d>=1)&&(d<=10^4))
	if((a*b) > (c*d))
	cout<<a*b;
	else
	cout<<c*d;
	return 0;
}

Measured memory_bytes: 256
local read = io.read

local n = read("n")
local a = {}
for i = 1, n do
	a[i] = read("n")
end

local mod_num = 1000000007

local back_sum_t = {}
back_sum_t[n + 1] = 0
for i = n, 2, -1 do
	back_sum_t[i] = (a[i] + back_sum_t[i + 1]) % mod_num
end
local out = 0
for i = 1, n - 1 do
	out = (out + ((a[i] * back_sum_t[i + 1]) % mod_num)) % mod_num
end

print(out)


Measured memory_bytes: 14628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int R;
	cin>>R;
	if(R<1200){
		cout<<"ABC"<<endl;
	}else if(R < 2800){
		cout<<"ARC"<<endl;
	}else{
		cout<<"AGC"<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  int t=1;
  //cin>>t;
    while(t--){
            int n;
            cin>>n;
    int arr[2][n];
    int i,j;
    fr(i,0,2)
    {
        fr(j,0,n)
        cin>>arr[i][j];
    }
    int l[2][n],r[2][n];
    r[0][n-1]=arr[0][n-1];
    r[1][n-1]=arr[1][n-1];
    for(j=n-2;j>=0;j--)
    {
        r[0][j]=arr[0][j]+r[0][j+1];
         r[1][j]=arr[1][j]+r[1][j+1];
    }
    l[0][0]=arr[0][0];
    l[1][0]=arr[1][0];
    for(j=1;j<n;j++)
    {
        l[0][j]=arr[0][j]+l[0][j-1];
         l[1][j]=arr[1][j]+l[1][j-1];
    }
    int ans=0;
    fr(i,0,n)
    {
        ans=max(ans,l[0][i]+r[1][i]);
    }
    cout<<ans;

  }
  return 0;
  }



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

struct unionfind {
	ll N;
	vector<ll> par;
	vector<ll> sz;//根の場合、その木のサイズ

	unionfind(ll N0) {
		N = N0;
		par.assign(N + 1, -1);
		sz.assign(N + 1, 1);

	}

	ll root(ll x) {
		if (par[x] == -1) { return x; }
		par[x] = root(par[x]);
		return par[x];
	}

	bool same(ll x, ll y) {
		return root(x) == root(y);
	}

	void unite(ll x, ll y) {
		ll a = root(x);
		ll b = root(y);
		if (a != b) { par[a] = b; sz[b] += sz[a];
		}
		
	}

	ll size(ll x) {
		ll r = root(x);
		return sz[r];
	}
};

int main() {

	ll N, M, K;
	cin >> N >> M >> K;

	unionfind un(N);

	
	vector<ll> A(M + 1), B(M + 1);
	vector<ll> C(K + 1), D(K + 1);

	repn(i, M) cin >> A[i] >> B[i];
	repn(i, K) cin >> C[i] >> D[i];

	repn(i, M) un.unite(A[i], B[i]);

	vector<ll> ans(N + 1);
	repn(i, N) ans[i] = un.size(i)-1;

	

	repn(i, M) {
		if (un.same(A[i], B[i])) { ans[A[i]]--; ans[B[i]]--; }
	}

	repn(i, K) {
		if (un.same(C[i], D[i])) { ans[C[i]]--; ans[D[i]]--; }
	}

	repn(i, N) cout << ans[i]<<" ";

	system("PAUSE");
}






Measured memory_bytes: 7412
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
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 print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define DEBUG_VEC2(v) rep(i,v.size())cout<<#v<<":"<<v[i]<<'\n'
#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 pi=pair<int,int>;
using pll=pair<int,int>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };


void solve() {
    ll n,m; cin >> n >> m;
    ll ans = 0;
    ans += min(n,m/2);
    n -= ans;
    m -= 2*ans;
    ans += m/4;
    print(ans);
}

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: 3636
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
    
dp = [[0]*pow(2,n) for _ in range(n+1)]
dp[0][0] = 1
M = 10**9+7
for i in range(1,n+1):
    comb = (1<<(i)) - 1
    while comb < 1 << n:
        # ここに処理
        for j in range(n):
            if comb>>j and a[i-1][j]:
                dp[i][comb] += dp[i-1][comb-(1<<j)]
                dp[i][comb] %= M
        x = comb & (-comb); y = comb + x
        comb = (((comb&~y) // x )>>1) | y
print(dp[n][pow(2,n)-1])

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

string FILENAME = "template";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;

#define forl(V, N) for(int V = 0; V < N; V++)
#define forll(V, S, E) for(int V = S; V < E; V++)
#define fore(V, N) for(auto &V:N)
#define print(X) cout << X
#define printsp(X) cout << X << " "
#define println(X) cout << X << endl
#define rem(X) X.top(); X.pop()
#define graph unordered_map<int, vector<int>>
#define vi vector<int>
#define pb push_back
#define ll long long

int main() {
    int N;
    cin >> N;
    vector<ll> nums(N);
    vector<ll> onecount(60);
    vector<ll> zerocount(60);
    forl(i, N) cin >> nums[i];
    fore(num, nums) {
        forl(i, 60) {
            ll test = pow(2, i);
            if(num & test) onecount[i]++;
            else zerocount[i]++;
        }
    }
    ll res = 0;
    forl(i, 60) {
        ll test = pow(2, i);
        ll val = ((((test % 1000000007) * (onecount[i] % 1000000007)) % 1000000007) * (zerocount[i] % 1000000007)) % 1000000007;
        res += val;
    }
    println(res % 1000000007);
}

Measured memory_bytes: 2560
#include<iostream>
#include<queue>
using namespace std;
#define int long long
signed main(){
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	priority_queue<pair<int,int> >h;
	while(a--){
		int w;
		cin>>w;
		h.push(make_pair(w,1));
	}
	while(b--){
		int w;
		cin>>w;
		h.push(make_pair(w,2));
	}
	while(c--){
		int w;
		cin>>w;
		h.push(make_pair(w,3));
	}
	int z=x+y;
	int ans=0;
	while(z){
		pair<int,int>f=h.top();
		h.pop();
		if(f.second==3){
			ans+=f.first;
			--z;
		}
		else if(f.second==1&&x){
			ans+=f.first;
			--x;
			--z;
		}
		else if(f.second==2&&y){
			ans+=f.first;
			--y;
			--z;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  vector<ll> a(n);
  rep(i, n)  {
    cin >> a[i];
    a[i] -= (i+1);
  }
  sort(a.begin(), a.end());

  ll ans = 0;
  rep(i, n) ans += abs(a[i] - a[n/2]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4788
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>

using namespace std;

#define ZZZ -1000000007

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

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

	sort(a, a + n);

	int sum = 0;

	for (int i = 0; i < n - 1; i++) {
		sum += a[i];
	}

	if (a[n-1] < sum) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, k, n, ans = 0, m, t, bef, a;
  scanf("%d%d%d", &n, &m, &t);
  bef = -m;
  for(i = 0; i < n; ++i) {
    scanf("%d", &a);
    if(a - bef > 2 * m) ans += a - bef - 2 * m;
    bef = a;
  }
  if(t - a > m) ans += t - a - m;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2752
#include <iostream>
#include <cstdint>

using namespace std;

int main(int argc, char const* argv[]) {
	int32_t N, M;

	cin >> N;
	cin >> M;

	int32_t count = 0;
	for (int32_t i = 1; i <= M; i++) {
		int32_t t;
		cin >> t;
		count += t;
	}

	int32_t res = N - count;
	if (res < 0)
		res = -1;

	cout << res << endl;

	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

int main() {
    cin >> n >> m;
    if (n % m)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

		int max = 0;
		for (int i = 0; i < n; i++) {
			max = Math.max(max, a[i]);
		}

		int min = max;
		int idx = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == max) {
				continue;
			}
			int d = Math.abs(max / 2 - a[i]);
			if (d < min) {
				min = d;
				idx = i;
			}
		}
		System.out.println(max + " " + a[idx]);
	}
}


Measured memory_bytes: 50192
#include<stdio.h>

int main()
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if (W>=x+r && H>=y+r && r<=x && r<=y && x>=0 && y>=0){
		printf("Yes\n");}
		else {
			printf("No\n");}
			
	return 0;
}


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

int main()
{
  string S;
  cin >> S;
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" <<endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n = INF;
	cin >> n;
	int ans = 1;
	bool yes = false;
	for(int i =1;i<n+1;i++)  {	
		if(int(i*1.08) == n) { 
			ans = i;
			yes = true;
		}
	}
	if(yes)
		cout << ans << '\n';
	else
		cout << ":(\n";
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(){
	char a[11234],b[11234];
	scanf(" %s", a);
	scanf(" %s", b);
	if (strlen(a) < strlen(b)) {
		puts("LESS");
	}else if (strlen(a) > strlen(b)){
		puts("GREATER");
	}else{
		if (strcmp(a,b) < 0){
			puts("LESS");
		}else if (strcmp(a,b) > 0) {
			puts("GREATER");
		}else{
			puts("EQUAL");
		}
	}
	return 0;
}


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

namespace ABC128B
{
    class ReverseComparer<T> : IComparer<T>
    {
        private IComparer<T> comparer;

        public ReverseComparer(IComparer<T> comparer)
        {
            this.comparer = comparer;
        }

        public int Compare(T x, T y)
        {
            // 指定する引数の順序を逆にすることで、元になったIComparer<T>とは逆の結果を返す
            return comparer.Compare(y, x);
        }
    }

    class Program
    {

        // 内容はそのままで並べ替え順序を逆にしたSortedListを作成するメソッド
        static SortedList<TKey, TValue> CreateReversed<TKey, TValue>(SortedList<TKey, TValue> source)
        {
            // コレクションの内容はsourceと同じもの、並べ替え順序はsource.Comparerで
            // 定義されているものとは逆となるようなインスタンスを返す
            return new SortedList<TKey, TValue>(source, new ReverseComparer<TKey>(source.Comparer));
        }

          static void Main(string[] args)
        {
            SortedDictionary<string, SortedList<int, int>> R_Book = new SortedDictionary<string, SortedList<int, int>>();
            int N = int.Parse(Console.ReadLine());
            for (int i = 0; i < N; i++)
            {
                string[] inputSP = Console.ReadLine().Split();
                SortedList<int, int> R_List = new SortedList<int, int>();
                string city = inputSP[0];
                int num = i + 1;
                int evaluation = int.Parse(inputSP[1]);
                R_List.Add(evaluation,num);

                if (R_Book.ContainsKey(city))
                {
                    R_Book[city].Add(evaluation,num);
                }
                else
                {
                    R_Book.Add(city, R_List);
                }
            }
            foreach (var item in R_Book)
            {
                //Console.WriteLine(item.Key + " ");

                foreach (var item2 in CreateReversed(item.Value))
                {
                    //Console.WriteLine(item2.Key + " " + item2.Value);
                    Console.WriteLine(item2.Value);
                }
            }
        }
    }
}


Measured memory_bytes: 13536
import sys
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  G[a].append(b)
  G[b].append(a)
seen = [False]*n
def dfs(v, rep):
  seen[v] = True
  for nv in G[v]:
    if seen[nv]:
      continue
    rep.append(nv+1)
    dfs(nv, rep)
    break
  else:
    return rep
L1, L2 = [], []
dfs(0, L1)
dfs(0, L2)
ANS = L2[::-1] + [1] + L1
print(len(ANS))
print(*ANS)

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

using namespace std;

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

	vector<int> dp(n,1e9);
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i],abs(a[i-1]-a[i])+dp[i-1]);
		dp[i]=min(dp[i],abs(a[i-2]-a[i])+dp[i-2]);
	}

	// for(auto i:dp)
	// 	cout<<i<<" ";
	// cout<<endl;
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N,p[15] ;
  cin >> N;
  cinf(N,p) ;
  int max=0,sum=0 ;
  for(int i=0;i<N;i++){
    sum += p[i] ;
    if( p[i] > max)
      max = p[i] ;
  }
  cout << sum - max / 2 << endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<queue>
 
 int main(){
    using namespace std;
     
    int n,i;
    cin>>n>>i;
    queue<int> q[n]={};

    for(int j=0;j<i;j++){
        int t,inst1,inst2;
        cin>>inst1>>t;
        switch(inst1){
            case 0:{
                cin>>inst2;
                q[t].push(inst2);//backから要素を入れる
                break;
            }
            case 1:{
                if(!q[t].empty()){
                    cout<<q[t].front()<<endl;//frontから要素を取り出す
                }
                break;
            }
            case 2:{
                if(!q[t].empty()){
                    q[t].pop();//要素の削除
                }
                break;
            }
        }
    }
    return 0;
 }


Measured memory_bytes: 4288
# -*- coding: UTF-8 -*-
# Stack

top = 0
S = {}

def push(x):
    global top
    global S
    top += 1
    S[top] = x

def pop():
    global top
    global S
    top -= 1
    return S[top + 1]

input_list = list(input().split()) #計算対象（スペース区切り→配列に展開）

for target in input_list:
    if target == '+':
        a = pop()
        b = pop()
        c = b+a
        push(c)
    elif target == '-':
        a = pop()
        b = pop()
        c = b-a
        push(c)
    elif target == '*':
        a = pop()
        b = pop()
        c = b*a
        push(c)
    else:
        push(int(target))

print(pop())



Measured memory_bytes: 5604
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

AA = [0] * (n + 1)
BB = [0] * (m + 1)

for itr, a in enumerate(A):
  AA[itr + 1] = a + AA[itr]

for itr, b in enumerate(B):
  BB[itr + 1] = b + BB[itr]

ans = 0
for itr, aa in enumerate(AA):
  if aa <= k:
    pos = k - aa
    # にぶたん
    ok = 0
    ng = m + 1
    while abs(ok - ng) > 1:
      mid = (ok + ng) // 2
      if aa + BB[mid] > k:
        ng = mid
      else:
        ok = mid
    ans = max(ans, ok + itr)
  else:
    break
print(ans)
  

Measured memory_bytes: 47548
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin>>t;
	while (t--)
	{
		int n;
		cin >> n;
		vector<ld> dp(n + 1);
		dp[0] = 1;
		for (int i = 0; i < n; i++) {
			ld pd;
			cin >> pd;
			for (int j = i + 1; j >= 0; j--) {
				dp[j] = (j == 0 ? 0 : dp[j - 1] * pd) + dp[j] * (1.0 - pd);
			}
		}
		ld ans = 0;
		for (int i = (n + 1) / 2; i <= n; i++) ans += dp[i];
		cout << fixed << setprecision(10) << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 3816
n, p = map(int, input().split())
a = list(map(int, input().split()))

count = 0
for i in a:
    if i%2 == 0:
        count += 1
if count == n:
    if p == 1:
        print(0)
    else:
        print(2**n)
else:
    print(2**(n-1))

    


Measured memory_bytes: 9184
#include <iostream>

using std::cout;
using std::endl;
using std::cin;

bool f[100'010];
int  c[100'010];

int main() {
	for(int i =2; i <=100000; ++i)
		if(!f[i])
			for(int j = i + i ;j <=100000; j += i )
				f[j]= true ;
	for(int i =3; i <=100000; i += 2)
		if(!f[i] && !f[(i + 1) / 2])
			++c[i];
	for(int i =3; i <=100000; ++i)
		c[i]+= c[i - 1];
	int N, L, R;
	cin >> N;
	while (N--) {
		cin >> L >> R;
		cout << c[R] - c[L-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
	list<int> L;
	list<int>::iterator itr = L.begin(); 
	int q, query, x;
	cin >> q;
	rep(i, q)
	{
		cin >> query;
		if (query == 0)
		{
			cin >> x;
			L.insert(itr, x);
			itr--;
		}
		else if (query == 1)
		{
			cin >> x;
			if (x >= 0)
			{
			    rep(j, x)
			    {
			        itr++;
			    }
			}
			else
			{
			    rep(j, -x)
			    {
			        itr--;
			    }
			}
		}
		else
		{
			itr = L.erase(itr);
		}
	}
	
	for(itr = L.begin(); itr != L.end(); itr++)
	{
	    cout << *itr << endl;
	}
}


Measured memory_bytes: 18564
import sys
readline = sys.stdin.readline

def main():
    N = int(input())
    H = list(map(int, readline().rstrip().split()))
    m = H[0]
    cnt = 1
    for h in H[1:]:
        if h >= m:
            cnt += 1
        m = max(m, h)
    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
s = input()
q = int(input())

query = [input() for _ in range(q)]
count = 0
right = ""
left = ""
for qu in query:
    if len(qu.split()) == 1:
        count += 1
        right, left = left, right
        continue
    num, f, c = qu.split()
    f = int(f)

    if f == 1:
        left += c
        
    else:
        right += c
if count % 2 == 1:
  s = s[::-1]

print(left[::-1] + s + right)


Measured memory_bytes: 16888
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cnt=0
for i in range(N):
    cnt+=min(A[i]+A[i+1],B[i])
    A[i+1]=max(0,min(A[i]+A[i+1]-B[i],A[i+1]))
print(cnt)

Measured memory_bytes: 19156
module Weighted01DirectedGraph
  (* 道の表現 *)
  (Path : sig
    type t
    (* 辺の名前 *)
    type edge
    (* 長さ0の道 *)
    val nil : t
    (* 道の後ろに辺を付け足した道 *)
    val snoc : t -> edge -> t
  end) :
sig
  val bfs01 :
    (* 頂点数 *)
    int ->
    (* 辺の名前が付いた隣接リスト *)
    (* 辺の重さが0ならfalse，1ならtrue *)
    ('v -> ('v * Path.edge * bool) list) ->
    (* 始点 *)
    'v ->
    (* 最短経路を返す関数 辿り着けなければNoneを返す） *)
    ('v -> Path.t option)
end =
struct
  let bfs01 n es s =
    (* 始点sからの経路 *)
    let d = Hashtbl.create n in
    (* 現在BFSで走査している頂点のリスト *)
    let vps = ref [(s, Path.nil)] in
    let rec bfs t =
      try Some (Hashtbl.find d t)
      with Not_found ->
        match !vps with
        | [] -> None
        | _ :: _ -> vps := List.fold_left dfs [] !vps; bfs t
    and dfs vps (v, p) =
      if Hashtbl.mem d v then vps
      else begin
        Hashtbl.add d v p;
        List.fold_left (fun vps (u, e, b) ->
          if b
          then (u, Path.snoc p e) :: vps
          else dfs vps (u, Path.snoc p e)) vps (es v)
      end
    in bfs
end

module Int = struct
  type t = int
  let zero = 0
  let ( + ) = ( + )
  let compare = compare
end

module G = Weighted01DirectedGraph (struct
  type t = int
  type edge = int
  let nil = 0
  let snoc = ( + )
end)

let () = Scanf.scanf "%d\n" @@ fun k ->
  let Some d = G.bfs01 k (fun i -> [((i + 1) mod k, 1, true); (i * 10 mod k, 0, false)]) 1 0 in
  Printf.printf "%d\n" @@ 1 + d
  



Measured memory_bytes: 20992