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


public class Main {

	public static boolean isSolved;
	public static int[] A;
	public static int n;
	
	static void solve(int index, int num) {
		if (num == 0) {
			isSolved = true;
			return;
		}

		if (isSolved || num < 0 || index == n) return;
		
		solve(index+1, num - A[index]);
		solve(index+1, num);
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		n = scan.nextInt();
		A = new int[n];
		for (int i = 0; i < n; i++) {
			A[i] = scan.nextInt();
		}
		
		int q = scan.nextInt();
		int[] M = new int[q];
		for (int i = 0; i < q; i++) {
			M[i] = scan.nextInt();
		}
		
		for (int i = 0; i < q; i++) {
			isSolved = false;
			
			solve(0, M[i]);
			
			if (isSolved) System.out.println("yes");
			else System.out.println("no");
		}
		
		scan.close();
	}

}

Measured memory_bytes: 20820
#include<bits/stdc++.h>
#include<algorithm>
using namespace std; 
#define int long long
#define float double
#define MAX 100005
const int  mod = 99824435300;
#define LMT 100000000000
#define int long long 
#define pb push_back 
#define lp(i,n) for( i=0;i<n;i++) 
#define lop(j,n)for( j=0;j<n;j++)
typedef pair<int,int> pii;
typedef pair<pii,pii> ppi;
#define m_p make_pair
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minheap priority_queue<int,vector<int>,greater<int>>
#define maxheap priority_queue<int>
#define kickstart  cout<<"Case #"<<cc<<": "
#define pair_pq priority_queue<pii,vector<pii>,greater<pii>>
#define ff first
#define ss second
#define pff pair<float,float>
#define piii pair<int,pii>
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = a * a;
        b >>= 1;
    }
    return res;
}


int fact(int a){int ans=1;
  while(a>1){ans=(ans*a)%mod;a--;}return ans;
}

void solve(){
int i,j,k,l=0,r=mod,m,diff=0,n,q;
cin>>n>>k;int a[n],dp[n];lp(i,n)cin>>a[i],dp[i]=LMT;
dp[0]=0;dp[1]=abs(a[1]-a[0]);
for(i=2;i<n;i++)
  for(int j=1;i-j>=0 && j<=k;j++)
  dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i]);//dp[i-1]+abs(a[i]-a[i-1]));
cout<<dp[n-1]<<endl;
}
 int32_t main(){
  fastio
 #ifndef ONLINE_JUDGE 
  freopen("input.txt", "r", stdin); 
  freopen("output.txt", "w", stdout); 
 #endif
int t=1;
//cin>>t;
while(t--)solve();
return 0;
 }


Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    ll n,a,b;
  	ll zer=0;
    cin >> n >> a >> b;
    a--;
    b--;
    ll dif=b-a;
    if(dif%2==0)cout << dif/2;
    else{
        ll aa,bb;
        ll zsum=0;
        ll z=min(a,b)+1;
        aa=max(zer,a-z);
        bb=max(zer,b-z);
        zsum+=z;
        zsum+=abs(bb-aa)/2;
        ll nsum=0;
        ll nn=n-max(a,b);
        a=min(n-1,a+nn);
        b=min(n-1,b+nn);
        nsum+=nn;
        nsum+=abs(b-a)/2;
        ll ans=min(zsum,nsum);
        cout << ans;
    }



    
}

/*
*/



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

using namespace std;

typedef long long ll;

int main()
{
    int a, b, c;

    cin >> a >> b >> c;

    int c5 = 0, c7 = 0;

    if(a == 5)
    {
        c5++;
    }
    else if(a == 7)
    {
        c7++;
    }

    if(b == 5)
    {
        c5++;
    }
    else if(b == 7)
    {
        c7++;
    }

    if(c == 5)
    {
        c5++;
    }
    else if(c == 7)
    {
        c7++;
    }

    if(c5 == 2 && c7 == 1)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}



Measured memory_bytes: 3592
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	abcd := strings.Split(s, "")
	a, _ := strconv.Atoi(abcd[0])
	b, _ := strconv.Atoi(abcd[1])
	c, _ := strconv.Atoi(abcd[2])
	d, _ := strconv.Atoi(abcd[3])

	if a+b+c+d == 7 {
		fmt.Printf("%d+%d+%d+%d=7\n", a, b, c, d)
	} else if a+b+c-d == 7 {
		fmt.Printf("%d+%d+%d-%d=7\n", a, b, c, d)
	} else if a+b-c+d == 7 {
		fmt.Printf("%d+%d-%d+%d=7\n", a, b, c, d)
	} else if a+b-c-d == 7 {
		fmt.Printf("%d+%d-%d-%d=7\n", a, b, c, d)
	} else if a-b+c+d == 7 {
		fmt.Printf("%d-%d+%d+%d=7\n", a, b, c, d)
	} else if a-b+c-d == 7 {
		fmt.Printf("%d-%d+%d-%d=7\n", a, b, c, d)
	} else if a-b-c+d == 7 {
		fmt.Printf("%d-%d-%d+%d=7\n", a, b, c, d)
	} else if a-b-c-d == 7 {
		fmt.Printf("%d-%d-%d+%d=7\n", a, b, c, d)
	}
}


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1e9 + 7;
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
const int MAXN = 210000;

ll fc[MAXN];
ll bfc[MAXN]; 
int was[MAXN];
vector<int> fr;
vector<int> st;
vector<int> vv;
vector<int> eds[MAXN];
int sz[MAXN];
int en[MAXN];

ll cnk(int n, int k) {
	if (k > n)
		return 0;
	return fc[n] * bfc[k] % MOD * bfc[n - k] % MOD;
}

int dfs1(int v, int p) {
	was[v] = 1;
	st.push_back(v);
	for (int u: eds[v]) {
		if (u == p)
			continue;
		if (was[u]) {
			for (int j = 0; j < st.size(); ++j) {
				if (st[j] == u) {
					for (int k = j; k < st.size(); ++k)
						vv.push_back(st[k]);
					break;
				}
			}
			return 1;
		}
		if (dfs1(u, v))
			return 1;
	}
	st.pop_back();
	return 0;
}

pair<int, ll> dfs2(int v, int p, int tm) {
	was[v] = tm;
	int sz = 0;
	ll cur = 1;
	for (int u: eds[v]) {
		if (was[u] >= tm)
			continue;
		pair<int, ll> tmp = dfs2(u, v, tm);
		cur = (cur * tmp.second) % MOD;
		if (u > p) {
			fr.push_back(tmp.first);
		}
		else {
			cur = cur * cnk(sz + tmp.first, tmp.first) % MOD;
			sz += tmp.first;
		}
	}
	return make_pair(sz + 1, cur);
}

pair<ll, int> func(int k, int tm) {
	ll cur = 1;
	fr.clear();
	for (int i = 1; i <= k; ++i) {
		int go = vv[i + 1];
		int ng = vv[i - 1];
		pair<int, ll> tmp = dfs2(vv[i], go, tm);
		sz[i] = tmp.first;
		cur = (cur * tmp.second) % MOD;
		if (go < ng)
			en[i] = 1;
		else
			en[i] = 0;
	}
	int csz = 0;
	for (int i = 1; i <= k; ++i) {
		if (en[i]) {
			if (csz)
				fr.push_back(csz);
			csz = sz[i];
		}
		else if (!csz) {
			continue;
		}
		else {
			cur = cur * cnk(csz + sz[i] - 1, sz[i] - 1) % MOD; 
			csz += sz[i];
		}
	}
	if (!csz)
		cur = 0;
	for (int i = 1; i <= k; ++i) {
		if (en[i]) {
			if (csz)
				fr.push_back(csz);
			break;
		}
		else {
			cur = cur * cnk(csz + sz[i] - 1, sz[i] - 1) % MOD; 
			csz += sz[i];
		}
	}
	csz = 0;
	for (int i: fr) {
		csz += i;
		cur = (cur * cnk(csz, i)) % MOD;
	}
	return make_pair(cur, csz);
}

int n;

int main() {
	fc[0] = bfc[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fc[i] = (fc[i - 1] * i) % MOD, bfc[i] = pw(fc[i], MOD - 2);
	scanf("%d", &n);
	for (int i = 0; i < n * 2; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		--x, --y;
		eds[x].push_back(y + n);
		eds[y + n].push_back(x);
	}
	ll ans = 1;
	int csz = 0;
	for (int i = 0; i < 2 * n; ++i) {
		if (was[i])
			continue;
		vv.clear();
		st.clear();
		if (!dfs1(i, -1)) {
			cout << 0 << "\n";
			return 0;
		}
		int k = vv.size();
		vv.push_back(vv[0]);
		vv.push_back(vv[1]);
		ll sum = 0;
		int sz = 0;
		for (int u: vv)
			was[u] = 2;
		tie(sum, sz) = func(k, 2);
		reverse(vv.begin(), vv.end());
		for (int u: vv)
			was[u] = 3;
		sum = (sum + func(k, 3).first) % MOD;
		ans = (ans * sum) % MOD;
		csz += sz;
		ans = (ans * cnk(csz, sz)) % MOD;
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 20988
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  stack<int> S1;
  stack<pair<int, int>> S2;
  char ch;
  int sum = 0;
  for (int i = 0; cin >> ch; i++)
  {
    if (ch == '\\')
    {
      S1.push(i);
    }
    else if (ch == '/' && S1.size() > 0)
    {
      int j = S1.top();
      S1.pop();
      sum += i - j;
      int a = i - j;
      while (S2.size() > 0 && S2.top().first > j)
      {
        a += S2.top().second;
        S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  while (S2.size() > 0)
  {
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++)
  {
    cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}


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

int main(void) {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i = 0; i < m; i++) {
        cin >> b.at(i);
    }
    int ans = 0;
    for (int x = 0; x < n; x++) {
        int sum = 0;
        for (int i = 0; i < m; i++) {
            int a;
            cin >> a;
            sum += a * b.at(i);
        }
        if (sum + c > 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {

  int N;
  string S;
  cin >> N >> S;

  int l = 0,r = 0;
  for(int i = 1;i < S.size();i++) {
    if(S.at(i) == 'E') r++;
  }

  int ans = r;
  for(int i = 1;i < S.size();i++) {
    if(S.at(i) == 'E') {
      r--;
      if(S.at(i - 1) == 'W') l++;
    }else {
      if(S.at(i - 1) == 'W') l++;
    }
    ans = min(ans,r+l);
  }

  cout << ans << endl;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  i64 a, b, c;
  cin >> a >> b >> c;
  cout << (a + b >= c ? c + b : a + (b * 2) + 1) << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int N;
vector<int> graph[10010];
vector<int> C,ans;
int idx = 0;
void dfs(int from, int now){
    //cout << from << " " << now << " " << idx << endl;
    ans[now] = C[idx];
    for(auto next: graph[now]){
        if(next == from)continue;
        idx++;
        dfs(now, next);
    }
}
main(){
    cin >> N;
    vector<int> A(N-1), B(N-1);
    rep(i,0,N-1){
        cin >> A[i] >> B[i];
        A[i]--, B[i]--;
        graph[A[i]].push_back(B[i]);
        graph[B[i]].push_back(A[i]);
    }
    C.resize(N);
    ans.resize(N);
    rep(i,0,N)cin >> C[i];
    sort(C.rbegin(), C.rend());
    
    dfs(-1, 0);

    ll sum = 0;
    rep(i,0,N-1){
        sum += min(ans[A[i]], ans[B[i]]);
    }
    cout << sum << endl;
    rep(i,0,N){
        cout << ans[i] << " \n"[i==N-1];
    }

}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
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;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}




ll A, B, C;

int main () {
  cin >> A >> B >> C;

  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
    cout << "0\n";
  } else {
    vector<ll> v;
    v.push_back(A);v.push_back(B);v.push_back(C);
    sort(All(v));
    cout << v[0] * v[1] << "\n";
  }
}

Measured memory_bytes: 256
import io.StdIn._

object Main extends App {
  val regex = "[0-9a-zA-Z]+".r
  (readLine, readLine) match {
    case (l1, l2)
        if 1 <= l1.length && l1.length <= 10 && regex.matches(l1) && l2.startsWith(l1) && l1.length + 1 == l2.length =>
      println("Yes")
    case _ => println("No")
  }
}


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

int check(const int& one, const int& two, const int& three){
    if((two >= one) && (two <= three)) return 1;
    if((two <= one) && (two >= three)) return 1;
    return 0;
}

int main(){
    int n;
    cin >> n;
    vector<int> p;
    int a;
    for(int i = 0; i < n; i++){
        cin >> a;
        p.emplace_back(a);
    }

    int ans = 0;
    for(int i = 1; i < (n-1); i++) ans += check(p[i-1], p[i], p[i+1]);
    cout << ans;
}

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

		int N = sc.nextInt();
		int R = sc.nextInt();
		if( N>=10 ){
			System.out.println(R);
		}else{
			System.out.println(R+100*(10-N));
		}
	}
}


Measured memory_bytes: 22228
#!/usr/bin/env python3
#AGC24 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b,c,k = LI()
if k % 2:
    print(b-a)
else:
    print(a-b)


Measured memory_bytes: 38256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
      	int count = 0;
      	for(int i = 0 ; i < 3 ; i++){
         if(a.substring(i,i+1).equals("1")){
  			count ++ ;       
         }
        }          
            System.out.print(count);
    }
}



Measured memory_bytes: 35600
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<52;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	vvi dp(n,vi(3,1));
	for(int i=1;i<n;i++){
		if(a[i]!=a[i-1]){
			dp[i][0]=dp[i-1][0]+1;
			dp[i][1]=dp[i-1][1]+1;
			dp[i][2]=dp[i-1][2]+1;
		}
		else{
			dp[i][1]=dp[i-1][2]+1;
			dp[i][2]=dp[i-1][0]+1;
		}
	}
	int M=0;
	for(int i=0;i<n;i++) for(int j=0;j<3;j++) M=max(M,dp[i][j]);
	cout<<M<<endl;
}

Measured memory_bytes: 8680
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,val;
    cin>>n;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>val;
        v[i].first=(val);
    }
    for(int i=0;i<n;i++)
    {
        cin>>val;
        v[i].second=(val);
    }
    int sum1=0;
    int sum2=0;
    for(int i=0;i<n;i++)
    {
        if(v[i].first>v[i].second){
            sum1+=v[i].first;
            sum2+=v[i].second;
    }
    }
    cout<<sum1-sum2<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a=0,m=0, c=0,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n;
  while(n--){
  cin>>s;
  string s1="AC", s2="WA", s3="TLE";
  if(s==s1) a++;
  else if(s==s2) m++;
  else if(s==s3) c++;
  else k++;
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<m<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<k<<endl;
  }
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 123;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

void solve(){
    int n, m, x;
    cin >> n >> m;
    while (m--){
        cin >> x;
        n -= x;
    }
    cout << max(-1, n);
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        //cout << "case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s1,s2,s3;
cin>>s1>>s2>>s3;
int t1,t2,t3;
t1=t2=t3=0;
int l1 = s1.length();
int l2 = s2.length();
int l3 = s3.length();
int nt = 1;
while(true)
{
	if ( nt == 1 )
	{
		if (t1 == l1)
		{
			cout<<'A';
			break;
		}
		
		if ( char(s1[t1]) == 'a')
		{
			nt = 1;
		}
		if ( char(s1[t1]) == 'b')
		{
			nt = 2;
		}
		if ( char(s1[t1]) == 'c')
		{
			nt = 3;
		}	
		t1++;
	}
	if ( nt == 2 )
	{

		if (t2 == l2)
		{
			cout<<'B';	
			break;
		}

		if (char(s2[t2]) == 'a')
		{
			nt = 1;
		}
		if (char(s2[t2]) == 'b')
		{
			nt = 2;
		}
		if (char(s2[t2]) == 'c')
		{
			nt = 3;
		}
			t2++;
	}
	if ( nt == 3 )
	{
		if (t3 == l3)
		{
			cout<<'C';
			break;
		}

		if ( char(s3[t3]) == 'a')
		{
			nt = 1;
		}
		if (char(s3[t3]) == 'b')
		{
			nt = 2;	
		}
		if (char(s3[t3]) == 'c')
		{
			nt = 3 ;
		}
			t3++;
	}	
}
return 0;	
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  while (cin >> n >> k) {
    map<int, int> cnt;
    for (int i = 0; i < n; ++i) {
      int x;
      cin >> x;
      ++cnt[x];
    }
    vector<pair<int, int>> v;
    each (i, cnt) v.push_back(make_pair(i.second, i.first));
    sort(v.begin(), v.end());
    lli sum = 0;
    for (int i = 0; i + k < v.size(); ++i) {
      sum += v[i].first;
    }
    cout << sum << endl;
  }
  
  return 0;
}


Measured memory_bytes: 11764
#include <iostream>
#include <algorithm>

#define MAX_M 100000000
#define MAX_N 10000

bool is_prime(int n) {
    for (int i=2; i*i<=n; i++) {
        if (n%i == 0) return false;
    }
    return n != 1;
}

/*
int n;
int prime[MAX_M], input[MAX_N];
bool is_prime[MAX_M+1];

int sieve(int m) {
    int p = 0;

    for (int i=2; i<=m; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (int j=2*i; j<=m; j+=i) is_prime[j] = false;
        }
    }
    return p;
}

void solve(int m) {
    int p, res=0;

    p = sieve( m );

    for (int i=0; i<n; i++) {
        if (is_prime[ input[i] ]) res++;
    }
    std::cout << res << std::endl;
}


void init_is_prime() {
    for (int i=0; i<MAX_M; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
}
*/

int main() {
    int res=0, n;
    std::cin >> n;

    // init_is_prime();

    for (int i=0; i<n; i++) {
        // std::cin >> input[i];
        int k;
        std::cin >> k;
        if ( is_prime( k ) ) res++;
    }
    // std::sort(input, input+n);

    // solve( input[n-1] );
    std::cout << res << std::endl;
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;
	deque<int> ans;
	int a;
	if (n % 2 == 0) {
		rep(i, n) {
			cin >> a;
			if (i % 2 == 0) {
				ans.push_back(a);
			}
			else {
				ans.push_front(a);
			}
		}
	}
	else {
		rep(i, n) {
			cin >> a;
			if (i % 2 == 0) {
				ans.push_front(a);
			}
			else {
				ans.push_back(a);
			}
		}
	}

	rep(i, n) {
		cout << ans[i];
		cout << ' ';
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 3072
#define ll long long
#define pi acos(-1.0)
#define Go "\n"
#define bye return 0
#define Afor(i,b) for(int i=0;i<b;i++)
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,p;
    cin>>n>>p;
    cout<<n-p+1<<Go;
    bye;


}


Measured memory_bytes: 256
N,M,X=map(int,input().split())
s=[list(map(int,input().split())) for i in range(N)]
t=[-1]
for i in range(1<<N):
  u=[0]*(M+1)
  for j in range(N):
    if ((i>>j)&1)==1:
      u=[u[k]+s[j][k] for k in range(M+1)] 
  for k in range(M):
    if u[k+1]<X:
      break
  else:
    if t==[-1]:
      t.clear()
    t.append(u[0])
t.sort()
print(t[0])

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

#define endl "\n"
#define int long long
#define vec(x) vector<x>
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
const int MOD = 1e9 + 7; 
const double pi = acos(-1);
int power(int a,int b,int m=MOD)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}
int dir[]={-1, 0, 1, 0, -1};
int dx[]={1,1,0,-1,-1,-1, 0, 1};
int dy[]={0,1,1, 1, 0,-1,-1,-1};

const int N = 1e5+1;

void solve()
{
	int i,n;
	cin>>n;
	int d=n%10;
	if(d==0 or d==1 or d==6 or d==8)
	cout<<"pon"<<endl;
	else if(d!=3)
	cout<<"hon"<<endl;
	else
	cout<<"bon"<<endl;
}

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
using namespace std;
ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x);
        x=(x*x);
        y=y/2;
    }
    return res;
}
int main()
{
    ll n,p,k;
    cin>>n>>k;
    vector<ll>v,dp(n+1);
    dp[0]=0;//if one stone then cost incurred=0
    for(ll i=0;i<n;i++)
    {
        cin>>p;
        v.pb(p);
    }
    dp[1]=abs(v[0]-v[1]);
    for(ll i=2;i<n;i++)
    {
        ll ans=INT_MAX;
        for(ll j=1;j<=k&&i-j>=0;j++)
        {
            ans=min(ans,dp[i-j]+abs(v[i]-v[i-j]));
        }
        dp[i]=ans;
    }
        
        //if at current stone then answer till that stone can be from 2 ways..first, the frog 
        //is at prev stone and comes to present with one jump this cost him v[i]-v[i-1]..answer till the prev was dp[i-1] so answer now is dp[i-1]+abs(v[i]-v[i-1])
        //second he is at next prev stone and come to present stone by 2 jump cost v[i]-v[i-2] answer=dp[i-2]+abs(v[i]-v[i-2])
    cout<<dp[n-1];
}

Measured memory_bytes: 2168
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll dp[2][110][110];  /* dp[id][i+1][j] : 先頭からi桁目までで0以外の数字がj個現れるs以下の数の個数。
                                        ただし、id = 0 のとき現時点でsと等しい。
                                        id = 1 のとき現時点でs未満が確定。 */

int main() {
    string s;
    ll k;
    cin >> s >> k;
    ll m = s.size();  // sはm桁とする

    dp[0][0][0] = 1;
    rep(id, 2) {
        rep(i, m) {
            rep(j, m) {
                ll lim = s[i] - '0';  //  先頭からi桁目にはlim以下の数を置ける
                if(id) {
                    lim = 9;
                }
                exrep(x, 0, lim) {  // 先頭からi桁目にxを置くとする
                    dp[id || x < lim][i+1][j + (x != 0)] += dp[id][i][j];
                }
            }
        }
    }

    ll ans = dp[0][m][k] + dp[1][m][k];

    out(ans);
    re0;
}

Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

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

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

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

fn main() {
    let mut v: Vec<usize> = read_vec();
    let (n, m) = (v[0], v[1]);
    let mut a = vec![VecDeque::new(); n];
    for i in 0..n {
        let v = read_vec::<usize>();
        let v = v.into_iter().map(|x| x - 1).collect::<VecDeque<_>>();
        a[i] = v;
    }

    if n == 1 {
        println!("1");
        return;
    }

    let mut ans = n + 1;
    let mut removed = HashSet::new();
    {
        let mut a = a.clone();
        for _ in 0..m - 1 {
            let mut count = vec![0; m];
            for i in 0..n {
                while removed.contains(&a[i][0]) {
                    a[i].pop_front();
                }
                count[a[i][0]] += 1;
            }

            let mut max_v = 0;
            let mut max_index = 0;
            for j in 0..m {
                if count[j] > max_v {
                    max_v = count[j];
                    max_index = j;
                }
            }
            ans = min(ans, max_v);
            removed.insert(max_index);
        }
    }
    println!("{}", ans);
}


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

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector< pair<int,int> > v(M);
    for(int i=0; i<M; i++) {
        cin >> v[i].second >> v[i].first;
    }

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

    int ans = 0;
    int last = 0;
    for(auto e: v) {
        if(e.second >= last) {
            ++ans;
            last = e.first;
        }
    }

    cout << ans << endl;
    return 0;
}


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

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

   
  for(int i = 0; i < alpha.size(); i++){
      alpha[i] = (alpha[i] -'A' + n) % 26 + 'A';
  }
  cout << alpha << endl;

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env perl
use strict;
use warnings;


#
#3 1 (3 monsters, 1 special attack. #special attack kills monster immediately)
#4 1 5 (HP of monsters)


chomp (my @input1 = split / /, <STDIN>);
chomp (my @enemies  = split / /, <STDIN>);  # input2

my $sp_attk = $input1[1];

@enemies = sort { $b <=> $a } @enemies;  # reverse sort numerically

my $num_attacks = 0;

while ($sp_attk) {
  shift @enemies;
  $sp_attk--;
#  print "y\n";
}

#print "@enemies", "\n";

for (@enemies) {
  $num_attacks += $_;
}

print "$num_attacks\n";





Measured memory_bytes: 37156
#include<iostream>

using namespace std;

int start,year,ans,test;

int fukuri(double p, int t){
  int mon = start,r;
  for(int i = 0; i < year; i++){
    r = mon*p;
    mon += r-t;
  }
  return mon;
}

int tanri(double p, int t){
  int mon = start, r = 0;
  for(int i = 0; i < year; i++){
    r+=mon*p;
    mon-=t;
  }
  return mon+r;
}

int main(){
  int num;
  cin >> num;
  while(num--){
    ans = 0;
    cin >> start >> year >> test;
    for(int i = 0; i < test; i++){
      int w,t;
      double p;
      cin >> w >> p >> t;
      if(w) ans = max(fukuri(p,t),ans);
      else ans = max(tanri(p,t),ans);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
main = do
  s <- getContents
  let v = map (map read . words) . lines $ s
  let w = map solve v
  let x = map (\x-> if x then "YES" else "NO") $ w
  mapM_ putStrLn x

solve::[Double] -> Bool
solve [xa,ya,xb,yb,xc,yc,xd,yd] =
  abs(dot u v)/len(u)/len(v) < eps
  where u = (xb-xa, yb-ya)
        v = (xd-xc, yd-yc)
        dot (a,b) (c,d) = a*c + b*d
        len (a,b) = sqrt(a^2+b^2)
        eps=1e-10

Measured memory_bytes: 4428
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
#define REP(i, n) for(int i=0;i<n;i++)
template<typename T>
void get(T& t){cin >> t;}
int main(void){
	int n;
	get(n);
	vector<int> a1(n), a2(n);
	REP(i,n)get(a1[i]);
	REP(i,n)get(a2[i]);
	int ans = 0;
	REP(i, n){
		int x=0;
		REP(j,n){
			if(i>=j)x+=a1[j];
			if(i<=j)x+=a2[j];
		}
		ans = max(ans, x);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);
	int sum = 0;
	
	for (int i = 1; i <= N; i++){
		int digitSum = 0;
		int temp = i; //hrs pke variabel penampung 
		while (temp != 0){
			digitSum = digitSum + temp % 10;
			temp /= 10;
		}
		if (digitSum >= A && digitSum <= B){
			sum += i;
		}
		
	}
	printf ("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1688
import java.util.*;

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

        if (N==2) {
            if (x==2) {
                System.out.println("Yes");
                for (int i=1;i<=3;i++) {
                    System.out.println(i);
                }
            } else {
                System.out.println("No");
            }
            return;
        }
        // if (N==3) {
        //     if (x==2) {
        //         System.out.println("Yes");
        //         System.out.println(3);
        //         System.out.println(1);
        //         System.out.println(2);
        //         System.out.println(4);
        //         System.out.println(5);
        //     } else if (x==3) {
        //         System.out.println("Yes");
        //         for (int i=1;i<=5;i++) {
        //             System.out.println(i);
        //         }
        //     } else if (x==4) {
        //         System.out.println("Yes");
        //         System.out.println(3);
        //         System.out.println(4);
        //         System.out.println(5);
        //         System.out.println(1);
        //         System.out.println(2);
        //     } else {
        //         System.out.println("No");
        //     }
        //     return;
        // }
        if (2<=x && x<=2*N-1-1) {
            System.out.println("Yes");
            ArrayList<Integer> before = new ArrayList<Integer>();
            ArrayList<Integer> after = new ArrayList<Integer>();
            int cnt = 0;
            for (int i=1;i<=2*N-1;i++) {
                if (i==x-1 || i==x || i==x+1) continue;
                cnt++;
                if (cnt<=N-2) {
                    before.add(i);
                } else {
                    after.add(i);
                }
            }
            for (int i=0;i<N-2;i++) {
                System.out.println(before.get(i));
            }
            System.out.println(x-1);
            System.out.println(x);
            System.out.println(x+1);
            for (int i=0;i<N-2;i++) {
                System.out.println(after.get(i));
            }
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 55260
#include <stdio.h>

int main (){
	char a[19];
	scanf("%[^\n]", &a);
	for (int i=0; a[i]!= '\0'; i++){
		if (a[i]==','){
			printf(" ");
		}
		else {
			printf("%c", a[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 1600
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

typedef long long ll;

int n, a[100005];
int dp[MAX];

int main()
{
    FASTIO

    cin>>n;
    for(int i = 1; i <= n; i++)
        cin>>a[i];
    dp[1] = 0;
    for(int i = 2; i <= n; i++){
        dp[i] = dp[i-1] + abs (a[i] - a[i-1]);
        if(i > 2){
            dp[i] = min(dp[i], dp[i-2] + abs(a[i] - a[i-2]));
        }
    }
    cout << dp[n]<<endl;
    return 0;
} 


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7
 
int main(){
  int a, b;
  cin >> a >> b;
  int max_ = mod * -1;
  max_ = max(max_, a + b);
  max_ = max(max_, a * b);
  max_ = max(max_, a - b);
  print(max_);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    ll x, y;
    cin >> x >> y;

    ll ans = abs(abs(y) - abs(x));
    if (y < x)
        ans++;
    if (((x < 0 && y < 0) || (0 < x && 0 < y)) && y < x)
        ans++;
    if (x < 0 && 0 < y)
        ans++;
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;



int main() {
    int n; string s; cin >> n >> s;
    int cnt = 0,ans=0;
    for(int i = 0;i < s.length();i++){
        if(s[i] == 'I'){
            cnt++;
        }else{
            cnt--;
        }
        ans = max(ans,cnt);
    }
    cout << ans;
}




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

using llong = long long;

int main() {

    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        d[i] = tmp;
    }
    int sum = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
    return 0;
}


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

long long rng(long long l, long long r) {
  static mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<long long>(l, r - 1)(mt);
}

struct RollingHash {
  static constexpr uint64_t m31 = (1LL << 31) - 1;
  static int mod_m31(uint64_t a) {
    a = (a >> 31) + (a & m31);
    return a >= m31 ? a - m31 : a;
  }
  static long long base[2];
  static vector<int> powb[2];
  vector<int> h[2];
  RollingHash(const string& s) : h{{0}, {0}} {
    for (int k : {0, 1}) {
      for (char c : s) h[k].push_back(mod_m31(h[k].back() * base[k] + c));
      while (powb[k].size() <= s.size())
        powb[k].push_back(mod_m31(powb[k].back() * base[k]));
    }
  }
  int get(int l, int r, int k) const {
    return mod_m31(h[k][r] + (m31 - h[k][l]) * powb[k][r - l]);
  }
  auto get(int l, int r) const { return make_pair(get(l, r, 0), get(l, r, 1)); }
  int size() const { return h[0].size() - 1; }
  static int get(const string& t, int k) {
    long long res = 0;
    for (char c : t) res = mod_m31(res * base[k] + c);
    return res;
  }
  static pair<int, int> get(const string& t) {
    return {get(t, 0), get(t, 1)};
  }
};
long long RollingHash::base[2] = {rng(1e9, 2e9), rng(1e9, 2e9)};
vector<int> RollingHash::powb[2] = {{1}, {1}};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  vector<int> b(n);
  for (auto&& e : b) {
    cin >> e;
  }
  vector<bool> ok(n, true);
  vector<int> res(n);
  for (int k = 0; k < 30; ++k) {
    string s, t;
    for (int i = 0; i < n; ++i) {
      s += a[i] >> k & 1 ? '1' : '0';
      t += b[i] >> k & 1 ? '1' : '0';
    }
    s += s;
    RollingHash rh(s);
    auto zero = RollingHash::get(t);
    for (auto&& e : t) {
      e ^= 1;
    }
    auto one = RollingHash::get(t);
    for (int i = 0; i < n; ++i) {
      if (rh.get(i, i + n) == zero) {
      } else if (rh.get(i, i + n) == one) {
        res[i] |= 1 << k;
      } else {
        ok[i] = false;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    if (ok[i]) {
      cout << i << ' ' << res[i] << '\n';
    }
  }
}


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

int main(){
    int N,a[100],Alice=0,Bob=0;

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

    sort(a,a+N,greater<int>());

    for(int i=0;i<N;i++){
        if(i%2==0){
            Alice+=a[i];
        }else Bob+=a[i];
    }
    cout<<Alice-Bob<<endl;
}

Measured memory_bytes: 256
'use strict'

function main(input) {
  const n = Number(input)
  let ans = 0
  if (n == 1) {
    console.log(1)
    return
  }
  let i = 0
  while (Math.pow(2, i+1) <= n) {
    i++
    ans = Math.pow(2, i)
  }
 
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using namespace std;

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

VL prime_decomposition(ll n) {
	ll i = 2;
	VL table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace_back(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace_back(n);
		return table;
	}
}

ll p(ll n) {

	static map<ll, ll> memo;
	if (n <= 0) { return 1; }
	if (memo.find(n) != memo.end()) {
		return memo[n];
	}
	if (n == 1) {
		memo[1] = 2;
		return 2;
	}
	if (n == 2) {
		memo[2] = 3;
		return 3;
	}
	ll tmp = p(n - 1) + p(n - 2);
	memo[n] = tmp;
	return tmp;

}

int main() {
	ll h, w, k;
	cin >> h >> w >> k;

	VVL dp = VVL(h + 1, VL(w));
	dp[0][0] = 1;
	FOR(i, 1, h + 1) {
		REP(j, w) {
			ll sum = 0;
			ll e = p(w - j - 2) * p(j - 1);
			sum += dp[i - 1][j] * e;

			if (j > 0) {
				e = p(w - j - 2) * p(j - 2);
				sum += dp[i - 1][j - 1] * e;
			}
			if (j < w - 1) {
				e = p(w - j - 3) * p(j - 1);
				sum += dp[i - 1][j + 1] * e;
			}
			sum %= MOD;
			dp[i][j] = sum;
		}
	}
	cout << dp[h][k - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

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

int main() {
  int N, M;
  cin >> N >> M;
  string S, T;
  cin >> S >> T;
  int64_t g = gcd(N, M);
  int64_t L = N / g * M;
  // cout << L << endl;
  if (g == 1) {
    if (S.at(0) == T.at(0)) cout << L << endl;
    else cout << -1 << endl;
  }
  else {
  bool OK = true;
  for (int i = 0; i < L; i += L / g) {
    if (S.at(i / (L / N)) != T.at(i / (L / M))) OK = false;
    }
  if (OK) {
    cout << L << endl;
  }
  else cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
int main(){
	int n;cin>>n;
	int ans=0,tmp=n;
	while(tmp){
		ans+=tmp%10;
		tmp/=10;
	}
	if(n%ans==0)cout<<"Yes"<<endl;else cout<<"No"<<endl;
}


Measured memory_bytes: 256